Skip to content

Commit

Permalink
UI select done and WIP on odoo selected domain logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Nardecchia authored and Alessandro Nardecchia committed Apr 15, 2024
1 parent 7af42fc commit 0029b3a
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 69 deletions.
4 changes: 4 additions & 0 deletions imageroot/actions/configure-module/20Configure
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ data = json.load(sys.stdin)

# Setup default values
host = data.get("host")

ldap_domain = data.get("ldap_domain", "")
agent.set_env("ODOO_LDAP_DOMAIN", ldap_domain)

18 changes: 15 additions & 3 deletions imageroot/actions/get-configuration/20read
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import os
import json
import sys
import agent
from agent.ldapproxy import Ldapproxy

# Prepare return variable
config = {}
Expand All @@ -12,9 +13,20 @@ config = {}
env = f'module/{os.environ["MODULE_ID"]}/environment'
rdb = agent.redis_connect()

config["host"] = rdb.hget(env, "TRAEFIK_HOST");
config["http2https"] = rdb.hget(env, "TRAEFIK_HTTP2HTTPS") == "True";
config["lets_encrypt"] = rdb.hget(env, "TRAEFIK_LETS_ENCRYPT") == "True";
config["host"] = rdb.hget(env, "TRAEFIK_HOST");
config["ldap_domain"] = rdb.hget(env, "ODOO_LDAP_DOMAIN") if rdb.hget(env, "ODOO_LDAP_DOMAIN") else "";
config["http2https"] = rdb.hget(env, "TRAEFIK_HTTP2HTTPS") == "True";
config["lets_encrypt"] = rdb.hget(env, "TRAEFIK_LETS_ENCRYPT") == "True";


# Get available ldap domains
lp = Ldapproxy()
config["ldap_available_domains"] = [""]

domains = lp.get_domains_list()

for domain in domains:
config["ldap_available_domains"].append(domain)

