コード例 #1
0
ファイル: RemoteConfig.razor.cs プロジェクト: bhtz/HKLM
        private async Task OpenCreateDialog()
        {
            var dialog = _dialogService.Show <RemoteConfigFormDialog>("Modal", new DialogOptions
            {
                MaxWidth             = MaxWidth.Medium,
                FullWidth            = true,
                CloseButton          = true,
                DisableBackdropClick = true
            });

            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var newItem = (RemoteConfigFormViewModel)result.Data;
                //In a real world scenario we would reload the data from the source
                FilteredRemoteConfigQueryResult newRemoteConfig = new FilteredRemoteConfigQueryResult
                {
                    Id        = newItem.Id,
                    Key       = newItem.Key,
                    Dimension = newItem.Dimension
                };

                this.RemoteConfigs.Add(newRemoteConfig);
            }
        }
コード例 #2
0
ファイル: RemoteConfig.razor.cs プロジェクト: bhtz/HKLM
        private async Task Delete(FilteredRemoteConfigQueryResult item)
        {
            var parameters = new DialogParameters();

            parameters.Add("ContentText", "Are you sure ?");
            parameters.Add("ButtonText", "Delete");
            parameters.Add("Color", Color.Error);

            var options = new DialogOptions()
            {
                CloseButton = true, MaxWidth = MaxWidth.Medium
            };

            var dialog = _dialogService.Show <ConfirmDialog>("Delete", parameters, options);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var res = await this._httpClient.DeleteAsync("api/remoteconfig/" + item.Id);

                if (res.IsSuccessStatusCode)
                {
                    this.RemoteConfigs.Remove(item);
                    _snackBar.Add("Remote Config deleted", Severity.Success);
                }
                else
                {
                    _snackBar.Add("Error", Severity.Error);
                }
            }
        }
コード例 #3
0
ファイル: RemoteConfig.razor.cs プロジェクト: bhtz/HKLM
        private bool FilterFunc(FilteredRemoteConfigQueryResult element)
        {
            if (string.IsNullOrWhiteSpace(SearchTerm))
            {
                return(true);
            }
            if (element.Key.Contains(SearchTerm, StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            return(false);
        }
コード例 #4
0
ファイル: RemoteConfig.razor.cs プロジェクト: bhtz/HKLM
        private async Task OnSelectItem(FilteredRemoteConfigQueryResult item)
        {
            RemoteConfigFormViewModel dto = new RemoteConfigFormViewModel
            {
                Id        = item.Id,
                Key       = item.Key,
                Dimension = item.Dimension
            };

            var parameters = new DialogParameters {
                ["RemoteConfig"] = dto
            };

            //await this.JSONEditor();

            var dialog = _dialogService.Show <RemoteConfigFormDialog>("Modal", parameters, new DialogOptions
            {
                MaxWidth             = MaxWidth.Medium,
                FullWidth            = true,
                CloseButton          = true,
                DisableBackdropClick = true
            });
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                //In a real world scenario we would reload the data

                var editedItem = (RemoteConfigFormViewModel)result.Data;

                var remoteConfigToUpdate = this.RemoteConfigs.FirstOrDefault(a => a.Id == editedItem.Id);
                if (remoteConfigToUpdate != null)
                {
                    remoteConfigToUpdate.Key       = editedItem.Key;
                    remoteConfigToUpdate.Dimension = editedItem.Dimension;
                }
            }
        }