Skip to content

Commit

Permalink
Oversight
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Jan 31, 2024
1 parent 0ee69e1 commit 50652d4
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 49 deletions.
13 changes: 9 additions & 4 deletions Protest/Database/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ public record Entry {
private long lastCachedVersion = -1;
private Cache.Entry lastCached;

private readonly JsonSerializerOptions databaseSerializerOptions = new();
private readonly JsonSerializerOptions attrubutesSerializerOptions = new();
private readonly JsonSerializerOptions attrubutesSerializerOptionsWithPassword = new();
private readonly JsonSerializerOptions contactsSerializerOptions = new();
private readonly JsonSerializerOptions databaseSerializerOptions;
private readonly JsonSerializerOptions attrubutesSerializerOptions;
private readonly JsonSerializerOptions attrubutesSerializerOptionsWithPassword;
private readonly JsonSerializerOptions contactsSerializerOptions;

public Database(string name, string location) {
this.name = name;
this.location = location;
dictionary = new ConcurrentDictionary<string, Entry>();

databaseSerializerOptions = new JsonSerializerOptions();
attrubutesSerializerOptions = new JsonSerializerOptions();
attrubutesSerializerOptionsWithPassword = new JsonSerializerOptions();
contactsSerializerOptions = new JsonSerializerOptions();

databaseSerializerOptions.Converters.Add(new DatabaseJsonConverter(name, location, true));
attrubutesSerializerOptions.Converters.Add(new AttributesJsonConverter(true));
attrubutesSerializerOptionsWithPassword.Converters.Add(new AttributesJsonConverter(false));
Expand Down
21 changes: 14 additions & 7 deletions Protest/Front/oversight.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ class Oversight extends Window {
this.socket.send(this.params.file);
this.ConsoleLog("Web-socket connection established", "info");

this.socket.send("ping=true");
this.socket.send("cpu=true");
this.socket.send("cores=true");
//this.socket.send("ping=true");
//this.socket.send("cpu=true");
//this.socket.send("cores=true");

if (this.hideConsoleOnce) {
this.hideConsoleOnce = false;
Expand Down Expand Up @@ -477,21 +477,28 @@ class Oversight extends Window {
btnOK.addEventListener("click", ()=> {
//TODO:
this.count++;
this.socket.send(`addwmi=${queryInput.value}&id=${this.count}`);
chartsList.push("");
//this.socket.send(`wmi=${queryInput.value}&id=${this.count}`);

this.socket.send(JSON.stringify({
action: "addwmi",
value: queryInput.value,
id: this.count
}));

this.chartsList.push("");
});
}

Start() {
if (!this.socket) return;
this.socket.send("start");
this.socket.send("{\"action\":\"start\"}");
this.startButton.disabled = true;
this.pauseButton.disabled = false;
}

Pause() {
if (!this.socket) return;
this.socket.send("pause");
this.socket.send("{\"action\":\"pause\"}");
this.startButton.disabled = false;
this.pauseButton.disabled = true;
}
Expand Down
12 changes: 10 additions & 2 deletions Protest/Front/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@
}
.menufilter-option:hover {
background-color: var(--clr-transparent);

border: var(--clr-transparent) 1px solid;
}
.menufilter-option:active {
background-color: color-mix(in hsl shorter hue, var(--clr-transparent) 85%, rgba(0,0,0,.6));
border: var(--clr-transparent) 1px solid;
}

#menufilterdot {
Expand Down Expand Up @@ -226,6 +227,7 @@
background-position: center 8px;
background-repeat: no-repeat;
background-color: #80808030;
box-shadow: #484848 0 0 0 1px inset;

transition: .15s;
}
Expand All @@ -247,18 +249,21 @@
background-position: 4px 4px;
background-repeat: no-repeat;
background-color: #80808030;
box-shadow: #484848 0 0 0 1px inset;

transition: .15s;
}

.menu-grid-item:hover,
.menu-list-item:hover {
background-color: var(--clr-transparent) !important;
box-shadow: var(--clr-transparent) 0 0 0 1px inset;
}

.menu-grid-item:active,
.menu-list-item:active {
background-color: color-mix(in hsl shorter hue, var(--clr-transparent) 85%, rgba(0,0,0,.6)) !important;
box-shadow: var(--clr-transparent) 0 0 0 1px inset;
}

#btnPersonalize, #btnLogout {
Expand Down Expand Up @@ -322,24 +327,27 @@
opacity: 0;
}


#username:focus-within > #btnLogout {
visibility: visible;
opacity: 1;
}
#username:focus-within > #lblUsername {
right: 48px;
background-color: var(--clr-transparent) !important;
border: var(--clr-transparent) 1px solid;
}

#lblUsername:focus {
background-color: var(--clr-transparent) !important;
border: var(--clr-transparent) 1px solid;
}
#lblUsername:hover, #btnPersonalize:hover, #btnLogout:hover {
background-color: var(--clr-transparent);
border: var(--clr-transparent) 1px solid;
}
#lblUsername:active, #btnPersonalize:active, #btnLogout:active {
background-color: color-mix(in hsl shorter hue, var(--clr-transparent) 85%, rgba(0,0,0,.6)) !important;
border: var(--clr-transparent) 1px solid;
}

