From 984dae745066d068a7801a935ae9fcbb09962afe Mon Sep 17 00:00:00 2001 From: jamesread Date: Fri, 21 Oct 2022 15:14:58 +0100 Subject: [PATCH 1/2] feature: #61 - Descriptions in arguments --- OliveTin.proto | 2 ++ config.yaml | 2 ++ internal/config/config.go | 1 + internal/grpcapi/grpcApiActions.go | 1 + webui/js/ArgumentForm.js | 9 +++++++++ webui/style.css | 4 ++++ 6 files changed, 19 insertions(+) diff --git a/OliveTin.proto b/OliveTin.proto index ad6c4b5..dd7112a 100644 --- a/OliveTin.proto +++ b/OliveTin.proto @@ -20,6 +20,8 @@ message ActionArgument { string defaultValue = 4; repeated ActionArgumentChoice choices = 5; + + string description = 6; } message ActionArgumentChoice { diff --git a/config.yaml b/config.yaml index c8d73de..a7ac3f3 100644 --- a/config.yaml +++ b/config.yaml @@ -25,11 +25,13 @@ actions: title: host type: ascii_identifier default: example.com + description: The host that you want to ping - name: count title: Count type: int default: 1 + description: How many times to do you want to ping? # Restart lightdm on host "server1" # Docs: https://docs.olivetin.app/action-ping.html diff --git a/internal/config/config.go b/internal/config/config.go index 9e1a866..6079ca3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -17,6 +17,7 @@ type Action struct { type ActionArgument struct { Name string Title string + Description string Type string Default string Choices []ActionArgumentChoice diff --git a/internal/grpcapi/grpcApiActions.go b/internal/grpcapi/grpcApiActions.go index 7fb9e3b..e70a75f 100644 --- a/internal/grpcapi/grpcApiActions.go +++ b/internal/grpcapi/grpcApiActions.go @@ -36,6 +36,7 @@ func actionCfgToPb(action config.Action, user *acl.AuthenticatedUser) *pb.Action Name: cfgArg.Name, Title: cfgArg.Title, Type: cfgArg.Type, + Description: cfgArg.Description, DefaultValue: cfgArg.Default, Choices: buildChoices(cfgArg.Choices), } diff --git a/webui/js/ArgumentForm.js b/webui/js/ArgumentForm.js index 107b30f..bb8b6b8 100644 --- a/webui/js/ArgumentForm.js +++ b/webui/js/ArgumentForm.js @@ -64,6 +64,7 @@ class ArgumentForm extends window.HTMLElement { domFieldWrapper.appendChild(this.createDomLabel(arg)) domFieldWrapper.appendChild(this.createDomInput(arg)) + domFieldWrapper.appendChild(this.createDomDescription(arg)) this.domArgs.appendChild(domFieldWrapper) } @@ -130,6 +131,14 @@ class ArgumentForm extends window.HTMLElement { return domEl } + createDomDescription (arg) { + const domArgumentDescription = document.createElement('span') + domArgumentDescription.classList.add('inputDescription') + domArgumentDescription.innerText = arg.description + + return domArgumentDescription + } + createSelectOption (choice) { const domEl = document.createElement('option') diff --git a/webui/style.css b/webui/style.css index a74e1ab..71ee5ce 100644 --- a/webui/style.css +++ b/webui/style.css @@ -282,6 +282,10 @@ input[name="start"]:hover { background-color: #aceaac; } +span.inputDescription { + margin-left: 1em; +} + form div.buttons { text-align: right; } From 8e59ac9fb4fbedb11b4a7f828c34c9225b8193eb Mon Sep 17 00:00:00 2001 From: jamesread Date: Fri, 21 Oct 2022 15:21:07 +0100 Subject: [PATCH 2/2] bugfix: Fixing CSS class name convention --- webui/js/ArgumentForm.js | 2 +- webui/style.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webui/js/ArgumentForm.js b/webui/js/ArgumentForm.js index bb8b6b8..4242a9f 100644 --- a/webui/js/ArgumentForm.js +++ b/webui/js/ArgumentForm.js @@ -133,7 +133,7 @@ class ArgumentForm extends window.HTMLElement { createDomDescription (arg) { const domArgumentDescription = document.createElement('span') - domArgumentDescription.classList.add('inputDescription') + domArgumentDescription.classList.add('argument-description') domArgumentDescription.innerText = arg.description return domArgumentDescription diff --git a/webui/style.css b/webui/style.css index 71ee5ce..7c77002 100644 --- a/webui/style.css +++ b/webui/style.css @@ -282,7 +282,7 @@ input[name="start"]:hover { background-color: #aceaac; } -span.inputDescription { +span.argument-description { margin-left: 1em; }