web/admin: add backup status card

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-05 20:40:30 +02:00
parent dcc873b88b
commit b98b4f2ae7
4 changed files with 95 additions and 30 deletions

View File

@ -168,7 +168,7 @@ msgstr "Application's display Name."
msgid "Applications"
msgstr "Applications"
#: src/pages/admin-overview/AdminOverviewPage.ts:40
#: src/pages/admin-overview/AdminOverviewPage.ts:41
msgid "Apps with most usage"
msgstr "Apps with most usage"
@ -301,6 +301,18 @@ msgstr "Background"
msgid "Background shown during execution."
msgstr "Background shown during execution."
#: src/pages/admin-overview/cards/BackupStatusCard.ts:35
msgid "Backup finished with errors."
msgstr "Backup finished with errors."
#: src/pages/admin-overview/cards/BackupStatusCard.ts:30
msgid "Backup finished with warnings."
msgstr "Backup finished with warnings."
#: src/pages/admin-overview/AdminOverviewPage.ts:58
msgid "Backup status"
msgstr "Backup status"
#: src/pages/sources/ldap/LDAPSourceForm.ts:130
#: src/pages/sources/ldap/LDAPSourceViewPage.ts:91
msgid "Base DN"
@ -356,11 +368,11 @@ msgstr "Build hash: {0}"
msgid "CA which the endpoint's Certificate is verified against. Can be left empty for no validation."
msgstr "CA which the endpoint's Certificate is verified against. Can be left empty for no validation."
#: src/pages/admin-overview/AdminOverviewPage.ts:55
#: src/pages/admin-overview/AdminOverviewPage.ts:56
msgid "Cached Flows"
msgstr "Cached Flows"
#: src/pages/admin-overview/AdminOverviewPage.ts:53
#: src/pages/admin-overview/AdminOverviewPage.ts:54
msgid "Cached Policies"
msgstr "Cached Policies"
@ -1565,6 +1577,7 @@ msgstr "Last run"
msgid "Last seen: {0}"
msgstr "Last seen: {0}"
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:23
#: src/pages/sources/ldap/LDAPSourceViewPage.ts:150
msgid "Last sync: {0}"
msgstr "Last sync: {0}"
@ -1665,7 +1678,7 @@ msgstr "Login to continue to {0}."
msgid "Logins"
msgstr "Logins"
#: src/pages/admin-overview/AdminOverviewPage.ts:37
#: src/pages/admin-overview/AdminOverviewPage.ts:38
#: src/pages/applications/ApplicationViewPage.ts:71
msgid "Logins over the last 24 hours"
msgstr "Logins over the last 24 hours"
@ -1926,7 +1939,7 @@ msgstr "Not found"
msgid "Not synced in the last hour, check System tasks."
msgstr "Not synced in the last hour, check System tasks."
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:28
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:32
msgid "Not synced."
msgstr "Not synced."
@ -2150,7 +2163,7 @@ msgid "Please enter your password"
msgstr "Please enter your password"
#: src/interfaces/AdminInterface.ts:26
#: src/pages/admin-overview/AdminOverviewPage.ts:45
#: src/pages/admin-overview/AdminOverviewPage.ts:46
#: src/pages/flows/FlowListPage.ts:50
#: src/pages/policies/PolicyListPage.ts:38
msgid "Policies"
@ -2300,7 +2313,7 @@ msgid "Provider type"
msgstr "Provider type"
#: src/interfaces/AdminInterface.ts:20
#: src/pages/admin-overview/AdminOverviewPage.ts:43
#: src/pages/admin-overview/AdminOverviewPage.ts:44
#: src/pages/outposts/OutpostForm.ts:82
#: src/pages/outposts/OutpostListPage.ts:50
msgid "Providers"
@ -3081,11 +3094,7 @@ msgstr "Sync users"
msgid "Sync users' passwords"
msgstr "Sync users' passwords"
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:34
msgid "Synced {0}:{1}:{2}"
msgstr "Synced {0}:{1}:{2}"
#: src/pages/admin-overview/AdminOverviewPage.ts:32
#: src/pages/admin-overview/AdminOverviewPage.ts:33
msgid "System Overview"
msgstr "System Overview"
@ -3525,7 +3534,7 @@ msgid "Username: Same as Text input, but checks for and prevents duplicate usern
msgstr "Username: Same as Text input, but checks for and prevents duplicate usernames."
#: src/interfaces/AdminInterface.ts:32
#: src/pages/admin-overview/AdminOverviewPage.ts:47
#: src/pages/admin-overview/AdminOverviewPage.ts:48
#: src/pages/users/UserListPage.ts:31
msgid "Users"
msgstr "Users"
@ -3558,7 +3567,7 @@ msgstr "Validity days"
msgid "Verification Certificate"
msgstr "Verification Certificate"
#: src/pages/admin-overview/AdminOverviewPage.ts:49
#: src/pages/admin-overview/AdminOverviewPage.ts:50
msgid "Version"
msgstr "Version"
@ -3658,7 +3667,7 @@ msgstr "Whoops!"
msgid "Windows"
msgstr "Windows"
#: src/pages/admin-overview/AdminOverviewPage.ts:51
#: src/pages/admin-overview/AdminOverviewPage.ts:52
msgid "Workers"
msgstr "Workers"

