From f5871e89e2b2bebe1b54f56a64009102d53fc6aa Mon Sep 17 00:00:00 2001 From: jendib Date: Sat, 3 Aug 2013 21:51:15 +0200 Subject: [PATCH] Display server logs --- docs-parent/TODO | 1 - .../docs/rest/resource/FileResource.java | 8 ++++++++ docs-web/src/main/webapp/index.html | 1 + docs-web/src/main/webapp/js/app.js | 9 +++++++++ .../main/webapp/js/controller/SettingsLog.js | 12 ++++++++++++ docs-web/src/main/webapp/partial/settings.html | 3 +++ .../src/main/webapp/partial/settings.log.html | 18 ++++++++++++++++++ docs-web/src/main/webapp/style/main.less | 9 +++++++++ 8 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 docs-web/src/main/webapp/js/controller/SettingsLog.js create mode 100644 docs-web/src/main/webapp/partial/settings.log.html diff --git a/docs-parent/TODO b/docs-parent/TODO index a202029a..6f626eec 100644 --- a/docs-parent/TODO +++ b/docs-parent/TODO @@ -1,3 +1,2 @@ -- Display logs (client) - Tag stats (client/server) - Users administration (client) \ No newline at end of file diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java index 5c3d7401..f6f1aeca 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java @@ -175,6 +175,14 @@ public class FileResource extends BaseResource { ValidationUtil.validateRequired(documentId, "id"); ValidationUtil.validateRequired(idList, "order"); + // Get the document + DocumentDao documentDao = new DocumentDao(); + try { + documentDao.getDocument(documentId, principal.getId()); + } catch (NoResultException e) { + throw new ClientException("DocumentNotFound", MessageFormat.format("Document not found: {0}", documentId)); + } + // Reorder files FileDao fileDao = new FileDao(); for (File file : fileDao.getByDocumentId(documentId)) { diff --git a/docs-web/src/main/webapp/index.html b/docs-web/src/main/webapp/index.html index bb5b69b8..52f78eb6 100644 --- a/docs-web/src/main/webapp/index.html +++ b/docs-web/src/main/webapp/index.html @@ -41,6 +41,7 @@ + diff --git a/docs-web/src/main/webapp/js/app.js b/docs-web/src/main/webapp/js/app.js index 45ffeb67..4c322ef8 100644 --- a/docs-web/src/main/webapp/js/app.js +++ b/docs-web/src/main/webapp/js/app.js @@ -66,6 +66,15 @@ var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.ke } } }) + .state('settings.log', { + url: '/log', + views: { + 'settings': { + templateUrl: 'partial/settings.log.html', + controller: 'SettingsLog' + } + } + }) .state('document', { url: '/document', abstract: true, diff --git a/docs-web/src/main/webapp/js/controller/SettingsLog.js b/docs-web/src/main/webapp/js/controller/SettingsLog.js new file mode 100644 index 00000000..0745675c --- /dev/null +++ b/docs-web/src/main/webapp/js/controller/SettingsLog.js @@ -0,0 +1,12 @@ +'use strict'; + +/** + * Settings logs controller. + */ +App.controller('SettingsLog', function($scope, Restangular) { + Restangular.one('app/log').get({ + limit: 100 + }).then(function(data) { + $scope.logs = data.logs; + }); +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/partial/settings.html b/docs-web/src/main/webapp/partial/settings.html index e4d12fc1..19424a39 100644 --- a/docs-web/src/main/webapp/partial/settings.html +++ b/docs-web/src/main/webapp/partial/settings.html @@ -5,6 +5,9 @@
  • User account
  • Opened sessions
  • + + +
  • Server logs
  • diff --git a/docs-web/src/main/webapp/partial/settings.log.html b/docs-web/src/main/webapp/partial/settings.log.html new file mode 100644 index 00000000..bd9046f2 --- /dev/null +++ b/docs-web/src/main/webapp/partial/settings.log.html @@ -0,0 +1,18 @@ +

    Server logs

    + + + + + + + + + + + + + + + +
    DateTagMessage
    {{ log.date | date: 'yyyy-MM-dd HH:mm' }}{{ log.tag }}{{ log.message }}
    diff --git a/docs-web/src/main/webapp/style/main.less b/docs-web/src/main/webapp/style/main.less index fa6ae9b2..7709a7ce 100644 --- a/docs-web/src/main/webapp/style/main.less +++ b/docs-web/src/main/webapp/style/main.less @@ -10,6 +10,15 @@ } } +// Logs list +.table-logs { + tbody tr td { + &:first-child { + white-space: nowrap; + } + } +} + // File thumbnails .thumbnail-file { cursor: pointer;