Merge pull request #1663 from sbwalker/dev
file manager component improvements
This commit is contained in:
commit
2ac069082d
|
@ -59,7 +59,7 @@
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if (_image != string.Empty && ShowImage)
|
@if (_image != string.Empty)
|
||||||
{
|
{
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
@((MarkupString) _image)
|
@((MarkupString) _image)
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
public EventCallback<int> OnUpload { get; set; } // optional - executes a method in the calling component when a file is uploaded
|
public EventCallback<int> OnUpload { get; set; } // optional - executes a method in the calling component when a file is uploaded
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<int> OnChange { get; set; } // optional - executes a method in the calling component when a file is selected
|
public EventCallback<int> OnSelect { get; set; } // optional - executes a method in the calling component when a file is selected
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<int> OnDelete { get; set; } // optional - executes a method in the calling component when a file is deleted
|
public EventCallback<int> OnDelete { get; set; } // optional - executes a method in the calling component when a file is deleted
|
||||||
|
@ -138,6 +138,11 @@
|
||||||
_id = Id;
|
_id = Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ShowFiles)
|
||||||
|
{
|
||||||
|
ShowImage = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Folder))
|
if (!string.IsNullOrEmpty(Folder))
|
||||||
{
|
{
|
||||||
_folders = new List<Folder> { new Folder { FolderId = -1, Name = Folder } };
|
_folders = new List<Folder> { new Folder { FolderId = -1, Name = Folder } };
|
||||||
|
@ -154,12 +159,14 @@
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
FolderId = file.FolderId;
|
FolderId = file.FolderId;
|
||||||
|
await OnSelect.InvokeAsync(FileId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FileId = -1; // file does not exist
|
FileId = -1; // file does not exist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await SetImage();
|
await SetImage();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Filter))
|
if (!string.IsNullOrEmpty(Filter))
|
||||||
|
@ -237,7 +244,10 @@
|
||||||
{
|
{
|
||||||
_message = string.Empty;
|
_message = string.Empty;
|
||||||
FileId = int.Parse((string)e.Value);
|
FileId = int.Parse((string)e.Value);
|
||||||
await OnChange.InvokeAsync(FileId);
|
if (FileId != -1)
|
||||||
|
{
|
||||||
|
await OnSelect.InvokeAsync(FileId);
|
||||||
|
}
|
||||||
|
|
||||||
await SetImage();
|
await SetImage();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
@ -250,7 +260,7 @@
|
||||||
if (FileId != -1)
|
if (FileId != -1)
|
||||||
{
|
{
|
||||||
_file = await FileService.GetFileAsync(FileId);
|
_file = await FileService.GetFileAsync(FileId);
|
||||||
if (_file != null && _file.ImageHeight != 0 && _file.ImageWidth != 0)
|
if (_file != null && ShowImage && _file.ImageHeight != 0 && _file.ImageWidth != 0)
|
||||||
{
|
{
|
||||||
var maxwidth = 200;
|
var maxwidth = 200;
|
||||||
var maxheight = 200;
|
var maxheight = 200;
|
||||||
|
@ -292,21 +302,14 @@
|
||||||
_message = Localizer["Success.File.Upload"];
|
_message = Localizer["Success.File.Upload"];
|
||||||
_messagetype = MessageType.Success;
|
_messagetype = MessageType.Success;
|
||||||
|
|
||||||
|
// set FileId to first file in upload collection
|
||||||
await GetFiles();
|
await GetFiles();
|
||||||
|
var file = _files.Where(item => item.Name == upload[0]).FirstOrDefault();
|
||||||
if (upload.Length == 1)
|
if (file != null)
|
||||||
{
|
{
|
||||||
var file = _files.Where(item => item.Name == upload[0]).FirstOrDefault();
|
FileId = file.FileId;
|
||||||
if (file != null)
|
await SetImage();
|
||||||
{
|
await OnUpload.InvokeAsync(FileId);
|
||||||
FileId = file.FileId;
|
|
||||||
await SetImage();
|
|
||||||
await OnUpload.InvokeAsync(FileId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await OnUpload.InvokeAsync(-1);
|
|
||||||
}
|
}
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ namespace Oqtane.Repository
|
||||||
Permissions = new List<Permission>
|
Permissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.Browse, RoleNames.Admin, true),
|
new Permission(PermissionNames.Browse, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions()
|
}.EncodePermissions()
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user