From 190efb3f6e0d2794cd753a5becb61a6d7d403100 Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Tue, 15 Oct 2024 14:54:07 +0200 Subject: [PATCH] Add proxy installation status and translation support (#318) Add proxy installation status and translation support NethServer/dev#7057 --- imageroot/actions/get-proxy-status/10get | 20 ++++ .../get-proxy-status/validate-output.json | 20 ++++ .../10_get_proxy_status_integrations.robot | 8 ++ ui/public/i18n/en/translation.json | 4 +- ui/src/views/Settings.vue | 94 +++++++++++++++---- 5 files changed, 129 insertions(+), 17 deletions(-) create mode 100755 imageroot/actions/get-proxy-status/10get create mode 100644 imageroot/actions/get-proxy-status/validate-output.json create mode 100644 tests/10_nethvoice_actions/10_get_proxy_status_integrations.robot diff --git a/imageroot/actions/get-proxy-status/10get b/imageroot/actions/get-proxy-status/10get new file mode 100755 index 000000000..7e20fd993 --- /dev/null +++ b/imageroot/actions/get-proxy-status/10get @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +# +# Copyright (C) 2022 Nethesis S.r.l. +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import json +import sys +import agent + +rdb = agent.redis_connect(privileged=True) + +# Find default proxy instance for current node +proxy_id = agent.resolve_agent_id('nethvoice-proxy@node') +config = { + "proxy_installed": True if proxy_id is not None else False, +} + +json.dump(config, fp=sys.stdout) diff --git a/imageroot/actions/get-proxy-status/validate-output.json b/imageroot/actions/get-proxy-status/validate-output.json new file mode 100644 index 000000000..688f757ea --- /dev/null +++ b/imageroot/actions/get-proxy-status/validate-output.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Get the status of nethvoice proxy", + "$id": "http://nethserver.org/json-schema/task/output/nethvoice/get-proxy-status", + "description": "Get the status of nethvoice proxy", + "examples": [ + { + "proxy_installed": true + } + ], + "type": "object", + "properties": { + "proxy_installed": { + "description": "Test if the Nethvoice proxy is installed", + "type": "boolean" + } + }, + "required": ["proxy_installed"], + "additionalProperties": false +} diff --git a/tests/10_nethvoice_actions/10_get_proxy_status_integrations.robot b/tests/10_nethvoice_actions/10_get_proxy_status_integrations.robot new file mode 100644 index 000000000..341c3ea3e --- /dev/null +++ b/tests/10_nethvoice_actions/10_get_proxy_status_integrations.robot @@ -0,0 +1,8 @@ +*** Settings *** +Library SSHLibrary +Resource ../api.resource + +*** Test Cases *** +Check get-proxy-status action output + ${response} = Run task module/${module_id}/get-proxy-status {} + Should Be Equal As Strings ${response['proxy_installed']} True diff --git a/ui/public/i18n/en/translation.json b/ui/public/i18n/en/translation.json index 79a0d0238..8c4fa8b43 100644 --- a/ui/public/i18n/en/translation.json +++ b/ui/public/i18n/en/translation.json @@ -71,7 +71,9 @@ "error_message_hostname": "By changing the user provider of an already configured NethVoice, all the users and extensions configuration will be reset.", "nethvoice_host_format": "Must be a valid domain name be a valid domain name.", "nethcti_ui_host_format": "Must be a valid domain name be a valid domain name.", - "set_rebranding": "Rebranding setup" + "set_rebranding": "Rebranding setup", + "proxy_not_installed": "Nethvoice Proxy", + "proxy_not_installed_description": "The proxy needs to be installed before configuring NethVoice." }, "warning": { "warning_title_message": "Warning" diff --git a/ui/src/views/Settings.vue b/ui/src/views/Settings.vue index f91745824..7a5b38070 100644 --- a/ui/src/views/Settings.vue +++ b/ui/src/views/Settings.vue @@ -19,6 +19,16 @@ /> + + + + + @@ -27,7 +37,7 @@ :label="$t('settings.nethvoice_host')" v-model="form.nethvoice_host" placeholder="voice.example.com" - :disabled="loadingState" + :disabled="loadingState || !proxy_installed" :invalid-message="error.nethvoice_host" ref="nethvoice_host" /> @@ -35,7 +45,7 @@ :label="$t('settings.nethcti_ui_host')" v-model="form.nethcti_ui_host" placeholder="cti.example.com" - :disabled="loadingState" + :disabled="loadingState || !proxy_installed" :invalid-message="error.nethcti_ui_host" ref="nethcti_ui_host" /> @@ -51,7 +61,7 @@ :options="domainList" :auto-highlight="true" :label="$t('settings.user_domain_placeholder')" - :disabled="loadingState" + :disabled="loadingState || !proxy_installed" :invalid-message="error.user_domain" v-model="form.user_domain" ref="user_domain" @@ -72,7 +82,8 @@ :disabled=" loading.getConfiguration || loading.configureModule || - loading.getDefaults + loading.getDefaults || + !proxy_installed " tooltipAlignment="start" tooltipDirection="top" @@ -85,14 +96,14 @@