diff --git a/monujo/README.org b/monujo/README.org new file mode 100644 index 0000000..062e96b --- /dev/null +++ b/monujo/README.org @@ -0,0 +1,146 @@ +# -*- ispell-local-dictionary: "english" -*- + +#+TITLE: Monujo charm + +* Usage + +=monujo= service needs to know how to reach it's administrative backend. +So either you specify one by yourself: + +#+begin_src yaml +monujo: + options: + lokapi-host: http://admin.mycur.org + #lokapi-db: odoo ## Default: 'odoo' + +#+end_src + +Either you can provide in sibling services an =odoo-server= providing +service. It'll then discover it and use it by default as administrative +backend. + +#+begin_src yaml +monujo: + +odoo: +#+end_src + +Note that =monujo= charm is describing a subordinate service, meaning +that it'll run in an existing service providing =publish-dir= relation +(creating one if not available). + +By default, =lokapi-db= if not set will be infered from option =dbname= +in the relation =odoo-server=, or default database from =odoo-server=. + +So all these are equivalent: + +#+begin_src yaml +monujo: + options: + lokapi-db: foo + +odoo: +#+end_src + +#+begin_src yaml +monujo: + relations: + odoo-server: + odoo: + dbname: foo + +odoo: +#+end_src + + +#+begin_src yaml +monujo: + +odoo: + relations: + postgres-database: + postgres: + dbname: foo +#+end_src + + +** Map + +=monujo= optionaly can add a link to a map. If you want to do so, either +add it explicitly, or add it automatically. This is the explicit way: + +#+begin_src yaml +monujo: + options: + map-url: http://map.mycur.org + +#+end_src + +The map will be added automatically if a =map-server= provider is +found (=gogocarto= charm creates services that provides =map-server= +relations). + +#+begin_src yaml +monujo: + +gogocarto: + +#+end_src + + +** Theming + +This charm allows to write all the =config.json= values supported by +monujo, including the =theme= option, here's the default fully valued +options of =theme= as of version =1.0.0-rc.3= of =monujo=: + +#+begin_src yaml +monujo: + options: + lokapi-host: example.org + lokapi-db: odoo + map-url: https://carte.example.org + help-url: https://help.com + cgu-url: https://cgu.com + local-password-retention-time: 900 + logo-url: https://example.com/img/logo.png + login-logo-url: https://example.com/img/logo-2.png + theme: + color-1: "#e4f2f1" + color-2: "#009688" + top-menu-background-color: "#fefefe" + top-menu-link-color: "#4a4a4a" + top-menu-link-background-color: white + top-menu-link-background-color-bg: white + top-menu-link-hover-color: "#777777" + top-menu-link-hover-color-bg: "#848484" + top-menu-link-hover-background-color: whitesmoke + top-menu-dropdown-divider-color: whitesmoke + btn-payer-text-color: "#ffffff" + btn-payer-border-color: $color-2 + btn-payer-background-color: $color-2 + btn-recevoir-text-color: "#ffffff" + btn-recevoir-border-color: $color-2 + btn-recevoir-background-color: $color-2 + btn-recharger-text-color: $color-2 + btn-recharger-border-color: $color-2 + btn-recharger-background-color: "#ffffff" + btn-login-text-color: "#ffffff" + btn-login-border-color: $color-2 + btn-login-background-color: $color-2 + inner-card-background-color: "#f0faf9" + inner-card-border-color: "#f0faf9" + inner-card-text-color: "#4a4a4a" + inner-card-text-color-backend: "#242424" + inner-card-label-background-color: transparent + inner-card-label-text-color: "#4a4a4a" + inner-card-alt-text-color: "#009688" + body-size: 14px + tabs-border-bottom-color: white + tabs-border-bottom-width: 4px + tabs-link-hover-border-bottom-color: $color-2 + tabs-link-active-color: rgba(0 0 0 0.8) + tabs-link-active-border-bottom-color: $color-2 + tabs-link-color: rgba(0 0 0 0.6) + navbar-fixed-z: 50 +#+end_src diff --git a/monujo/hooks/pre_deploy b/monujo/hooks/pre_deploy index 7a5e8c4..8743c8a 100755 --- a/monujo/hooks/pre_deploy +++ b/monujo/hooks/pre_deploy @@ -5,25 +5,44 @@ set -e -if service:traverse "${SERVICE_NAME}":odoo-server >/dev/null; then - if ! url=$(relation:get "${SERVICE_NAME}":odoo-server:web-proxy url); then - err "Monujo doesn't support odoo-server not having a web-proxy yet." +if ! admin_backend=$(options-get "lokapi-host" 2>/dev/null) || [ -z "$admin_backend" ]; then + + if ! service:traverse "${SERVICE_NAME}":odoo-server >/dev/null; then + err "Monujo requires either a ${WHITE}lokapi-host${NORMAL} option set," + echo " or a ${DARKCYAN}odoo-server${NORMAL} relation satisfied." >&2 exit 1 fi - if ! dbname=$(relation:get "${SERVICE_NAME}":odoo-server:postgres-database dbname); then - err "Can't find db name of our odoo-server relation." + if ! url=$(relation:get "${SERVICE_NAME}":odoo-server:web-proxy url); then + err "Monujo doesn't support odoo-server not having a web-proxy yet." exit 1 fi + monujo:config_merge "{ - \"lokapiHost\": \"$url\", - \"lokapiDb\": \"$dbname\" + \"lokapiHost\": \"$url\" }" -fi + if ! dbname=$(options-get "lokapi-db" 2>/dev/null) || [ -z "$dbname" ]; then + if ! dbname=$(relation:get "${SERVICE_NAME}":odoo-server dbname) || [ -z "$dbname" ]; then + err "Can't find db name of our ${DARKCYAN}odoo-server${NORMAL} relation." + if ! dbname=$(relation:get "${SERVICE_NAME}":odoo-server:postgres-database dbname) || [ -z "$dbname" ]; then + err "Can't find db name of ${DARKCYAN}odoo-server${NORMAL}-->${DARKCYAN}postgres-database${NORMAL} relation." + exit 1 + fi + fi + monujo:config_merge "{ + \"lokapiDb\": \"$dbname\" + }" + fi -if map_url=$(relation:get "${SERVICE_NAME}":map-server:publish-dir url); then - monujo:config_merge "{ - \"mapUrl\": \"$map_url\" - }" fi + + +if ! map_url=$(options-get "map-url" 2>/dev/null) || [ -z "$map_url" ] ; then + + if map_url=$(relation:get "${SERVICE_NAME}":map-server:publish-dir url); then + monujo:config_merge "{ + \"mapUrl\": \"$map_url\" + }" + fi +fi \ No newline at end of file