From 6fef804fe1a9c932333c84f3f79a3509ac843759 Mon Sep 17 00:00:00 2001 From: Axolotle Date: Fri, 25 Sep 2020 09:20:41 +0200 Subject: [PATCH] add Diagnosis view/route --- app/src/filters/date.js | 15 +- app/src/helpers/api.js | 6 +- app/src/i18n/locales/en.json | 6 +- app/src/router/routes.js | 14 ++ app/src/scss/main.scss | 4 +- app/src/views/diagnosis/Diagnosis.vue | 216 ++++++++++++++++++++++++++ 6 files changed, 251 insertions(+), 10 deletions(-) create mode 100644 app/src/views/diagnosis/Diagnosis.vue diff --git a/app/src/filters/date.js b/app/src/filters/date.js index 77e41d81..572d29ef 100644 --- a/app/src/filters/date.js +++ b/app/src/filters/date.js @@ -3,10 +3,17 @@ import format from 'date-fns/format' import { dateFnsLocale as locale } from '@/i18n/helpers' -export function distanceToNow (dateStr, addSuffix = true) { - return formatDistanceToNow(new Date(dateStr), { addSuffix, locale }) +export function distanceToNow (date, addSuffix = true, isTimestamp = false) { + return formatDistanceToNow( + new Date(isTimestamp ? date * 1000 : date), + { addSuffix, locale } + ) } -export function readableDate (dateStr) { - return format(new Date(dateStr), 'PPPpp', { locale }) +export function readableDate (date, isTimestamp = false) { + return format( + new Date(isTimestamp ? date * 1000 : date), + 'PPPpp', + { locale } + ) } diff --git a/app/src/helpers/api.js b/app/src/helpers/api.js index 6738d935..4103a5d8 100644 --- a/app/src/helpers/api.js +++ b/app/src/helpers/api.js @@ -17,7 +17,11 @@ import store from '@/store' export function objectToParams (object, { addLocale = false } = {}) { const urlParams = new URLSearchParams() for (const [key, value] of Object.entries(object)) { - urlParams.append(key, value) + if (Array.isArray(value)) { + value.forEach(v => urlParams.append(key, v)) + } else { + urlParams.append(key, value) + } } if (addLocale) { urlParams.append('locale', store.getters.locale) diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json index 9721b164..954cf27a 100644 --- a/app/src/i18n/locales/en.json +++ b/app/src/i18n/locales/en.json @@ -167,7 +167,7 @@ "hook_data_mail_desc": "Raw emails stored on the server", "id": "ID", "ignore": "Ignore", - "ignored": "%s ignored", + "ignored": "{count} ignored", "inactive": "Inactive", "infos": "Info", "install": "Install", @@ -178,7 +178,7 @@ "internal_exception": "Yunohost encountered an internal error:/
Really sorry about that.
You should look for help on the forum or the chat to fix the situation, or report the bug on the bugtracker.

The following information might be useful for the person helping you:

Action

%s%s

Traceback

%s
", "ipv4": "IPv4", "ipv6": "IPv6", - "issues": "%s issues", + "issues": "{count} issues", "label": "Label", "label_for_manifestname": "Label for %s", "last_ran": "Last time ran:", @@ -361,7 +361,7 @@ "users_new": "New user", "users_no": "No users.", "version": "Version", - "warnings": "%s warnings", + "warnings": "{count} warnings", "warning_first_user": "You probably need to create a user first.", "words": { "collapse": "Collapse" diff --git a/app/src/router/routes.js b/app/src/router/routes.js index 2c6dc8ea..3a508568 100644 --- a/app/src/router/routes.js +++ b/app/src/router/routes.js @@ -263,6 +263,20 @@ const routes = [ { name: 'tool-power', trad: 'tools_shutdown_reboot' } ] } + }, + + /* ────────────╮ + │ DIAGNOSIS │ + ╰──────────── */ + { + name: 'diagnosis', + path: '/diagnosis', + component: () => import(/* webpackChunkName: "views/diagnosis" */ '@/views/diagnosis/Diagnosis'), + meta: { + breadcrumb: [ + { name: 'diagnosis', trad: 'diagnosis' } + ] + } } ] diff --git a/app/src/scss/main.scss b/app/src/scss/main.scss index 5140c2af..6d144a97 100644 --- a/app/src/scss/main.scss +++ b/app/src/scss/main.scss @@ -80,10 +80,10 @@ body { } // collapse icon -.not-collapsed .icon { +.not-collapsed > .icon { transform: rotate(-90deg); } -.collapsed .icon { +.collapsed > .icon { transform: rotate(90deg); position: relative; top: 2px; diff --git a/app/src/views/diagnosis/Diagnosis.vue b/app/src/views/diagnosis/Diagnosis.vue new file mode 100644 index 00000000..e5a2c841 --- /dev/null +++ b/app/src/views/diagnosis/Diagnosis.vue @@ -0,0 +1,216 @@ + + + + +