From dbd3f48f6863f301ad890e2eb3d4e9ffcab77d30 Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Sat, 21 Aug 2021 21:12:44 +0200 Subject: [PATCH 01/31] Added clean monitor table for smaller screens --- src/assets/app.scss | 12 ++++++++++++ src/pages/DashboardHome.vue | 29 +++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/assets/app.scss b/src/assets/app.scss index f043d785b..851b1c2e9 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -80,6 +80,12 @@ h2 { } } +@media (max-width: 550px) { + tbody .shadow-box { + background-color: white; + } +} + // Dark Theme override here .dark { background-color: #090C10; @@ -192,6 +198,12 @@ h2 { .multiselect__option--selected { background-color: $dark-bg; } + + @media (max-width: 550px) { + tbody .shadow-box { + background-color: $dark-bg2; + } + } } /* diff --git a/src/pages/DashboardHome.vue b/src/pages/DashboardHome.vue index 5c14eb356..fa4e6817a 100644 --- a/src/pages/DashboardHome.vue +++ b/src/pages/DashboardHome.vue @@ -49,11 +49,11 @@ - + {{ beat.name }} - {{ beat.msg }} + {{ beat.msg }} @@ -191,4 +191,29 @@ table { transition: all ease-in-out 0.2ms; } } + +@media (max-width: 550px) { + .no-border { + border: 0px; + } + + tr.shadow-box, .shadow-box:last-child { + padding: 10px; + } + + thead { + display: none; + } + + tr { + display: block; + margin-bottom: 10px; + } + + td { + border-bottom: 1px solid $dark-font-color; + display: block; + padding: 6px; + } +} From ca38cc91e9ab73ce997a781f1dac7ecf6570e780 Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Sat, 21 Aug 2021 21:12:44 +0200 Subject: [PATCH 02/31] Use bootstrap integraded class instead of new ones --- src/pages/DashboardHome.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pages/DashboardHome.vue b/src/pages/DashboardHome.vue index fa4e6817a..23632c8ab 100644 --- a/src/pages/DashboardHome.vue +++ b/src/pages/DashboardHome.vue @@ -52,8 +52,8 @@ {{ beat.name }} - - {{ beat.msg }} + + {{ beat.msg }} @@ -193,10 +193,6 @@ table { } @media (max-width: 550px) { - .no-border { - border: 0px; - } - tr.shadow-box, .shadow-box:last-child { padding: 10px; } From b892a92fc8d515addf967378f41fe2cdd008f2e1 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Sun, 22 Aug 2021 23:35:24 +0800 Subject: [PATCH 03/31] retry if acquire error --- server/database.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/database.js b/server/database.js index ff0304f1f..8c7de6213 100644 --- a/server/database.js +++ b/server/database.js @@ -40,20 +40,22 @@ class Database { Dialect.prototype.destroyRawConnection = async () => { } + const acquireConnectionTimeout = 120 * 1000; + const knexInstance = knex({ client: Dialect, connection: { }, // Do not remove, Leave it empty is ok useNullAsDefault: true, + acquireConnectionTimeout: acquireConnectionTimeout, pool: { min: 1, max: 1, - idleTimeoutMillis: 30000, + idleTimeoutMillis: 120 * 1000, + propagateCreateError: false, + acquireTimeoutMillis: acquireConnectionTimeout, } }); - console.log( knexInstance.pool) - console.log("pool size") - R.setup(knexInstance); if (process.env.SQL_LOG === "1") { From ce79f8bfc76dbfffff0db2cbea6834cbc6a0df02 Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Mon, 23 Aug 2021 01:22:55 +0200 Subject: [PATCH 04/31] CSS optimizations --- src/assets/app.scss | 24 ++++++++++++++++++++++++ src/pages/DashboardHome.vue | 24 ++---------------------- src/pages/Details.vue | 8 ++++---- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/assets/app.scss b/src/assets/app.scss index 851b1c2e9..5a6d1c64b 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -84,6 +84,30 @@ h2 { tbody .shadow-box { background-color: white; } + + div.tableShadowbox { + padding: 10px !important; + } + + .tableShadowbox tr { + margin-top: 0 !important; + padding: 10px !important; + } + + .tableShadowbox thead { + display: none; + } + + .tableShadowbox tr { + display: block; + margin-bottom: 10px; + } + + .tableShadowbox td { + border-bottom: 1px solid $dark-font-color; + display: block; + padding: 6px; + } } // Dark Theme override here diff --git a/src/pages/DashboardHome.vue b/src/pages/DashboardHome.vue index 23632c8ab..2821c575f 100644 --- a/src/pages/DashboardHome.vue +++ b/src/pages/DashboardHome.vue @@ -38,7 +38,7 @@ -
+
@@ -182,6 +182,7 @@ export default { .shadow-box { padding: 20px; + margin-top: 25px; } table { @@ -191,25 +192,4 @@ table { transition: all ease-in-out 0.2ms; } } - -@media (max-width: 550px) { - tr.shadow-box, .shadow-box:last-child { - padding: 10px; - } - - thead { - display: none; - } - - tr { - display: block; - margin-bottom: 10px; - } - - td { - border-bottom: 1px solid $dark-font-color; - display: block; - padding: 6px; - } -} diff --git a/src/pages/Details.vue b/src/pages/Details.vue index b723def2e..05b001ed5 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -128,7 +128,7 @@ -
+
@@ -138,10 +138,10 @@ - + - - + + From ee3bf2961cc57ff757e333c545b3bec6874a5865 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 23 Aug 2021 11:33:24 +0800 Subject: [PATCH 05/31] Fix: fix typescript errors --- src/util.ts | 24 ++++++++++++++---------- tsconfig.json | 7 ++++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/util.ts b/src/util.ts index 7d7b8e01d..3b96f7b94 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,4 +1,3 @@ -// @ts-nocheck // Common Util for frontend and backend // Backend uses the compiled file util.js // Frontend uses util.ts @@ -13,7 +12,7 @@ export const DOWN = 0; export const UP = 1; export const PENDING = 2; -export function flipStatus(s) { +export function flipStatus(s: number) { if (s === UP) { return DOWN; } @@ -25,7 +24,7 @@ export function flipStatus(s) { return s; } -export function sleep(ms) { +export function sleep(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); } @@ -33,8 +32,8 @@ export function sleep(ms) { * PHP's ucfirst * @param str */ -export function ucfirst(str) { - if (! str) { +export function ucfirst(str: string) { + if (!str) { return str; } @@ -42,12 +41,15 @@ export function ucfirst(str) { return firstLetter.toUpperCase() + str.substr(1); } -export function debug(msg) { +export function debug(msg: any) { if (isDev) { console.log(msg); } } + +declare global { interface String { replaceAll(str: string, newStr: string): string; } } + export function polyfill() { /** * String.prototype.replaceAll() polyfill @@ -56,7 +58,7 @@ export function polyfill() { * @license MIT */ if (!String.prototype.replaceAll) { - String.prototype.replaceAll = function (str, newStr) { + String.prototype.replaceAll = function (str: string, newStr: string) { // If a regex pattern if (Object.prototype.toString.call(str).toLowerCase() === "[object regexp]") { @@ -71,11 +73,13 @@ export function polyfill() { } export class TimeLogger { + startTime: number; + constructor() { this.startTime = dayjs().valueOf(); } - print(name) { + print(name: string) { if (isDev) { console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms") } @@ -85,7 +89,7 @@ export class TimeLogger { /** * Returns a random number between min (inclusive) and max (exclusive) */ -export function getRandomArbitrary(min, max) { +export function getRandomArbitrary(min: number, max: number) { return Math.random() * (max - min) + min; } @@ -98,7 +102,7 @@ export function getRandomArbitrary(min, max) { * lower than max if max isn't an integer). * Using Math.round() will give you a non-uniform distribution! */ -export function getRandomInt(min, max) { +export function getRandomInt(min: number, max: number) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; diff --git a/tsconfig.json b/tsconfig.json index eb23619e4..41db8c524 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,14 +4,15 @@ "target": "es2018", "module": "commonjs", "lib": [ - "es2020" + "es2020", + "DOM", ], "removeComments": true, "preserveConstEnums": true, "sourceMap": false, - "files.insertFinalNewline": true + "strict": true }, "files": [ - "./server/util.ts" + "./src/util.ts" ] } From a02edf1b4ffc714bef1672286113f00b7342d568 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Mon, 23 Aug 2021 16:59:27 +0800 Subject: [PATCH 06/31] fix detail page empty if the monitor list is not yet ready --- src/pages/Details.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Details.vue b/src/pages/Details.vue index b723def2e..016fc81c1 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -1,6 +1,6 @@
{{ beat.msg }}{{ beat.msg }}