# Dump the configuratio to stdout
json.dump(config, fp=sys.stdout)
1 change: 1 addition & 0 deletions imageroot/actions/restore-module/06copyenv
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ for evar in [
"TRAEFIK_HOST",
"TRAEFIK_HTTP2HTTPS",
"TRAEFIK_LETS_ENCRYPT",
"ODOO_LDAP_DOMAIN"
]:
agent.set_env(evar, original_environment[evar])
4 changes: 2 additions & 2 deletions imageroot/actions/restore-module/50traefik
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ response2 = agent.tasks.run(
action='set-route',
data={
'instance': "gevent%s" % (os.environ['MODULE_ID']),
'url': 'http://127.0.0.1:%s/longpolling/poll' % (get_second_tcp_port()),
'path': '/longpolling/poll',
'url': 'http://127.0.0.1:%s' % (get_second_tcp_port()),
'path': '/websocket',
'host': os.environ["TRAEFIK_HOST"],
'lets_encrypt': os.environ["TRAEFIK_LETS_ENCRYPT"] == True,
'http2https': os.environ["TRAEFIK_HTTP2HTTPS"] == True
Expand Down
130 changes: 66 additions & 64 deletions ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
{
"common": {
"required": "Required",
"work_in_progress": "Work in progress"
},
"status": {
"title": "Status",
"app_instance": "App instance",
"services": "Service | Services",
"app_images": "App image | App images",
"app_volumes": "App volume | App volumes",
"installation_node": "Installation node",
"node": "Node",
"failed_services": "{num} failed service | {num} failed services",
"active_services": "{num} active service | {num} active services",
"inactive_services": "{num} inactive service | {num} inactive services",
"name": "Name",
"size": "Size",
"created": "Created",
"mount": "Mount",
"no_services": "No services",
"no_images": "No images",
"no_volumes": "No volumes",
"open_odoo_page": "Go to application",
"odoo_url": "Odoo URL"
},
"settings": {
"title": "Settings",
"odoo_fqdn": "Odoo FQDN",
"save": "Save",
"lets_encrypt": "Let's Encrypt",
"http_to_https": "HTTP to HTTPS",
"enabled": "Enabled",
"disabled": "Disabled",
"instance_configuration": "Configure {instance}",
"configuring": "Configuring...",
"email_format": "Invalid email address",
"domain_already_used_in_traefik":"This domain is already used in traefik"
},
"about": {
"title": "About"
},
"task": {
"cannot_create_task": "Cannot create task {action}"
},
"action": {
"get-status": "Get status",
"get-configuration": "Get configuration",
"configure-module": "Configure module",
"get-module-info": "Get module info",
"get-name": "Get name"
},
"error": {
"error": "Error",
"generic_error": "Something went wrong",
"validation_error": "Validation error",
"network_error": "Network error",
"network_timeout": "Network timeout",
"401": "Invalid authentication",
"403": "Operation not authorized",
"404": "Resource not found",
"cannot_retrieve_module_info": "Cannot retrieve module info",
"cannot_retrieve_installed_modules": "Cannot retrieve installed modules"
}
}
"common": {
"required": "Required",
"work_in_progress": "Work in progress"
},
"status": {
"title": "Status",
"app_instance": "App instance",
"services": "Service | Services",
"app_images": "App image | App images",
"app_volumes": "App volume | App volumes",
"installation_node": "Installation node",
"node": "Node",
"failed_services": "{num} failed service | {num} failed services",
"active_services": "{num} active service | {num} active services",
"inactive_services": "{num} inactive service | {num} inactive services",
"name": "Name",
"size": "Size",
"created": "Created",
"mount": "Mount",
"no_services": "No services",
"no_images": "No images",
"no_volumes": "No volumes",
"open_odoo_page": "Go to application",
"odoo_url": "Odoo URL"
},
"settings": {
"title": "Settings",
"odoo_fqdn": "Odoo FQDN",
"ldap_domain": "LDAP domain",
"no_domain": "No domain",
"save": "Save",
"lets_encrypt": "Let's Encrypt",
"http_to_https": "HTTP to HTTPS",
"enabled": "Enabled",
"disabled": "Disabled",
"instance_configuration": "Configure {instance}",
"configuring": "Configuring...",
"email_format": "Invalid email address",
"domain_already_used_in_traefik": "This domain is already used in traefik"
},
"about": {
"title": "About"
},
"task": {
"cannot_create_task": "Cannot create task {action}"
},
"action": {
"get-status": "Get status",
"get-configuration": "Get configuration",
"configure-module": "Configure module",
"get-module-info": "Get module info",
"get-name": "Get name"
},
"error": {
"error": "Error",
"generic_error": "Something went wrong",
"validation_error": "Validation error",
"network_error": "Network error",
"network_timeout": "Network timeout",
"401": "Invalid authentication",
"403": "Operation not authorized",
"404": "Resource not found",
"cannot_retrieve_module_info": "Cannot retrieve module info",
"cannot_retrieve_installed_modules": "Cannot retrieve installed modules"
}
}
2 changes: 2 additions & 0 deletions ui/public/i18n/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"configuring": "Configurazione...",
"domain_already_used_in_traefik": "Questo dominio è già utilizzato in traefik",
"odoo_fqdn": "FQDN Odoo",
"ldap_domain": "Dominio LDAP",
"no_domain": "Nessun dominio",
"disabled": "Disabilitato",
"email_format": "Indirizzo e-mail non valido"
},
Expand Down
23 changes: 23 additions & 0 deletions ui/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@
$t("settings.enabled")
}}</template>
</cv-toggle>
<cv-select
:label="$t('settings.ldap_domain')"
v-model.trim="host"
v-model="selectedDomain"
class="mg-bottom"
:invalid-message="$t(error.host)"
:disabled="loading.getConfiguration || loading.configureModule"
ref="host"
>
<option v-for="(item, index) in ldapDomainOptions"
v-bind:value="item"
v-bind:key="index"
>
{{item != "" ? item : $t("settings.no_domain")}}
</option>
</cv-select>
<div v-if="error.configureModule" class="bx--row">
<div class="bx--col">
<NsInlineNotification
Expand Down Expand Up @@ -110,6 +126,10 @@ export default {
getConfiguration: false,
configureModule: false,
},
ldapDomainOptions: [
""
],
selectedDomain: "",
error: {
getConfiguration: "",
configureModule: "",
Expand Down Expand Up @@ -181,6 +201,8 @@ export default {
getConfigurationCompleted(taskContext, taskResult) {
const config = taskResult.output;
this.host = config.host;
this.selectedDomain = config.ldap_domain ? config.ldap_domain : "";
this.ldapDomainOptions = config.ldap_available_domains ? config.ldap_available_domains : [""];
this.isLetsEncryptEnabled = config.lets_encrypt;
this.isHttpToHttpsEnabled = config.http2https;
this.loading.getConfiguration = false;
Expand Down Expand Up @@ -252,6 +274,7 @@ export default {
action: taskAction,
data: {
host: this.host,
ldap_domain: this.selectedDomain,
lets_encrypt: this.isLetsEncryptEnabled,
http2https: this.isHttpToHttpsEnabled,
},
Expand Down

0 comments on commit 0029b3a

Please sign in to comment.