Files with editor update
This commit is contained in:
		@@ -1,3 +1,12 @@
 | 
			
		||||
@inherits FileItemBase
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<div class="level">
 | 
			
		||||
	<div class="level-left">
 | 
			
		||||
		<div class="level-item">
 | 
			
		||||
			<p class="is-size-7"><sub>@File.Folder</sub></p>
 | 
			
		||||
			<p class="@(File.CanBeDeleted ? "has-text-danger" : null)">
 | 
			
		||||
				@File.Name
 | 
			
		||||
			</p>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
@@ -14,7 +14,7 @@
 | 
			
		||||
		<div class="content">
 | 
			
		||||
			<div class="field">
 | 
			
		||||
				<div class="control">
 | 
			
		||||
					<InputText Value="SearchInput" ValueChanged="OnSearchChanged" class="input is-primary" type="text" placeholder="Search..." />
 | 
			
		||||
					<InputText Value="SearchInput" ValueChanged="SearchInputChanged" class="input is-primary" type="text" placeholder="Search..." />
 | 
			
		||||
				</div>
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
@@ -23,30 +23,28 @@
 | 
			
		||||
				<ul class="menu-list">
 | 
			
		||||
					@foreach (var file in Files)
 | 
			
		||||
					{
 | 
			
		||||
						<li>
 | 
			
		||||
							<FileItem File="file" @onclick="OnFileClick(file)"></FileItem>
 | 
			
		||||
						<li @onclick="e => OnFileClick(file)" @key="file" class="@file.IsVisible">
 | 
			
		||||
							<FileItem File="file"></FileItem>
 | 
			
		||||
						</li>
 | 
			
		||||
					}
 | 
			
		||||
					<li><a>Dashboard</a></li>
 | 
			
		||||
					<li><a>Customers</a></li>
 | 
			
		||||
				</ul>
 | 
			
		||||
			</aside>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div class="content">
 | 
			
		||||
			<div class="buttons has-addons">
 | 
			
		||||
				<button class="button is-primary">
 | 
			
		||||
				<button class="button is-primary" @onclick="OnAddDialog">
 | 
			
		||||
					<span class="icon is-small">
 | 
			
		||||
						<i class="mdi mdi-plus-box-outline"></i>
 | 
			
		||||
					</span>
 | 
			
		||||
					Add
 | 
			
		||||
				</button>
 | 
			
		||||
				<button class="button is-warning">
 | 
			
		||||
				<button class="button is-warning" @onclick="OnUpdateDialog">
 | 
			
		||||
					<span class="icon is-small">
 | 
			
		||||
						<i class="mdi mdi-pencil-box-outline"></i>
 | 
			
		||||
					</span>
 | 
			
		||||
					Update
 | 
			
		||||
				</button>
 | 
			
		||||
				<button class="button is-danger">
 | 
			
		||||
				<button class="button is-danger" @onclick="OnDeleteDialog">
 | 
			
		||||
					<span class="icon is-small">
 | 
			
		||||
						<i class="mdi mdi-minus-box-outline"></i>
 | 
			
		||||
					</span>
 | 
			
		||||
@@ -61,5 +59,7 @@
 | 
			
		||||
		@Editor
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,13 @@ namespace Seenginx.Components
 | 
			
		||||
		[Parameter]
 | 
			
		||||
		public EventCallback<string> ApplyFilter { get; set; }
 | 
			
		||||
 | 
			
		||||
		[Parameter]
 | 
			
		||||
		public EventCallback AddFile { get; set; }
 | 
			
		||||
		[Parameter]
 | 
			
		||||
		public EventCallback<CFile> UpdateFile { get; set; }
 | 
			
		||||
		[Parameter]
 | 
			
		||||
		public EventCallback<CFile> DeleteFile { get; set; }
 | 
			
		||||
 | 
			
		||||
		[Parameter]
 | 
			
		||||
		public RenderFragment<CFile> Editor { get; set; }
 | 
			
		||||
 | 
			
		||||
