Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a button link to dokuwiki in status page #24

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"mount": "Mount",
"no_services": "No services",
"no_images": "No images",
"no_volumes": "No volumes"
"no_volumes": "No volumes",
"dokuwiki_webapp": "Dokuwiki webapp",
"not_configured": "Not configured",
"open_webapp": "Open Dokuwiki",
"configure": "Configure"
},
"settings": {
"title": "Settings",
Expand Down Expand Up @@ -66,6 +70,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"
}
}
94 changes: 92 additions & 2 deletions ui/src/views/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,52 @@
/>
</div>
</div>
<div class="bx--row">
<div class="bx--col-md-4 bx--col-max-4">
<NsInfoCard
light
:title="$t('status.dokuwiki_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>
</div>
</div>
<div class="bx--row">
<div class="bx--col-md-4 bx--col-max-4">
<NsInfoCard
light
:title="status ? status.instance : ''"
:description="$t('status.app_instance')"
:icon="Application32"
:loading="loading.status"
:loading="loading.status || loading.getConfiguration"
class="min-height-card"
/>
</div>
Expand All @@ -33,7 +71,7 @@
:titleTooltip="installationNodeTitleTooltip"
:description="$t('status.installation_node')"
:icon="Chip32"
:loading="loading.status"
:loading="loading.status || loading.getConfiguration"
class="min-height-card"
/>
</div>
Expand Down Expand Up @@ -253,6 +291,7 @@ export default {
backupRepositories: [],
backups: [],
loading: {
getConfiguration: true,
status: true,
listBackupRepositories: true,
listBackups: true,
Expand Down Expand Up @@ -284,6 +323,7 @@ export default {
},
},
created() {
this.getConfiguration();
this.getStatus();
this.listBackupRepositories();
},
Expand All @@ -308,6 +348,56 @@ export default {
clearTimeout(this.redirectTimeout);
},
methods: {
goToWebapp() {
window.open(`https://${this.host}`, "_blank");
},
async getConfiguration() {
this.loading.getConfiguration = true;
this.error.getConfiguration = "";
const taskAction = "get-configuration";

// register to task error
this.core.$root.$off(taskAction + "-aborted");
this.core.$root.$once(
taskAction + "-aborted",
this.getConfigurationAborted
);

// register to task completion
this.core.$root.$off(taskAction + "-completed");
this.core.$root.$once(
taskAction + "-completed",
this.getConfigurationCompleted
);

const res = await to(
this.createModuleTaskForApp(this.instanceName, {
action: taskAction,
extra: {
title: this.$t("action." + taskAction),
isNotificationHidden: true,
},
})
);
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.status = true;
this.error.getStatus = "";
Expand Down
Loading