Skip to content

Commit

Permalink
Merge pull request #26 from NethServer/status_ui NethServer/dev#7108
Browse files Browse the repository at this point in the history
Add a button to configure and access the web application.
  • Loading branch information
stephdl authored Nov 12, 2024
2 parents 9d593c1 + 6973c2c commit c024ac9
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
"mount": "Mount",
"no_services": "No services",
"no_images": "No images",
"no_volumes": "No volumes"
"no_volumes": "No volumes",
"not_configured": "Not configured",
"sogo_webapp": "SOGo webmail",
"open_webapp": "Open SOGo",
"configure": "Configure"
},
"settings": {
"title": "Settings",
Expand All @@ -37,7 +41,7 @@
"mail_server_is_not_valid": "This mail server cannot be used by SOGo webmail",
"adminList": "Administrator list",
"Write_administrator_list": "Write one administrator per line",
"dav_tips":"Dav allows to synchronize calendars and adressbooks",
"dav_tips": "Dav allows to synchronize calendars and adressbooks",
"dav": "DAV",
"activesync": "ActiveSync",
"activesync_tips": "ActiveSync allows to syncronize mobile devices",
Expand Down Expand Up @@ -78,6 +82,7 @@
"403": "Operation not authorized",
"404": "Resource not found",
"cannot_retrieve_module_info": "Cannot retrieve module info",
"cannot_retrieve_installed_modules": "Cannot retrieve installed modules"
"cannot_retrieve_installed_modules": "Cannot retrieve installed modules",
"cannot_retrieve_configuration": "Cannot retrieve configuration"
}
}
87 changes: 87 additions & 0 deletions ui/src/views/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,40 @@
</cv-column>
</cv-row>
<cv-row>
<cv-column :md="4" :max="4">
<NsInfoCard
light
:title="$t('status.sogo_webapp')"
:description="this.host ? this.host : $t('status.not_configured')"
:icon="Wikis32"
:loading="loading.getConfiguration"
:isErrorShown="error.getConfiguration"
:errorTitle="$t('error.cannot_retrieve_configuration')"
:errorDescription="error.getConfiguration"
class="min-height-card"
>
<template slot="content">
<NsButton
v-if="this.host"
kind="ghost"
:icon="Launch20"
:disabled="loading.getConfiguration"
@click="goToWebapp"
>
{{ $t("status.open_webapp") }}
</NsButton>
<NsButton
v-else
kind="ghost"
:disabled="loading.getConfiguration"
:icon="ArrowRight20"
@click="goToAppPage(instanceName, 'settings')"
>
{{ $t("status.configure") }}
</NsButton>
</template>
</NsInfoCard>
</cv-column>
<cv-column :md="4" :max="4">
<NsInfoCard
light
Expand Down Expand Up @@ -282,6 +316,7 @@ export default {
urlCheckInterval: null,
isRedirectChecked: false,
redirectTimeout: 0,
host: "",
status: {
instance: "",
services: [],
Expand All @@ -291,6 +326,7 @@ export default {
backupRepositories: [],
backups: [],
loading: {
getConfiguration: true,
getStatus: false,
listBackupRepositories: false,
listBackups: false,
Expand All @@ -299,6 +335,7 @@ export default {
getStatus: "",
listBackupRepositories: "",
listBackups: "",
getConfiguration: "",
},
};
},
Expand Down Expand Up @@ -343,10 +380,60 @@ export default {
clearTimeout(this.redirectTimeout);
},
created() {
this.getConfiguration();
this.getStatus();
this.listBackupRepositories();
},
methods: {
goToWebapp() {
window.open(`https://${this.host}`, "_blank");
},
async getConfiguration() {
this.loading.getConfiguration = true;
this.error.getConfiguration = "";
const taskAction = "get-configuration";
const eventId = this.getUuid();
// register to task error
this.core.$root.$once(
`${taskAction}-aborted-${eventId}`,
this.getConfigurationAborted
);

// register to task completion
this.core.$root.$once(
`${taskAction}-completed-${eventId}`,
this.getConfigurationCompleted
);

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.getConfiguration = false;
return;
}
},
getConfigurationAborted(taskResult, taskContext) {
console.error(`${taskContext.action} aborted`, taskResult);
this.error.getConfiguration = this.core.$t("error.generic_error");
this.loading.getConfiguration = false;
},
getConfigurationCompleted(taskContext, taskResult) {
const config = taskResult.output;
this.host = config.host;
this.loading.getConfiguration = false;
},
async getStatus() {
this.loading.getStatus = true;
this.error.getStatus = "";
Expand Down

0 comments on commit c024ac9

Please sign in to comment.