View File

@ -168,7 +168,7 @@ msgstr ""
msgid "Applications"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:40
#: src/pages/admin-overview/AdminOverviewPage.ts:41
msgid "Apps with most usage"
msgstr ""
@ -297,6 +297,18 @@ msgstr ""
msgid "Background shown during execution."
msgstr ""
#: src/pages/admin-overview/cards/BackupStatusCard.ts:35
msgid "Backup finished with errors."
msgstr ""
#: src/pages/admin-overview/cards/BackupStatusCard.ts:30
msgid "Backup finished with warnings."
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:58
msgid "Backup status"
msgstr ""
#: src/pages/sources/ldap/LDAPSourceForm.ts:130
#: src/pages/sources/ldap/LDAPSourceViewPage.ts:91
msgid "Base DN"
@ -352,11 +364,11 @@ msgstr ""
msgid "CA which the endpoint's Certificate is verified against. Can be left empty for no validation."
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:55
#: src/pages/admin-overview/AdminOverviewPage.ts:56
msgid "Cached Flows"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:53
#: src/pages/admin-overview/AdminOverviewPage.ts:54
msgid "Cached Policies"
msgstr ""
@ -1561,6 +1573,7 @@ msgstr ""
msgid "Last seen: {0}"
msgstr ""
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:23
#: src/pages/sources/ldap/LDAPSourceViewPage.ts:150
msgid "Last sync: {0}"
msgstr ""
@ -1661,7 +1674,7 @@ msgstr ""
msgid "Logins"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:37
#: src/pages/admin-overview/AdminOverviewPage.ts:38
#: src/pages/applications/ApplicationViewPage.ts:71
msgid "Logins over the last 24 hours"
msgstr ""
@ -1922,7 +1935,7 @@ msgstr ""
msgid "Not synced in the last hour, check System tasks."
msgstr ""
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:28
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:32
msgid "Not synced."
msgstr ""
@ -2146,7 +2159,7 @@ msgid "Please enter your password"
msgstr ""
#: src/interfaces/AdminInterface.ts:26
#: src/pages/admin-overview/AdminOverviewPage.ts:45
#: src/pages/admin-overview/AdminOverviewPage.ts:46
#: src/pages/flows/FlowListPage.ts:50
#: src/pages/policies/PolicyListPage.ts:38
msgid "Policies"
@ -2296,7 +2309,7 @@ msgid "Provider type"
msgstr ""
#: src/interfaces/AdminInterface.ts:20
#: src/pages/admin-overview/AdminOverviewPage.ts:43
#: src/pages/admin-overview/AdminOverviewPage.ts:44
#: src/pages/outposts/OutpostForm.ts:82
#: src/pages/outposts/OutpostListPage.ts:50
msgid "Providers"
@ -3077,11 +3090,7 @@ msgstr ""
msgid "Sync users' passwords"
msgstr ""
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:34
msgid "Synced {0}:{1}:{2}"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:32
#: src/pages/admin-overview/AdminOverviewPage.ts:33
msgid "System Overview"
msgstr ""
@ -3519,7 +3528,7 @@ msgid "Username: Same as Text input, but checks for and prevents duplicate usern
msgstr ""
#: src/interfaces/AdminInterface.ts:32
#: src/pages/admin-overview/AdminOverviewPage.ts:47
#: src/pages/admin-overview/AdminOverviewPage.ts:48
#: src/pages/users/UserListPage.ts:31
msgid "Users"
msgstr ""
@ -3552,7 +3561,7 @@ msgstr ""
msgid "Verification Certificate"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:49
#: src/pages/admin-overview/AdminOverviewPage.ts:50
msgid "Version"
msgstr ""
@ -3652,7 +3661,7 @@ msgstr ""
msgid "Windows"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:51
#: src/pages/admin-overview/AdminOverviewPage.ts:52
msgid "Workers"
msgstr ""

