private async Task Remove(Infrastructure.Schema.Whitelist row) { var confirmed = await JSRuntime.InvokeAsync <bool>("confirm", new object[] { $"Remove rule '{row.Pattern}'?" }); if (confirmed) { WhitelistModel.Remove(row); _whitelistTable !.InvalidateData(); await ReloadWhitelist(); } }
public bool Commit() { if (!CanCommit()) { return(false); } WhitelistModel.Submit(_newWhitelist); OnCommit?.Invoke(); _newWhitelist = new Whitelist(); return(true); }
protected override void OnInitialized() { _clientRole = Utility.GetRole(AuthenticationStateTask ?? throw new ArgumentNullException()).Result; _newRule = new Infrastructure.Schema.Whitelist(); if (_clientRole != UserRole.Roles.Privileged && _clientRole != UserRole.Roles.Administrator) { throw new Exception(); } Log?fromLog = LogActionService.GetAndUnset(); if (fromLog != null) { Console.WriteLine("From log: " + fromLog.Question); string pattern = @"(?:^|.+\.)" + fromLog.Question.Replace(".", @"\.") + "$"; Rule().Pattern = pattern; } InitValidators(); InitInputs(); // _whitelistTable = new FlareTable <Infrastructure.Schema.Whitelist>( () => _clientRole == UserRole.Roles.Privileged ? WhitelistModel.List(ClientIP !) : WhitelistModel.List(), sessionStorage: SessionStorageService, identifier: "Rules.WhitelistTable", monospace: true); _whitelistTable.RegisterColumn(nameof(Infrastructure.Schema.Whitelist.ID)); _whitelistTable.RegisterColumn(nameof(Infrastructure.Schema.Whitelist.Pattern)); _whitelistTable.RegisterColumn(nameof(Infrastructure.Schema.Whitelist.Expires)); _whitelistTable.RegisterColumn("_Edit", sortable: false, filterable: false, displayName: "", width: "56px"); _whitelistTable.RegisterColumn("_Remove", sortable: false, filterable: false, displayName: "", width: "82px"); _whitelistTable.OnRowClick += whitelist => { }; BuildHeaders(); }
public static void Remove(Whitelist row) { WhitelistModel.Remove(row); }