Skip to content

Commit

Permalink
Almost done get-configuration and previous ldap_domain selected | don…
Browse files Browse the repository at this point in the history
…e ui with block if user already selected a domain and saved successfully | WIP
  • Loading branch information
Alessandro Nardecchia authored and Alessandro Nardecchia committed Apr 15, 2024
1 parent 0029b3a commit d0c1524
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 69 deletions.
6 changes: 4 additions & 2 deletions imageroot/actions/configure-module/20Configure
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

import os
import json
import sys
Expand All @@ -7,9 +9,9 @@ import agent
# If parsing fails, output everything to stderr
data = json.load(sys.stdin)

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

# TODO move this part to 90ldap. if an error occurs during set ldap on odoo
# we need to set ODOO_LDAP_DOMAIN = "" otherwise user can't select anymore a domain!
ldap_domain = data.get("ldap_domain", "")
agent.set_env("ODOO_LDAP_DOMAIN", ldap_domain)

1 change: 1 addition & 0 deletions ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"odoo_fqdn": "Odoo FQDN",
"ldap_domain": "LDAP domain",
"no_domain": "No domain",
"change_ldap_domain_already_set": "Modify not available, a LDAP domain is already configured.",
"save": "Save",
"lets_encrypt": "Let's Encrypt",
"http_to_https": "HTTP to HTTPS",
Expand Down
1 change: 1 addition & 0 deletions ui/public/i18n/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"odoo_fqdn": "FQDN Odoo",
"ldap_domain": "Dominio LDAP",
"no_domain": "Nessun dominio",
"change_ldap_domain_already_set": "Modifica non disponibile, un dominio LDAP è stato già configurato.",
"disabled": "Disabilitato",
"email_format": "Indirizzo e-mail non valido"
},
Expand Down
115 changes: 48 additions & 67 deletions ui/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,89 +7,63 @@
</div>
<div v-if="error.getConfiguration" class="bx--row">
<div class="bx--col">
<NsInlineNotification
kind="error"
:title="$t('action.get-configuration')"
:description="error.getConfiguration"
:showCloseButton="false"
/>
<NsInlineNotification kind="error" :title="$t('action.get-configuration')" :description="error.getConfiguration"
:showCloseButton="false" />
</div>
</div>
<div class="bx--row">
<div class="bx--col-lg-16">
<cv-tile :light="true">
<cv-form @submit.prevent="configureModule">
<cv-text-input
:label="$t('settings.odoo_fqdn')"
placeholder="odoo.example.org"
v-model.trim="host"
class="mg-bottom"
:invalid-message="$t(error.host)"
:disabled="loading.getConfiguration || loading.configureModule"
ref="host"
>
<cv-text-input :label="$t('settings.odoo_fqdn')" placeholder="odoo.example.org" v-model.trim="host"
class="mg-bottom" :invalid-message="$t(error.host)"
:disabled="loading.getConfiguration || loading.configureModule" ref="host">
</cv-text-input>
<cv-toggle
value="letsEncrypt"
:label="$t('settings.lets_encrypt')"
v-model="isLetsEncryptEnabled"
:disabled="loading.getConfiguration || loading.configureModule"
class="mg-bottom"
>
<cv-toggle value="letsEncrypt" :label="$t('settings.lets_encrypt')" v-model="isLetsEncryptEnabled"
:disabled="loading.getConfiguration || loading.configureModule" class="mg-bottom">
<template slot="text-left">{{
$t("settings.disabled")
}}</template>
$t("settings.disabled")
}}</template>
<template slot="text-right">{{
$t("settings.enabled")
}}</template>
$t("settings.enabled")
}}</template>
</cv-toggle>
<cv-toggle
value="httpToHttps"
:label="$t('settings.http_to_https')"
v-model="isHttpToHttpsEnabled"
:disabled="loading.getConfiguration || loading.configureModule"
class="mg-bottom"
>
<cv-toggle value="httpToHttps" :label="$t('settings.http_to_https')" v-model="isHttpToHttpsEnabled"
:disabled="loading.getConfiguration || loading.configureModule" class="mg-bottom">
<template slot="text-left">{{
$t("settings.disabled")
}}</template>
$t("settings.disabled")
}}</template>
<template slot="text-right">{{
$t("settings.enabled")
}}</template>
$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>
<label class="bx--toggle-input__label" for="selectedDomain" v-if="ldap_domain === ''">
{{ $t('settings.ldap_domain') }}
</label>
<label class="bx--toggle-input__label" for="selectedDomain" v-if="ldap_domain !== ''">
{{ $t('settings.ldap_domain') }} ({{$t('settings.change_ldap_domain_already_set')}})
</label>
<cv-select id="selectedDomain" v-model.trim="selectedDomain"
:label="''"
:title="ldap_domain === '' ? '' : $t('settings.change_ldap_domain_already_set')"
class="mg-bottom" :invalid-message="$t(error.ldap_domain)"
:disabled="loading.getConfiguration || loading.configureModule || ldap_domain !== ''"
ref="selectedDomain">
<option v-for="(item, index) in ldapDomainOptions" v-bind:value="item" v-bind:key="index"
v-bind:selected="item === selectedDomain">
{{ item !== "" ? item : $t("settings.no_domain") }}
</option>
</cv-select>
</div>
<div v-if="error.configureModule" class="bx--row">
<div class="bx--col">
<NsInlineNotification
kind="error"
:title="$t('action.configure-module')"
:description="error.configureModule"
:showCloseButton="false"
/>
<NsInlineNotification kind="error" :title="$t('action.configure-module')"
:description="error.configureModule" :showCloseButton="false" />
</div>
</div>
<NsButton
kind="primary"
:icon="Save20"
:loading="loading.configureModule"
:disabled="loading.getConfiguration || loading.configureModule"
>{{ $t("settings.save") }}</NsButton
>
<NsButton kind="primary" :icon="Save20" :loading="loading.configureModule"
:disabled="loading.getConfiguration || loading.configureModule">{{ $t("settings.save") }}</NsButton>
</cv-form>
</cv-tile>
</div>
Expand Down Expand Up @@ -120,6 +94,7 @@ export default {
},
urlCheckInterval: null,
host: "",
ldap_domain: "",
isLetsEncryptEnabled: false,
isHttpToHttpsEnabled: false,
loading: {
Expand Down Expand Up @@ -201,6 +176,7 @@ export default {
getConfigurationCompleted(taskContext, taskResult) {
const config = taskResult.output;
this.host = config.host;
this.ldap_domain = config.ldap_domain ? config.ldap_domain : "";
this.selectedDomain = config.ldap_domain ? config.ldap_domain : "";
this.ldapDomainOptions = config.ldap_available_domains ? config.ldap_available_domains : [""];
this.isLetsEncryptEnabled = config.lets_encrypt;
Expand Down Expand Up @@ -245,6 +221,8 @@ export default {
return;
}
this.ldap_domain = this.selectedDomain;
this.loading.configureModule = true;
const taskAction = "configure-module";
Expand Down Expand Up @@ -274,7 +252,7 @@ export default {
action: taskAction,
data: {
host: this.host,
ldap_domain: this.selectedDomain,
ldap_domain: this.ldap_domain,
lets_encrypt: this.isLetsEncryptEnabled,
http2https: this.isHttpToHttpsEnabled,
},
Expand All @@ -292,13 +270,15 @@ export default {
console.error(`error creating task ${taskAction}`, err);
this.error.configureModule = this.getErrorMessage(err);
this.loading.configureModule = false;
this.ldap_domain = "";
return;
}
},
configureModuleAborted(taskResult, taskContext) {
console.error(`${taskContext.action} aborted`, taskResult);
this.error.configureModule = this.core.$t("error.generic_error");
this.loading.configureModule = false;
this.ldap_domain = "";
},
configureModuleCompleted() {
this.loading.configureModule = false;
Expand All @@ -312,6 +292,7 @@ export default {

<style scoped lang="scss">
@import "../styles/carbon-utils";
.mg-bottom {
margin-bottom: $spacing-06;
}
Expand Down
5 changes: 5 additions & 0 deletions utils/README_DEV
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

- bash build-images.sh && buildah push ghcr.io/innovyou/odoo:latest docker://ghcr.io/innovyou/odoo:development && add-module ghcr.io/innovyou/odoo:development 1

- GITHUB PERSONAL TOKEN
- - buildah login ghcr.io
- - generate personal token on github (nardellu/innovyou | secret_key)


## remove module

- remove-module --no-preserve odoo106
Expand Down

0 comments on commit d0c1524

Please sign in to comment.