From 7bfdc83779dd7b4da4326d01e89eb05d7576290e Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Fri, 26 Aug 2022 11:45:14 +0200 Subject: [PATCH] Initial commit on branch: Rewrite config.tmpl as svelte component(s) --- internal/routerConfig/routes.go | 1 + web/frontend/rollup.config.js | 4 +- web/frontend/src/Configsvelte.root.svelte | 31 ++++ web/frontend/src/config/AdminSettings.svelte | 36 ++++ web/frontend/src/config/PlotSettings.svelte | 170 ++++++++++++++++++ web/frontend/src/config/admin/AddRole.svelte | 70 ++++++++ web/frontend/src/config/admin/AddUser.svelte | 85 +++++++++ web/frontend/src/config/admin/Options.svelte | 29 +++ .../src/config/admin/ShowUsers.svelte | 67 +++++++ .../src/config/admin/ShowUsersRow.svelte | 27 +++ web/frontend/src/configsvelte.entrypoint.js | 12 ++ web/templates/config.tmpl | 4 +- web/templates/configsvelte.tmpl | 15 ++ 13 files changed, 547 insertions(+), 4 deletions(-) create mode 100644 web/frontend/src/Configsvelte.root.svelte create mode 100644 web/frontend/src/config/AdminSettings.svelte create mode 100644 web/frontend/src/config/PlotSettings.svelte create mode 100644 web/frontend/src/config/admin/AddRole.svelte create mode 100644 web/frontend/src/config/admin/AddUser.svelte create mode 100644 web/frontend/src/config/admin/Options.svelte create mode 100644 web/frontend/src/config/admin/ShowUsers.svelte create mode 100644 web/frontend/src/config/admin/ShowUsersRow.svelte create mode 100644 web/frontend/src/configsvelte.entrypoint.js create mode 100644 web/templates/configsvelte.tmpl diff --git a/internal/routerConfig/routes.go b/internal/routerConfig/routes.go index ad3a103..068709f 100644 --- a/internal/routerConfig/routes.go +++ b/internal/routerConfig/routes.go @@ -36,6 +36,7 @@ type Route struct { var routes []Route = []Route{ {"/", "home.tmpl", "ClusterCockpit", false, setupHomeRoute}, {"/config", "config.tmpl", "Settings", false, func(i InfoType, r *http.Request) InfoType { return i }}, + {"/configsvelte", "configsvelte.tmpl", "Settings as Svelte", false, func(i InfoType, r *http.Request) InfoType { return i }}, {"/monitoring/jobs/", "monitoring/jobs.tmpl", "Jobs - ClusterCockpit", true, func(i InfoType, r *http.Request) InfoType { return i }}, {"/monitoring/job/{id:[0-9]+}", "monitoring/job.tmpl", "Job - ClusterCockpit", false, setupJobRoute}, {"/monitoring/users/", "monitoring/list.tmpl", "Users - ClusterCockpit", true, func(i InfoType, r *http.Request) InfoType { i["listType"] = "USER"; return i }}, diff --git a/web/frontend/rollup.config.js b/web/frontend/rollup.config.js index 13d988a..199a157 100644 --- a/web/frontend/rollup.config.js +++ b/web/frontend/rollup.config.js @@ -65,6 +65,6 @@ export default [ entrypoint('systems', 'src/systems.entrypoint.js'), entrypoint('node', 'src/node.entrypoint.js'), entrypoint('analysis', 'src/analysis.entrypoint.js'), - entrypoint('status', 'src/status.entrypoint.js') + entrypoint('status', 'src/status.entrypoint.js'), + entrypoint('configsvelte', 'src/configsvelte.entrypoint.js') ]; - diff --git a/web/frontend/src/Configsvelte.root.svelte b/web/frontend/src/Configsvelte.root.svelte new file mode 100644 index 0000000..6b1eb40 --- /dev/null +++ b/web/frontend/src/Configsvelte.root.svelte @@ -0,0 +1,31 @@ + + +{#if user.IsAdmin} + + + Admin Options + + + +{/if} + + + + Plotting Options + + + diff --git a/web/frontend/src/config/AdminSettings.svelte b/web/frontend/src/config/AdminSettings.svelte new file mode 100644 index 0000000..3564865 --- /dev/null +++ b/web/frontend/src/config/AdminSettings.svelte @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/web/frontend/src/config/PlotSettings.svelte b/web/frontend/src/config/PlotSettings.svelte new file mode 100644 index 0000000..1b7542d --- /dev/null +++ b/web/frontend/src/config/PlotSettings.svelte @@ -0,0 +1,170 @@ + + + + + + +
handleSettingSubmit('#line-width-form', 'lw')}> + + +
Line Width
+ + {#if displayMessage && message.target == 'lw'} +
+ + Update: {message.msg} + +
+ {/if} +
+ +
+ + +
Width of the lines in the timeseries plots.
+
+ +
+
+ + + +
handleSettingSubmit('#plots-per-row-form', 'ppr')}> + + +
Plots per Row
+ {#if displayMessage && message.target == 'ppr'}
Update: {message.msg}
{/if} +
+ +
+ + +
How many plots to show next to each other on pages such as /monitoring/job/, /monitoring/system/...
+
+ +
+
+ + + +
handleSettingSubmit('#backgrounds-form', 'bg')}> + + +
Colored Backgrounds
+ {#if displayMessage && message.target == 'bg'}
Update: {message.msg}
{/if} +
+ +
+
+ {#if config.plot_general_colorBackground} + + {:else} + + {/if} + +
+
+ {#if config.plot_general_colorBackground} + + {:else} + + {/if} + +
+
+ +
+
+
+ + + + +
handleSettingSubmit("#colorscheme-form", "cs")}> + + +
Color Scheme for Timeseries Plots
+ {#if displayMessage && message.target == 'cs'}
Update: {message.msg}
{/if} +
+ + + + {#each Object.entries(colorschemes) as [name, rgbrow]} + + + + + + {/each} + +
{name} + {#if rgbrow.join(',') == config.plot_general_colorscheme} + + {:else} + + {/if} + + {#each rgbrow as rgb} + + {/each} +
+ +
+
+
+ + diff --git a/web/frontend/src/config/admin/AddRole.svelte b/web/frontend/src/config/admin/AddRole.svelte new file mode 100644 index 0000000..dcd4cef --- /dev/null +++ b/web/frontend/src/config/admin/AddRole.svelte @@ -0,0 +1,70 @@ + + + + + Add Role to User +
+ + + + + +
+

+ {#if displayMessage}Update: {message.msg}{/if} +

+
+
diff --git a/web/frontend/src/config/admin/AddUser.svelte b/web/frontend/src/config/admin/AddUser.svelte new file mode 100644 index 0000000..bca89f0 --- /dev/null +++ b/web/frontend/src/config/admin/AddUser.svelte @@ -0,0 +1,85 @@ + + + +
+ Create User +
+ + +
Optional, can be blank.
+
+
+ + +
Optional, can be blank.
+
+
+ + +
Must be unique.
+
+
+ + +
Only API users are allowed to have a blank password. Users with a blank password can only authenticate via Tokens.
+
+
+

Role:

+
+ + +
+
+ + +
+
+ + +
+
+

+ + {#if displayMessage}

{message.msg}
{/if} +

+
+
diff --git a/web/frontend/src/config/admin/Options.svelte b/web/frontend/src/config/admin/Options.svelte new file mode 100644 index 0000000..44f9650 --- /dev/null +++ b/web/frontend/src/config/admin/Options.svelte @@ -0,0 +1,29 @@ + + + + + Scramble Names / Presentation Mode + + Active? + + diff --git a/web/frontend/src/config/admin/ShowUsers.svelte b/web/frontend/src/config/admin/ShowUsers.svelte new file mode 100644 index 0000000..5726fc4 --- /dev/null +++ b/web/frontend/src/config/admin/ShowUsers.svelte @@ -0,0 +1,67 @@ + + + + + Special Users +

+ Not created by an LDAP sync and/or having a role other than user + +

+
+ + + + + + + + + + + + + {#each userList as user} + + + + + {:else} + + + + {/each} + +
UsernameNameEmailRolesJWTDelete
+
Loading...
+
+
+
+
diff --git a/web/frontend/src/config/admin/ShowUsersRow.svelte b/web/frontend/src/config/admin/ShowUsersRow.svelte new file mode 100644 index 0000000..64b5dd4 --- /dev/null +++ b/web/frontend/src/config/admin/ShowUsersRow.svelte @@ -0,0 +1,27 @@ + + +{user.username} +{user.name} +{user.email} +{user.roles.join(', ')} + + {#if ! jwt} + + {:else} + + {/if} + diff --git a/web/frontend/src/configsvelte.entrypoint.js b/web/frontend/src/configsvelte.entrypoint.js new file mode 100644 index 0000000..43e3434 --- /dev/null +++ b/web/frontend/src/configsvelte.entrypoint.js @@ -0,0 +1,12 @@ +import {} from './header.entrypoint.js' +import Configsvelte from './Configsvelte.root.svelte' + +new Configsvelte({ + target: document.getElementById('svelte-app'), + props: { + user: user + }, + context: new Map([ + ['cc-config', clusterCockpitConfig] + ]) +}) diff --git a/web/templates/config.tmpl b/web/templates/config.tmpl index deccf92..b8a3027 100644 --- a/web/templates/config.tmpl +++ b/web/templates/config.tmpl @@ -247,7 +247,7 @@ 'BlueWaves': ['rgb(83,0,215)','rgb(43,6,108)','rgb(9,16,16)','rgb(8,32,25)','rgb(0,50,8)','rgb(27,64,66)','rgb(69,67,178)','rgb(115,62,210)','rgb(155,50,104)','rgb(178,43,41)','rgb(180,51,34)','rgb(161,78,87)','rgb(124,117,187)','rgb(78,155,203)','rgb(34,178,85)','rgb(4,176,2)','rgb(9,152,27)','rgb(4,118,2)','rgb(34,92,85)','rgb(78,92,203)','rgb(124,127,187)','rgb(161,187,87)','rgb(180,248,34)','rgb(178,220,41)','rgb(155,217,104)','rgb(115,254,210)'], 'BlueGreenRedYellow': ['rgb(0,0,0)','rgb(0,0,20)','rgb(0,0,41)','rgb(0,0,62)','rgb(0,25,83)','rgb(0,57,101)','rgb(0,87,101)','rgb(0,118,101)','rgb(0,150,101)','rgb(0,150,69)','rgb(0,148,37)','rgb(0,141,6)','rgb(60,120,0)','rgb(131,87,0)','rgb(180,25,0)','rgb(203,13,0)','rgb(208,36,0)','rgb(213,60,0)','rgb(219,83,0)','rgb(224,106,0)','rgb(229,129,0)','rgb(233,152,0)','rgb(238,176,0)','rgb(243,199,0)','rgb(248,222,0)','rgb(254,245,0)'] }; - + for (const name in colorschemes) { const colorscheme = colorschemes[name] const json = JSON.stringify(colorscheme) @@ -292,4 +292,4 @@ handleSubmit('#backgrounds-form') handleSubmit('#colorscheme-form') -{{end}} \ No newline at end of file +{{end}} diff --git a/web/templates/configsvelte.tmpl b/web/templates/configsvelte.tmpl new file mode 100644 index 0000000..ab188b1 --- /dev/null +++ b/web/templates/configsvelte.tmpl @@ -0,0 +1,15 @@ +{{define "content"}} +
+{{end}} + +{{define "stylesheets"}} + +{{end}} +{{define "javascript"}} + + +{{end}}