diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/AuditLogResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/AuditLogResource.java index 8c128e06..a1ad4e72 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/AuditLogResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/AuditLogResource.java @@ -19,6 +19,7 @@ import com.sismics.docs.core.util.jpa.PaginatedLists; import com.sismics.docs.core.util.jpa.SortCriteria; import com.sismics.rest.exception.ForbiddenClientException; import com.sismics.rest.exception.ServerException; +import com.sismics.rest.util.JsonUtil; /** * Audit log REST resources. @@ -70,7 +71,7 @@ public class AuditLogResource extends BaseResource { .add("target", auditLogDto.getEntityId()) .add("class", auditLogDto.getEntityClass()) .add("type", auditLogDto.getType().name()) - .add("message", auditLogDto.getMessage()) + .add("message", JsonUtil.nullable(auditLogDto.getMessage())) .add("create_date", auditLogDto.getCreateTimestamp())); } diff --git a/docs-web/src/main/webapp/src/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js index 4a88388a..ab3a7c9a 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -125,6 +125,9 @@ angular.module('docs', } } }) + .state('document.default.search', { + url: '/search/:search' + }) .state('document.default.file', { url: '/file/:fileId', views: { diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/Document.js index 551c1dcc..4497d41a 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Document.js @@ -12,7 +12,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, $scope.offset = 0; $scope.currentPage = 1; $scope.limit = _.isUndefined(localStorage.documentsPageSize) ? 10 : localStorage.documentsPageSize; - $scope.search = ''; + $scope.search = $state.params.search ? $state.params.search : ''; $scope.setSearch = function(search) { $scope.search = search }; // A timeout promise is used to slow down search requests to the server @@ -66,6 +66,17 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, $timeout.cancel(timeoutPromise); } + if ($state.current.name == 'document.default' + || $state.current.name == 'document.default.search') { + $state.go($scope.search == '' ? + 'document.default' : 'document.default.search', { + search: $scope.search + }, { + location: 'replace', + notify: false + }); + } + // Call API later timeoutPromise = $timeout(function () { $scope.loadDocuments(); @@ -100,7 +111,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, * Display a document. */ $scope.viewDocument = function(id) { - $state.transitionTo('document.view', { id: id }); + $state.go('document.view', { id: id }); }; // Load tags diff --git a/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js index e5433e09..361ef241 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js @@ -81,7 +81,7 @@ angular.module('docs').controller('DocumentDefault', function($scope, $state, Re * Navigate to the selected file. */ $scope.openFile = function (file) { - $state.transitionTo('document.default.file', { fileId: file.id }) + $state.go('document.default.file', { fileId: file.id }) }; /** @@ -107,6 +107,6 @@ angular.module('docs').controller('DocumentDefault', function($scope, $state, Re * Add a document with checked files. */ $scope.addDocument = function() { - $state.transitionTo('document.add', { files: _.pluck($scope.checkedFiles(), 'id') }); + $state.go('document.add', { files: _.pluck($scope.checkedFiles(), 'id') }); }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js index c0d7d4b3..c9141ec7 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js @@ -95,7 +95,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ if ($scope.isEdit()) { // Go back to the edited document $scope.pageDocuments(); - $state.transitionTo('document.view', { id: $stateParams.id }); + $state.go('document.view', { id: $stateParams.id }); } else { // Reset the scope and stay here var fileUploadCount = _.size($scope.newFiles) + resolve.length; @@ -188,9 +188,9 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ */ $scope.cancel = function() { if ($scope.isEdit()) { - $state.transitionTo('document.view', { id: $stateParams.id }); + $state.go('document.view', { id: $stateParams.id }); } else { - $state.transitionTo('document.default'); + $state.go('document.default'); } }; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js index 8962c884..dbe473d5 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js @@ -62,7 +62,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta * Navigate to the selected file. */ $scope.openFile = function (file) { - $state.transitionTo('document.view.file', { id: $stateParams.id, fileId: file.id }) + $state.go('document.view.file', { id: $stateParams.id, fileId: file.id }) }; /** @@ -80,7 +80,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta if (result == 'ok') { Restangular.one('document', document.id).remove().then(function () { $scope.loadDocuments(); - $state.transitionTo('document.default'); + $state.go('document.default'); }); } }); diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Login.js b/docs-web/src/main/webapp/src/app/docs/controller/Login.js index 14340858..9c695aa3 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Login.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Login.js @@ -9,7 +9,7 @@ angular.module('docs').controller('Login', function($scope, $rootScope, $state, User.userInfo(true).then(function(data) { $rootScope.userInfo = data; }); - $state.transitionTo('document.default'); + $state.go('document.default'); }, function() { var title = 'Login failed'; var msg = 'Username or password invalid'; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Main.js b/docs-web/src/main/webapp/src/app/docs/controller/Main.js index bb56d24e..18e04ce7 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Main.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Main.js @@ -6,9 +6,9 @@ angular.module('docs').controller('Main', function($scope, $rootScope, $state, User) { User.userInfo().then(function(data) { if (data.anonymous) { - $state.transitionTo('login'); + $state.go('login'); } else { - $state.transitionTo('document.default'); + $state.go('document.default'); } }); }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js b/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js index 64417aa9..d21bbb09 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js @@ -41,7 +41,7 @@ angular.module('docs').controller('Navigation', function($scope, $http, $state, */ $scope.openLogs = function() { $scope.errorNumber = 0; - $state.transitionTo('settings.log'); + $state.go('settings.log'); }; /** @@ -52,7 +52,7 @@ angular.module('docs').controller('Navigation', function($scope, $http, $state, User.userInfo(true).then(function(data) { $rootScope.userInfo = data; }); - $state.transitionTo('main'); + $state.go('main'); }); $event.preventDefault(); }; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js index f65160aa..8a499264 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js @@ -19,6 +19,6 @@ angular.module('docs').controller('SettingsUser', function($scope, $state, Resta * Edit a user. */ $scope.editUser = function(user) { - $state.transitionTo('settings.user.edit', { username: user.username }); + $state.go('settings.user.edit', { username: user.username }); }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js index ecd4d027..91537989 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js @@ -38,7 +38,7 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog, promise.then(function() { $scope.loadUsers(); - $state.transitionTo('settings.user'); + $state.go('settings.user'); }); }; @@ -54,9 +54,9 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog, if (result == 'ok') { Restangular.one('user', $stateParams.username).remove().then(function() { $scope.loadUsers(); - $state.transitionTo('settings.user'); + $state.go('settings.user'); }, function () { - $state.transitionTo('settings.user'); + $state.go('settings.user'); }); } }); diff --git a/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js b/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js index 8426022d..f705378c 100644 --- a/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js +++ b/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js @@ -24,7 +24,7 @@ angular.module('share').controller('FileModalView', function($rootScope, $modalI if (value.id == $stateParams.fileId) { var next = $scope.files[key + 1]; if (next) { - $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: next.id }); + $state.go('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: next.id }); } } }); @@ -38,7 +38,7 @@ angular.module('share').controller('FileModalView', function($rootScope, $modalI if (value.id == $stateParams.fileId) { var previous = $scope.files[key - 1]; if (previous) { - $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: previous.id }); + $state.go('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: previous.id }); } } }); diff --git a/docs-web/src/main/webapp/src/app/share/controller/FileView.js b/docs-web/src/main/webapp/src/app/share/controller/FileView.js index 3ea83514..07e45b23 100644 --- a/docs-web/src/main/webapp/src/app/share/controller/FileView.js +++ b/docs-web/src/main/webapp/src/app/share/controller/FileView.js @@ -16,6 +16,6 @@ angular.module('share').controller('FileView', function($modal, $state, $statePa modal.closed = true; },function(result) { modal.closed = true; - $state.transitionTo('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); + $state.go('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); }); }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/share/controller/Share.js b/docs-web/src/main/webapp/src/app/share/controller/Share.js index f3ddda15..c1e15ae6 100644 --- a/docs-web/src/main/webapp/src/app/share/controller/Share.js +++ b/docs-web/src/main/webapp/src/app/share/controller/Share.js @@ -10,7 +10,7 @@ angular.module('share').controller('Share', function($scope, $state, $stateParam $scope.document = data; }, function (response) { if (response.status == 403) { - $state.transitionTo('403'); + $state.go('403'); } }); @@ -24,6 +24,6 @@ angular.module('share').controller('Share', function($scope, $state, $stateParam * Navigate to the selected file. */ $scope.openFile = function (file) { - $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: file.id }) + $state.go('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: file.id }) }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/partial/docs/document.html b/docs-web/src/main/webapp/src/partial/docs/document.html index ab403e40..207e4374 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.html @@ -11,6 +11,7 @@ Tags @@ -48,7 +49,7 @@ {{ document.title }} ({{ document.file_count }}) - + {{ document.create_date | date: 'yyyy-MM-dd' }}