Exemple #1
0
        private static async Task <FileSpecificationsStore> BuildFileSpecificationsStoreAsync(HttpClient httpClient)
        {
            var fileSpecificationsStore = new FileSpecificationsStore();
            await SampleFileStoreLoader.LoadFileSpecsAsync(fileSpecificationsStore, httpClient);

            return(fileSpecificationsStore);
        }
Exemple #2
0
        private void Decode(MouseEventArgs e)
        {
            var content = _editorManager.GetValue();

            if (string.IsNullOrEmpty(content))
            {
                Toaster.Add("Content is empty", MatToastType.Warning);
                return;
            }

            if (_model.SelectedFileSpecId == -1)
            {
                Toaster.Add("A file definition must be selected", MatToastType.Warning);
                return;
            }

            var getFileSpecificationResult = FileSpecificationsStore.GetFileSpecificationById(_model.SelectedFileSpecId);

            if (!getFileSpecificationResult.Succeed)
            {
                Toaster.Add(getFileSpecificationResult.Message, MatToastType.Warning);
                return;
            }

            DecodeContent(content, getFileSpecificationResult.Data.Content);
        }
Exemple #3
0
 private void LoadFileSpecificationOptions()
 {
     _model.FileSpecificationOptions = FileSpecificationsStore.GetAllFileSpecificationOptions().Data;
     if (HomePageState.SelectedFileSpecId > 0)
     {
         _model.SelectedFileSpecId = HomePageState.SelectedFileSpecId;
     }
     else
     {
         if (_model.FileSpecificationOptions.Any())
         {
             _model.SelectedFileSpecId = _model.FileSpecificationOptions.First().Id;
         }
     }
 }
Exemple #4
0
        private void LoadSelectedFileSpecification(FileSpecificationOption fileSpecificationOption)
        {
            var getFileSpecificationByIdResult = FileSpecificationsStore.GetFileSpecificationById(fileSpecificationOption.Id);

            if (!getFileSpecificationByIdResult.Succeed)
            {
                ClearSelectedFileSpecification();
                Toaster.Add(getFileSpecificationByIdResult.Message, MatToastType.Danger);
                return;
            }

            FileSpecificationsPageState.SelectedFileSpecification = getFileSpecificationByIdResult.Data;
            _editorManager.SetValue(getFileSpecificationByIdResult.Data.Content);
            StateHasChanged();
        }
Exemple #5
0
        private void Save()
        {
            _newFileSpecification.Content = _editorManager.GetValue();

            var updateFileSpecificationResult = FileSpecificationsStore.UpdateFileSpecification(_newFileSpecification);

            if (updateFileSpecificationResult.Succeed)
            {
                FileSpecificationsPageState.SelectedFileSpecification = _newFileSpecification;

                Toaster.Add("File specification saved", MatToastType.Success);

                _inEditMode     = false;
                _allowSelection = true;
                _editorManager.SetReadOnly(!_inEditMode);
                _editorManager.Focus();
            }
            else
            {
                Toaster.Add(updateFileSpecificationResult.Message, MatToastType.Danger);
            }
        }
Exemple #6
0
 protected override void OnInitialized()
 {
     base.OnInitialized();
     ApplicationsEvents.MenuItemClicked += MenuItemClicked;
     _fileSpecs = FileSpecificationsStore.GetAllFileSpecificationOptions().Data.OrderBy(a => a.Name);
 }