#contextmenu {
Expand Down
3 changes: 2 additions & 1 deletion Protest/Front/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ const UI = {
}

//automatically disable animations if prefers-reduced-motion
if (window.matchMedia('(prefers-reduced-motion)').matches && localStorage.getItem("animations") === null)
if (window.matchMedia('(prefers-reduced-motion)').matches && localStorage.getItem("animations") === null) {
localStorage.setItem("animations", "false");
}

WIN.always_maxed = localStorage.getItem("w_always_maxed") === "true";
taskbar.className = localStorage.getItem("w_tasktooltip") === "false" ? "no-tooltip" : "";
Expand Down
3 changes: 2 additions & 1 deletion Protest/Http/Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class Auth {
private const long HOUR = 36_000_000_000L;
private const long SESSION_TIMEOUT = 120L * HOUR; //5 days

private static readonly JsonSerializerOptions serializerOptions = new();
private static readonly JsonSerializerOptions serializerOptions;

internal static readonly ConcurrentDictionary<string, AccessControl> acl = new();
internal static readonly ConcurrentDictionary<string, Session> sessions = new();
Expand All @@ -37,6 +37,7 @@ public record Session {
}

static Auth() {
serializerOptions = new JsonSerializerOptions();
serializerOptions.Converters.Add(new AccessControlJsonConverter());
}

Expand Down
6 changes: 3 additions & 3 deletions Protest/Http/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
//#define SVG_TO_SVGZ
#define SVG_TO_LIGHT

using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Collections.Generic;
using System.Text;
using System.Collections.Concurrent;
using System.Threading;

namespace Protest.Http;
Expand Down Expand Up @@ -87,7 +87,7 @@ public Cache(string path) {
LoadFiles();

#if DEBUG
Console.WriteLine("Front end cache:");
Console.WriteLine("Front-end cache:");
if (_gzip > 0) { Console.WriteLine($" GZip : {100 * _gzip / (_raw + 1),5}% {_raw,10} -> {_gzip,8}"); }
if (_deflate > 0) { Console.WriteLine($" Deflate : {100 * _deflate / (_raw + 1),5}% {_raw,10} -> {_deflate,8}"); }
if (_brotli > 0) { Console.WriteLine($" Brotli : {100 * _brotli / (_raw + 1),5}% {_raw,10} -> {_brotli,8}"); }
Expand Down
3 changes: 2 additions & 1 deletion Protest/Http/KeepAlive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ private struct Entry {

private static readonly ConcurrentDictionary<WebSocket, Entry> connections = new();

private static readonly JsonSerializerOptions messageSerializerOptions = new();
private static readonly JsonSerializerOptions messageSerializerOptions;

static KeepAlive() {
messageSerializerOptions = new JsonSerializerOptions();
messageSerializerOptions.Converters.Add(new MessageJsonConverter());
}

Expand Down
3 changes: 2 additions & 1 deletion Protest/Tasks/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ struct Result {
public int unsuccessful;
}

private static readonly JsonSerializerOptions fetchSerializerOptions = new();
private static readonly JsonSerializerOptions fetchSerializerOptions;

public static TaskWrapper task;
private static Result? result;

static Fetch() {
fetchSerializerOptions = new JsonSerializerOptions();
fetchSerializerOptions.Converters.Add(new FetchedDataJsonConverter());
}

Expand Down
3 changes: 2 additions & 1 deletion Protest/Tools/DebitNotes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Protest.Tools;
internal static class DebitNotes {
static private readonly object syncLock = new object();

static private readonly JsonSerializerOptions debitSerializerOptions = new();
static private readonly JsonSerializerOptions debitSerializerOptions;

public record Device {
public string description;
Expand All @@ -34,6 +34,7 @@ public record Record {
}

static DebitNotes() {
debitSerializerOptions = new JsonSerializerOptions();
debitSerializerOptions.Converters.Add(new DebitJsonConverter());
}

Expand Down
7 changes: 5 additions & 2 deletions Protest/Tools/LocateIp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ namespace Protest.Tools;

internal static class LocateIp {

static private readonly JsonSerializerOptions locationDerializerOptions = new();
static private readonly JsonSerializerOptions locationDerializerOptionsOnlyLocation = new();
static private readonly JsonSerializerOptions locationDerializerOptions;
static private readonly JsonSerializerOptions locationDerializerOptionsOnlyLocation;

static LocateIp() {
locationDerializerOptions = new JsonSerializerOptions();
locationDerializerOptionsOnlyLocation = new JsonSerializerOptions();

locationDerializerOptions.Converters.Add(new IP2LApiJsonConverter(false));
locationDerializerOptionsOnlyLocation.Converters.Add(new IP2LApiJsonConverter(true));
}
Expand Down
Loading

0 comments on commit 50652d4

Please sign in to comment.