-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feature: Action button with custom URL #1465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking "Sign up for GitHub", you agree to our terms of service and privacy statement. We'll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
feature: Action button with custom URL #1465
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1138,6 +1138,36 @@ where specified. | |
|
|
||
| *Introduced*: 3.0 | ||
|
|
||
| ``custom_action_name`` | ||
|
|
||
| Custom action name to be displayed along the usual Start/Stop/Tail log | ||
| actions in the Web UI. When this custom action button is clicked a new | ||
| browser window will open with URL provided by custom_action_href parameter. | ||
| This is useful for example to open an application dashboard or control panel. | ||
| Both custom_action_name and custom_action_href parameters have to be | ||
| defined for custom button to be displayed. | ||
|
|
||
| *Default*: None | ||
|
|
||
| *Required*: No. | ||
|
|
||
| *Introduced*: 4.3.0 | ||
|
|
||
| ``custom_action_href`` | ||
|
|
||
| Custom action link to be displayed along the usual Start/Stop/Tail log | ||
| actions in the Web UI. Title for the custom action link is defined by the | ||
| custom_action_name parameter. When this custom action button is clicked a new | ||
| browser window will open with URL provided by custom_action_href parameter. | ||
| Both custom_action_name and custom_action_href parameters have to be | ||
| defined for custom button to be displayed. | ||
|
|
||
| *Default*: None | ||
|
|
||
| *Required*: No. | ||
|
|
||
| *Introduced*: 4.3.0 | ||
|
|
||
| ``[program:x]`` Section Example | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1026,6 +1026,13 @@ def get(section, opt, *args, **kwargs): | |
| raise ValueError( | ||
| 'program section %s does not specify a command' % section) | ||
|
|
||
| custom_action_name = get(section, 'custom_action_name', None, expansions=expansions) | ||
| custom_action_href = get(section, 'custom_action_href', None, expansions=expansions) | ||
| if custom_action_name is None: | ||
| custom_action_href = None | ||
| if custom_action_href is None: | ||
| custom_action_name = None | ||
|
|
||
| pconfig = klass( | ||
| self, | ||
| name=expand(process_name, expansions, 'process_name'), | ||
|
|
@@ -1057,7 +1064,9 @@ def get(section, opt, *args, **kwargs): | |
| exitcodes=exitcodes, | ||
| redirect_stderr=redirect_stderr, | ||
| environment=environment, | ||
| serverurl=serverurl) | ||
| serverurl=serverurl, | ||
| custom_action_name=custom_action_name, | ||
| custom_action_href=custom_action_href) | ||
|
|
||
| programs.append(pconfig) | ||
|
|
||
|
|
@@ -1874,7 +1883,8 @@ class ProcessConfig(Config): | |
| 'stderr_logfile_backups', 'stderr_logfile_maxbytes', | ||
| 'stderr_events_enabled', 'stderr_syslog', | ||
| 'stopsignal', 'stopwaitsecs', 'stopasgroup', 'killasgroup', | ||
| 'exitcodes', 'redirect_stderr' ] | ||
| 'exitcodes', 'redirect_stderr', | ||
| 'custom_action_name', 'custom_action_href' ] | ||
| optional_param_names = [ 'environment', 'serverurl' ] | ||
|
|
||
| def __init__(self, options, **params): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,6 +115,8 @@ serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket | |
| ;stderr_syslog=false ; send stderr to syslog with process name (default false) | ||
| ;environment=A="1",B="2" ; process environment additions (def no adds) | ||
| ;serverurl=AUTO ; override serverurl computation (childutils) | ||
| ;custom_action_name=Link Title ; Title for custom action in the web UI | ||
| ;custom_action_href=http://url ; URL for custom action button in the web UI | ||
|
|
||
| ; The sample eventlistener section below shows all possible eventlistener | ||
| ; subsection values. Create one or more 'real' eventlistener: sections to be | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -269,13 +269,23 @@ def actions_for_process(self, process): | |
| 'href': 'logtail/%s/stderr' % processname, | ||
| 'target': '_blank' | ||
| } | ||
| if (process.config.custom_action_name is not None | ||
| and process.config.custom_action_href is not None): | ||
| custom_action = { | ||
| 'name': process.config.custom_action_name, | ||
| 'href': process.config.custom_action_href, | ||
| 'target': '_blank' | ||
| } | ||
| else: | ||
| custom_action = None | ||
| if state == ProcessStates.RUNNING: | ||
| actions = [restart, stop, clearlog, tailf_stdout, tailf_stderr] | ||
| actions = [restart, stop, clearlog, tailf_stdout, tailf_stderr, | ||
| custom_action] | ||
| elif state in (ProcessStates.STOPPED, ProcessStates.EXITED, | ||
| ProcessStates.FATAL): | ||
| actions = [start, None, clearlog, tailf_stdout, tailf_stderr] | ||
| actions = [start, None, clearlog, tailf_stdout, tailf_stderr, None] | ||
| else: | ||
| actions = [None, None, clearlog, tailf_stdout, tailf_stderr] | ||
| actions = [None, None, clearlog, tailf_stdout, tailf_stderr, None] | ||
| return actions | ||
|
|
||
| def css_class_for_state(self, state): | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.