cmdbox 0.5.1.2__py3-none-any.whl → 0.5.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cmdbox might be problematic. Click here for more details.
- cmdbox/app/app.py +4 -2
- cmdbox/app/auth/signin.py +634 -631
- cmdbox/app/client.py +10 -10
- cmdbox/app/common.py +50 -6
- cmdbox/app/commons/convert.py +9 -0
- cmdbox/app/commons/module.py +113 -113
- cmdbox/app/commons/redis_client.py +40 -29
- cmdbox/app/edge.py +4 -4
- cmdbox/app/features/cli/audit_base.py +138 -0
- cmdbox/app/features/cli/cmdbox_audit_createdb.py +224 -0
- cmdbox/app/features/cli/cmdbox_audit_delete.py +308 -0
- cmdbox/app/features/cli/cmdbox_audit_search.py +416 -0
- cmdbox/app/features/cli/cmdbox_audit_write.py +247 -0
- cmdbox/app/features/cli/cmdbox_client_file_copy.py +207 -207
- cmdbox/app/features/cli/cmdbox_client_file_download.py +207 -207
- cmdbox/app/features/cli/cmdbox_client_file_list.py +193 -193
- cmdbox/app/features/cli/cmdbox_client_file_mkdir.py +191 -191
- cmdbox/app/features/cli/cmdbox_client_file_move.py +199 -199
- cmdbox/app/features/cli/cmdbox_client_file_remove.py +190 -190
- cmdbox/app/features/cli/cmdbox_client_file_rmdir.py +190 -190
- cmdbox/app/features/cli/cmdbox_client_file_upload.py +212 -212
- cmdbox/app/features/cli/cmdbox_client_server_info.py +166 -166
- cmdbox/app/features/cli/cmdbox_server_list.py +88 -88
- cmdbox/app/features/cli/cmdbox_server_stop.py +138 -138
- cmdbox/app/features/web/cmdbox_web_audit.py +81 -0
- cmdbox/app/features/web/cmdbox_web_audit_metrics.py +72 -0
- cmdbox/app/features/web/cmdbox_web_del_cmd.py +2 -0
- cmdbox/app/features/web/cmdbox_web_del_pipe.py +1 -0
- cmdbox/app/features/web/cmdbox_web_do_signin.py +12 -2
- cmdbox/app/features/web/cmdbox_web_do_signout.py +1 -0
- cmdbox/app/features/web/cmdbox_web_exec_cmd.py +31 -2
- cmdbox/app/features/web/cmdbox_web_exec_pipe.py +1 -0
- cmdbox/app/features/web/cmdbox_web_filer download.py +43 -42
- cmdbox/app/features/web/cmdbox_web_filer.py +1 -0
- cmdbox/app/features/web/cmdbox_web_filer_upload.py +65 -64
- cmdbox/app/features/web/cmdbox_web_gui.py +166 -165
- cmdbox/app/features/web/cmdbox_web_load_pin.py +43 -43
- cmdbox/app/features/web/cmdbox_web_raw_pipe.py +87 -87
- cmdbox/app/features/web/cmdbox_web_save_cmd.py +1 -0
- cmdbox/app/features/web/cmdbox_web_save_pin.py +42 -42
- cmdbox/app/features/web/cmdbox_web_save_pipe.py +1 -0
- cmdbox/app/features/web/cmdbox_web_user_data.py +58 -0
- cmdbox/app/features/web/cmdbox_web_users.py +12 -0
- cmdbox/app/options.py +788 -601
- cmdbox/app/web.py +7 -1
- cmdbox/extensions/features.yml +23 -0
- cmdbox/extensions/sample_project/sample/app/features/cli/sample_client_time.py +82 -82
- cmdbox/extensions/sample_project/sample/app/features/cli/sample_server_time.py +145 -145
- cmdbox/extensions/user_list.yml +5 -0
- cmdbox/licenses/{LICENSE.Sphinx.8.1.3(BSD License).txt → LICENSE.Sphinx.8.2.3(UNKNOWN).txt} +1 -1
- cmdbox/licenses/LICENSE.argcomplete.3.6.2(Apache Software License).txt +177 -0
- cmdbox/licenses/{LICENSE.babel.2.16.0(BSD License).txt → LICENSE.babel.2.17.0(BSD License).txt } +1 -1
- cmdbox/licenses/{LICENSE.pkginfo.1.10.0(MIT License).txt → LICENSE.charset-normalizer.3.4.1(MIT License).txt } +1 -1
- cmdbox/licenses/LICENSE.gevent.25.4.1(MIT).txt +25 -0
- cmdbox/licenses/LICENSE.greenlet.3.2.0(MIT AND Python-2.0).txt +30 -0
- cmdbox/licenses/LICENSE.gunicorn.23.0.0(MIT License).txt +23 -0
- cmdbox/licenses/LICENSE.importlib_metadata.8.6.1(Apache Software License).txt +202 -0
- cmdbox/licenses/LICENSE.nh3.0.2.21(MIT).txt +21 -0
- cmdbox/licenses/{LICENSE.pillow.11.0.0(CMU License (MIT-CMU)).txt → LICENSE.pillow.11.1.0(CMU License (MIT-CMU)).txt } +27 -40
- cmdbox/licenses/LICENSE.pillow.11.2.1(UNKNOWN).txt +1200 -0
- cmdbox/licenses/LICENSE.plyer.2.1.0(MIT License).txt +19 -0
- cmdbox/licenses/LICENSE.prompt_toolkit.3.0.50(BSD License).txt +27 -0
- cmdbox/licenses/LICENSE.prompt_toolkit.3.0.51(BSD License).txt +27 -0
- cmdbox/licenses/LICENSE.psycopg-binary.3.2.6(GNU Lesser General Public License v3 (LGPLv3)).txt +165 -0
- cmdbox/licenses/LICENSE.psycopg-pool.3.2.6(GNU Lesser General Public License v3 (LGPLv3)).txt +165 -0
- cmdbox/licenses/LICENSE.psycopg.3.2.6(GNU Lesser General Public License v3 (LGPLv3)).txt +165 -0
- cmdbox/licenses/LICENSE.pycryptodome.3.22.0(BSD License; Public Domain).txt +61 -0
- cmdbox/licenses/LICENSE.pydantic.2.11.3(MIT License).txt +21 -0
- cmdbox/licenses/LICENSE.pydantic_core.2.33.1(MIT License).txt +21 -0
- cmdbox/licenses/LICENSE.pystray.0.19.5(GNU Lesser General Public License v3 (LGPLv3)).txt +674 -0
- cmdbox/licenses/LICENSE.questionary.2.1.0(MIT License).txt +19 -0
- cmdbox/licenses/LICENSE.roman-numerals-py.3.1.0(CC0 1.0 Universal (CC0 1.0) Public Domain Dedication; Zero-Clause BSD (0BSD)).txt +146 -0
- cmdbox/licenses/{LICENSE.six.1.16.0(MIT License).txt → LICENSE.six.1.17.0(MIT License).txt } +1 -1
- cmdbox/licenses/LICENSE.starlette.0.46.2(BSD License).txt +27 -0
- cmdbox/licenses/{LICENSE.charset-normalizer.3.4.0(MIT License).txt → LICENSE.typing-inspection.0.4.0(MIT License).txt } +2 -2
- cmdbox/licenses/LICENSE.typing_extensions.4.13.2(UNKNOWN).txt +279 -0
- cmdbox/licenses/LICENSE.tzdata.2025.2(Apache Software License).txt +15 -0
- cmdbox/licenses/LICENSE.urllib3.2.4.0(UNKNOWN).txt +21 -0
- cmdbox/licenses/LICENSE.uvicorn.0.34.1(BSD License).txt +27 -0
- cmdbox/licenses/LICENSE.watchfiles.1.0.5(MIT License).txt +21 -0
- cmdbox/licenses/files.txt +49 -38
- cmdbox/logconf_audit.yml +30 -0
- cmdbox/logconf_cmdbox.yml +30 -0
- cmdbox/version.py +2 -2
- cmdbox/web/assets/apexcharts/apexcharts.css +679 -0
- cmdbox/web/assets/apexcharts/apexcharts.min.js +38 -0
- cmdbox/web/assets/cmdbox/audit.js +340 -0
- cmdbox/web/assets/cmdbox/color_mode.css +520 -0
- cmdbox/web/assets/cmdbox/common.js +416 -24
- cmdbox/web/assets/cmdbox/filer_modal.js +1 -1
- cmdbox/web/assets/cmdbox/list_cmd.js +10 -275
- cmdbox/web/assets/cmdbox/list_pipe.js +3 -3
- cmdbox/web/assets/cmdbox/main.js +2 -2
- cmdbox/web/assets/cmdbox/result.js +2 -2
- cmdbox/web/assets/cmdbox/signin.js +2 -2
- cmdbox/web/assets/cmdbox/users.js +19 -20
- cmdbox/web/assets/cmdbox/view_raw.js +1 -1
- cmdbox/web/assets/cmdbox/view_result.js +11 -13
- cmdbox/web/assets/filer/filer.js +2 -2
- cmdbox/web/assets/filer/main.js +2 -2
- cmdbox/web/assets_license_list.txt +4 -1
- cmdbox/web/audit.html +268 -0
- cmdbox/web/filer.html +37 -12
- cmdbox/web/gui.html +36 -53
- cmdbox/web/result.html +24 -3
- cmdbox/web/signin.html +35 -14
- cmdbox/web/users.html +21 -3
- {cmdbox-0.5.1.2.dist-info → cmdbox-0.5.3.dist-info}/METADATA +28 -5
- {cmdbox-0.5.1.2.dist-info → cmdbox-0.5.3.dist-info}/RECORD +142 -103
- {cmdbox-0.5.1.2.dist-info → cmdbox-0.5.3.dist-info}/entry_points.txt +0 -1
- cmdbox/licenses/LICENSE.nh3.0.2.18(MIT).txt +0 -1
- /cmdbox/licenses/{LICENSE.Jinja2.3.1.4(BSD License).txt → LICENSE.Jinja2.3.1.6(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.Pygments.2.18.0(BSD License).txt → LICENSE.Pygments.2.19.1(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.anyio.4.6.2.post1(MIT License).txt → LICENSE.anyio.4.9.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.argcomplete.3.5.1(Apache Software License).txt → LICENSE.argcomplete.3.6.1(Apache Software License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.certifi.2024.8.30(Mozilla Public License 2.0 (MPL 2.0)).txt → LICENSE.certifi.2025.1.31(Mozilla Public License 2.0 (MPL 2.0)).txt} +0 -0
- /cmdbox/licenses/{LICENSE.click.8.1.7(BSD License).txt → LICENSE.click.8.1.8(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.cryptography.43.0.3(Apache Software License; BSD License).txt → LICENSE.cryptography.44.0.2(Apache Software License; BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.fastapi.0.115.5(MIT License).txt → LICENSE.fastapi.0.115.12(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.importlib_metadata.8.5.0(Apache Software License).txt → LICENSE.id.1.5.0(Apache Software License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.keyring.25.5.0(MIT License).txt → LICENSE.keyring.25.6.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.more-itertools.10.5.0(MIT License).txt → LICENSE.more-itertools.10.6.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.numpy.2.1.3(BSD License).txt → LICENSE.numpy.2.2.4(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.prettytable.3.12.0(BSD License).txt → LICENSE.prettytable.3.16.0(UNKNOWN).txt} +0 -0
- /cmdbox/licenses/{LICENSE.pydantic.2.10.2(MIT License).txt → LICENSE.pydantic.2.11.1(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.pydantic_core.2.27.1(MIT License).txt → LICENSE.pydantic_core.2.33.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.python-dotenv.1.0.1(BSD License).txt → LICENSE.python-dotenv.1.1.0(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.python-multipart.0.0.17(Apache Software License).txt → LICENSE.python-multipart.0.0.20(Apache Software License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.redis.5.2.0(MIT License).txt → LICENSE.redis.5.2.1(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.rich.13.9.4(MIT License).txt → LICENSE.rich.14.0.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.sphinx-intl.2.3.0(BSD License).txt → LICENSE.sphinx-intl.2.3.1(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.starlette.0.41.3(BSD License).txt → LICENSE.starlette.0.46.1(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.tomli.2.1.0(MIT License).txt → LICENSE.tomli.2.2.1(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.twine.5.1.1(Apache Software License).txt → LICENSE.twine.6.1.0(Apache Software License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.typing_extensions.4.12.2(Python Software Foundation License).txt → LICENSE.typing_extensions.4.13.0(UNKNOWN).txt} +0 -0
- /cmdbox/licenses/{LICENSE.urllib3.2.2.3(MIT License).txt → LICENSE.urllib3.2.3.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.uvicorn.0.32.1(BSD License).txt → LICENSE.uvicorn.0.34.0(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.watchfiles.1.0.0(MIT License).txt → LICENSE.watchfiles.1.0.4(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.websockets.14.1(BSD License).txt → LICENSE.websockets.15.0.1(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.zope.interface.7.1.1(Zope Public License).txt → LICENSE.zope.interface.7.2(Zope Public License).txt} +0 -0
- {cmdbox-0.5.1.2.dist-info → cmdbox-0.5.3.dist-info}/LICENSE +0 -0
- {cmdbox-0.5.1.2.dist-info → cmdbox-0.5.3.dist-info}/WHEEL +0 -0
- {cmdbox-0.5.1.2.dist-info → cmdbox-0.5.3.dist-info}/top_level.txt +0 -0
|
@@ -10,6 +10,25 @@ cmdbox.change_dark_mode = (dark_mode) => {
|
|
|
10
10
|
else html.attr('data-bs-theme','dark');
|
|
11
11
|
$('body').css('background-color', '');
|
|
12
12
|
};
|
|
13
|
+
cmdbox.change_color_mode = (color_mode) => {
|
|
14
|
+
const html = $('html');
|
|
15
|
+
color_mode = !color_mode ? localStorage.getItem('color_mode') : color_mode;
|
|
16
|
+
if(color_mode == 'light') html.attr('data-bs-theme','light');
|
|
17
|
+
else if(color_mode == 'midnight') html.attr('data-bs-theme','midnight');
|
|
18
|
+
else if(color_mode == 'deepsea') html.attr('data-bs-theme','deepsea');
|
|
19
|
+
else if(color_mode == 'verdant') html.attr('data-bs-theme','verdant');
|
|
20
|
+
else if(color_mode == 'bumblebee') html.attr('data-bs-theme','bumblebee');
|
|
21
|
+
else if(color_mode == 'crimson') html.attr('data-bs-theme','crimson');
|
|
22
|
+
else html.attr('data-bs-theme','dark');
|
|
23
|
+
localStorage.setItem('color_mode', color_mode);
|
|
24
|
+
if (color_mode) {
|
|
25
|
+
const elem = $('.change_color_mode');
|
|
26
|
+
elem.val(color_mode);
|
|
27
|
+
elem.css('background-color', 'var(--bs-body-bg)');
|
|
28
|
+
elem.css('color', 'var(--bs-body-color)');
|
|
29
|
+
}
|
|
30
|
+
$('body').css('background-color', '');
|
|
31
|
+
};
|
|
13
32
|
/**
|
|
14
33
|
* ローディング表示
|
|
15
34
|
*/
|
|
@@ -129,7 +148,9 @@ cmdbox.passchange = async () => {
|
|
|
129
148
|
const form = $(`<form id="chpass_form" class="modal-content novalidate"/>`).appendTo(daialog);
|
|
130
149
|
const header = $(`<div class="modal-header"/>`).appendTo(form);
|
|
131
150
|
header.append('<h5 class="modal-title">Change Password</h5>');
|
|
132
|
-
header.append('<button type="button" class="btn-
|
|
151
|
+
header.append('<button type="button" class="btn btn_close p-0 m-0" data-bs-dismiss="modal" aria-label="Close" style="margin-left: 0px;">'
|
|
152
|
+
+'<svg class="bi bi-x" width="24" height="24" fill="currentColor"><use href="#btn_x"></use></svg>'
|
|
153
|
+
+'</button>');
|
|
133
154
|
const body = $(`<div class="modal-body"/>`).appendTo(form);
|
|
134
155
|
const row_content = $(`<div class="row row_content"/>`).appendTo(body);
|
|
135
156
|
const crrent_pass = $(`<div class="col-12 mb-3"><div class="input-group">`+
|
|
@@ -961,18 +982,60 @@ cmdbox.progress = (_min, _max, _now, _text, _show, _cycle) => {
|
|
|
961
982
|
}, 20);
|
|
962
983
|
}
|
|
963
984
|
};
|
|
985
|
+
/**
|
|
986
|
+
* ユーザーデータを保存
|
|
987
|
+
* @param {string} cat - カテゴリ
|
|
988
|
+
* @param {string} key - キー
|
|
989
|
+
* @param {string} val - 値
|
|
990
|
+
* @returns {Promise}
|
|
991
|
+
*/
|
|
992
|
+
cmdbox.save_user_data = async (cat, key, val) => {
|
|
993
|
+
const formData = new FormData();
|
|
994
|
+
formData.append('categoly', cat);
|
|
995
|
+
formData.append('key', key);
|
|
996
|
+
formData.append('val', val);
|
|
997
|
+
const res = await fetch('gui/user_data/save', {method:'POST', body:formData});
|
|
998
|
+
if (!res.ok) cmdbox.message({'error':`${res.status}: ${res.statusText}`});
|
|
999
|
+
const msg = await res.json()
|
|
1000
|
+
return msg;
|
|
1001
|
+
};
|
|
1002
|
+
/**
|
|
1003
|
+
* ユーザーデータを取得
|
|
1004
|
+
* @param {string} cat - カテゴリ
|
|
1005
|
+
* @param {string} key - キー
|
|
1006
|
+
* @returns {Promise}
|
|
1007
|
+
*/
|
|
1008
|
+
cmdbox.load_user_data = async (cat, key) => {
|
|
1009
|
+
const formData = new FormData();
|
|
1010
|
+
formData.append('categoly', cat);
|
|
1011
|
+
if (key) formData.append('key', key);
|
|
1012
|
+
const res = await fetch('gui/user_data/load', {method:'POST', body:formData});
|
|
1013
|
+
if (!res.ok) cmdbox.message({'error':`${res.status}: ${res.statusText}`});
|
|
1014
|
+
const data = await res.json();
|
|
1015
|
+
return data;
|
|
1016
|
+
};
|
|
1017
|
+
/**
|
|
1018
|
+
* ユーザーデータを削除
|
|
1019
|
+
* @param {string} cat - カテゴリ
|
|
1020
|
+
* @param {string} key - キー
|
|
1021
|
+
* @returns {Promise}
|
|
1022
|
+
*/
|
|
1023
|
+
cmdbox.delete_user_data = async (cat, key) => {
|
|
1024
|
+
const formData = new FormData();
|
|
1025
|
+
formData.append('categoly', cat);
|
|
1026
|
+
formData.append('key', key);
|
|
1027
|
+
const res = await fetch('gui/user_data/delete', {method:'POST', body:formData});
|
|
1028
|
+
if (!res.ok) cmdbox.message({'error':`${res.status}: ${res.statusText}`});
|
|
1029
|
+
const data = await res.json();
|
|
1030
|
+
return data;
|
|
1031
|
+
};
|
|
964
1032
|
/**
|
|
965
1033
|
* コマンドピンを保存
|
|
966
1034
|
* @param {string} title - タイトル
|
|
967
1035
|
* @param {bool} pin - ピン
|
|
968
1036
|
*/
|
|
969
1037
|
cmdbox.save_cmd_pin = async (title, pin) => {
|
|
970
|
-
|
|
971
|
-
formData.append('title', title);
|
|
972
|
-
formData.append('pin', pin?'on':'off');
|
|
973
|
-
const res = await fetch('gui/save_cmd_pin', {method:'POST', body:formData});
|
|
974
|
-
if (!res.ok) cmdbox.message({'error':`${res.status}: ${res.statusText}`});
|
|
975
|
-
const msg = await res.json()
|
|
1038
|
+
return await cmdbox.save_user_data('cmdpins', title, pin?'on':'off');
|
|
976
1039
|
};
|
|
977
1040
|
/**
|
|
978
1041
|
* コマンドピンをロード
|
|
@@ -980,12 +1043,7 @@ cmdbox.save_cmd_pin = async (title, pin) => {
|
|
|
980
1043
|
* @returns {Promise}
|
|
981
1044
|
*/
|
|
982
1045
|
cmdbox.load_cmd_pin = async (title) => {
|
|
983
|
-
|
|
984
|
-
if (title) formData.append('title', title);
|
|
985
|
-
const res = await fetch('gui/load_cmd_pin', {method:'POST', body:formData});
|
|
986
|
-
if (!res.ok) cmdbox.message({'error':`${res.status}: ${res.statusText}`});
|
|
987
|
-
const pins = await res.json();
|
|
988
|
-
return pins;
|
|
1046
|
+
return await cmdbox.load_user_data('cmdpins', title);
|
|
989
1047
|
};
|
|
990
1048
|
/**
|
|
991
1049
|
* パイプピンを保存
|
|
@@ -993,12 +1051,7 @@ cmdbox.load_cmd_pin = async (title) => {
|
|
|
993
1051
|
* @param {bool} pin - ピン
|
|
994
1052
|
*/
|
|
995
1053
|
cmdbox.save_pipe_pin = async (title, pin) => {
|
|
996
|
-
|
|
997
|
-
formData.append('title', title);
|
|
998
|
-
formData.append('pin', pin?'on':'off');
|
|
999
|
-
const res = await fetch('gui/save_pipe_pin', {method:'POST', body:formData});
|
|
1000
|
-
if (!res.ok) cmdbox.message({'error':`${res.status}: ${res.statusText}`});
|
|
1001
|
-
const msg = await res.json()
|
|
1054
|
+
return await cmdbox.save_user_data('pipepins', title, pin?'on':'off');
|
|
1002
1055
|
};
|
|
1003
1056
|
/**
|
|
1004
1057
|
* パイプピンをロード
|
|
@@ -1006,10 +1059,349 @@ cmdbox.save_pipe_pin = async (title, pin) => {
|
|
|
1006
1059
|
* @returns {Promise}
|
|
1007
1060
|
*/
|
|
1008
1061
|
cmdbox.load_pipe_pin = async (title) => {
|
|
1062
|
+
return await cmdbox.load_user_data('pipepins', title);
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* コマンドモーダルのフォームを追加
|
|
1066
|
+
* @param {number} i - インデックス
|
|
1067
|
+
* @param {$} cmd_modal - コマンドモーダル
|
|
1068
|
+
* @param {$} row_content - 行コンテンツ
|
|
1069
|
+
* @param {object} row - 行データ(コマンドオプション)
|
|
1070
|
+
* @param {$} next_elem - 次の要素
|
|
1071
|
+
* @param {number} lcolsize - 横長のカラムサイズ
|
|
1072
|
+
* @param {number} scolsize - 通常のカラムサイズ
|
|
1073
|
+
* @returns {void}
|
|
1074
|
+
*/
|
|
1075
|
+
cmdbox.add_form_func = (i, cmd_modal, row_content, row, next_elem, lcolsize=12, scolsize=6) => {
|
|
1076
|
+
const target_name = row.opt;
|
|
1077
|
+
// clmsg_idのオプションは隠しオプション扱い。restapiで指定はできる。
|
|
1078
|
+
if (target_name=='clmsg_id') return;
|
|
1079
|
+
let input_elem, elem;
|
|
1080
|
+
if(!row.choice) {
|
|
1081
|
+
// 選択肢がない場合
|
|
1082
|
+
if(row.type=='text') {
|
|
1083
|
+
elem = $(`<div class="col-${lcolsize} mb-3">` // row_content_template_text
|
|
1084
|
+
+'<div class="input-group">'
|
|
1085
|
+
+'<label class="input-group-text row_content_template_title">title</label>'
|
|
1086
|
+
+'<textarea class="form-control row_content_template_input" rows="1" style="field-sizing:content;"></textarea>'
|
|
1087
|
+
+'</div></div>');
|
|
1088
|
+
} else if(row.type=='dict') {
|
|
1089
|
+
elem = $(`<div class="col-${lcolsize} mb-3">` // row_content_template_dict
|
|
1090
|
+
+'<div class="input-group">'
|
|
1091
|
+
+'<label class="input-group-text row_content_template_title">title</label>'
|
|
1092
|
+
+'<input type="text" class="form-control row_content_key row_content_template_input">'
|
|
1093
|
+
+'<label class="input-group-text">=</label>'
|
|
1094
|
+
+'<input type="text" class="form-control row_content_val row_content_template_input">'
|
|
1095
|
+
+'</div></div>');
|
|
1096
|
+
} else {
|
|
1097
|
+
elem = $(`<div class="col-${scolsize} mb-3">` // row_content_template_str
|
|
1098
|
+
+'<div class="input-group">'
|
|
1099
|
+
+'<label class="input-group-text row_content_template_title">title</label>'
|
|
1100
|
+
+'<input type="text" class="form-control row_content_template_input">'
|
|
1101
|
+
+'</div></div>');
|
|
1102
|
+
}
|
|
1103
|
+
if (next_elem) next_elem.after(elem);
|
|
1104
|
+
else row_content.append(elem);
|
|
1105
|
+
input_elem = elem.find('.row_content_template_input');
|
|
1106
|
+
if(row.type=='date') input_elem.attr('type', 'date');
|
|
1107
|
+
else if(row.type=='datetime') input_elem.attr('type', 'datetime-local');
|
|
1108
|
+
input_elem.removeClass('row_content_template_input');
|
|
1109
|
+
input_elem.val(row.default);
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
// 選択肢がある場合
|
|
1113
|
+
if(row.type=='dict') {
|
|
1114
|
+
if (Array.isArray(row.choice)) {
|
|
1115
|
+
elem = $(`<div class="col-${lcolsize} mb-3">` // row_content_template_dict_choice
|
|
1116
|
+
+'<div class="input-group">'
|
|
1117
|
+
+'<label class="input-group-text row_content_template_title">title</label>'
|
|
1118
|
+
+'<input type="text" class="form-control row_content_key row_content_template_input">'
|
|
1119
|
+
+'<label class="input-group-text">=</label>'
|
|
1120
|
+
+'<select class="form-select row_content_template_select"></select>'
|
|
1121
|
+
+'</div></div>');
|
|
1122
|
+
}
|
|
1123
|
+
else {
|
|
1124
|
+
elem = $(`<div class="col-${lcolsize} mb-3">` // row_content_template_dict_choice
|
|
1125
|
+
+'<div class="input-group">'
|
|
1126
|
+
+'<label class="input-group-text row_content_template_title">title</label>'
|
|
1127
|
+
+'<select class="form-select row_content_key row_content_template_select"></select>'
|
|
1128
|
+
+'<label class="input-group-text">=</label>'
|
|
1129
|
+
+'<select class="form-select row_content_template_select"></select>'
|
|
1130
|
+
+'</div></div>');
|
|
1131
|
+
}
|
|
1132
|
+
} else {
|
|
1133
|
+
elem = $(`<div class="col-${scolsize} mb-3">` // row_content_template_choice
|
|
1134
|
+
+'<div class="input-group">'
|
|
1135
|
+
+'<label class="input-group-text row_content_template_title">title</label>'
|
|
1136
|
+
+'<select class="form-select row_content_template_select"></select>'
|
|
1137
|
+
+'</div></div>');
|
|
1138
|
+
}
|
|
1139
|
+
if (next_elem) next_elem.after(elem);
|
|
1140
|
+
else row_content.append(elem);
|
|
1141
|
+
input_elem = elem.find('.row_content_template_select,.row_content_template_input');
|
|
1142
|
+
input_elem.removeClass('row_content_template_select').removeClass('row_content_template_input');
|
|
1143
|
+
if (row.choice_show) {
|
|
1144
|
+
input_elem.addClass('choice_show');
|
|
1145
|
+
input_elem.change(() => {
|
|
1146
|
+
let names = []
|
|
1147
|
+
for (const ns of Object.values(row.choice_show)) {
|
|
1148
|
+
if (Array.isArray(ns)) {
|
|
1149
|
+
ns.forEach(n => names.push(n));
|
|
1150
|
+
} else {
|
|
1151
|
+
names.push(ns);
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
names = [...new Set(names)];
|
|
1155
|
+
names.forEach(name => row_content.find(`[name="${name}"]`).parent().parent().hide());
|
|
1156
|
+
const v = input_elem.val();
|
|
1157
|
+
if (!row.choice_show[v]) return;
|
|
1158
|
+
row.choice_show[v].forEach(n => row_content.find(`[name="${n}"]`).parent().parent().show());
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
// 配列をoptionタグに変換
|
|
1162
|
+
const mkopt = (arr) => {
|
|
1163
|
+
if (!arr) return '';
|
|
1164
|
+
const opt = arr.map(row => {
|
|
1165
|
+
if (row && typeof row === 'object') {
|
|
1166
|
+
key = Object.keys(row)[0];
|
|
1167
|
+
d = window.navigator.language=='ja'?row[key].discription_ja:row[key].discription_en;
|
|
1168
|
+
return `<option value="${key}" discription="${d}">${key}</option>`;
|
|
1169
|
+
}
|
|
1170
|
+
return `<option value="${row}" discription="">${row}</option>`;
|
|
1171
|
+
}).join('');
|
|
1172
|
+
return opt;
|
|
1173
|
+
}
|
|
1174
|
+
if (Array.isArray(row.choice)) {
|
|
1175
|
+
// 配列の場合
|
|
1176
|
+
input_elem.html(mkopt(row.choice));
|
|
1177
|
+
input_elem.val(`${row.default!=null?row.default:''}`);
|
|
1178
|
+
} else {
|
|
1179
|
+
// 辞書の場合
|
|
1180
|
+
const cho = [row.choice['key'], row.choice['val']];
|
|
1181
|
+
let def = row.default!=null?[row.default, row.default]:null;
|
|
1182
|
+
if (row.default && typeof row.default === 'object') {
|
|
1183
|
+
def[0] = Object.keys(row.default)[0];
|
|
1184
|
+
def[1] = row.default[def[0]];
|
|
1185
|
+
}
|
|
1186
|
+
input_elem.each((i, e) => {
|
|
1187
|
+
$(e).html(mkopt(cho[i]));
|
|
1188
|
+
$(e).val(`${def!=null?def[i]:''}`);
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
let index = 0;
|
|
1193
|
+
if (cmd_modal.find(`[name="${target_name}"]`).length > 0) {
|
|
1194
|
+
index = 0;
|
|
1195
|
+
cmd_modal.find(`[name="${target_name}"][param_data_index]`).each((i, val) => {
|
|
1196
|
+
v = Number($(val).attr('param_data_index'));
|
|
1197
|
+
if (index <= v) index = v + 1;
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
input_elem.attr('name', target_name);
|
|
1201
|
+
if(row.type=='dict') {
|
|
1202
|
+
input_elem.each((i, e) => {
|
|
1203
|
+
$(e).attr('id', target_name + (index + i));
|
|
1204
|
+
$(e).attr('param_data_index', (index + i));
|
|
1205
|
+
});
|
|
1206
|
+
} else {
|
|
1207
|
+
input_elem.attr('id', target_name + index);
|
|
1208
|
+
input_elem.attr('param_data_index', index);
|
|
1209
|
+
}
|
|
1210
|
+
input_elem.attr('required', row.required);
|
|
1211
|
+
input_elem.attr('param_data_type', row.type);
|
|
1212
|
+
input_elem.attr('param_data_multi', row.multi);
|
|
1213
|
+
input_elem.attr('param_data_web', row.web);
|
|
1214
|
+
if (row.web=='mask' || row.web=='readonly') {
|
|
1215
|
+
input_elem.attr('disabled', 'disabled');
|
|
1216
|
+
}
|
|
1217
|
+
// ファイルタイプの場合はファイラーモーダルを開くボタンを追加
|
|
1218
|
+
if(row.type=='file'){
|
|
1219
|
+
const btn = $('<button class="btn btn-secondary" type="button">file</button>');
|
|
1220
|
+
input_elem.parent().append(btn);
|
|
1221
|
+
const mk_func = (tid, tn) => {
|
|
1222
|
+
// tid, tnの値を残すためにクロージャーにする
|
|
1223
|
+
return () => {
|
|
1224
|
+
const current_path = $(`[id="${tid}"]`).val();
|
|
1225
|
+
fmodal.filer_modal_func(tid, tn, current_path, false, true);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
btn.click(mk_func(input_elem.attr('id'), input_elem.attr('name')));
|
|
1229
|
+
}
|
|
1230
|
+
// ディレクトリタイプの場合はファイラーモーダルを開くボタンを追加
|
|
1231
|
+
if(row.type=='dir'){
|
|
1232
|
+
const btn = $('<button class="btn btn-secondary" type="button">dir</button>');
|
|
1233
|
+
input_elem.parent().append(btn);
|
|
1234
|
+
const mk_func = (tid, tn) => {
|
|
1235
|
+
// tid, tnの値を残すためにクロージャーにする
|
|
1236
|
+
return () => {
|
|
1237
|
+
const current_path = $(`[id="${tid}"]`).val();
|
|
1238
|
+
fmodal.filer_modal_func(tid, tn, current_path, true, true);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
btn.click(mk_func(input_elem.attr('id'), input_elem.attr('name')));
|
|
1242
|
+
}
|
|
1243
|
+
// マルチの場合は追加ボタンを追加
|
|
1244
|
+
if(row.multi){
|
|
1245
|
+
const btn_a = $('<button class="btn btn-secondary add_buton" type="button"></button>');
|
|
1246
|
+
btn_a.append('<svg class="bi bi-plus" width="16" height="16" fill="currentColor"><use href="#btn_plus"></use></svg>');
|
|
1247
|
+
input_elem.parent().append(btn_a);
|
|
1248
|
+
let mk_func = (row, next_elem) => {
|
|
1249
|
+
// row, next_elemの値を残すためにクロージャーにする
|
|
1250
|
+
return () => {
|
|
1251
|
+
const r = {...row};
|
|
1252
|
+
//r.hide = next_elem.is(':hidden');
|
|
1253
|
+
cmdbox.add_form_func(0, cmd_modal, row_content, r, next_elem, lcolsize, scolsize);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
btn_a.click(mk_func(row, input_elem.parent().parent()));
|
|
1257
|
+
// 2個目以降は削除ボタンを追加
|
|
1258
|
+
const len = cmd_modal.find(`[name="${target_name}"]`).length;
|
|
1259
|
+
if (row.type!='dict' && len > 1 || row.type=='dict' && len > 2) {
|
|
1260
|
+
mk_func = (del_elem, row) => {
|
|
1261
|
+
// del_elemの値を残すためにクロージャーにする
|
|
1262
|
+
return () => del_elem.remove();
|
|
1263
|
+
}
|
|
1264
|
+
const btn_t = $('<button class="btn btn-secondary" type="button"></button>');
|
|
1265
|
+
btn_trash
|
|
1266
|
+
btn_t.append('<svg class="bi bi-trash" width="16" height="16" fill="currentColor"><use href="#btn_trash"></use></svg>');
|
|
1267
|
+
input_elem.parent().append(btn_t);
|
|
1268
|
+
btn_t.click(mk_func(input_elem.parent().parent(), row));
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
const title = elem.find('.row_content_template_title');
|
|
1272
|
+
title.html('');
|
|
1273
|
+
title.attr('title', window.navigator.language=='ja'?row.discription_ja:row.discription_en)
|
|
1274
|
+
if (row.required) {
|
|
1275
|
+
title.append('<span class="text-danger" title="required">*</span>');
|
|
1276
|
+
}
|
|
1277
|
+
if (row.choice_show) {
|
|
1278
|
+
title.append('<span class="text-primary" title="choice_show">*</span>');
|
|
1279
|
+
}
|
|
1280
|
+
title.append(`<span>${row.opt}</span>`);
|
|
1281
|
+
if (row.hide) {
|
|
1282
|
+
if (row_content.find('.row_content_hide').is(':hidden')) elem.hide();
|
|
1283
|
+
elem.addClass('row_content_hide');
|
|
1284
|
+
} else {
|
|
1285
|
+
title.addClass('text-decoration-underline');
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* コマンド選択肢取得
|
|
1290
|
+
* @param {string} mode - モード
|
|
1291
|
+
* @param {string} cmd - コマンド
|
|
1292
|
+
* @returns {Promise} - コマンドオプション
|
|
1293
|
+
*/
|
|
1294
|
+
cmdbox.get_cmd_choices = async (mode, cmd) => {
|
|
1009
1295
|
const formData = new FormData();
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
return
|
|
1296
|
+
formData.append('mode', mode);
|
|
1297
|
+
formData.append('cmd', cmd);
|
|
1298
|
+
const res = await fetch('gui/get_cmd_choices', {method: 'POST', body: formData});
|
|
1299
|
+
if (res.status != 200) cmdbox.message({'error':`${res.status}: ${res.statusText}`});
|
|
1300
|
+
return await res.json();
|
|
1301
|
+
}
|
|
1302
|
+
// コマンドフォームからパラメータを取得
|
|
1303
|
+
cmdbox.get_param = (modal_elem) => {
|
|
1304
|
+
modal_elem.find('.is-invalid, .is-valid').removeClass('is-invalid').removeClass('is-valid');
|
|
1305
|
+
const opt = {};
|
|
1306
|
+
const title = modal_elem.find('[name="title"]').val();
|
|
1307
|
+
opt["modal_mode"] = modal_elem.find('[name="modal_mode"]').val();
|
|
1308
|
+
opt["mode"] = modal_elem.find('[name="mode"]').val();
|
|
1309
|
+
opt["cmd"] = modal_elem.find('[name="cmd"]').val();
|
|
1310
|
+
if(!opt["mode"]) delete opt["mode"];
|
|
1311
|
+
if(!opt["cmd"]) delete opt["cmd"];
|
|
1312
|
+
opt["title"] = title;
|
|
1313
|
+
const isFloat = (i) => {
|
|
1314
|
+
try {
|
|
1315
|
+
n = Number(i);
|
|
1316
|
+
return n % 1 !== 0;
|
|
1317
|
+
} catch(e) {
|
|
1318
|
+
return false;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
const isInt = (i) => {
|
|
1322
|
+
try {
|
|
1323
|
+
n = Number(i);
|
|
1324
|
+
return n % 1 === 0;
|
|
1325
|
+
} catch(e) {
|
|
1326
|
+
return false;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
// フォームの入力値をチェック(不正な値があればフォームに'is-invalid'クラスを付加する)
|
|
1330
|
+
const dict_buf = {};
|
|
1331
|
+
modal_elem.find('.row_content, .row_content_common').find('input, select, textarea').each((i, elem) => {
|
|
1332
|
+
const data_name = $(elem).attr('name');
|
|
1333
|
+
let data_val = $(elem).val();
|
|
1334
|
+
const data_type = $(elem).attr('param_data_type');
|
|
1335
|
+
const data_web = $(elem).attr('param_data_web');
|
|
1336
|
+
const data_index = parseInt($(elem).attr('param_data_index'));
|
|
1337
|
+
const data_multi = $(elem).attr('param_data_multi');
|
|
1338
|
+
if ($(elem).attr('required') && (!data_val || data_val=='')) {
|
|
1339
|
+
$(elem).addClass('is-invalid');
|
|
1340
|
+
} else if (data_type=='int' && !data_web) {
|
|
1341
|
+
if(data_val && data_val!='') {
|
|
1342
|
+
if(!isInt(data_val)) $(elem).addClass('is-invalid');
|
|
1343
|
+
else {
|
|
1344
|
+
$(elem).removeClass('is-invalid');
|
|
1345
|
+
$(elem).addClass('is-valid');
|
|
1346
|
+
data_val = parseInt(data_val);
|
|
1347
|
+
}
|
|
1348
|
+
} else {
|
|
1349
|
+
$(elem).removeClass('is-invalid');
|
|
1350
|
+
$(elem).addClass('is-valid');
|
|
1351
|
+
}
|
|
1352
|
+
} else if (data_type=='float') {
|
|
1353
|
+
if(data_val && data_val!='') {
|
|
1354
|
+
if(!isFloat(data_val) && !isInt(data_val)) $(elem).addClass('is-invalid');
|
|
1355
|
+
else {
|
|
1356
|
+
$(elem).removeClass('is-invalid');
|
|
1357
|
+
$(elem).addClass('is-valid');
|
|
1358
|
+
data_val = parseFloat(data_val);
|
|
1359
|
+
}
|
|
1360
|
+
} else {
|
|
1361
|
+
$(elem).removeClass('is-invalid');
|
|
1362
|
+
$(elem).addClass('is-valid');
|
|
1363
|
+
}
|
|
1364
|
+
} else if (data_type=='bool') {
|
|
1365
|
+
if(data_val!='true' && data_val!='false' && !$(elem).prop('disabled')) $(elem).addClass('is-invalid');
|
|
1366
|
+
else {
|
|
1367
|
+
data_val = data_val=='true';
|
|
1368
|
+
$(elem).removeClass('is-invalid');
|
|
1369
|
+
$(elem).addClass('is-valid');
|
|
1370
|
+
}
|
|
1371
|
+
} else if (data_type=='dict') {
|
|
1372
|
+
data_val = data_val ? data_val : '';
|
|
1373
|
+
if(data_val.indexOf(' ')>=0) $(elem).addClass('is-invalid');
|
|
1374
|
+
else {
|
|
1375
|
+
$(elem).removeClass('is-invalid');
|
|
1376
|
+
$(elem).addClass('is-valid');
|
|
1377
|
+
}
|
|
1378
|
+
} else if (data_type=='text') {
|
|
1379
|
+
$(elem).removeClass('is-invalid');
|
|
1380
|
+
$(elem).addClass('is-valid');
|
|
1381
|
+
} else {
|
|
1382
|
+
$(elem).removeClass('is-invalid');
|
|
1383
|
+
$(elem).addClass('is-valid');
|
|
1384
|
+
}
|
|
1385
|
+
if(data_multi=='true' || data_type=='dict') {
|
|
1386
|
+
if (data_type=='dict') {
|
|
1387
|
+
if(!opt[data_name]) {
|
|
1388
|
+
opt[data_name] = {};
|
|
1389
|
+
dict_buf[data_name] = {};
|
|
1390
|
+
}
|
|
1391
|
+
if(data_index%2==0) dict_buf[data_name]['key'] = data_val;
|
|
1392
|
+
else if (dict_buf[data_name]['key']) {
|
|
1393
|
+
opt[data_name][dict_buf[data_name]['key']] = data_val;
|
|
1394
|
+
delete dict_buf[data_name]['key'];
|
|
1395
|
+
}
|
|
1396
|
+
} else {
|
|
1397
|
+
if(!opt[data_name]) opt[data_name] = [];
|
|
1398
|
+
if(data_val && data_val!='') opt[data_name].push(data_val);
|
|
1399
|
+
else if(data_val==false) opt[data_name].push(data_val);
|
|
1400
|
+
}
|
|
1401
|
+
} else {
|
|
1402
|
+
if(data_val && data_val!='') opt[data_name] = data_val;
|
|
1403
|
+
else if(data_val==false) opt[data_name] = data_val;
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
return [title, opt];
|
|
1015
1407
|
}
|
|
@@ -62,7 +62,7 @@ fmodal.filer_modal_func = async (target_id, modal_title, current_path, select_di
|
|
|
62
62
|
filer_modal.find('.file-list').html('');
|
|
63
63
|
filer_modal.find('.file-list').append(table);
|
|
64
64
|
const table_head = $('<thead></thead>');
|
|
65
|
-
table_head.append($('<tr><th scope="col">-</th><th scope="col">name</th><th scope="col">size</th><th scope="col">last</th></tr>'));
|
|
65
|
+
table_head.append($('<tr><th class="th" scope="col">-</th><th class="th" scope="col">name</th><th class="th" scope="col">size</th><th class="th" scope="col">last</th></tr>'));
|
|
66
66
|
table.append(table_head);
|
|
67
67
|
const table_body = $('<tbody></tbody>');
|
|
68
68
|
table.append(table_body);
|