@@ -35,14 +42,17 @@ namespace Seenginx.Components
 | 
			
		||||
 | 
			
		||||
		protected bool IsAnyFileSelected => SelectedFile != default;
 | 
			
		||||
 | 
			
		||||
		private CFile SelectedFile { get; set; }
 | 
			
		||||
		[Parameter]
 | 
			
		||||
		public EventCallback<CFile> SelectedFileChanged { get; set; }
 | 
			
		||||
		[Parameter]
 | 
			
		||||
		public CFile SelectedFile { get; set; }
 | 
			
		||||
 | 
			
		||||
		protected string SearchInput { get; set; }
 | 
			
		||||
 | 
			
		||||
		protected async Task OnDeselectClick()
 | 
			
		||||
		{
 | 
			
		||||
			SelectedFile = null;
 | 
			
		||||
			//Clean on the right
 | 
			
		||||
			await SelectedFileChanged.InvokeAsync(SelectedFile);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		protected async Task OnFilterClick(EventArgs e, string filter)
 | 
			
		||||
@@ -55,7 +65,7 @@ namespace Seenginx.Components
 | 
			
		||||
					Files[index].Unhide();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		protected async Task OnSearchChanged()
 | 
			
		||||
		protected void SearchInputChanged()
 | 
			
		||||
		{
 | 
			
		||||
			if (string.IsNullOrEmpty(SearchInput))
 | 
			
		||||
				Files.ForEach(f => f.Hide());
 | 
			
		||||
@@ -71,17 +81,20 @@ namespace Seenginx.Components
 | 
			
		||||
 | 
			
		||||
		protected async Task OnFileClick(CFile file)
 | 
			
		||||
		{
 | 
			
		||||
			SelectedFile = file;
 | 
			
		||||
			await SelectedFileChanged.InvokeAsync(file);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		protected async Task OnCreateFile()
 | 
			
		||||
		protected async Task OnAddDialog()
 | 
			
		||||
		{
 | 
			
		||||
			await AddFile.InvokeAsync(null);
 | 
			
		||||
		}
 | 
			
		||||
		protected async Task OnUpdateDialog(CFile file)
 | 
			
		||||
		protected async Task OnUpdateDialog()
 | 
			
		||||
		{
 | 
			
		||||
			await UpdateFile.InvokeAsync(SelectedFile);
 | 
			
		||||
		}
 | 
			
		||||
		protected async Task OnDeleteDialog(CFile file)
 | 
			
		||||
		protected async Task OnDeleteDialog()
 | 
			
		||||
		{
 | 
			
		||||
			await UpdateFile.InvokeAsync(SelectedFile);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +0,0 @@
 | 
			
		||||
@*<RadzenTabs>
 | 
			
		||||
 | 
			
		||||
</RadzenTabs>*@
 | 
			
		||||
@@ -1,13 +0,0 @@
 | 
			
		||||
using Microsoft.AspNetCore.Components;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Seenginx.Components
 | 
			
		||||
{
 | 
			
		||||
	public class TabsBase : ComponentBase
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -2,17 +2,20 @@
 | 
			
		||||
@page "/nginx"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<FilesWithEditor CFile="ConfigFile" Filters="Filters" FilteredOutFiles="FilteredOutFiles" Files="ConfigFiles"
 | 
			
		||||
								 SelectedFile="SelectedFile" SelectedFileChanged="SelectedFileChanged" ApplyFilter="ApplyFilter"
 | 
			
		||||
								 AddFile="AddFile" UpdateFile="UpdateFile" DeleteFile="DeleteFile" >
 | 
			
		||||
	<CreateDialog>
 | 
			
		||||
 | 
			
		||||
<div class="pure-g">
 | 
			
		||||
	<div class="pure-u-1-5">
 | 
			
		||||
		<p>Configuration Files</p>
 | 
			
		||||
		heh
 | 
			
		||||
	</div>
 | 
			
		||||
	</CreateDialog>
 | 
			
		||||
	<UpdateDialog>
 | 
			
		||||
 | 
			
		||||
	<div class="pure-u-4-5">
 | 
			
		||||
		<h1>
 | 
			
		||||
			Hello
 | 
			
		||||
		</h1>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
	</UpdateDialog>
 | 
			
		||||
	<DeleteDialog>
 | 
			
		||||
 | 
			
		||||
	</DeleteDialog>
 | 
			
		||||
	<Editor>
 | 
			
		||||
 | 
			
		||||
	</Editor>
 | 
			
		||||
</FilesWithEditor>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,19 +19,51 @@ namespace Seenginx.Pages
 | 
			
		||||
		public string InputSearch { get; set; }
 | 
			
		||||
 | 
			
		||||
		public List<ConfigFile> ConfigFiles { get; set; } = new List<ConfigFile>();
 | 
			
		||||
		public ConfigFile SelectedFile { get; set; }
 | 
			
		||||
		public List<string> Filters { get; set; } = new List<string>();
 | 
			
		||||
		public List<int> FilteredOutFiles { get; set; } = new List<int>();
 | 
			
		||||
 | 
			
		||||
		private Dictionary<string, string> FilterFolder { get; set; } = new Dictionary<string, string>();
 | 
			
		||||
 | 
			
		||||
		protected override async Task OnInitializedAsync()
 | 
			
		||||
		{
 | 
			
		||||
			ConfigFiles.AddRange(await NginxService.GetFilesAsync());
 | 
			
		||||
			Filters.AddRange(new List<string> { "All", "Root", "Conf.d", "Enabled", "Disabled" });
 | 
			
		||||
			FilterFolder.Add("All", null);
 | 
			
		||||
			FilterFolder.Add("Root", "/");
 | 
			
		||||
			FilterFolder.Add("Conf.d", "/conf.d");
 | 
			
		||||
			FilterFolder.Add("Enabled", "/sites-enabled");
 | 
			
		||||
			FilterFolder.Add("Disabled", "/sites-disabled");
 | 
			
		||||
			await base.OnInitializedAsync();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		protected void Change(object value, string name)
 | 
			
		||||
		public async Task ApplyFilter(string filter)
 | 
			
		||||
		{
 | 
			
		||||
			var str = value is IEnumerable<object> ? string.Join(", ", (IEnumerable<object>)value) : value;
 | 
			
		||||
 | 
			
		||||
			StateHasChanged();
 | 
			
		||||
			if (filter == "All")
 | 
			
		||||
				ConfigFiles.ForEach(f => f.Unhide());
 | 
			
		||||
			else
 | 
			
		||||
				ConfigFiles.ForEach(f =>
 | 
			
		||||
				{
 | 
			
		||||
					if (f.Folder.Contains(FilterFolder[filter]))
 | 
			
		||||
						f.Unhide();
 | 
			
		||||
					else
 | 
			
		||||
						f.Hide();
 | 
			
		||||
				});
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public async Task SelectedFileChanged(ConfigFile configFile)
 | 
			
		||||
		{
 | 
			
		||||
			SelectedFile = configFile;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public async Task AddFile()
 | 
			
		||||
		{
 | 
			
		||||
		}
 | 
			
		||||
		public async Task UpdateFile(ConfigFile configFile)
 | 
			
		||||
		{
 | 
			
		||||
		}
 | 
			
		||||
		public async Task DeleteFile(ConfigFile configFile)
 | 
			
		||||
		{
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,6 @@
 | 
			
		||||
@using Microsoft.JSInterop
 | 
			
		||||
@using Seenginx
 | 
			
		||||
@using Seenginx.Shared
 | 
			
		||||
@using Seenginx.Models
 | 
			
		||||
@using Seenginx.Components
 | 
			
		||||
 | 
			
		||||
@using Radzen
 | 
			
		||||
@using Radzen.Blazor
 | 
			
		||||
		Reference in New Issue
	
	Block a user