diff --git a/src/bower.json b/src/bower.json index 970655e5..f27d25da 100644 --- a/src/bower.json +++ b/src/bower.json @@ -7,6 +7,7 @@ "bootstrap": "3.3.6", "font-awesome": "4.5.0", "handlebars": "1.3.0", + "handlebars-helper-intl": "1.1.2", "sammy": "0.7.6", "js-cookie": "2.1.0", "source-sans-pro": "git://github.com/adobe-fonts/source-sans-pro.git#2.020R-ro/1.075R-it", diff --git a/src/gulpfile.js b/src/gulpfile.js index 608a8748..c754f518 100644 --- a/src/gulpfile.js +++ b/src/gulpfile.js @@ -41,6 +41,7 @@ gulp.task('js', function() { 'bower_components/jquery/dist/jquery.js', 'bower_components/js-cookie/src/js.cookie.js', 'bower_components/handlebars/handlebars.js', + 'bower_components/handlebars-helper-intl/dist/handlebars-intl-with-locales.js', 'bower_components/sammy/lib/sammy.js', 'bower_components/sammy/lib/plugins/sammy.handlebars.js', 'bower_components/sammy/lib/plugins/sammy.json.js', diff --git a/src/js/yunohost/controllers/tools.js b/src/js/yunohost/controllers/tools.js index d2ae7a4f..cc2c6a1c 100644 --- a/src/js/yunohost/controllers/tools.js +++ b/src/js/yunohost/controllers/tools.js @@ -96,12 +96,11 @@ }); // Display journals list - app.get('#/tools/journals', function (c) { - c.api("/journals", function(categories) { - c.view('tools/tools_journals', { + app.get('#/tools/logs', function (c) { + c.api("/logs", function(categories) { + c.view('tools/tools_logs', { "data": categories, formatDate: function() { - console.log("caca"); return this.started_at.getDate(); } }); @@ -109,10 +108,26 @@ }); // One journal - app.get('#/tools/journals/:file_name', function (c) { - c.api("/journals/" + c.params["file_name"], function(journal) { - c.view('tools/tools_journal', { - "journal": journal, + app.get(/\#\/tools\/logs\/(.*)(\?number=(\d+))?/, function (c) { + var params = "?path=" + c.params["splat"][0]; + var number = (c.params["number"])?c.params["number"]:50; + params += "&number=" + number; + + 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 + } + } + c.view('tools/tools_log', { + "log": log, + "next_number": log.logs.length == number ? number * 10:false }); }); }); diff --git a/src/js/yunohost/helpers.js b/src/js/yunohost/helpers.js index 4b10707f..70e7a7f0 100644 --- a/src/js/yunohost/helpers.js +++ b/src/js/yunohost/helpers.js @@ -383,7 +383,7 @@ // Paste
prePaste: function() { - var pasteButtons = $('button[data-paste-content]'); + var pasteButtons = $('button[data-paste-content],a[data-paste-content]'); pasteButtons.on('click', function(){ // Get paste content element var preElement = $($(this).data('paste-content')); diff --git a/src/js/yunohost/main.js b/src/js/yunohost/main.js index 4c741efd..bcf70f48 100644 --- a/src/js/yunohost/main.js +++ b/src/js/yunohost/main.js @@ -10,6 +10,7 @@ // Plugins sam.use('Handlebars', 'ms'); + window.HandlebarsIntl.registerWith(Handlebars); Handlebars.registerHelper('ucwords', function(str) { return (str + '').replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, function ($1) { @@ -122,4 +123,4 @@ app.run('#/'); }); -})(); \ No newline at end of file +})(); diff --git a/src/views/tools/tools_journal.ms b/src/views/tools/tools_journal.ms deleted file mode 100644 index 392ebcb5..00000000 --- a/src/views/tools/tools_journal.ms +++ /dev/null @@ -1,46 +0,0 @@ -{{#journal}} -- - - --- ---{{ name }}
----
-- {{t 'started_at'}}
- {{ started_at }}
-- {{t 'path'}}
- {{ path }}
- {{#each metadata}} -- {{@key}}
-- {{.}}
- {{/each}} ---{{/journal}} diff --git a/src/views/tools/tools_list.ms b/src/views/tools/tools_list.ms index 6c8608e4..d744f68d 100644 --- a/src/views/tools/tools_list.ms +++ b/src/views/tools/tools_list.ms @@ -11,9 +11,9 @@--{{t 'logs'}}
----
-- -- -{{#logs}}{{datetime}} -{{/logs}}-- -{{#logs}}{{{line}}} -{{/logs}}-{{t 'diagnosis'}}
- + -{{t 'journals'}}
+{{t 'logs'}}
diff --git a/src/views/tools/tools_log.ms b/src/views/tools/tools_log.ms new file mode 100644 index 00000000..2fd0bd7a --- /dev/null +++ b/src/views/tools/tools_log.ms @@ -0,0 +1,71 @@ + + + + + + +{{#if log.metadata}} +++{{#if log.metadata.env}} +++{{ log.description }}
++++
+- {{t 'path'}}
- {{ log.log_path }}
+ {{#if log.metadata.started_at}} +- {{t 'started_at'}}
+- {{formatTime log.metadata.started_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}
+ {{/if}} + {{#if log.metadata.ended_at}} +- {{t 'ended_at'}}
+- {{formatTime log.metadata.ended_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}
+ {{/if}} +++{{/if}} + +{{/if}} ++++ + {{t 'Context'}} + +
++++++ {{#each log.metadata.env}} +
+- {{@key}}
+- {{.}}
+ {{/each}} ++diff --git a/src/views/tools/tools_journals.ms b/src/views/tools/tools_logs.ms similarity index 50% rename from src/views/tools/tools_journals.ms rename to src/views/tools/tools_logs.ms index 905f97d0..12e4e43e 100644 --- a/src/views/tools/tools_journals.ms +++ b/src/views/tools/tools_logs.ms @@ -1,30 +1,28 @@ {{#if data}} {{#data}} -{{#categories}}++{{#if log.metadata}}{{t 'logs'}}{{else}}{{log.log_path}}{{/if}}
++ {{#if log.metadata.error}} ++{{t 'Error'}}: {{log.metadata.error}}+ {{/if}} + +{{#if next_number}}MORE{{/if}} +{{#log.logs}}{{.}} +{{/log.logs}}+-+ --{{/categories}} {{/data}} {{/if}} diff --git a/src/views/tools/tools_rebooting.ms b/src/views/tools/tools_rebooting.ms new file mode 100644 index 00000000..1d4d95cc --- /dev/null +++ b/src/views/tools/tools_rebooting.ms @@ -0,0 +1 @@ +-{{#journals}} - {{ started_at }} {{ name }} - {{/journals}}++{{#operations}} + {{ started_at }} {{ name }} + {{/operations}}{{t 'tools_rebooting'}}diff --git a/src/views/tools/tools_shuttingdown.ms b/src/views/tools/tools_shuttingdown.ms new file mode 100644 index 00000000..e7294efd --- /dev/null +++ b/src/views/tools/tools_shuttingdown.ms @@ -0,0 +1 @@ +{{t 'tools_shuttingdown'}}