Many more updates and cleanups

This commit is contained in:
Eugene ;) 2020-04-19 03:04:46 +02:00
parent 234a0e28cd
commit f2cc603195
18 changed files with 147 additions and 82 deletions

View File

@ -1,12 +1,5 @@
@inherits FileItemBase @inherits FileItemBase
<a>
<a class="level"> <p class="subtitle is-6"><sub>@File.Folder</sub></p>
<div class="level-left"> <h6 class="title is-6 @(File.CanBeDeleted ? null : "has-text-danger")">@File.Name</h6>
<div class="level-item"> </a>
<p class="is-size-7"><sub>@File.Folder</sub></p>
<p class="@(File.CanBeDeleted ? "has-text-danger" : null)">
@File.Name
</p>
</div>
</div>
</a>

View File

@ -49,6 +49,14 @@ namespace Seenginx.Components
[Parameter] [Parameter]
public CFile SelectedFile { get; set; } public CFile SelectedFile { get; set; }
protected async override Task OnInitializedAsync()
{
SelectedFilter = Filters.First();
await base.OnInitializedAsync();
}
protected async Task OnDeselectClick() protected async Task OnDeselectClick()
{ {
SelectedFile = null; SelectedFile = null;
@ -94,31 +102,27 @@ namespace Seenginx.Components
{ {
if (SelectedFilter == "All") if (SelectedFilter == "All")
Files.ForEach(f => { if (f.Name.ToLower().Contains(SearchInput)) f.Unhide(); else f.Hide(); }); Files.ForEach(f => { if (f.Name.ToLower().Contains(SearchInput)) f.Unhide(); else f.Hide(); });
else if (SelectedFilter == "Root") else
Files.ForEach(f => Files.ForEach(f =>
{ {
if (f.Folder == FilterFolder[SelectedFilter]) if (SelectedFilter == "Root")
{
if (f.Folder == FilterFolder[SelectedFilter] && f.Folder.ToLower().Contains(SearchInput.ToLower()))
f.Unhide();
else
f.Hide();
}
else
{
Files.ForEach(f =>
{
if (f.Folder.Contains(FilterFolder[SelectedFilter]) && f.Folder.ToLower().Contains(SearchInput.ToLower()))
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();
}); });
//Files.ForEach(f => f.Unhide());
//else
// Files.ForEach(f =>
// {
// if (f.Name.ToLower().Contains(searchInput.ToLower()))
// f.Unhide();
// else
// f.Hide();
// });
} }
} }

View File

@ -15,7 +15,7 @@
</DeleteDialog> </DeleteDialog>
<Editor> <Editor>
<p>Qualcosa</p>
</Editor> </Editor>
</FilesWithEditor> </FilesWithEditor>

View File

@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Radzen;
using Radzen.Blazor;
using Seenginx.Models; using Seenginx.Models;
using Seenginx.Services; using Seenginx.Services;
using System; using System;
@ -28,12 +26,12 @@ namespace Seenginx.Pages
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
ConfigFiles.AddRange(await NginxService.GetFilesAsync()); ConfigFiles.AddRange(await NginxService.GetFilesAsync());
Filters.AddRange(new List<string> { "All", "Root", "Conf.d", "Enabled", "Disabled" }); Filters.AddRange(new List<string> { "All", "Root", "Conf.d", "Available", "Enabled" });
FilterFolder.Add("All", null); FilterFolder.Add("All", null);
FilterFolder.Add("Root", "/"); FilterFolder.Add("Root", "/");
FilterFolder.Add("Conf.d", "/conf.d"); FilterFolder.Add("Conf.d", "/conf.d");
FilterFolder.Add("Available", "/sites-available");
FilterFolder.Add("Enabled", "/sites-enabled"); FilterFolder.Add("Enabled", "/sites-enabled");
FilterFolder.Add("Disabled", "/sites-disabled");
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }

View File

@ -1,5 +1,5 @@
@inherits NginxLogsBase @inherits NginxLogsBase
@page "/nginx/logs" @page "/nginxlogs"

View File

@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Radzen;
using Radzen.Blazor;
using Seenginx.Models; using Seenginx.Models;
using Seenginx.Services; using Seenginx.Services;
using System; using System;

View File

@ -42,6 +42,6 @@
</div> </div>
<script src="_framework/blazor.server.js"></script> <script src="_framework/blazor.server.js"></script>
<script src="_content/Radzen.Blazor/Radzen.Blazor.js"></script> <script src="_content/Blazorise/blazorise.js"></script>
</body> </body>
</html> </html>

View File

@ -24,3 +24,8 @@ html {
.menu-list li a { .menu-list li a {
font-family: Ubuntu-Mono,'Noto Mono' font-family: Ubuntu-Mono,'Noto Mono'
} }
.menu-list a.active {
background-color: #3273dc;
color: #fff;
}

View File

@ -18,9 +18,10 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Blazorise.Bulma" Version="0.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
<PackageReference Include="Radzen.Blazor" Version="2.5.8" /> <PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -6,7 +6,7 @@ namespace Seenginx.Services
{ {
public interface INginxService public interface INginxService
{ {
Task<IEnumerable<ConfigFile>> GetFilesAsync(NginxFilter filter = null); Task<IEnumerable<ConfigFile>> GetFilesAsync();
Task<Result<bool>> TestNginxConfigurations(); Task<Result<bool>> TestNginxConfigurations();
} }
} }

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Seenginx.Services.Models
{
public class ConfigPaths
{
public string NginxPath { get; set; }
public string SystemDPath { get; set; }
}
}

View File

@ -1,6 +1,8 @@
using Seenginx.Models; using Seenginx.Models;
using Seenginx.Services.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -8,38 +10,72 @@ namespace Seenginx.Services
{ {
public class NginxService : INginxService public class NginxService : INginxService
{ {
public async Task<IEnumerable<ConfigFile>> GetFilesAsync(NginxFilter filter = null) private readonly ConfigPaths ConfigPaths;
public NginxService(ConfigPaths configPaths)
{ {
return new List<ConfigFile>() { ConfigPaths = configPaths;
new ConfigFile
{
Folder = "/conf.d",
Name = "matrix.conf",
LastUpdated = DateTime.Now.AddDays(new Random(DateTime.Now.Millisecond).Next(-50,0)),
OriginalBody = "something something",
Owners = new string[]{ "root" },
Permissions = "-drwe-rw-r"
},
new ConfigFile
{
Folder = "/conf.d",
Name = "pleroma.conf",
LastUpdated = DateTime.Now.AddDays(new Random(DateTime.Now.Millisecond).Next(-100,0)),
OriginalBody = "something something 2",
Owners = new string[]{ "root", "void" },
Permissions = "-drwe-rw-r"
},
new ConfigFile
{
Folder = "/conf.d",
Name = "ghost.conf",
LastUpdated = DateTime.Now.AddDays(new Random(DateTime.Now.Millisecond).Next(-25,0)),
OriginalBody = "something something 3",
Owners = new string[]{ "root" },
Permissions = "-drwe-rw-r",
CanBeDeleted = false
} }
};
public async Task<IEnumerable<ConfigFile>> GetFilesAsync()
{
var rootConfigs = Directory.GetFiles(ConfigPaths.NginxPath, "*.conf");
var confdConfigs = Directory.GetFiles(Path.Combine(ConfigPaths.NginxPath, "conf.d"), "*.conf");
var sitesAvailableConfigs = Directory.GetFiles(Path.Combine(ConfigPaths.NginxPath, "sites-available"), "*.conf");
var sitesEnabledConfigs = Directory.GetFiles(Path.Combine(ConfigPaths.NginxPath, "sites-enabled"), "*.conf");
var rootConfigFiles = rootConfigs.Select(fp =>
{
var fileName = Path.GetFileName(fp);
var configFile = new ConfigFile();
configFile.CanBeDeleted = fileName != "nginx.conf";
configFile.Folder = "/";
configFile.LastUpdated = File.GetLastWriteTime(fp);
configFile.Name = fileName;
configFile.OriginalBody = File.ReadAllText(fp);
return configFile;
});
var confdConfigFiles = confdConfigs.Select(fp =>
{
var fileName = Path.GetFileName(fp);
var configFile = new ConfigFile();
configFile.CanBeDeleted = true;
configFile.Folder = "/conf.d";
configFile.LastUpdated = File.GetLastWriteTime(fp);
configFile.Name = fileName;
configFile.OriginalBody = File.ReadAllText(fp);
return configFile;
});
var sitesAvailableConfigFiles = sitesAvailableConfigs.Select(fp =>
{
var fileName = Path.GetFileName(fp);
var configFile = new ConfigFile();
configFile.CanBeDeleted = true;
configFile.Folder = "/sites-available";
configFile.LastUpdated = File.GetLastWriteTime(fp);
configFile.Name = fileName;
configFile.OriginalBody = File.ReadAllText(fp);
return configFile;
});
var sitesEnabledConfigFiles = sitesEnabledConfigs.Select(fp =>
{
var fileName = Path.GetFileName(fp);
var configFile = new ConfigFile();
configFile.CanBeDeleted = true;
configFile.Folder = "/sites-enabled";
configFile.LastUpdated = File.GetLastWriteTime(fp);
configFile.Name = fileName;
configFile.OriginalBody = File.ReadAllText(fp);
return configFile;
});
var finalList = new List<ConfigFile>();
finalList.AddRange(rootConfigFiles);
finalList.AddRange(confdConfigFiles);
finalList.AddRange(sitesAvailableConfigFiles);
finalList.AddRange(sitesEnabledConfigFiles);
return finalList;
} }
public async Task<Result<bool>> TestNginxConfigurations() public async Task<Result<bool>> TestNginxConfigurations()

View File

@ -22,10 +22,10 @@
</NavLink> </NavLink>
</li> </li>
<li> <li>
<NavLink href="/nginx/logs" class="petiteCaps" <NavLink href="/nginxlogs" class="petiteCaps"
@key="@ActiveNav.Keys.ElementAt(1)" @key="@ActiveNav.Keys.ElementAt(1)"
ActiveClass="@ActiveNav.GetValueOrDefault("nginx/logs")" ActiveClass="@ActiveNav.GetValueOrDefault("nginxlogs")"
@onclick="@(e => SelectMenuItem("nginx/logs"))"> @onclick="@(e => SelectMenuItem("nginxlogs"))">
<span class="mdi mdi-information-outline"></span> <span class="mdi mdi-information-outline"></span>
Logs Logs
</NavLink> </NavLink>
@ -46,10 +46,10 @@
</NavLink> </NavLink>
</li> </li>
<li> <li>
<NavLink href="/systemd/logs" class="petiteCaps" <NavLink href="/systemdlogs" class="petiteCaps"
@key="@ActiveNav.Keys.ElementAt(3)" @key="@ActiveNav.Keys.ElementAt(3)"
ActiveClass="@ActiveNav.GetValueOrDefault("systemd/logs")" ActiveClass="@ActiveNav.GetValueOrDefault("systemdlogs")"
@onclick="@(e => SelectMenuItem("systemd/logs"))"> @onclick="@(e => SelectMenuItem("systemdlogs"))">
<span class="mdi mdi-information-outline"></span> <span class="mdi mdi-information-outline"></span>
Logs Logs
</NavLink> </NavLink>

View File

@ -16,9 +16,9 @@ namespace Seenginx.Shared
ActiveNav = new Dictionary<string, string> ActiveNav = new Dictionary<string, string>
{ {
{ "nginx", null }, { "nginx", null },
{ "nginx/logs", null }, { "nginxlogs", null },
{ "systemd", null }, { "systemd", null },
{ "systemd/logs", null }, { "systemdlogs", null },
{ "dmesg", null } { "dmesg", null }
}; };
await base.OnInitializedAsync(); await base.OnInitializedAsync();

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Blazorise;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@ -9,6 +10,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Seenginx.Services; using Seenginx.Services;
using Seenginx.Services.Models;
namespace Seenginx namespace Seenginx
{ {
@ -31,6 +33,15 @@ namespace Seenginx
#endif #endif
; ;
services.AddServerSideBlazor(); services.AddServerSideBlazor();
services.AddBlazorise(options =>
{
options.ChangeTextOnKeyPress = true; // optional
});
var configPaths = new ConfigPaths();
configPaths.NginxPath = @"C:\nginx\";
configPaths.SystemDPath = @"C:\systemd\system\";
services.AddSingleton(configPaths);
services.AddTransient<IDmesgService, DmesgService>(); services.AddTransient<IDmesgService, DmesgService>();
services.AddTransient<INginxService, NginxService>(); services.AddTransient<INginxService, NginxService>();
services.AddTransient<ISystemDService, SystemDService>(); services.AddTransient<ISystemDService, SystemDService>();

View File

@ -9,4 +9,6 @@
@using Seenginx.Shared @using Seenginx.Shared
@using Seenginx.Models @using Seenginx.Models
@using Seenginx.Components @using Seenginx.Components
@using Blazorise
@using Blazorise.Bulma

View File

@ -88,6 +88,10 @@ html {
.menu-list li a { .menu-list li a {
font-family: Ubuntu-Mono,'Noto Mono'; } font-family: Ubuntu-Mono,'Noto Mono'; }
.menu-list a.active {
background-color: #3273dc;
color: #fff; }
.main { .main {
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;

View File

@ -1 +1 @@
#blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.isHidden{display:none;}@media only screen and (max-width:37.5em){.isHiddenMobile{display:none;}}.petiteCaps{font-variant:petite-caps;}.flexCenter{display:flex;align-content:center;align-items:center;}.isNoWrap{white-space:nowrap;}.isFinger{cursor:pointer;}.neomorph{box-shadow:-8px -8px 16px rgba(251,238,208,.5),8px 8px 16px rgba(241,185,65,.5);}.neomorphSmall{box-shadow:-6px -6px 12px rgba(251,238,208,.5),6px 6px 12px rgba(241,185,65,.5);}.neomorphBottom{filter:drop-shadow(8px 8px 14px #f1b941);}.gradientBackground{background:linear-gradient(to right bottom,#f7d794,#f5cd79);}.borderR{border-radius:14px;}.borderRSmall{border-radius:7px;}.borderRBig{border-radius:28px;}.bg{background:#f6d287;}.sameMarginBottom{margin-bottom:1rem !important;}@font-face{font-family:'Ubuntu';src:url(/fonts/ubuntu-light-webfont.woff2) format("woff2");font-weight:300;font-style:normal;}@font-face{font-family:'Ubuntu-Mono';src:url(/fonts/ubuntumono-regular-webfont.woff2) format("woff2");font-style:normal;}html{font-family:Ubuntu,sans-serif;}.pure-menu-heading{text-transform:none;font-family:Ubuntu-Mono,'Noto Mono';}.menu-list li a{font-family:Ubuntu-Mono,'Noto Mono';}.main{display:flex;flex-wrap:nowrap;align-items:start;width:100%;height:100vh;padding:2.5%;}.mainNav{overflow-y:auto;padding:14px;width:17%;margin-right:40px;}.mainPage{overflow-y:auto;padding:28px;width:calc(83% - 40px);align-self:stretch;}.files{display:flex;flex-direction:column;align-items:stretch;}.filesWithEditor{display:flex;align-items:stretch;height:100%;}.files .buttons{justify-content:space-between;align-items:stretch;}.filesList{height:100%;overflow-y:auto;} #blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.isHidden{display:none;}@media only screen and (max-width:37.5em){.isHiddenMobile{display:none;}}.petiteCaps{font-variant:petite-caps;}.flexCenter{display:flex;align-content:center;align-items:center;}.isNoWrap{white-space:nowrap;}.isFinger{cursor:pointer;}.neomorph{box-shadow:-8px -8px 16px rgba(251,238,208,.5),8px 8px 16px rgba(241,185,65,.5);}.neomorphSmall{box-shadow:-6px -6px 12px rgba(251,238,208,.5),6px 6px 12px rgba(241,185,65,.5);}.neomorphBottom{filter:drop-shadow(8px 8px 14px #f1b941);}.gradientBackground{background:linear-gradient(to right bottom,#f7d794,#f5cd79);}.borderR{border-radius:14px;}.borderRSmall{border-radius:7px;}.borderRBig{border-radius:28px;}.bg{background:#f6d287;}.sameMarginBottom{margin-bottom:1rem !important;}@font-face{font-family:'Ubuntu';src:url(/fonts/ubuntu-light-webfont.woff2) format("woff2");font-weight:300;font-style:normal;}@font-face{font-family:'Ubuntu-Mono';src:url(/fonts/ubuntumono-regular-webfont.woff2) format("woff2");font-style:normal;}html{font-family:Ubuntu,sans-serif;}.pure-menu-heading{text-transform:none;font-family:Ubuntu-Mono,'Noto Mono';}.menu-list li a{font-family:Ubuntu-Mono,'Noto Mono';}.menu-list a.active{background-color:#3273dc;color:#fff;}.main{display:flex;flex-wrap:nowrap;align-items:start;width:100%;height:100vh;padding:2.5%;}.mainNav{overflow-y:auto;padding:14px;width:17%;margin-right:40px;}.mainPage{overflow-y:auto;padding:28px;width:calc(83% - 40px);align-self:stretch;}.files{display:flex;flex-direction:column;align-items:stretch;}.filesWithEditor{display:flex;align-items:stretch;height:100%;}.files .buttons{justify-content:space-between;align-items:stretch;}.filesList{height:100%;overflow-y:auto;}