Skip to main content
Component Name: ManageDocuments.razor
Version: 1.0.0
Manage Documents Screenshot

Dependencies

Services:
AdminSettingsService, UserService, SermonCollectionService, GroupService, DocumentStorageService, Snackbar

Variables

Variable NameTypeDescription
_uploadPermissionsGroupIdstringThe Guid of the general upload permissions group, retrieved from AdminSettings
_userInUploadPermissionsGroupboolIndicates whether current user has general upload permissions
_uploadCollectionstringThe IndexIdentifier of the sermon collection selected for uploading files
_dragClassstringThe class applied when dragging & dropping a file
_fileNamesList<string>A list of the drag & dropped files’ names
_fileUploadMudFileUpload<IReadOnlyList<IBrowserFile>>?A representation of the MudFileUpload element that handles uploading files
_filesToUploadList<IBrowserFile>A list of IBrowserFile, each of which will need to be opened in a read stream & uploaded to Azure storage
_sermonCollectionsUploadAccessIEnumerable<SermonCollection>The sermon collections that are available for uploading files

Lifecycle Methods

protected override async Task OnInitializedAsync()
{
    await UserService.InitializeCurrentUserAsync();

    if ( UserService.CurrentUser != null )
    {
        _uploadPermissionsGroupId = AdminSettingsService.CurrentAdminSettings?.UploadPermissionsGroupId ?? "";
        _userInUploadPermissionsGroup = await GroupService.UserIsInGroup( UserService.CurrentUser.Id, _uploadPermissionsGroupId );
    }

    _sermonCollectionsUploadAccess = await SermonCollectionService.GetSermonCollectionsByUploadPermissionsAsync();
}

Runtime Methods

ClearAsync()

Clears the selected files from the upload box.
private async Task ClearAsync()

OpenFilePickerAsync()

Opens the local computer’s file picker.
private Task OpenFilePickerAsync()

OnInputFileChanged(InputFileChangeEventArgs)

Sets _fileNames and _filesToUpload when selected files change.
private void OnInputFileChanged( InputFileChangeEventArgs e )

Upload()

Opens a read stream for each file in _filesToUpload and calls DocumentStorageService.UploadBlobAsync to upload them to Azure Storage in the container associated with _uploadCollection.
private async void Upload()

SetDragClass()

Sets _dragClass to include a border.
private void SetDragClass()

ClearDragClass()

Sets _dragClass to default.
private void ClearDragClass()