Implementing filtering
This commit is contained in:
parent
ae1726ce7a
commit
234a0e28cd
@ -4,7 +4,13 @@
|
|||||||
|
|
||||||
<div class="files">
|
<div class="files">
|
||||||
|
|
||||||
<div class="field is-horizontal sameMarginBottom">
|
<div class="field has-addons sameMarginBottom">
|
||||||
|
<div class="control has-icons-left is-expanded">
|
||||||
|
<input formnovalidate @oninput="e => SearchInputChanged(e.Value.ToString())" class="input is-rounded is-small" type="text" placeholder="Search...">
|
||||||
|
<span class="icon is-small is-left">
|
||||||
|
<i class="mdi mdi-search-web"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div class="control has-icons-left">
|
<div class="control has-icons-left">
|
||||||
<div class="select is-small is-rounded">
|
<div class="select is-small is-rounded">
|
||||||
<select @onchange="e => OnFilterClick(e.Value.ToString())">
|
<select @onchange="e => OnFilterClick(e.Value.ToString())">
|
||||||
@ -18,12 +24,6 @@
|
|||||||
<i class="mdi mdi-folder-cog-outline"></i>
|
<i class="mdi mdi-folder-cog-outline"></i>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p class="control has-icons-left">
|
|
||||||
<input formnovalidate @oninput="e => SearchInputChanged(e.Value.ToString())" class="input is-rounded is-small" type="text" placeholder="Search...">
|
|
||||||
<span class="icon is-small is-left">
|
|
||||||
<i class="mdi mdi-search-web"></i>
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="filesList neomorphSmall borderRSmall sameMarginBottom">
|
<div class="filesList neomorphSmall borderRSmall sameMarginBottom">
|
||||||
|
@ -18,9 +18,7 @@ namespace Seenginx.Components
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public List<string> Filters { get; set; } = new List<string>();
|
public List<string> Filters { get; set; } = new List<string>();
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public List<int> FilteredOutFiles { get; set; } = new List<int>();
|
public Dictionary<string, string> FilterFolder { get; set; } = new Dictionary<string, string>();
|
||||||
[Parameter]
|
|
||||||
public EventCallback<string> ApplyFilter { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback AddFile { get; set; }
|
public EventCallback AddFile { get; set; }
|
||||||
@ -42,6 +40,7 @@ namespace Seenginx.Components
|
|||||||
public RenderFragment<CFile> DeleteDialog { get; set; }
|
public RenderFragment<CFile> DeleteDialog { get; set; }
|
||||||
|
|
||||||
protected string SelectedFilter { get; set; }
|
protected string SelectedFilter { get; set; }
|
||||||
|
protected string SearchInput { get; set; }
|
||||||
|
|
||||||
protected bool IsAnyFileSelected => SelectedFile != default;
|
protected bool IsAnyFileSelected => SelectedFile != default;
|
||||||
|
|
||||||
@ -58,26 +57,69 @@ namespace Seenginx.Components
|
|||||||
|
|
||||||
protected async Task OnFilterClick(string filter)
|
protected async Task OnFilterClick(string filter)
|
||||||
{
|
{
|
||||||
await ApplyFilter.InvokeAsync(filter);
|
SelectedFilter = filter;
|
||||||
//for (int index = 0; index < Files.Count; index++)
|
SearchFile();
|
||||||
// if (FilteredOutFiles.Contains(index))
|
|
||||||
// Files[index].Hide();
|
|
||||||
// else
|
|
||||||
// Files[index].Unhide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task SearchInputChanged(string searchInput)
|
protected async Task SearchInputChanged(string searchInput)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(searchInput))
|
SearchInput = searchInput;
|
||||||
|
SearchFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SearchFile()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(SearchInput))
|
||||||
|
{
|
||||||
|
if (SelectedFilter == "All")
|
||||||
Files.ForEach(f => f.Unhide());
|
Files.ForEach(f => f.Unhide());
|
||||||
else
|
else if (SelectedFilter == "Root")
|
||||||
Files.ForEach(f =>
|
Files.ForEach(f =>
|
||||||
{
|
{
|
||||||
if (f.Name.ToLower().Contains(searchInput.ToLower()))
|
if (f.Folder == FilterFolder[SelectedFilter])
|
||||||
f.Unhide();
|
f.Unhide();
|
||||||
else
|
else
|
||||||
f.Hide();
|
f.Hide();
|
||||||
});
|
});
|
||||||
|
else
|
||||||
|
Files.ForEach(f =>
|
||||||
|
{
|
||||||
|
if (f.Folder.Contains(FilterFolder[SelectedFilter]))
|
||||||
|
f.Unhide();
|
||||||
|
else
|
||||||
|
f.Hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (SelectedFilter == "All")
|
||||||
|
Files.ForEach(f => { if (f.Name.ToLower().Contains(SearchInput)) f.Unhide(); else f.Hide(); });
|
||||||
|
else if (SelectedFilter == "Root")
|
||||||
|
Files.ForEach(f =>
|
||||||
|
{
|
||||||
|
if (f.Folder == FilterFolder[SelectedFilter])
|
||||||
|
f.Unhide();
|
||||||
|
else
|
||||||
|
f.Hide();
|
||||||
|
});
|
||||||
|
else
|
||||||
|
Files.ForEach(f =>
|
||||||
|
{
|
||||||
|
if (f.Folder.Contains(FilterFolder[SelectedFilter]))
|
||||||
|
f.Unhide();
|
||||||
|
else
|
||||||
|
f.Hide();
|
||||||
|
});
|
||||||
|
//Files.ForEach(f => f.Unhide());
|
||||||
|
//else
|
||||||
|
// Files.ForEach(f =>
|
||||||
|
// {
|
||||||
|
// if (f.Name.ToLower().Contains(searchInput.ToLower()))
|
||||||
|
// f.Unhide();
|
||||||
|
// else
|
||||||
|
// f.Hide();
|
||||||
|
// });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task OnFileClick(MouseEventArgs e, CFile file)
|
protected async Task OnFileClick(MouseEventArgs e, CFile file)
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
@page "/nginx"
|
@page "/nginx"
|
||||||
|
|
||||||
|
|
||||||
<FilesWithEditor CFile="ConfigFile" Filters="Filters" FilteredOutFiles="FilteredOutFiles" Files="ConfigFiles"
|
<FilesWithEditor CFile="ConfigFile" Filters="Filters" Files="ConfigFiles" FilterFolder="FilterFolder"
|
||||||
SelectedFile="SelectedFile" SelectedFileChanged="SelectedFileChanged" ApplyFilter="ApplyFilter"
|
SelectedFile="SelectedFile" SelectedFileChanged="SelectedFileChanged"
|
||||||
AddFile="AddFile" UpdateFile="UpdateFile" DeleteFile="DeleteFile" >
|
AddFile="AddFile" UpdateFile="UpdateFile" DeleteFile="DeleteFile" >
|
||||||
<CreateDialog>
|
<CreateDialog>
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace Seenginx.Pages
|
|||||||
public List<string> Filters { get; set; } = new List<string>();
|
public List<string> Filters { get; set; } = new List<string>();
|
||||||
public List<int> FilteredOutFiles { get; set; } = new List<int>();
|
public List<int> FilteredOutFiles { get; set; } = new List<int>();
|
||||||
|
|
||||||
private Dictionary<string, string> FilterFolder { get; set; } = new Dictionary<string, string>();
|
public Dictionary<string, string> FilterFolder { get; set; } = new Dictionary<string, string>();
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@ -37,28 +37,6 @@ namespace Seenginx.Pages
|
|||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ApplyFilter(string filter)
|
|
||||||
{
|
|
||||||
if (filter == "All")
|
|
||||||
ConfigFiles.ForEach(f => f.Unhide());
|
|
||||||
else if (filter == "Root")
|
|
||||||
ConfigFiles.ForEach(f =>
|
|
||||||
{
|
|
||||||
if (f.Folder == FilterFolder[filter])
|
|
||||||
f.Unhide();
|
|
||||||
else
|
|
||||||
f.Hide();
|
|
||||||
});
|
|
||||||
else
|
|
||||||
ConfigFiles.ForEach(f =>
|
|
||||||
{
|
|
||||||
if (f.Folder.Contains(FilterFolder[filter]))
|
|
||||||
f.Unhide();
|
|
||||||
else
|
|
||||||
f.Hide();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task SelectedFileChanged(ConfigFile configFile)
|
public async Task SelectedFileChanged(ConfigFile configFile)
|
||||||
{
|
{
|
||||||
SelectedFile = configFile;
|
SelectedFile = configFile;
|
||||||
|
Loading…
Reference in New Issue
Block a user