Added basic export and import feature
This commit is contained in:
@@ -135,8 +135,26 @@
|
||||
}
|
||||
|
||||
removeBg();
|
||||
|
||||
window.downloadFileFromStream = async (fileName, contentStreamReference) => {
|
||||
const arrayBuffer = await contentStreamReference.arrayBuffer();
|
||||
const blob = new Blob([arrayBuffer]);
|
||||
const url = URL.createObjectURL(blob);
|
||||
const anchorElement = document.createElement('a');
|
||||
anchorElement.href = url;
|
||||
anchorElement.download = fileName ?? '';
|
||||
anchorElement.click();
|
||||
anchorElement.remove();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
window.triggerClick = (elt) => elt.click();
|
||||
</script>
|
||||
|
||||
<FluentToastProvider MaxToastCount="10" />
|
||||
|
||||
<InputFile style="display: none" @ref="FileInputElement" OnChange="OnInputFiles"></InputFile>
|
||||
|
||||
@inject IContextExplorer Explorer
|
||||
@inject NavigationManager Navigator
|
||||
@inject IJSRuntime Js
|
||||
@@ -254,7 +272,7 @@
|
||||
await Reload();
|
||||
}
|
||||
|
||||
private async Task Reload() {
|
||||
public async Task Reload() {
|
||||
_loading = true;
|
||||
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new ReloadEvent(this) {
|
||||
@@ -275,7 +293,7 @@
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
private async Task ChangePage(int page) {
|
||||
public async Task ChangePage(int page) {
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new PageChangeEvent(this) {
|
||||
CurrentPage = _currentPage,
|
||||
NewPage = page,
|
||||
@@ -383,4 +401,21 @@
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
public InputFile? FileInputElement;
|
||||
public Func<IEnumerable<IBrowserFile>, Task>? OnFileUpload;
|
||||
private async Task OnInputFiles(InputFileChangeEventArgs e) {
|
||||
if (OnFileUpload is null) return;
|
||||
|
||||
if (e.FileCount == 1) {
|
||||
await OnFileUpload.Invoke([e.File]);
|
||||
}
|
||||
else {
|
||||
await OnFileUpload.Invoke(e.GetMultipleFiles());
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestRender() {
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user