1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-18 01:50:50 +00:00

Fix wails issues in frontend

This commit is contained in:
Ash Keel 2022-11-18 20:28:13 +01:00
parent 466cd0581b
commit bc54d07e86
No known key found for this signature in database
GPG key ID: BAD8D93E7314ED3E
20 changed files with 441 additions and 94 deletions

30
app.go
View file

@ -2,6 +2,7 @@ package main
import (
"context"
"strconv"
"github.com/strimertul/strimertul/modules"
"github.com/strimertul/strimertul/modules/database"
@ -16,6 +17,7 @@ type App struct {
ctx context.Context
cliParams *cli.Context
driver DatabaseDriver
manager *modules.Manager
}
// NewApp creates a new App application struct
@ -30,7 +32,7 @@ func (a *App) startup(ctx context.Context) {
a.ctx = ctx
// Create module manager
manager := modules.NewManager(logger)
a.manager = modules.NewManager(logger)
// Make KV hub
var err error
@ -50,20 +52,20 @@ func (a *App) startup(ctx context.Context) {
hub := a.driver.Hub()
go hub.Run()
db, err := database.NewDBModule(hub, manager)
db, err := database.NewDBModule(hub, a.manager)
failOnError(err, "failed to initialize database module")
// Set meta keys
_ = db.PutKey("stul-meta/version", appVersion)
for module, constructor := range moduleList {
err := constructor(manager)
err := constructor(a.manager)
if err != nil {
logger.Error("could not register module", zap.String("module", string(module)), zap.Error(err))
} else {
//goland:noinspection GoDeferInLoop
defer func() {
if err := manager.Modules[module].Close(); err != nil {
if err := a.manager.Modules[module].Close(); err != nil {
logger.Error("could not close module", zap.String("module", string(module)), zap.Error(err))
}
}()
@ -71,7 +73,7 @@ func (a *App) startup(ctx context.Context) {
}
// Create logger and endpoints
httpServer, err := http.NewServer(manager)
httpServer, err := http.NewServer(a.manager)
failOnError(err, "could not initialize http server")
defer func() {
if err := httpServer.Close(); err != nil {
@ -81,12 +83,26 @@ func (a *App) startup(ctx context.Context) {
// Run HTTP server
go failOnError(httpServer.Listen(), "HTTP server stopped")
// Wait until server is up
}
func (a *App) stop(context.Context) {
failOnError(a.driver.Close(), "could not close driver")
}
func (a *App) AuthenticateKVClient(id int64) {
a.driver.Hub().SetAuthenticated(id, true)
func (a *App) AuthenticateKVClient(id string) {
idInt, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return
}
a.driver.Hub().SetAuthenticated(idInt, true)
}
func (a *App) IsServerReady() bool {
return a.manager.Modules[modules.ModuleHTTP].Status().Working
}
func (a *App) GetKilovoltBind() string {
return a.manager.Modules[modules.ModuleHTTP].Status().Data.(http.StatusData).Bind
}

View file

@ -21,7 +21,7 @@
"@redux-devtools/extension": "^3.2.3",
"@reduxjs/toolkit": "^1.9.0",
"@stitches/react": "^1.2.8",
"@strimertul/kilovolt-client": "^6.4.0",
"@strimertul/kilovolt-client": "^6.5.0",
"@types/node": "^18.11.9",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
@ -41,7 +41,8 @@
"redux-thunk": "^2.4.2",
"sass": "^1.56.1",
"typescript": "^4.9.3",
"vite": "^3.2.4"
"vite": "^3.2.4",
"vite-tsconfig-paths": "^3.5.2"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.43.0",
@ -494,6 +495,11 @@
"resolved": "https://registry.npmjs.org/@billjs/event-emitter/-/event-emitter-1.0.3.tgz",
"integrity": "sha512-ZvzKYD/Gk9HSq42jCHFlTXb3oJztspH7WTdlVU6WdW3MKk6Jja/wWhxRSpT07aDkU69pqdUl9zx6lpG6/qxO6g=="
},
"node_modules/@cush/relative": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@cush/relative/-/relative-1.0.0.tgz",
"integrity": "sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA=="
},
"node_modules/@esbuild/android-arm": {
"version": "0.15.14",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.14.tgz",
@ -1179,9 +1185,9 @@
}
},
"node_modules/@strimertul/kilovolt-client": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/@strimertul/kilovolt-client/-/kilovolt-client-6.4.0.tgz",
"integrity": "sha512-ju80ZwiH1vSvDDeRG5OLclZHvgeO91z7bTX6ESb9XM34IrS+ryhQrbpWY1Mcvc384QwiOS6Dr444iEhXowatTQ=="
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/@strimertul/kilovolt-client/-/kilovolt-client-6.5.0.tgz",
"integrity": "sha512-FAuMgkIkBklGAsJ4xewiSHz7U51cImrmuGTduKXQy4QwwNqb/scU3fURts5oZQndskadvD7oHGsXdiZr9apuUw=="
},
"node_modules/@types/hoist-non-react-statics": {
"version": "3.3.1",
@ -1512,6 +1518,11 @@
"node": ">=4"
}
},
"node_modules/any-promise": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
"integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A=="
},
"node_modules/anymatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
@ -1599,8 +1610,7 @@
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"node_modules/binary-extensions": {
"version": "2.2.0",
@ -1614,7 +1624,6 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -1823,11 +1832,18 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
},
"node_modules/commander": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==",
"engines": {
"node": ">= 6"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"node_modules/confusing-browser-globals": {
"version": "1.0.10",
@ -2930,8 +2946,7 @@
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"node_modules/fsevents": {
"version": "2.3.2",
@ -3037,7 +3052,6 @@
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"dev": true,
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -3065,6 +3079,11 @@
"node": ">=10.13.0"
}
},
"node_modules/glob-regex": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/glob-regex/-/glob-regex-0.3.2.tgz",
"integrity": "sha512-m5blUd3/OqDTWwzBBtWBPrGlAzatRywHameHeekAZyZrskYouOGdNB8T/q6JucucvJXtOuyHIn0/Yia7iDasDw=="
},
"node_modules/globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
@ -3102,8 +3121,7 @@
"node_modules/globrex": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==",
"dev": true
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
},
"node_modules/graceful-fs": {
"version": "4.2.10",
@ -3279,7 +3297,6 @@
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"dependencies": {
"once": "^1.3.0",
"wrappy": "1"
@ -3288,8 +3305,7 @@
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/inter-ui": {
"version": "3.19.3",
@ -3631,6 +3647,11 @@
"node": ">= 0.8.0"
}
},
"node_modules/lines-and-columns": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg=="
},
"node_modules/locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
@ -3712,7 +3733,6 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
@ -3724,7 +3744,6 @@
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
"dev": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
@ -3734,6 +3753,16 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/mz": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
"integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==",
"dependencies": {
"any-promise": "^1.0.0",
"object-assign": "^4.0.1",
"thenify-all": "^1.0.0"
}
},
"node_modules/nanoid": {
"version": "3.3.4",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
@ -3775,6 +3804,14 @@
"resolved": "https://registry.npmjs.org/normalize.css/-/normalize.css-8.0.1.tgz",
"integrity": "sha512-qizSNPO93t1YUuUhP22btGOo3chcvDFqFaj2TRybP0DMxkHOCTYwp3n34fel4a31ORXy4m1Xq0Gyqpb5m33qIg=="
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",
@ -3846,7 +3883,6 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"dependencies": {
"wrappy": "1"
}
@ -3954,7 +3990,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
@ -4006,6 +4041,14 @@
"node": ">=0.10.0"
}
},
"node_modules/pirates": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz",
"integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==",
"engines": {
"node": ">= 6"
}
},
"node_modules/postcss": {
"version": "8.4.19",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.19.tgz",
@ -4338,6 +4381,23 @@
"node": ">=8.10.0"
}
},
"node_modules/recrawl-sync": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/recrawl-sync/-/recrawl-sync-2.2.3.tgz",
"integrity": "sha512-vSaTR9t+cpxlskkdUFrsEpnf67kSmPk66yAGT1fZPrDudxQjoMzPgQhSMImQ0pAw5k0NPirefQfhopSjhdUtpQ==",
"dependencies": {
"@cush/relative": "^1.0.0",
"glob-regex": "^0.3.0",
"slash": "^3.0.0",
"sucrase": "^3.20.3",
"tslib": "^1.9.3"
}
},
"node_modules/recrawl-sync/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
},
"node_modules/redux": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz",
@ -4572,7 +4632,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true,
"engines": {
"node": ">=8"
}
@ -4634,7 +4693,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
"dev": true,
"engines": {
"node": ">=4"
}
@ -4651,6 +4709,26 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/sucrase": {
"version": "3.29.0",
"resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.29.0.tgz",
"integrity": "sha512-bZPAuGA5SdFHuzqIhTAqt9fvNEo9rESqXIG3oiKdF8K4UmkQxC4KlNL3lVyAErXp+mPvUqZ5l13qx6TrDIGf3A==",
"dependencies": {
"commander": "^4.0.0",
"glob": "7.1.6",
"lines-and-columns": "^1.1.6",
"mz": "^2.7.0",
"pirates": "^4.0.1",
"ts-interface-checker": "^0.1.9"
},
"bin": {
"sucrase": "bin/sucrase",
"sucrase-node": "bin/sucrase-node"
},
"engines": {
"node": ">=8"
}
},
"node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
@ -4704,6 +4782,25 @@
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
"node_modules/thenify": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",
"integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==",
"dependencies": {
"any-promise": "^1.0.0"
}
},
"node_modules/thenify-all": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz",
"integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==",
"dependencies": {
"thenify": ">= 3.1.0 < 4"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/tiny-glob": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
@ -4733,6 +4830,11 @@
"node": ">=8.0"
}
},
"node_modules/ts-interface-checker": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz",
"integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA=="
},
"node_modules/tsconfig-paths": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
@ -4965,6 +5067,33 @@
}
}
},
"node_modules/vite-tsconfig-paths": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-3.5.2.tgz",
"integrity": "sha512-xJMgHA2oJ28QCG2f+hXrcqzo7IttrSRK4A//Tp94CfuX5eetOx33qiwXHUdi3FwkHP2ocpxHuvE45Ix67gwEmQ==",
"dependencies": {
"debug": "^4.1.1",
"globrex": "^0.1.2",
"recrawl-sync": "^2.0.3",
"tsconfig-paths": "^4.0.0"
},
"peerDependencies": {
"vite": ">2.0.0-0"
}
},
"node_modules/vite-tsconfig-paths/node_modules/tsconfig-paths": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.1.0.tgz",
"integrity": "sha512-AHx4Euop/dXFC+Vx589alFba8QItjF+8hf8LtmuiCwHyI4rHXQtOOENaM8kvYf5fR0dRChy3wzWIZ9WbB7FWow==",
"dependencies": {
"json5": "^2.2.1",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/void-elements": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz",
@ -5016,8 +5145,7 @@
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"node_modules/yallist": {
"version": "4.0.0",
@ -5355,6 +5483,11 @@
"resolved": "https://registry.npmjs.org/@billjs/event-emitter/-/event-emitter-1.0.3.tgz",
"integrity": "sha512-ZvzKYD/Gk9HSq42jCHFlTXb3oJztspH7WTdlVU6WdW3MKk6Jja/wWhxRSpT07aDkU69pqdUl9zx6lpG6/qxO6g=="
},
"@cush/relative": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@cush/relative/-/relative-1.0.0.tgz",
"integrity": "sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA=="
},
"@esbuild/android-arm": {
"version": "0.15.14",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.14.tgz",
@ -5856,9 +5989,9 @@
"requires": {}
},
"@strimertul/kilovolt-client": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/@strimertul/kilovolt-client/-/kilovolt-client-6.4.0.tgz",
"integrity": "sha512-ju80ZwiH1vSvDDeRG5OLclZHvgeO91z7bTX6ESb9XM34IrS+ryhQrbpWY1Mcvc384QwiOS6Dr444iEhXowatTQ=="
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/@strimertul/kilovolt-client/-/kilovolt-client-6.5.0.tgz",
"integrity": "sha512-FAuMgkIkBklGAsJ4xewiSHz7U51cImrmuGTduKXQy4QwwNqb/scU3fURts5oZQndskadvD7oHGsXdiZr9apuUw=="
},
"@types/hoist-non-react-statics": {
"version": "3.3.1",
@ -6076,6 +6209,11 @@
"color-convert": "^1.9.0"
}
},
"any-promise": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
"integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A=="
},
"anymatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
@ -6133,8 +6271,7 @@
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"binary-extensions": {
"version": "2.2.0",
@ -6145,7 +6282,6 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -6285,11 +6421,15 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
},
"commander": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA=="
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"confusing-browser-globals": {
"version": "1.0.10",
@ -7025,8 +7165,7 @@
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"fsevents": {
"version": "2.3.2",
@ -7098,7 +7237,6 @@
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -7117,6 +7255,11 @@
"is-glob": "^4.0.3"
}
},
"glob-regex": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/glob-regex/-/glob-regex-0.3.2.tgz",
"integrity": "sha512-m5blUd3/OqDTWwzBBtWBPrGlAzatRywHameHeekAZyZrskYouOGdNB8T/q6JucucvJXtOuyHIn0/Yia7iDasDw=="
},
"globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
@ -7145,8 +7288,7 @@
"globrex": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==",
"dev": true
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
},
"graceful-fs": {
"version": "4.2.10",
@ -7270,7 +7412,6 @@
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
@ -7279,8 +7420,7 @@
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"inter-ui": {
"version": "3.19.3",
@ -7514,6 +7654,11 @@
"type-check": "~0.4.0"
}
},
"lines-and-columns": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg=="
},
"locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
@ -7574,7 +7719,6 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -7582,14 +7726,23 @@
"minimist": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
"dev": true
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"mz": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
"integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==",
"requires": {
"any-promise": "^1.0.0",
"object-assign": "^4.0.1",
"thenify-all": "^1.0.0"
}
},
"nanoid": {
"version": "3.3.4",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
@ -7622,6 +7775,11 @@
"resolved": "https://registry.npmjs.org/normalize.css/-/normalize.css-8.0.1.tgz",
"integrity": "sha512-qizSNPO93t1YUuUhP22btGOo3chcvDFqFaj2TRybP0DMxkHOCTYwp3n34fel4a31ORXy4m1Xq0Gyqpb5m33qIg=="
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="
},
"object-inspect": {
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",
@ -7672,7 +7830,6 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1"
}
@ -7749,8 +7906,7 @@
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-key": {
"version": "3.1.1",
@ -7784,6 +7940,11 @@
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
},
"pirates": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz",
"integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ=="
},
"postcss": {
"version": "8.4.19",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.19.tgz",
@ -7963,6 +8124,25 @@
"picomatch": "^2.2.1"
}
},
"recrawl-sync": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/recrawl-sync/-/recrawl-sync-2.2.3.tgz",
"integrity": "sha512-vSaTR9t+cpxlskkdUFrsEpnf67kSmPk66yAGT1fZPrDudxQjoMzPgQhSMImQ0pAw5k0NPirefQfhopSjhdUtpQ==",
"requires": {
"@cush/relative": "^1.0.0",
"glob-regex": "^0.3.0",
"slash": "^3.0.0",
"sucrase": "^3.20.3",
"tslib": "^1.9.3"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}
}
},
"redux": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz",
@ -8119,8 +8299,7 @@
"slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q=="
},
"source-map-js": {
"version": "1.0.2",
@ -8166,8 +8345,7 @@
"strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
"dev": true
"integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA=="
},
"strip-json-comments": {
"version": "3.1.1",
@ -8175,6 +8353,19 @@
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true
},
"sucrase": {
"version": "3.29.0",
"resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.29.0.tgz",
"integrity": "sha512-bZPAuGA5SdFHuzqIhTAqt9fvNEo9rESqXIG3oiKdF8K4UmkQxC4KlNL3lVyAErXp+mPvUqZ5l13qx6TrDIGf3A==",
"requires": {
"commander": "^4.0.0",
"glob": "7.1.6",
"lines-and-columns": "^1.1.6",
"mz": "^2.7.0",
"pirates": "^4.0.1",
"ts-interface-checker": "^0.1.9"
}
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
@ -8210,6 +8401,22 @@
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
"thenify": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",
"integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==",
"requires": {
"any-promise": "^1.0.0"
}
},
"thenify-all": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz",
"integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==",
"requires": {
"thenify": ">= 3.1.0 < 4"
}
},
"tiny-glob": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
@ -8233,6 +8440,11 @@
"is-number": "^7.0.0"
}
},
"ts-interface-checker": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz",
"integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA=="
},
"tsconfig-paths": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
@ -8363,6 +8575,29 @@
"rollup": "^2.79.1"
}
},
"vite-tsconfig-paths": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-3.5.2.tgz",
"integrity": "sha512-xJMgHA2oJ28QCG2f+hXrcqzo7IttrSRK4A//Tp94CfuX5eetOx33qiwXHUdi3FwkHP2ocpxHuvE45Ix67gwEmQ==",
"requires": {
"debug": "^4.1.1",
"globrex": "^0.1.2",
"recrawl-sync": "^2.0.3",
"tsconfig-paths": "^4.0.0"
},
"dependencies": {
"tsconfig-paths": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.1.0.tgz",
"integrity": "sha512-AHx4Euop/dXFC+Vx589alFba8QItjF+8hf8LtmuiCwHyI4rHXQtOOENaM8kvYf5fR0dRChy3wzWIZ9WbB7FWow==",
"requires": {
"json5": "^2.2.1",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
}
}
}
},
"void-elements": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz",
@ -8399,8 +8634,7 @@
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"yallist": {
"version": "4.0.0",

View file

@ -16,7 +16,7 @@
"@redux-devtools/extension": "^3.2.3",
"@reduxjs/toolkit": "^1.9.0",
"@stitches/react": "^1.2.8",
"@strimertul/kilovolt-client": "^6.4.0",
"@strimertul/kilovolt-client": "^6.5.0",
"@types/node": "^18.11.9",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
@ -36,7 +36,8 @@
"redux-thunk": "^2.4.2",
"sass": "^1.56.1",
"typescript": "^4.9.3",
"vite": "^3.2.4"
"vite": "^3.2.4",
"vite-tsconfig-paths": "^3.5.2"
},
"scripts": {
"start": "vite",

View file

@ -1 +1 @@
15be0719d397474cd44695819d1b250f
24591b6315c04d57021b01b6fdb4e73f

View file

@ -11,4 +11,14 @@ export function getInterval(duration: number): [number, number] {
return [duration, 1];
}
/**
* Wait for an amount of time using async/await
* @param ms How many milliseconds to wait
*/
export function delay(ms: number): Promise<void> {
return new Promise((resolve) => {
setTimeout(() => resolve(), ms);
});
}
export default { getInterval };

View file

@ -11,6 +11,8 @@ import {
} from '@reduxjs/toolkit';
import KilovoltWS from '@strimertul/kilovolt-client';
import type { kvError } from '@strimertul/kilovolt-client/types/messages';
import { AuthenticateKVClient, IsServerReady } from '@wailsapp/go/main/App';
import { delay } from '../../lib/time-utils';
import {
APIState,
ConnectionStatus,
@ -91,6 +93,18 @@ const loyaltyRemoveRedeemKey = 'loyalty/@remove-redeem';
export const createWSClient = createAsyncThunk(
'api/createClient',
async (options: { address: string; password?: string }, { dispatch }) => {
// Wait for server to be ready
let ready = false;
while (!ready) {
// eslint-disable-next-line no-await-in-loop
ready = await IsServerReady();
if (ready) {
break;
}
// eslint-disable-next-line no-await-in-loop
await delay(1000);
}
// Connect to websocket
const client = new KilovoltWS(options.address, options.password);
client.on('error', (err) => {
void dispatch(kvErrorReceived(err.data as kvError));
@ -399,7 +413,21 @@ kvErrorReceived = createAsyncThunk(
default:
// Unsupported error
dispatch(apiReducer.actions.kvErrorReceived(error));
console.error(error);
}
},
);
export const useAuthBypass = createAsyncThunk(
'api/authBypass',
async (_: void, { getState, dispatch }) => {
const { api } = getState() as { api: APIState };
const response = await api.client.send({ command: '_uid' });
if ('ok' in response && response.ok && 'data' in response) {
const uid = response.data;
await AuthenticateKVClient(uid.toString());
dispatch(
apiReducer.actions.connectionStatusChanged(ConnectionStatus.Connected),
);
}
},
);

View file

@ -13,12 +13,13 @@ import {
} from '@radix-ui/react-icons';
import { Route, Routes } from 'react-router-dom';
import { ToastContainer } from 'react-toastify';
import { GetKilovoltBind } from '@wailsapp/go/main/App';
import Dashboard from './pages/Dashboard';
import Sidebar, { RouteSection } from './components/Sidebar';
import ServerSettingsPage from './pages/ServerSettings';
import { RootState, useAppDispatch } from '../store';
import { createWSClient } from '../store/api/reducer';
import { createWSClient, useAuthBypass } from '../store/api/reducer';
import { ConnectionStatus } from '../store/api/types';
import { styled } from './theme';
@ -154,17 +155,21 @@ export default function App(): JSX.Element {
);
const dispatch = useAppDispatch();
useEffect(() => {
if (!client) {
void dispatch(
const connectToKV = async () => {
const address = await GetKilovoltBind();
await dispatch(
createWSClient({
address:
process.env.NODE_ENV === 'development'
? 'ws://localhost:4337/ws'
: `ws://${window.location.host}/ws`,
password: localStorage.password as string,
address: `ws://${address}/ws`,
}),
);
};
useEffect(() => {
if (!client) {
void connectToKV();
}
if (connected === ConnectionStatus.AuthenticationNeeded) {
void dispatch(useAuthBypass());
}
});

View file

@ -0,0 +1,22 @@
import React from 'react';
import { BrowserOpenURL } from '@wailsapp/runtime';
function BrowserLink(props: React.AnchorHTMLAttributes<HTMLAnchorElement>) {
if (!props.href) {
return <a {...props}></a>;
}
const properties = { ...props };
delete properties.href;
return (
<a
{...properties}
style={{ ...properties.style, cursor: 'pointer' }}
onClick={() => {
BrowserOpenURL(props.href);
}}
></a>
);
}
export default React.memo(BrowserLink);

View file

@ -9,6 +9,7 @@ import { APPNAME, APPREPO } from '../theme';
// @ts-expect-error Asset import
import logo from '../../assets/icon-logo.svg';
import BrowserLink from './BrowserLink';
export interface RouteSection {
title: string;
@ -76,7 +77,7 @@ const VersionLabel = styled('div', {
paddingBottom: '0.4rem',
});
const UpdateButton = styled('a', {
const UpdateButton = styled(BrowserLink, {
textTransform: 'uppercase',
fontSize: '0.75rem',
fontWeight: 'bold',

View file

@ -26,6 +26,7 @@ import {
} from '../theme';
import eventsubTests from '../../data/eventsub-tests';
import { RootState, useAppDispatch } from '../../store';
import BrowserLink from '../components/BrowserLink';
interface UserData {
id: string;
@ -294,7 +295,9 @@ export default function BackendIntegrationPage(): React.ReactElement {
<TextBlock>
<Trans i18nKey="pages.stulbe.subtitle">
{' '}
<a href="https://github.com/strimertul/stulbe/">stulbe</a>
<BrowserLink href="https://github.com/strimertul/stulbe/">
stulbe
</BrowserLink>
</Trans>
</TextBlock>
</PageHeader>

View file

@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { PageContainer, SectionHeader, styled } from '../theme';
import { useLiveKey } from '../../lib/react-utils';
import WIPNotice from '../components/utils/WIPNotice';
import BrowserLink from '../components/BrowserLink';
interface StreamInfo {
id: string;
@ -47,7 +48,7 @@ const LiveIndicator = styled('div', {
backgroundSize: 'cover',
backgroundPosition: 'center',
});
const Darken = styled('a', {
const Darken = styled(BrowserLink, {
flex: 1,
display: 'flex',
alignItems: 'center',

View file

@ -3,6 +3,7 @@ import { keyframes } from '@stitches/react';
import { Trans, useTranslation } from 'react-i18next';
import { GitHubLogoIcon, TwitterLogoIcon } from '@radix-ui/react-icons';
import { APPNAME, PageContainer, PageHeader, styled } from '../theme';
import BrowserLink from '../components/BrowserLink';
// @ts-expect-error Asset import
import logo from '../../assets/icon-logo.svg';
@ -63,7 +64,7 @@ const Channel = styled('li', {
marginBottom: '1rem',
fontSize: '1.5rem',
});
const ChannelLink = styled('a', {
const ChannelLink = styled(BrowserLink, {
textDecoration: 'none',
color: '$teal11',
display: 'inline-flex',
@ -127,9 +128,9 @@ export default function StrimertulPage(): React.ReactElement {
values={{ APPNAME }}
components={{
license: (
<a href="https://github.com/strimertul/strimertul/blob/master/LICENSE">
<BrowserLink href="https://github.com/strimertul/strimertul/blob/master/LICENSE">
GNU Affero General Public License v3.0
</a>
</BrowserLink>
),
}}
/>

View file

@ -4,6 +4,7 @@ import { Trans, useTranslation } from 'react-i18next';
import { useModule, useStatus } from '../../lib/react-utils';
import { useAppDispatch } from '../../store';
import apiReducer, { modules } from '../../store/api/reducer';
import BrowserLink from '../components/BrowserLink';
import DefinitionTable from '../components/DefinitionTable';
import SaveButton from '../components/utils/SaveButton';
import {
@ -148,9 +149,9 @@ function TwitchBotSettings() {
<FieldNote>
<Trans i18nKey="pages.twitch-settings.bot-oauth-note">
{' '}
<a href="https://twitchapps.com/tmi/">
<BrowserLink href="https://twitchapps.com/tmi/">
https://twitchapps.com/tmi/
</a>
</BrowserLink>
</Trans>
</FieldNote>
</Field>
@ -206,9 +207,9 @@ function TwitchAPISettings() {
<Step>
<Trans i18nKey="pages.twitch-settings.apiguide-2">
{' '}
<a href="https://dev.twitch.tv/console/apps/create">
<BrowserLink href="https://dev.twitch.tv/console/apps/create">
https://dev.twitch.tv/console/apps/create
</a>
</BrowserLink>
</Trans>
</Step>
<Step>

View file

@ -5,6 +5,10 @@
"allowSyntheticDefaultImports": true,
"jsx": "react",
"lib": ["es2019", "dom"],
"resolveJsonModule": true
"resolveJsonModule": true,
"baseUrl": ".",
"paths": {
"@wailsapp/*": ["./wailsjs/*"]
}
}
}

View file

@ -1,6 +1,7 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig({
plugins: [react()],
plugins: [tsconfigPaths(), react()],
});

View file

@ -1,4 +1,8 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
export function AuthenticateKVClient(arg1:number):Promise<void>;
export function AuthenticateKVClient(arg1:string):Promise<void>;
export function GetKilovoltBind():Promise<string>;
export function IsServerReady():Promise<boolean>;

View file

@ -5,3 +5,11 @@
export function AuthenticateKVClient(arg1) {
return window['go']['main']['App']['AuthenticateKVClient'](arg1);
}
export function GetKilovoltBind() {
return window['go']['main']['App']['GetKilovoltBind']();
}
export function IsServerReady() {
return window['go']['main']['App']['IsServerReady']();
}

2
go.mod
View file

@ -10,7 +10,7 @@ require (
github.com/json-iterator/go v1.1.12
github.com/labstack/gommon v0.3.1
github.com/nicklaw5/helix/v2 v2.11.0
github.com/strimertul/kilovolt/v9 v9.0.0
github.com/strimertul/kilovolt/v9 v9.0.1
github.com/strimertul/kv-pebble v1.2.0
github.com/strimertul/stulbe-client-go v0.7.2
github.com/urfave/cli/v2 v2.23.5

8
go.sum
View file

@ -436,19 +436,22 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/strimertul/kilovolt-client-go/v8 v8.0.0 h1:d3BAm5qavK9GPUpOtljpsyrjmSfR2AInGe1ypZP9apc=
github.com/strimertul/kilovolt-client-go/v8 v8.0.0/go.mod h1:PNEbu0zrdYD9B9UYUoLSpV+saRJlC0cr9OHdPALUb+o=
github.com/strimertul/kilovolt/v8 v8.0.0/go.mod h1:vW++ELCWnYzENIIP33p+zDGQjz/GpQ5z7YRCBrBtCzA=
github.com/strimertul/kilovolt/v8 v8.0.5 h1:m3b6OK34qLywS+zhQFWoZJpRf9ImiLCWNIFhSFrIsdw=
github.com/strimertul/kilovolt/v8 v8.0.5/go.mod h1:rGfAix+UFEUTlwcI2BtHpwZ2JsqfOKZiexf8TkOUBwQ=
github.com/strimertul/kilovolt/v9 v9.0.0 h1:sKEOZf5UGFYLnB+7U9SyMlQfPc5aLQjgLqIVJDMIF14=
github.com/strimertul/kilovolt/v9 v9.0.0/go.mod h1:vyWfi7iAXdZ6+K2G+CE+PeIJWEHdAbuCdOZfIWs9NVo=
github.com/strimertul/kilovolt/v9 v9.0.1 h1:T915LgdbJpu3XZ4Idt+Tvv7hDW1wmSDmQCDj4696bUY=
github.com/strimertul/kilovolt/v9 v9.0.1/go.mod h1:i9cizfUV9B+XYkmLSPr2dhNe8kt4R0xjG2kCZb7XoZg=
github.com/strimertul/kv-pebble v1.2.0 h1:hX4bp1CntBvBwfjDjlpWrRYb1+JouMGUjv9e+7STcPI=
github.com/strimertul/kv-pebble v1.2.0/go.mod h1:FGLXP0Wagoz/JSZITG0PAlLvUdCE6bbCOzbdmqU45JY=
github.com/strimertul/stulbe-client-go v0.7.2 h1:mco2JjkYuahgq1p8nlH7TRWNgFKyQMPb83AnBNO6B6E=
@ -852,6 +855,7 @@ gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View file

@ -78,13 +78,16 @@ func NewServer(manager *modules.Manager) (*Server, error) {
return server, nil
}
// StatusData contains status info for the HTTP module
type StatusData struct {
Bind string
}
func (s *Server) Status() modules.ModuleStatus {
return modules.ModuleStatus{
Enabled: true,
Working: s.server != nil,
Data: struct {
Bind string
}{
Data: StatusData{
s.server.Addr,
},
StatusString: s.server.Addr,