Skip to content

Commit

Permalink
Add proxy installation status and translation support (#318)
Browse files Browse the repository at this point in the history
Add proxy installation status and translation support NethServer/dev#7057
  • Loading branch information
stephdl authored Oct 15, 2024
1 parent ca49287 commit 190efb3
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 17 deletions.
20 changes: 20 additions & 0 deletions imageroot/actions/get-proxy-status/10get
Original file line number Diff line number Diff line change
@@ -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)
20 changes: 20 additions & 0 deletions imageroot/actions/get-proxy-status/validate-output.json
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
94 changes: 78 additions & 16 deletions ui/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
/>
</cv-column>
</cv-row>
<cv-row v-if="!proxy_installed && !loadingState">
<cv-column>
<NsInlineNotification
kind="info"
:title="$t('settings.proxy_not_installed')"
:description="$t('settings.proxy_not_installed_description')"
:showCloseButton="false"
/>
</cv-column>
</cv-row>
<cv-row>
<cv-column>
<cv-tile light>
Expand All @@ -27,15 +37,15 @@
: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"
/>
<cv-text-input
: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"
/>
Expand All @@ -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"
Expand All @@ -72,7 +82,8 @@
:disabled="
loading.getConfiguration ||
loading.configureModule ||
loading.getDefaults
loading.getDefaults ||
!proxy_installed
"
tooltipAlignment="start"
tooltipDirection="top"
Expand All @@ -85,14 +96,14 @@
<cv-toggle
:label="$t('settings.lets_encrypt')"
value="lets_encrypt"
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
v-model="form.lets_encrypt"
/>
<NsTextInput
:label="$t('settings.reports_international_prefix')"
v-model="form.reports_international_prefix"
placeholder="+39"
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
:invalid-message="error.reports_international_prefix"
>
<template slot="tooltip">
Expand All @@ -103,7 +114,7 @@
:label="$t('settings.nethvoice_admin_password')"
v-model="form.nethvoice_admin_password"
placeholder=""
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
:invalid-message="error.nethvoice_admin_password"
ref="nethvoice_admin_password"
type="password"
Expand All @@ -128,7 +139,7 @@
ref="acc"
:align="align"
:size="size"
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
v-if="form.rebranding_active"
>
<cv-accordion-item :open="open[0]" class="test-card">
Expand All @@ -139,7 +150,7 @@
:label="$t('settings.rebranding_navbar_logo_url')"
v-model="form.rebranding_navbar_logo_url"
placeholder="https://.."
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
:invalid-message="error.rebranding_navbar_logo_url"
>
<template slot="tooltip">
Expand All @@ -151,7 +162,7 @@
:label="$t('settings.rebranding_navbar_logo_dark_url')"
v-model="form.rebranding_navbar_logo_dark_url"
placeholder="https://.."
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
:invalid-message="error.rebranding_navbar_logo_dark_url"
>
<template slot="tooltip">
Expand All @@ -165,7 +176,7 @@
:label="$t('settings.rebranding_login_background_url')"
v-model="form.rebranding_login_background_url"
placeholder="https://.."
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
:invalid-message="error.rebranding_login_background_url"
>
<template slot="tooltip">
Expand All @@ -179,7 +190,7 @@
:label="$t('settings.rebranding_favicon_url')"
v-model="form.rebranding_favicon_url"
placeholder="https://.."
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
:invalid-message="error.rebranding_favicon_url"
>
<template slot="tooltip">
Expand All @@ -191,7 +202,7 @@
:label="$t('settings.rebranding_login_logo_url')"
v-model="form.rebranding_login_logo_url"
placeholder="https://.."
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
:invalid-message="error.rebranding_login_logo_url"
>
<template slot="tooltip">
Expand All @@ -203,7 +214,7 @@
:label="$t('settings.rebranding_login_logo_dark_url')"
v-model="form.rebranding_login_logo_dark_url"
placeholder="https://.."
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
:invalid-message="error.rebranding_login_logo_dark_url"
>
<template slot="tooltip">
Expand All @@ -215,7 +226,7 @@
<NsCheckbox
:label="$t('settings.rebranding_login_people')"
v-model="form.rebranding_login_people"
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
:invalid-message="error.rebranding_login_people"
>
<template slot="tooltip">
Expand Down Expand Up @@ -317,7 +328,7 @@
kind="primary"
:icon="Save20"
:loading="loading.configureModule"
:disabled="loadingState"
:disabled="loadingState || !proxy_installed"
>
{{ $t("settings.save") }}
</NsButton>
Expand Down Expand Up @@ -383,6 +394,7 @@ export default {
nethvoice_adm: {},
},
isDarkMode: false,
proxy_installed: false,
config: {},
loading: {
getConfiguration: false,
Expand All @@ -391,6 +403,7 @@ export default {
userDomains: false,
getDefaults: false,
getUsers: false,
getProxyStatus: false,
},
domainList: [],
timezoneList: [],
Expand Down Expand Up @@ -1043,6 +1056,55 @@ export default {
})
);
this.loading.getDefaults = false;
this.getProxyStatus();
},
async getProxyStatus() {
this.loading.getProxyStatus = true;
const taskAction = "get-proxy-status";
const eventId = this.getUuid();
// register to task error
this.core.$root.$once(
`${taskAction}-aborted-${eventId}`,
this.getProxyStatusAborted
);
// register to task completion
this.core.$root.$once(
`${taskAction}-completed-${eventId}`,
this.getProxyStatusCompleted
);
const res = await to(
this.createModuleTaskForApp(this.instanceName, {
action: taskAction,
extra: {
title: this.$t("action." + taskAction),
isNotificationHidden: true,
eventId,
},
})
);
const err = res[0];
if (err) {
console.error(`error creating task ${taskAction}`, err);
this.error.getConfiguration = this.getErrorMessage(err);
this.loading.getProxyStatus = false;
return;
}
},
getProxyStatusAborted(taskResult, taskContext) {
console.error(`${taskContext.action} aborted`, taskResult);
this.error.getConfiguration = this.$t("error.generic_error");
this.loading.getProxyStatus = false;
this.getConfiguration();
},
getProxyStatusCompleted(taskContext, taskResult) {
const config = taskResult.output;
this.proxy_installed = config.proxy_installed;
this.loading.getProxyStatus = false;
this.getConfiguration();
},
async getUsers(domain) {
Expand Down

0 comments on commit 190efb3

Please sign in to comment.