View File

@ -6,6 +6,7 @@ import "../../elements/cards/AggregatePromiseCard";
import "./TopApplicationsTable";
import "./cards/AdminStatusCard";
import "./cards/BackupStatusCard";
import "./cards/FlowCacheStatusCard";
import "./cards/LDAPSyncStatusCardContainer";
import "./cards/PolicyCacheStatusCard";
@ -55,6 +56,8 @@ export class AdminOverviewPage extends LitElement {
</ak-admin-status-card-policy-cache>
<ak-admin-status-card-flow-cache class="pf-l-gallery__item pf-m-4-col" icon="pf-icon pf-icon-server" header=${t`Cached Flows`}>
</ak-admin-status-card-flow-cache>
<ak-admin-status-card-backup class="pf-l-gallery__item pf-m-4-col" icon="fa fa-database" header=${t`Backup status`} headerLink="#/administration/system-tasks">
</ak-admin-status-card-backup>
<ak-admin-status-card-ldap-sync-container >
</ak-admin-status-card-ldap-sync-container>
</div>

View File

@ -0,0 +1,44 @@
import { t } from "@lingui/macro";
import { customElement, html, TemplateResult } from "lit-element";
import { AdminStatus, AdminStatusCard } from "./AdminStatusCard";
import { AdminApi, TaskStatusEnum } from "authentik-api";
import { DEFAULT_CONFIG } from "../../../api/Config";
import { convertToTitle } from "../../../utils";
@customElement("ak-admin-status-card-backup")
export class BackupStatusCard extends AdminStatusCard<TaskStatusEnum> {
getPrimaryValue(): Promise<TaskStatusEnum> {
return new AdminApi(DEFAULT_CONFIG).adminSystemTasksRead({
id: "backup_database"
}).then((value) => {
return value.status;
}).catch(() => {
return TaskStatusEnum.Error;
});
}
renderValue(): TemplateResult {
return html`${convertToTitle(this.value?.toString() || "")}`;
}
getStatus(value: TaskStatusEnum): Promise<AdminStatus> {
switch (value) {
case TaskStatusEnum.Warning:
return Promise.resolve<AdminStatus>({
icon: "fa fa-exclamation-triangle pf-m-warning",
message: t`Backup finished with warnings.`,
});
case TaskStatusEnum.Error:
return Promise.resolve<AdminStatus>({
icon: "fa fas fa-times-circle pf-m-danger",
message: t`Backup finished with errors.`,
});
default:
return Promise.resolve<AdminStatus>({
icon: "fa fa-check-circle pf-m-success"
});
}
}
}