Closes #37: Search terms in URL

+ empty tag tree
+ transitionTo -> go
+ audit log message can be empty
This commit is contained in:
jendib 2015-09-22 01:34:01 +02:00
parent c7b7527183
commit 2c782a23d8
15 changed files with 41 additions and 25 deletions

View File

@ -19,6 +19,7 @@ import com.sismics.docs.core.util.jpa.PaginatedLists;
import com.sismics.docs.core.util.jpa.SortCriteria; import com.sismics.docs.core.util.jpa.SortCriteria;
import com.sismics.rest.exception.ForbiddenClientException; import com.sismics.rest.exception.ForbiddenClientException;
import com.sismics.rest.exception.ServerException; import com.sismics.rest.exception.ServerException;
import com.sismics.rest.util.JsonUtil;
/** /**
* Audit log REST resources. * Audit log REST resources.
@ -70,7 +71,7 @@ public class AuditLogResource extends BaseResource {
.add("target", auditLogDto.getEntityId()) .add("target", auditLogDto.getEntityId())
.add("class", auditLogDto.getEntityClass()) .add("class", auditLogDto.getEntityClass())
.add("type", auditLogDto.getType().name()) .add("type", auditLogDto.getType().name())
.add("message", auditLogDto.getMessage()) .add("message", JsonUtil.nullable(auditLogDto.getMessage()))
.add("create_date", auditLogDto.getCreateTimestamp())); .add("create_date", auditLogDto.getCreateTimestamp()));
} }

View File

@ -124,6 +124,9 @@ angular.module('docs',
controller: 'DocumentDefault' controller: 'DocumentDefault'
} }
} }
})
.state('document.default.search', {
url: '/search/:search'
}) })
.state('document.default.file', { .state('document.default.file', {
url: '/file/:fileId', url: '/file/:fileId',

View File

@ -12,7 +12,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state,
$scope.offset = 0; $scope.offset = 0;
$scope.currentPage = 1; $scope.currentPage = 1;
$scope.limit = _.isUndefined(localStorage.documentsPageSize) ? 10 : localStorage.documentsPageSize; $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 }; $scope.setSearch = function(search) { $scope.search = search };
// A timeout promise is used to slow down search requests to the server // 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); $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 // Call API later
timeoutPromise = $timeout(function () { timeoutPromise = $timeout(function () {
$scope.loadDocuments(); $scope.loadDocuments();
@ -100,7 +111,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state,
* Display a document. * Display a document.
*/ */
$scope.viewDocument = function(id) { $scope.viewDocument = function(id) {
$state.transitionTo('document.view', { id: id }); $state.go('document.view', { id: id });
}; };
// Load tags // Load tags

View File

@ -81,7 +81,7 @@ angular.module('docs').controller('DocumentDefault', function($scope, $state, Re
* Navigate to the selected file. * Navigate to the selected file.
*/ */
$scope.openFile = function (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. * Add a document with checked files.
*/ */
$scope.addDocument = function() { $scope.addDocument = function() {
$state.transitionTo('document.add', { files: _.pluck($scope.checkedFiles(), 'id') }); $state.go('document.add', { files: _.pluck($scope.checkedFiles(), 'id') });
}; };
}); });

View File

@ -95,7 +95,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $
if ($scope.isEdit()) { if ($scope.isEdit()) {
// Go back to the edited document // Go back to the edited document
$scope.pageDocuments(); $scope.pageDocuments();
$state.transitionTo('document.view', { id: $stateParams.id }); $state.go('document.view', { id: $stateParams.id });
} else { } else {
// Reset the scope and stay here // Reset the scope and stay here
var fileUploadCount = _.size($scope.newFiles) + resolve.length; var fileUploadCount = _.size($scope.newFiles) + resolve.length;
@ -188,9 +188,9 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $
*/ */
$scope.cancel = function() { $scope.cancel = function() {
if ($scope.isEdit()) { if ($scope.isEdit()) {
$state.transitionTo('document.view', { id: $stateParams.id }); $state.go('document.view', { id: $stateParams.id });
} else { } else {
$state.transitionTo('document.default'); $state.go('document.default');
} }
}; };

View File

@ -62,7 +62,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
* Navigate to the selected file. * Navigate to the selected file.
*/ */
$scope.openFile = function (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') { if (result == 'ok') {
Restangular.one('document', document.id).remove().then(function () { Restangular.one('document', document.id).remove().then(function () {
$scope.loadDocuments(); $scope.loadDocuments();
$state.transitionTo('document.default'); $state.go('document.default');
}); });
} }
}); });

View File

