From ba5418dc39ff66da5b1a1ce849972305d6c40e69 Mon Sep 17 00:00:00 2001 From: Masahiko AMANO Date: Wed, 15 Feb 2023 15:19:08 +0300 Subject: [PATCH] feat(web): add database management interface --- web/public/css/tdbms.css | 46 +++++++++++++ web/public/index.html | 1 + web/public/js/tdbms-management.js | 8 +++ web/public/js/tdbms-sappyou.js | 9 +++ web/public/js/tdbms-sasahyou.js | 9 +++ web/public/js/tdbms-settings.js | 68 +++++++++++++++++++ web/public/js/tdbms-shoppyou.js | 9 +++ web/public/js/tdbms-stats.js | 16 +++++ web/public/js/tdbms.js | 28 ++++---- web/public/js/tfm-settings.js | 32 +++++---- web/public/tdbms/index.html | 52 +++++++++++++++ web/public/tdbms/sappyou.html | 47 +++++++++++++ web/public/tdbms/sasahyou.html | 45 +++++++++++++ web/public/tdbms/settings.html | 107 ++++++++++++++++++++++++++++++ web/public/tdbms/shoppyou.html | 45 +++++++++++++ web/public/tdbms/stats.html | 65 ++++++++++++++++++ 16 files changed, 561 insertions(+), 26 deletions(-) create mode 100644 web/public/css/tdbms.css create mode 100644 web/public/js/tdbms-management.js create mode 100644 web/public/js/tdbms-sappyou.js create mode 100644 web/public/js/tdbms-sasahyou.js create mode 100644 web/public/js/tdbms-settings.js create mode 100644 web/public/js/tdbms-shoppyou.js create mode 100644 web/public/js/tdbms-stats.js create mode 100644 web/public/tdbms/index.html create mode 100644 web/public/tdbms/sappyou.html create mode 100644 web/public/tdbms/sasahyou.html create mode 100644 web/public/tdbms/settings.html create mode 100644 web/public/tdbms/shoppyou.html create mode 100644 web/public/tdbms/stats.html diff --git a/web/public/css/tdbms.css b/web/public/css/tdbms.css new file mode 100644 index 0000000..70983d6 --- /dev/null +++ b/web/public/css/tdbms.css @@ -0,0 +1,46 @@ +html, +body { + padding-bottom: 0; + padding-left: 0; + padding-right: 0; +} + +main { + position: relative; + width: 100%; + height: 100%; + max-width: 100vw; + background-color: #2c3034; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +main:hover { + background-color: #2c3034; +} + +.contents-wrapper { + padding: 0; + width: 100%; + height: 100%; + box-shadow: inset -5px 5px 5px #1111, inset -5px -5px 5px #1111; + overflow-y: scroll; + overflow-x: hidden; +} + +.contents-wrapper:after { + content: ""; + flex: auto; +} + +.button-flex { + position: sticky; + position: -webkit-sticky; + bottom: 0; + left: 0; + right: 0; + margin: 0; + padding-top: .5rem; + padding-bottom: .8rem; + background-color: #334; +} diff --git a/web/public/index.html b/web/public/index.html index 23ef52b..c2f7235 100644 --- a/web/public/index.html +++ b/web/public/index.html @@ -32,6 +32,7 @@
Authorize File Manager + Database Management
diff --git a/web/public/js/tdbms-management.js b/web/public/js/tdbms-management.js new file mode 100644 index 0000000..8f78a3c --- /dev/null +++ b/web/public/js/tdbms-management.js @@ -0,0 +1,8 @@ +db_name = localStorage["db_name"]; +if (db_name == null) { + location.href = "/tdbms/settings"; +} + +$(window).on("load", function (e) { + $(".db_name").text(db_name); +}); diff --git a/web/public/js/tdbms-sappyou.js b/web/public/js/tdbms-sappyou.js new file mode 100644 index 0000000..7861619 --- /dev/null +++ b/web/public/js/tdbms-sappyou.js @@ -0,0 +1,9 @@ +$(window).on("load", function (e) { + sappyou_load(); + sappyou.every(tanzaku => { + $("#content").append( + `${tanzaku.id}${new Date(tanzaku.cts * 1000).toLocaleDateString()} ${new Date(tanzaku.cts * 1000).toLocaleTimeString()}${new Date(tanzaku.mts * 1000).toLocaleDateString()} ${new Date(tanzaku.mts * 1000).toLocaleTimeString()}${tanzaku.name}${tanzaku.desc}` + ); + return true; + }); +}); diff --git a/web/public/js/tdbms-sasahyou.js b/web/public/js/tdbms-sasahyou.js new file mode 100644 index 0000000..7816f9d --- /dev/null +++ b/web/public/js/tdbms-sasahyou.js @@ -0,0 +1,9 @@ +$(window).on("load", function (e) { + sasahyou_load(); + sasahyou.every(sasa => { + $("#content").append( + `${sasa.id}${new Date(sasa.cts * 1000).toLocaleDateString()} ${new Date(sasa.cts * 1000).toLocaleTimeString()}${sasa.path}` + ); + return true; + }); +}); diff --git a/web/public/js/tdbms-settings.js b/web/public/js/tdbms-settings.js new file mode 100644 index 0000000..0e19f70 --- /dev/null +++ b/web/public/js/tdbms-settings.js @@ -0,0 +1,68 @@ +var db_name = localStorage["db_name"]; + +function settings_load() { + if (db_name != null) { + $("#db_name").val(db_name); + } else { + $("#db_name").val(""); + } + if (sort_sasa != null) { + if (sort_sasa[0] === '-') { + $("#sasa-reverse").prop("checked", true); + sort_sasa = sort_sasa.slice(1); + } + $(`#sasa-by-${sort_sasa}`).prop("checked", true); + } + if (sort_tanzaku != null) { + if (sort_tanzaku[0] === '-') { + $("#tanzaku-reverse").prop("checked", true); + sort_tanzaku = sort_tanzaku.slice(1); + } + $(`#tanzaku-by-${sort_tanzaku}`).prop("checked", true); + } +} + +$(window).on("load", function () { + settings_load(); + if (db_name != null) { + $(".db_name").text(db_name); + } + let resp = tdb_query(); + if (!resp.status) { + alert("Failed to fetch databases"); + throw new Error("Failed to fetch databases"); + } + resp.data.every(tdb => { + $("#db_name").append($("