2020-04-13 23:58:26 +02:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using Radzen;
|
|
|
|
|
using Radzen.Blazor;
|
|
|
|
|
using Seenginx.Models;
|
|
|
|
|
using Seenginx.Services;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Seenginx.Pages
|
|
|
|
|
{
|
|
|
|
|
public class NginxBase : ComponentBase
|
|
|
|
|
{
|
|
|
|
|
[Inject]
|
|
|
|
|
public INginxService NginxService { get; set; }
|
|
|
|
|
|
|
|
|
|
public string InputSearch { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<ConfigFile> ConfigFiles { get; set; } = new List<ConfigFile>();
|
2020-04-16 18:50:05 +02:00
|
|
|
|
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>();
|
2020-04-13 23:58:26 +02:00
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
ConfigFiles.AddRange(await NginxService.GetFilesAsync());
|
2020-04-16 18:50:05 +02:00
|
|
|
|
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");
|
2020-04-13 23:58:26 +02:00
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-16 18:50:05 +02:00
|
|
|
|
public async Task ApplyFilter(string filter)
|
2020-04-13 23:58:26 +02:00
|
|
|
|
{
|
2020-04-16 18:50:05 +02:00
|
|
|
|
if (filter == "All")
|
|
|
|
|
ConfigFiles.ForEach(f => f.Unhide());
|
2020-04-17 00:50:23 +02:00
|
|
|
|
else if (filter == "Root")
|
|
|
|
|
ConfigFiles.ForEach(f =>
|
|
|
|
|
{
|
|
|
|
|
if (f.Folder == FilterFolder[filter])
|
|
|
|
|
f.Unhide();
|
|
|
|
|
else
|
|
|
|
|
f.Hide();
|
|
|
|
|
});
|
2020-04-16 18:50:05 +02:00
|
|
|
|
else
|
|
|
|
|
ConfigFiles.ForEach(f =>
|
|
|
|
|
{
|
|
|
|
|
if (f.Folder.Contains(FilterFolder[filter]))
|
|
|
|
|
f.Unhide();
|
|
|
|
|
else
|
|
|
|
|
f.Hide();
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-04-13 23:58:26 +02:00
|
|
|
|
|
2020-04-16 18:50:05 +02:00
|
|
|
|
public async Task SelectedFileChanged(ConfigFile configFile)
|
|
|
|
|
{
|
|
|
|
|
SelectedFile = configFile;
|
2020-04-13 23:58:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-16 18:50:05 +02:00
|
|
|
|
public async Task AddFile()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public async Task UpdateFile(ConfigFile configFile)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public async Task DeleteFile(ConfigFile configFile)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-04-13 23:58:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|