@ -9,7 +9,7 @@ angular.module('docs').controller('Login', function($scope, $rootScope, $state,
User.userInfo(true).then(function(data) { User.userInfo(true).then(function(data) {
$rootScope.userInfo = data; $rootScope.userInfo = data;
}); });
$state.transitionTo('document.default'); $state.go('document.default');
}, function() { }, function() {
var title = 'Login failed'; var title = 'Login failed';
var msg = 'Username or password invalid'; var msg = 'Username or password invalid';

View File

@ -6,9 +6,9 @@
angular.module('docs').controller('Main', function($scope, $rootScope, $state, User) { angular.module('docs').controller('Main', function($scope, $rootScope, $state, User) {
User.userInfo().then(function(data) { User.userInfo().then(function(data) {
if (data.anonymous) { if (data.anonymous) {
$state.transitionTo('login'); $state.go('login');
} else { } else {
$state.transitionTo('document.default'); $state.go('document.default');
} }
}); });
}); });

View File

@ -41,7 +41,7 @@ angular.module('docs').controller('Navigation', function($scope, $http, $state,
*/ */
$scope.openLogs = function() { $scope.openLogs = function() {
$scope.errorNumber = 0; $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) { User.userInfo(true).then(function(data) {
$rootScope.userInfo = data; $rootScope.userInfo = data;
}); });
$state.transitionTo('main'); $state.go('main');
}); });
$event.preventDefault(); $event.preventDefault();
}; };

View File

@ -19,6 +19,6 @@ angular.module('docs').controller('SettingsUser', function($scope, $state, Resta
* Edit a user. * Edit a user.
*/ */
$scope.editUser = function(user) { $scope.editUser = function(user) {
$state.transitionTo('settings.user.edit', { username: user.username }); $state.go('settings.user.edit', { username: user.username });
}; };
}); });

View File

@ -38,7 +38,7 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
promise.then(function() { promise.then(function() {
$scope.loadUsers(); $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') { if (result == 'ok') {
Restangular.one('user', $stateParams.username).remove().then(function() { Restangular.one('user', $stateParams.username).remove().then(function() {
$scope.loadUsers(); $scope.loadUsers();
$state.transitionTo('settings.user'); $state.go('settings.user');
}, function () { }, function () {
$state.transitionTo('settings.user'); $state.go('settings.user');
}); });
} }
}); });

View File

@ -24,7 +24,7 @@ angular.module('share').controller('FileModalView', function($rootScope, $modalI
if (value.id == $stateParams.fileId) { if (value.id == $stateParams.fileId) {
var next = $scope.files[key + 1]; var next = $scope.files[key + 1];
if (next) { 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) { if (value.id == $stateParams.fileId) {
var previous = $scope.files[key - 1]; var previous = $scope.files[key - 1];
if (previous) { 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 });
} }
} }
}); });

View File

@ -16,6 +16,6 @@ angular.module('share').controller('FileView', function($modal, $state, $statePa
modal.closed = true; modal.closed = true;
},function(result) { },function(result) {
modal.closed = true; modal.closed = true;
$state.transitionTo('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); $state.go('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId });
}); });
}); });

View File

@ -10,7 +10,7 @@ angular.module('share').controller('Share', function($scope, $state, $stateParam
$scope.document = data; $scope.document = data;
}, function (response) { }, function (response) {
if (response.status == 403) { 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. * Navigate to the selected file.
*/ */
$scope.openFile = function (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 })
}; };
}); });

View File

@ -11,6 +11,7 @@
Tags <span class="caret"></span> Tags <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu tag-tree"> <ul class="dropdown-menu tag-tree">
<li ng-if="getChildrenTags().length == 0">No tags</li>
<li ng-repeat="tag in getChildrenTags()" ng-include="'tag-tree-item'"></li> <li ng-repeat="tag in getChildrenTags()" ng-include="'tag-tree-item'"></li>
</ul> </ul>
</div> </div>
@ -48,7 +49,7 @@
<td> <td>
{{ document.title }} ({{ document.file_count }}) {{ document.title }} ({{ document.file_count }})
<span class="glyphicon glyphicon-share" ng-if="document.shared" tooltip="Shared"></span> <span class="glyphicon glyphicon-share" ng-if="document.shared" tooltip="Shared"></span>
<a href="#/document/view/{{ document.id }}" ng-click="$event.stopPropagation()"><span class="glyphicon glyphicon-link"></span></a> <a href="#/document/view/{{ document.id }}" target="_blank" ng-click="$event.stopPropagation()"><span class="glyphicon glyphicon-link"></span></a>
</td> </td>
<td>{{ document.create_date | date: 'yyyy-MM-dd' }}</td> <td>{{ document.create_date | date: 'yyyy-MM-dd' }}</td>
<td class="hidden-xs cell-tags"> <td class="hidden-xs cell-tags">