From 7da64b8e7ef930733eff4d3fd1ebbf3f6a634b5a Mon Sep 17 00:00:00 2001 From: ljf Date: Sun, 9 Dec 2018 19:29:04 +0100 Subject: [PATCH 1/7] [enh] Display date in timezone of browser --- src/js/yunohost/controllers/apps.js | 8 ++++++-- src/js/yunohost/controllers/services.js | 4 ++++ src/js/yunohost/controllers/tools.js | 8 +------- src/js/yunohost/main.js | 4 ---- src/views/app/app_appslists_info.ms | 2 +- src/views/service/service_info.ms | 7 ++++++- src/views/service/service_list.ms | 7 ++++++- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index b1fe4cab..1785207a 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -60,7 +60,8 @@ c.view('app/app_appslists_list', { appslists: list, - has_community_list: has_community_list + has_community_list: has_community_list, + locale: y18n.locale }); }, 'GET'); }); @@ -88,7 +89,10 @@ 'lastUpdate': data[c.params['appslist']]['lastUpdate'], 'removable' : (c.params['appslist'] !== 'yunohost') ? true : false // Do not remove default apps list }; - c.view('app/app_appslists_info', {appslist: list}); + c.view('app/app_appslists_info', { + appslist: list, + locale: y18n.locale + }); } else { c.flash('warning', y18n.t('appslists_unknown_list', [c.params['appslist']])); diff --git a/src/js/yunohost/controllers/services.js b/src/js/yunohost/controllers/services.js index 86e515fc..605b1ac0 100644 --- a/src/js/yunohost/controllers/services.js +++ b/src/js/yunohost/controllers/services.js @@ -22,6 +22,8 @@ // Translate status and loaded state v.status = y18n.t(v.status); v.loaded = y18n.t(v.loaded); + if (v.active_at == 'unknown') + delete v.active_at; data2.services.push(v); }); @@ -52,6 +54,8 @@ // Translate status and loaded state data2.service.active = y18n.t(data.active); data2.service.loaded = y18n.t(data.loaded); + if (data.active_at != 'unknown') + data2.service.active_at = data.active_at; store.clear('slide'); c.view('service/service_info', data2); }, 'GET'); diff --git a/src/js/yunohost/controllers/tools.js b/src/js/yunohost/controllers/tools.js index dd39d89c..d01cb9f8 100644 --- a/src/js/yunohost/controllers/tools.js +++ b/src/js/yunohost/controllers/tools.js @@ -121,7 +121,7 @@ c.view('tools/tools_logs', { "data": data, - "locale": y18n.locale + "locale": y18n.locale }); }); }); @@ -134,12 +134,6 @@ c.api("/logs/display" + params, function(log) { if ('metadata' in log) { - if ('started_at' in log.metadata) { - log.metadata.started_at = Date.parse(log.metadata.started_at) - } - if ('ended_at' in log.metadata) { - log.metadata.ended_at = Date.parse(log.metadata.ended_at) - } if (!'env' in log.metadata && 'args' in log.metadata) { log.metadata.env = log.metadata.args } diff --git a/src/js/yunohost/main.js b/src/js/yunohost/main.js index 4ea32c8c..8ca70af2 100644 --- a/src/js/yunohost/main.js +++ b/src/js/yunohost/main.js @@ -26,10 +26,6 @@ Handlebars.registerHelper('humanTime', function(time) { return Math.round(time) + 's'; }); - Handlebars.registerHelper('timestampToDate', function(timestamp) { - var date = new Date(timestamp * 1000); - return date.toLocaleString(); - }); Handlebars.registerHelper('bitRate', function(bytes, time) { var sizes = ['b', 'Kb', 'Mb', 'Gb', 'Tb']; if (time === 0) return 'n/a'; diff --git a/src/views/app/app_appslists_info.ms b/src/views/app/app_appslists_info.ms index b1d30a52..4fa09040 100644 --- a/src/views/app/app_appslists_info.ms +++ b/src/views/app/app_appslists_info.ms @@ -18,7 +18,7 @@
{{t 'url'}}
{{appslist.url}}
{{t 'appslists_last_update'}}
-
{{timestampToDate appslist.lastUpdate}}
+
{{formatTime appslist.lastUpdate day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}
diff --git a/src/views/service/service_info.ms b/src/views/service/service_info.ms index 7ce9fe2c..3b8c7e19 100644 --- a/src/views/service/service_info.ms +++ b/src/views/service/service_info.ms @@ -43,7 +43,12 @@
{{t 'started_at'}} - {{active_at.human}} + {{#active_at}} + {{formatTime . day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}} + {{/active_at}} + {{^active_at}} + {{t 'unknown'}} + {{/active_at}}
diff --git a/src/views/service/service_list.ms b/src/views/service/service_list.ms index 55848ba6..dbffb18e 100644 --- a/src/views/service/service_list.ms +++ b/src/views/service/service_list.ms @@ -17,7 +17,12 @@
{{t 'started_at'}} - {{active_at.human}} + {{#active_at}} + {{formatTime . day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}} + {{/active_at}} + {{^active_at}} + {{t 'unknown'}} + {{/active_at}}
{{/services}} From f0d95f41ab321ea8174072dde2134ad8d576d6d4 Mon Sep 17 00:00:00 2001 From: ljf Date: Sun, 9 Dec 2018 19:45:24 +0100 Subject: [PATCH 2/7] [fix] Uneeded locale --- src/js/yunohost/controllers/apps.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 1785207a..7bb8a7e9 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -60,8 +60,7 @@ c.view('app/app_appslists_list', { appslists: list, - has_community_list: has_community_list, - locale: y18n.locale + has_community_list: has_community_list }); }, 'GET'); }); @@ -90,8 +89,7 @@ 'removable' : (c.params['appslist'] !== 'yunohost') ? true : false // Do not remove default apps list }; c.view('app/app_appslists_info', { - appslist: list, - locale: y18n.locale + appslist: list }); } else { From b82bdeac48dc8071977797bbf3ed51f3efcd0aa2 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 9 Dec 2018 19:54:39 +0100 Subject: [PATCH 3/7] Explicit bananas --- src/js/yunohost/controllers/services.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/js/yunohost/controllers/services.js b/src/js/yunohost/controllers/services.js index 605b1ac0..11ccbca0 100644 --- a/src/js/yunohost/controllers/services.js +++ b/src/js/yunohost/controllers/services.js @@ -23,7 +23,9 @@ v.status = y18n.t(v.status); v.loaded = y18n.t(v.loaded); if (v.active_at == 'unknown') + { delete v.active_at; + } data2.services.push(v); }); @@ -55,7 +57,9 @@ data2.service.active = y18n.t(data.active); data2.service.loaded = y18n.t(data.loaded); if (data.active_at != 'unknown') + { data2.service.active_at = data.active_at; + } store.clear('slide'); c.view('service/service_info', data2); }, 'GET'); From 28a0eaeb044a9008445e266bedb416f73757d7d4 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 9 Dec 2018 19:56:13 +0100 Subject: [PATCH 4/7] Formatting + simplify diff --- src/js/yunohost/controllers/apps.js | 4 +--- src/js/yunohost/controllers/tools.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 7bb8a7e9..b1fe4cab 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -88,9 +88,7 @@ 'lastUpdate': data[c.params['appslist']]['lastUpdate'], 'removable' : (c.params['appslist'] !== 'yunohost') ? true : false // Do not remove default apps list }; - c.view('app/app_appslists_info', { - appslist: list - }); + c.view('app/app_appslists_info', {appslist: list}); } else { c.flash('warning', y18n.t('appslists_unknown_list', [c.params['appslist']])); diff --git a/src/js/yunohost/controllers/tools.js b/src/js/yunohost/controllers/tools.js index d01cb9f8..d24566db 100644 --- a/src/js/yunohost/controllers/tools.js +++ b/src/js/yunohost/controllers/tools.js @@ -121,7 +121,7 @@ c.view('tools/tools_logs', { "data": data, - "locale": y18n.locale + "locale": y18n.locale }); }); }); From a71b6d4a880965c74d33a7affeb1ebf473a4de3d Mon Sep 17 00:00:00 2001 From: ljf Date: Sun, 9 Dec 2018 20:43:48 +0100 Subject: [PATCH 5/7] [enh] Display correctly backup dates --- src/js/yunohost/controllers/backup.js | 2 ++ src/views/backup/backup_info.ms | 2 +- src/views/backup/backup_list.ms | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/yunohost/controllers/backup.js b/src/js/yunohost/controllers/backup.js index 82b1e613..2d19b91a 100644 --- a/src/js/yunohost/controllers/backup.js +++ b/src/js/yunohost/controllers/backup.js @@ -136,6 +136,7 @@ data.name = c.params['archive']; data.system_parts = c.groupHooks(Object.keys(data['system'])); data.items = (data['hooks']!={} || data['apps']!=[]); + data.locale = y18n.locale c.view('backup/backup_info', data); }); }); @@ -153,6 +154,7 @@ data.archives2.unshift(info) }); data.archives = data.archives2; + data.locale = y18n.locale c.view('backup/backup_list', data); }); }); diff --git a/src/views/backup/backup_info.ms b/src/views/backup/backup_info.ms index e8c2f9ac..a891612f 100644 --- a/src/views/backup/backup_info.ms +++ b/src/views/backup/backup_info.ms @@ -14,7 +14,7 @@
{{t 'id'}}
{{ name }}
-
{{t 'created_at'}}
{{ created_at }}
+
{{t 'created_at'}}
{{formatTime created_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}
{{t 'size'}}
{{ humanSize size}}
{{t 'path'}}
{{ path }}
diff --git a/src/views/backup/backup_list.ms b/src/views/backup/backup_list.ms index 67bf6b5d..38daf760 100644 --- a/src/views/backup/backup_list.ms +++ b/src/views/backup/backup_list.ms @@ -12,11 +12,12 @@
+{{#intl locales=locale}} +{{/intl}}