diff --git a/web/frontend/src/Config.root.svelte b/web/frontend/src/Config.root.svelte index ddd714f..61e99a8 100644 --- a/web/frontend/src/Config.root.svelte +++ b/web/frontend/src/Config.root.svelte @@ -1,16 +1,15 @@ {#if isAdmin == true} @@ -24,7 +23,7 @@ - Plotting Options + User Options - + diff --git a/web/frontend/src/config.entrypoint.js b/web/frontend/src/config.entrypoint.js index 276f648..2978c8c 100644 --- a/web/frontend/src/config.entrypoint.js +++ b/web/frontend/src/config.entrypoint.js @@ -4,7 +4,9 @@ import Config from './Config.root.svelte' new Config({ target: document.getElementById('svelte-app'), props: { - isAdmin: isAdmin + isAdmin: isAdmin, + isApi: isApi, + username: username }, context: new Map([ ['cc-config', clusterCockpitConfig] diff --git a/web/frontend/src/config/PlotSettings.svelte b/web/frontend/src/config/PlotSettings.svelte deleted file mode 100644 index 60a3d7a..0000000 --- a/web/frontend/src/config/PlotSettings.svelte +++ /dev/null @@ -1,552 +0,0 @@ - - - - - - - - handleSettingSubmit("#line-width-form", "lw")} - > - - - Line Width - - {#if displayMessage && message.target == "lw"} - - - Update: {message.msg} - - - {/if} - - - - Line Width - - - Width of the lines in the timeseries plots. - - - Submit - - - - - - - handleSettingSubmit("#plots-per-row-form", "ppr")} - > - - - Plots per Row - {#if displayMessage && message.target == "ppr"} - Update: {message.msg} - {/if} - - - - Plots per Row - - - How many plots to show next to each other on pages such as - /monitoring/job/, /monitoring/system/... - - - Submit - - - - - - - handleSettingSubmit("#backgrounds-form", "bg")} - > - - - Colored Backgrounds - {#if displayMessage && message.target == "bg"} - Update: {message.msg} - {/if} - - - - - {#if config.plot_general_colorBackground} - - {:else} - - {/if} - Yes - - - {#if config.plot_general_colorBackground} - - {:else} - - {/if} - No - - - Submit - - - - - - - handleSettingSubmit("#paging-form", "pag")} - > - - - Paging Type - {#if displayMessage && message.target == "pag"} - Update: {message.msg} - {/if} - - - - - {#if config.job_list_usePaging} - - {:else} - - {/if} - Paging with selectable count of jobs. - - - {#if config.job_list_usePaging} - - {:else} - - {/if} - Continuous scroll iteratively adding 10 jobs. - - - Submit - - - - - - - - - - - Color Scheme for Timeseries Plots - {#if displayMessage && message.target == "cs"} - Update: {message.msg} - {/if} - - - - - {#each Object.entries(colorschemes) as [name, rgbrow]} - - {name} - - {#if rgbrow.join(",") == config.plot_general_colorscheme} - - handleSettingSubmit("#colorscheme-form", "cs")} - /> - {:else} - - handleSettingSubmit("#colorscheme-form", "cs")} - /> - {/if} - - - {#each rgbrow as rgb} - - {/each} - - - {/each} - - - - - - - diff --git a/web/frontend/src/config/UserSettings.svelte b/web/frontend/src/config/UserSettings.svelte new file mode 100644 index 0000000..cd1d9a3 --- /dev/null +++ b/web/frontend/src/config/UserSettings.svelte @@ -0,0 +1,47 @@ + + + handleSettingSubmit(e)}/> + handleSettingSubmit(e)}/> + handleSettingSubmit(e)}/> diff --git a/web/frontend/src/config/admin/ShowUsersRow.svelte b/web/frontend/src/config/admin/ShowUsersRow.svelte index 2971365..9ad9666 100644 --- a/web/frontend/src/config/admin/ShowUsersRow.svelte +++ b/web/frontend/src/config/admin/ShowUsersRow.svelte @@ -1,18 +1,17 @@ diff --git a/web/frontend/src/config/user/PlotColorScheme.svelte b/web/frontend/src/config/user/PlotColorScheme.svelte new file mode 100644 index 0000000..ad73791 --- /dev/null +++ b/web/frontend/src/config/user/PlotColorScheme.svelte @@ -0,0 +1,329 @@ + + + + + + + + + Color Scheme for Timeseries Plots + {#if displayMessage && message.target == "cs"} + Update: {message.msg} + {/if} + + + + + {#each Object.entries(colorschemes) as [name, rgbrow]} + + {name} + + {#if rgbrow.join(",") == config.plot_general_colorscheme} + + updateSetting("#colorscheme-form", "cs")} + /> + {:else} + + updateSetting("#colorscheme-form", "cs")} + /> + {/if} + + + {#each rgbrow as rgb} + + {/each} + + + {/each} + + + + + + + \ No newline at end of file diff --git a/web/frontend/src/config/user/PlotRenderOptions.svelte b/web/frontend/src/config/user/PlotRenderOptions.svelte new file mode 100644 index 0000000..eb96eda --- /dev/null +++ b/web/frontend/src/config/user/PlotRenderOptions.svelte @@ -0,0 +1,166 @@ + + + + + + + + updateSetting("#line-width-form", "lw")} + > + + + Line Width + + {#if displayMessage && message.target == "lw"} + + + Update: {message.msg} + + + {/if} + + + + Line Width + + + Width of the lines in the timeseries plots. + + + Submit + + + + + + + updateSetting("#plots-per-row-form", "ppr")} + > + + + Plots per Row + {#if displayMessage && message.target == "ppr"} + Update: {message.msg} + {/if} + + + + Plots per Row + + + How many plots to show next to each other on pages such as + /monitoring/job/, /monitoring/system/... + + + Submit + + + + + + + updateSetting("#backgrounds-form", "bg")} + > + + + Colored Backgrounds + {#if displayMessage && message.target == "bg"} + Update: {message.msg} + {/if} + + + + + {#if config.plot_general_colorBackground} + + {:else} + + {/if} + Yes + + + {#if config.plot_general_colorBackground} + + {:else} + + {/if} + No + + + Submit + + + \ No newline at end of file diff --git a/web/frontend/src/config/user/UserOptions.svelte b/web/frontend/src/config/user/UserOptions.svelte new file mode 100644 index 0000000..fe63118 --- /dev/null +++ b/web/frontend/src/config/user/UserOptions.svelte @@ -0,0 +1,131 @@ + + + + + + + + updateSetting("#paging-form", "pag")} + > + + + Paging Type + {#if displayMessage && message.target == "pag"} + Update: {message.msg} + {/if} + + + + + {#if config.job_list_usePaging} + + {:else} + + {/if} + Paging with selectable count of jobs. + + + {#if config.job_list_usePaging} + + {:else} + + {/if} + Continuous scroll iteratively adding 10 jobs. + + + Submit + + + + + {#if isApi} + + + + + Generate JWT + {#if jwt} + + Copy JWT to Clipboard + + + Your token is displayed on the right. Press this button to copy it to the clipboard. + + {:else} + + Generate JWT for '{username}' + + + Generate a JSON Web Token for use with the ClusterCockpit REST-API endpoints. + + {/if} + + + + + + + + + Display JWT + {jwt ? jwt : 'Press "Gen. JWT" to request token ...'} + + + + {/if} + \ No newline at end of file diff --git a/web/frontend/src/utils.js b/web/frontend/src/utils.js index 5346208..48bca6b 100644 --- a/web/frontend/src/utils.js +++ b/web/frontend/src/utils.js @@ -433,6 +433,18 @@ export function transformPerNodeDataForRoofline(nodes) { return data } +export async function fetchJwt(username) { + const raw = await fetch(`/userconfig/jwt/?username=${username}`); + + if (!raw.ok) { + const message = `An error has occured: ${response.status}`; + throw new Error(message); + } + + const res = await raw.text(); + return res; +} + // https://stackoverflow.com/questions/45309447/calculating-median-javascript // function median(numbers) { // const sorted = Array.from(numbers).sort((a, b) => a - b); diff --git a/web/templates/config.tmpl b/web/templates/config.tmpl index f72cd93..9f3f3be 100644 --- a/web/templates/config.tmpl +++ b/web/templates/config.tmpl @@ -8,6 +8,8 @@ {{define "javascript"}}
- Update: {message.msg} -
Update: {message.msg}
+ Update: {message.msg} +
+ Your token is displayed on the right. Press this button to copy it to the clipboard. +
+ Generate a JSON Web Token for use with the ClusterCockpit REST-API endpoints. +