diff --git a/docs-web/src/main/webapp/package.json b/docs-web/src/main/webapp/package.json index d3daccdf..da4c9ba5 100644 --- a/docs-web/src/main/webapp/package.json +++ b/docs-web/src/main/webapp/package.json @@ -43,13 +43,11 @@ "grunt-contrib-clean": "^1.0.0", "grunt-contrib-concat": "^1.0.1", "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-less": "^1.3.0", + "grunt-contrib-less": "^1.4.1", "grunt-contrib-uglify": "^1.0.1", "grunt-css": "^0.5.4", "grunt-htmlrefs": "^0.5.0", "grunt-ng-annotate": "^2.0.2", - "grunt-text-replace": "^0.4.0", - "protractor": "^3.3.0", - "selenium": "^2.20.0" + "grunt-text-replace": "^0.4.0" } } 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 c8407ab5..0f72ac61 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -5,14 +5,16 @@ */ angular.module('docs', // Dependencies - ['ui.router', 'ui.route', 'ui.bootstrap', 'ui.keypress', 'ui.validate', 'dialog', 'ngProgress', 'monospaced.qrcode', 'yaru22.angular-timeago', - 'ui.sortable', 'restangular', 'ngSanitize', 'ngTouch', 'colorpicker.module', 'angularFileUpload', 'pascalprecht.translate'] + ['ui.router', 'ui.bootstrap', 'dialog', 'ngProgress', 'monospaced.qrcode', 'yaru22.angular-timeago', 'ui.validate', + 'ui.sortable', 'restangular', 'ngSanitize', 'ngTouch', 'colorpicker.module', 'ngFileUpload', 'pascalprecht.translate'] ) /** * Configuring modules. */ -.config(function($stateProvider, $httpProvider, RestangularProvider, $translateProvider, timeAgoSettings) { +.config(function($locationProvider, $urlRouterProvider, $stateProvider, $httpProvider, RestangularProvider, $translateProvider, timeAgoSettings) { + $locationProvider.hashPrefix(''); + // Configuring UI Router $stateProvider .state('main', { @@ -417,20 +419,6 @@ angular.module('docs', $rootScope.appName = data.name; }); }) -/** - * Redirection support for ui-router. - * Thanks to https://github.com/acollard - * See https://github.com/angular-ui/ui-router/issues/1584#issuecomment-76993045 - */ -.run(function($rootScope, $state){ - $rootScope.$on('$stateChangeStart', function(event, toState, toParams) { - var redirect = toState.redirectTo; - if (redirect) { - event.preventDefault(); - $state.go(redirect, toParams); - } - }); -}) /** * Initialize ngProgress. */ diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js index 4497d41a..3e40cad2 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js @@ -3,7 +3,7 @@ /** * Document controller. */ -angular.module('docs').controller('Document', function($scope, $timeout, $state, Restangular) { +angular.module('docs').controller('Document', function ($scope, $rootScope, $timeout, $state, Restangular) { /** * Documents table sort status. */ @@ -13,7 +13,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, $scope.currentPage = 1; $scope.limit = _.isUndefined(localStorage.documentsPageSize) ? 10 : localStorage.documentsPageSize; $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 // We keep track of it for cancellation purpose @@ -22,9 +22,9 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, /** * Load new documents page. */ - $scope.pageDocuments = function() { - Restangular.one('document') - .getList('list', { + $scope.pageDocuments = function () { + Restangular.one('document/list') + .get({ offset: $scope.offset, limit: $scope.limit, sort_column: $scope.sortColumn, @@ -40,7 +40,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, /** * Reload documents. */ - $scope.loadDocuments = function() { + $scope.loadDocuments = function () { $scope.offset = 0; $scope.currentPage = 1; $scope.pageDocuments(); @@ -49,8 +49,8 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, /** * Watch for current page change. */ - $scope.$watch('currentPage', function(prev, next) { - if (prev == next) { + $scope.$watch('currentPage', function (prev, next) { + if (prev === next) { return; } $scope.offset = ($scope.currentPage - 1) * $scope.limit; @@ -60,15 +60,15 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, /** * Watch for search scope change. */ - $scope.$watch('search', function() { + $scope.$watch('search', function () { if (timeoutPromise) { // Cancel previous timeout $timeout.cancel(timeoutPromise); } - if ($state.current.name == 'document.default' - || $state.current.name == 'document.default.search') { - $state.go($scope.search == '' ? + if ($state.current.name === 'document.default' + || $state.current.name === 'document.default.search') { + $state.go($scope.search === '' ? 'document.default' : 'document.default.search', { search: $scope.search }, { @@ -86,8 +86,8 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, /** * Sort documents. */ - $scope.sortDocuments = function(sortColumn) { - if (sortColumn == $scope.sortColumn) { + $scope.sortDocuments = function (sortColumn) { + if (sortColumn === $scope.sortColumn) { $scope.asc = !$scope.asc; } else { $scope.asc = true; @@ -99,9 +99,9 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, /** * Watch for page size change. */ - $scope.$watch('limit', function(next, prev) { + $scope.$watch('limit', function (next, prev) { localStorage.documentsPageSize = next; - if (next == prev) { + if (next === prev) { return; } $scope.loadDocuments(); @@ -110,13 +110,13 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, /** * Display a document. */ - $scope.viewDocument = function(id) { + $scope.viewDocument = function (id) { $state.go('document.view', { id: id }); }; // Load tags var tags = []; - Restangular.one('tag/list').getList().then(function(data) { + Restangular.one('tag/list').get().then(function (data) { tags = data.tags; }); @@ -126,7 +126,16 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, */ $scope.getChildrenTags = function(parent) { return _.filter(tags, function(tag) { - return tag.parent == parent; + return tag.parent === parent; }); }; + + // Hack to reload the pagination directive after language change + $scope.paginationShown = true; + $rootScope.$on('$translateChangeSuccess', function () { + $scope.paginationShown = false; + $timeout(function () { + $scope.paginationShown = true; + }); + }) }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentDefault.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentDefault.js index ea370ac1..fd0e998b 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentDefault.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentDefault.js @@ -3,7 +3,7 @@ /** * Document default controller. */ -angular.module('docs').controller('DocumentDefault', function($scope, $rootScope, $state, Restangular, $upload, $translate) { +angular.module('docs').controller('DocumentDefault', function($scope, $rootScope, $state, Restangular, Upload, $translate) { // Load user audit log Restangular.one('auditlog').get().then(function(data) { $scope.logs = data.logs; @@ -13,7 +13,7 @@ angular.module('docs').controller('DocumentDefault', function($scope, $rootScope * Load unlinked files. */ $scope.loadFiles = function() { - Restangular.one('file').getList('list').then(function (data) { + Restangular.one('file/list').get().then(function (data) { $scope.files = data.files; // TODO Keep currently uploading files }); @@ -59,7 +59,7 @@ angular.module('docs').controller('DocumentDefault', function($scope, $rootScope $scope.uploadFile = function(file, newfile) { // Upload the file newfile.status = $translate.instant('document.default.upload_progress'); - return $upload.upload({ + return Upload.upload({ method: 'PUT', url: '../api/file', file: file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js index 65e19ea5..ce642fe9 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js @@ -11,7 +11,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ $scope.vocabularies = []; // Orphan files to add - $scope.orphanFiles = $stateParams.files ? $stateParams.files.split(',') : []; + $scope.orphanFiles = $stateParams.files ? $stateParams.files : []; /** * Close an alert. @@ -25,8 +25,8 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ */ $scope.getTitleTypeahead = function($viewValue) { var deferred = $q.defer(); - Restangular.one('document') - .getList('list', { + Restangular.one('document/list') + .get({ limit: 5, sort_column: 1, asc: true, diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalPdf.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalPdf.js index ed8ab96c..c1dac720 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalPdf.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalPdf.js @@ -3,7 +3,7 @@ /** * Document modal PDF controller. */ -angular.module('docs').controller('DocumentModalPdf', function ($scope, $window, $stateParams, $modalInstance) { +angular.module('docs').controller('DocumentModalPdf', function ($scope, $window, $stateParams, $uibModalInstance) { $scope.export = { metadata: false, comments: false, @@ -19,11 +19,11 @@ angular.module('docs').controller('DocumentModalPdf', function ($scope, $window, + '&fitimagetopage=' + $scope.export.fitimagetopage + '&margin=' + $scope.export.margin); - $modalInstance.close(); + $uibModalInstance.close(); }; // Close the modal $scope.close = function () { - $modalInstance.close(); + $uibModalInstance.close(); } }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalShare.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalShare.js index 2695591d..aa0f5f76 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalShare.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalShare.js @@ -3,9 +3,9 @@ /** * Document modal share controller. */ -angular.module('docs').controller('DocumentModalShare', function ($scope, $modalInstance) { +angular.module('docs').controller('DocumentModalShare', function ($scope, $uibModalInstance) { $scope.name = ''; $scope.close = function(name) { - $modalInstance.close(name); + $uibModalInstance.close(name); } }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentView.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentView.js index 67a22779..73368b92 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentView.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentView.js @@ -3,7 +3,7 @@ /** * Document view controller. */ -angular.module('docs').controller('DocumentView', function ($scope, $state, $stateParams, $location, $dialog, $modal, Restangular, $translate) { +angular.module('docs').controller('DocumentView', function ($scope, $state, $stateParams, $location, $dialog, $uibModal, Restangular, $translate) { // Load document data from server Restangular.one('document', $stateParams.id).get().then(function(data) { $scope.document = data; @@ -81,7 +81,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta * Open the share dialog. */ $scope.share = function () { - $modal.open({ + $uibModal.open({ templateUrl: 'partial/docs/document.share.html', controller: 'DocumentModalShare' }).result.then(function (name) { @@ -131,7 +131,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta * Export the current document to PDF. */ $scope.exportPdf = function() { - $modal.open({ + $uibModal.open({ templateUrl: 'partial/docs/document.pdf.html', controller: 'DocumentModalPdf' }); diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewContent.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewContent.js index d6e456d9..2d33e949 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewContent.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewContent.js @@ -3,7 +3,7 @@ /** * Document view content controller. */ -angular.module('docs').controller('DocumentViewContent', function ($scope, $rootScope, $stateParams, Restangular, $dialog, $state, $upload, $translate) { +angular.module('docs').controller('DocumentViewContent', function ($scope, $rootScope, $stateParams, Restangular, $dialog, $state, Upload, $translate) { /** * Configuration for file sorting. */ @@ -27,7 +27,7 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root * Load files from server. */ $scope.loadFiles = function () { - Restangular.one('file').getList('list', { id: $stateParams.id }).then(function (data) { + Restangular.one('file/list').get({ id: $stateParams.id }).then(function (data) { $scope.files = data.files; // TODO Keep currently uploading files }); @@ -53,7 +53,7 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root ]; $dialog.messageBox(title, msg, btns, function (result) { - if (result == 'ok') { + if (result === 'ok') { Restangular.one('file', file.id).remove().then(function () { // File deleted, decrease used quota $rootScope.userInfo.storage_current -= file.size; @@ -105,7 +105,7 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root $scope.uploadFile = function(file, newfile) { // Upload the file newfile.status = $translate.instant('document.view.content.upload_progress'); - return $upload.upload({ + return Upload.upload({ method: 'PUT', url: '../api/file', file: file, @@ -126,7 +126,7 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root }) .error(function (data) { newfile.status = $translate.instant('document.view.content.upload_error'); - if (data.type == 'QuotaReached') { + if (data.type === 'QuotaReached') { newfile.status += ' - ' + $translate.instant('document.view.content.upload_error_quota'); } }); diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/FileModalView.js b/docs-web/src/main/webapp/src/app/docs/controller/document/FileModalView.js index fd5f1b55..ae4baf6a 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/FileModalView.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/FileModalView.js @@ -3,14 +3,14 @@ /** * File modal view controller. */ -angular.module('docs').controller('FileModalView', function($rootScope, $modalInstance, $scope, $state, $stateParams, Restangular) { +angular.module('docs').controller('FileModalView', function($uibModalInstance, $scope, $state, $stateParams, Restangular, $transitions) { // Load files - Restangular.one('file').getList('list', { id: $stateParams.id }).then(function(data) { + Restangular.one('file/list').get({ id: $stateParams.id }).then(function(data) { $scope.files = data.files; // Search current file _.each($scope.files, function(value) { - if (value.id == $stateParams.fileId) { + if (value.id === $stateParams.fileId) { $scope.file = value; } }); @@ -21,7 +21,7 @@ angular.module('docs').controller('FileModalView', function($rootScope, $modalIn */ $scope.nextFile = function() { _.each($scope.files, function(value, key) { - if (value.id == $stateParams.fileId) { + if (value.id === $stateParams.fileId) { var next = $scope.files[key + 1]; if (next) { $state.go('^.file', { id: $stateParams.id, fileId: next.id }); @@ -35,7 +35,7 @@ angular.module('docs').controller('FileModalView', function($rootScope, $modalIn */ $scope.previousFile = function() { _.each($scope.files, function(value, key) { - if (value.id == $stateParams.fileId) { + if (value.id === $stateParams.fileId) { var previous = $scope.files[key - 1]; if (previous) { $state.go('^.file', { id: $stateParams.id, fileId: previous.id }); @@ -66,16 +66,16 @@ angular.module('docs').controller('FileModalView', function($rootScope, $modalIn * Close the file preview. */ $scope.closeFile = function () { - $modalInstance.dismiss(); + $uibModalInstance.dismiss(); }; // Close the modal when the user exits this state - var off = $rootScope.$on('$stateChangeStart', function(event, toState) { - if (!$modalInstance.closed) { - if (toState.name == $state.current.name) { - $modalInstance.close(); + var off = $transitions.onStart({}, function(transition) { + if (!$uibModalInstance.closed) { + if (transition.to().name === $state.current.name) { + $uibModalInstance.close(); } else { - $modalInstance.dismiss(); + $uibModalInstance.dismiss(); } } off(); diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/FileView.js b/docs-web/src/main/webapp/src/app/docs/controller/document/FileView.js index 02c887d2..45b86c10 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/FileView.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/FileView.js @@ -3,8 +3,8 @@ /** * File view controller. */ -angular.module('docs').controller('FileView', function($modal, $state, $stateParams) { - var modal = $modal.open({ +angular.module('docs').controller('FileView', function($uibModal, $state, $stateParams) { + var modal = $uibModal.open({ windowClass: 'modal modal-fileview', templateUrl: 'partial/docs/file.view.html', controller: 'FileModalView' diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsConfig.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsConfig.js index 5e0532d5..7efaac1d 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsConfig.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsConfig.js @@ -26,7 +26,7 @@ angular.module('docs').controller('SettingsConfig', function($scope, $rootScope, // Update the theme $scope.update = function() { - $scope.theme.name = $scope.theme.name.length == 0 ? 'Sismics Docs' : $scope.theme.name; + $scope.theme.name = $scope.theme.name.length === 0 ? 'Sismics Docs' : $scope.theme.name; Restangular.one('theme').post('', $scope.theme).then(function() { var stylesheet = $('#theme-stylesheet')[0]; stylesheet.href = stylesheet.href.replace(/\?.*|$/, '?' + new Date().getTime()); @@ -39,7 +39,7 @@ angular.module('docs').controller('SettingsConfig', function($scope, $rootScope, $scope.sendImage = function(type, image) { // Build the payload var formData = new FormData(); - formData.append('image', image[0]); + formData.append('image', image); // Send the file var done = function() { diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsGroupEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsGroupEdit.js index 21db3000..3650c480 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsGroupEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsGroupEdit.js @@ -60,7 +60,7 @@ angular.module('docs').controller('SettingsGroupEdit', function($scope, $dialog, ]; $dialog.messageBox(title, msg, btns, function(result) { - if (result == 'ok') { + if (result === 'ok') { Restangular.one('group', $stateParams.name).remove().then(function() { $scope.loadGroups(); $state.go('settings.group'); @@ -77,7 +77,7 @@ angular.module('docs').controller('SettingsGroupEdit', function($scope, $dialog, $scope.getGroupTypeahead = function($viewValue) { var deferred = $q.defer(); Restangular.one('group') - .getList('', { + .get({ sort_column: 1, asc: true }).then(function(data) { @@ -93,8 +93,8 @@ angular.module('docs').controller('SettingsGroupEdit', function($scope, $dialog, */ $scope.getUserTypeahead = function($viewValue) { var deferred = $q.defer(); - Restangular.one('user') - .getList('list', { + Restangular.one('user/list') + .get({ search: $viewValue, sort_column: 1, asc: true diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js index 27946f37..c1e2a0d7 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js @@ -3,7 +3,7 @@ /** * Settings security controller. */ -angular.module('docs').controller('SettingsSecurity', function($scope, User, $dialog, $modal, Restangular, $translate) { +angular.module('docs').controller('SettingsSecurity', function($scope, User, $dialog, $uibModal, Restangular, $translate) { User.userInfo().then(function(data) { $scope.user = data; }); @@ -20,7 +20,7 @@ angular.module('docs').controller('SettingsSecurity', function($scope, User, $di ]; $dialog.messageBox(title, msg, btns, function(result) { - if (result == 'ok') { + if (result === 'ok') { Restangular.one('user/enable_totp').post().then(function(data) { $scope.secret = data.secret; User.userInfo(true).then(function(data) { @@ -35,11 +35,11 @@ angular.module('docs').controller('SettingsSecurity', function($scope, User, $di * Disable TOTP. */ $scope.disableTotp = function() { - $modal.open({ + $uibModal.open({ templateUrl: 'partial/docs/settings.security.disabletotp.html', controller: 'SettingsSecurityModalDisableTotp' }).result.then(function (password) { - if (password == null) { + if (password === null) { return; } diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurityModalDisableTotp.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurityModalDisableTotp.js index 2f588bdb..d0c082b9 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurityModalDisableTotp.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurityModalDisableTotp.js @@ -3,9 +3,9 @@ /** * Settings modal disable TOTP controller. */ -angular.module('docs').controller('SettingsSecurityModalDisableTotp', function ($scope, $modalInstance) { +angular.module('docs').controller('SettingsSecurityModalDisableTotp', function ($scope, $uibModalInstance) { $scope.password = ''; $scope.close = function(password) { - $modalInstance.close(password); + $uibModalInstance.close(password); } }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSession.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSession.js index 26f2957c..cc1be24e 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSession.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSession.js @@ -8,7 +8,7 @@ angular.module('docs').controller('SettingsSession', function($scope, Restangula * Load sessions. */ $scope.loadSession = function() { - Restangular.one('user').getList('session').then(function(data) { + Restangular.one('user/session').get().then(function(data) { $scope.sessions = data.sessions; }); }; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js index 5905fbba..1df1c2d2 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js @@ -10,7 +10,7 @@ angular.module('docs').controller('TagEdit', function($scope, $stateParams, Rest // Replace the tag from the list with this reference _.each($scope.tags, function(tag, i) { - if (tag.id == $scope.tag.id) { + if (tag.id === $scope.tag.id) { $scope.tags[i] = $scope.tag; } }); @@ -36,7 +36,7 @@ angular.module('docs').controller('TagEdit', function($scope, $stateParams, Rest ]; $dialog.messageBox(title, msg, btns, function(result) { - if (result == 'ok') { + if (result === 'ok') { Restangular.one('tag', tag.id).remove().then(function() { $scope.loadTags(); $state.go('tag.default'); diff --git a/docs-web/src/main/webapp/src/app/docs/directive/Acl.js b/docs-web/src/main/webapp/src/app/docs/directive/Acl.js index 3fd0a22c..7a88b7e5 100644 --- a/docs-web/src/main/webapp/src/app/docs/directive/Acl.js +++ b/docs-web/src/main/webapp/src/app/docs/directive/Acl.js @@ -6,7 +6,7 @@ angular.module('docs').directive('acl', function() { return { restrict: 'E', - template: '{{ \'acl.\' + data.type | translate }} {{ data.name }}', + template: '{{ \'acl.\' + data.type | translate }} {{ data.name }}', replace: true, scope: { data: '=' diff --git a/docs-web/src/main/webapp/src/app/docs/directive/AclEdit.js b/docs-web/src/main/webapp/src/app/docs/directive/AclEdit.js index 0e53b207..06b2c7c2 100644 --- a/docs-web/src/main/webapp/src/app/docs/directive/AclEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/directive/AclEdit.js @@ -43,7 +43,7 @@ angular.module('docs').directive('aclEdit', function() { // Compute ACLs to add $scope.acl.source = $scope.source; var acls = []; - if ($scope.acl.perm == 'READWRITE') { + if ($scope.acl.perm === 'READWRITE') { acls = [{ source: $scope.source, target: $scope.acl.target.name, diff --git a/docs-web/src/main/webapp/src/app/docs/directive/ImgError.js b/docs-web/src/main/webapp/src/app/docs/directive/ImgError.js index 78772edd..5cbcd62a 100644 --- a/docs-web/src/main/webapp/src/app/docs/directive/ImgError.js +++ b/docs-web/src/main/webapp/src/app/docs/directive/ImgError.js @@ -8,7 +8,7 @@ angular.module('docs').directive('imgError', function() { restrict: 'A', link: function(scope, element, attrs) { element.bind('error', function() { - //call the function that was passed + // call the function that was passed scope.$apply(attrs.imgError); }); } diff --git a/docs-web/src/main/webapp/src/app/docs/directive/SelectRelation.js b/docs-web/src/main/webapp/src/app/docs/directive/SelectRelation.js index df0cdce6..bdbd3ee4 100644 --- a/docs-web/src/main/webapp/src/app/docs/directive/SelectRelation.js +++ b/docs-web/src/main/webapp/src/app/docs/directive/SelectRelation.js @@ -20,7 +20,7 @@ angular.module('docs').directive('selectRelation', function() { $scope.addRelation = function($item) { // Does the new relation is already in the model var duplicate = _.find($scope.relations, function(relation) { - if ($item.id == relation.id) { + if ($item.id === relation.id) { return relation; } }); @@ -41,7 +41,7 @@ angular.module('docs').directive('selectRelation', function() { */ $scope.deleteRelation = function(deleteRelation) { $scope.relations = _.reject($scope.relations, function(relation) { - return relation.id == deleteRelation.id; + return relation.id === deleteRelation.id; }) }; @@ -50,8 +50,8 @@ angular.module('docs').directive('selectRelation', function() { */ $scope.getDocumentTypeahead = function($viewValue) { var deferred = $q.defer(); - Restangular.one('document') - .getList('list', { + Restangular.one('document/list') + .get({ limit: 5, sort_column: 1, asc: true, diff --git a/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js b/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js index d61ee60e..3765e0b8 100644 --- a/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js +++ b/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js @@ -25,14 +25,14 @@ angular.module('docs').directive('selectTag', function() { $scope.addTag = function($event) { // Does the new tag exists var tag = _.find($scope.allTags, function(tag) { - if (tag.name == $scope.input) { + if (tag.name === $scope.input) { return tag; } }); // Does the new tag is already in the model var duplicate = _.find($scope.tags, function(tag2) { - if (tag && tag2.id == tag.id) { + if (tag && tag2.id === tag.id) { return tag2; } }); @@ -55,7 +55,7 @@ angular.module('docs').directive('selectTag', function() { */ $scope.deleteTag = function(deleteTag) { $scope.tags = _.reject($scope.tags, function(tag) { - return tag.id == deleteTag.id; + return tag.id === deleteTag.id; }) }; }, diff --git a/docs-web/src/main/webapp/src/app/docs/service/User.js b/docs-web/src/main/webapp/src/app/docs/service/User.js index 31c411f6..980aafd1 100644 --- a/docs-web/src/main/webapp/src/app/docs/service/User.js +++ b/docs-web/src/main/webapp/src/app/docs/service/User.js @@ -12,7 +12,7 @@ angular.module('docs').factory('User', function(Restangular) { * @param force If true, force reloading data */ userInfo: function(force) { - if (userInfo == null || force) { + if (userInfo === null || force) { userInfo = Restangular.one('user').get(); } return userInfo; diff --git a/docs-web/src/main/webapp/src/app/share/app.js b/docs-web/src/main/webapp/src/app/share/app.js index e9c69b98..c162fb96 100644 --- a/docs-web/src/main/webapp/src/app/share/app.js +++ b/docs-web/src/main/webapp/src/app/share/app.js @@ -11,7 +11,9 @@ angular.module('share', /** * Configuring modules. */ -.config(function($stateProvider, $httpProvider, RestangularProvider) { +.config(function($locationProvider, $stateProvider, $httpProvider, RestangularProvider) { + $locationProvider.hashPrefix(''); + // Configuring UI Router $stateProvider .state('main', { 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 f705378c..497d29bd 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 @@ -3,14 +3,14 @@ /** * File modal view controller. */ -angular.module('share').controller('FileModalView', function($rootScope, $modalInstance, $scope, $state, $stateParams, Restangular) { +angular.module('share').controller('FileModalView', function($uibModalInstance, $scope, $state, $stateParams, Restangular, $transitions) { // Load files - Restangular.one('file').getList('list', { id: $stateParams.documentId, share: $stateParams.shareId }).then(function(data) { + Restangular.one('file/list').get({ id: $stateParams.documentId, share: $stateParams.shareId }).then(function(data) { $scope.files = data.files; // Search current file _.each($scope.files, function(value) { - if (value.id == $stateParams.fileId) { + if (value.id === $stateParams.fileId) { $scope.file = value; } }); @@ -21,7 +21,7 @@ angular.module('share').controller('FileModalView', function($rootScope, $modalI */ $scope.nextFile = function() { _.each($scope.files, function(value, key) { - if (value.id == $stateParams.fileId) { + if (value.id === $stateParams.fileId) { var next = $scope.files[key + 1]; if (next) { $state.go('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: next.id }); @@ -35,7 +35,7 @@ angular.module('share').controller('FileModalView', function($rootScope, $modalI */ $scope.previousFile = function() { _.each($scope.files, function(value, key) { - if (value.id == $stateParams.fileId) { + if (value.id === $stateParams.fileId) { var previous = $scope.files[key - 1]; if (previous) { $state.go('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: previous.id }); @@ -66,16 +66,16 @@ angular.module('share').controller('FileModalView', function($rootScope, $modalI * Close the file preview. */ $scope.closeFile = function () { - $modalInstance.dismiss(); + $uibModalInstance.dismiss(); }; // Close the modal when the user exits this state - var off = $rootScope.$on('$stateChangeStart', function(event, toState){ - if (!$modalInstance.closed) { - if (toState.name == 'share.file') { - $modalInstance.close(); + var off = $transitions.onStart({}, function(transition) { + if (!$uibModalInstance.closed) { + if (transition.to().name === $state.current.name) { + $uibModalInstance.close(); } else { - $modalInstance.dismiss(); + $uibModalInstance.dismiss(); } } off(); 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 07e45b23..9ae22d2d 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 @@ -3,8 +3,8 @@ /** * File view controller. */ -angular.module('share').controller('FileView', function($modal, $state, $stateParams) { - var modal = $modal.open({ +angular.module('share').controller('FileView', function($uibModal, $state, $stateParams) { + var modal = $uibModal.open({ windowClass: 'modal modal-fileview', templateUrl: 'partial/share/file.view.html', controller: 'FileModalView' @@ -14,7 +14,7 @@ angular.module('share').controller('FileView', function($modal, $state, $statePa modal.closed = false; modal.result.then(function() { modal.closed = true; - },function(result) { + },function() { modal.closed = true; $state.go('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); }); 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 981aea98..72d7e510 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 @@ -3,19 +3,19 @@ /** * Share controller. */ -angular.module('share').controller('Share', function($scope, $state, $stateParams, Restangular, $modal) { +angular.module('share').controller('Share', function($scope, $state, $stateParams, Restangular, $uibModal) { // Load document Restangular.one('document', $stateParams.documentId).get({ share: $stateParams.shareId }) .then(function (data) { $scope.document = data; }, function (response) { - if (response.status == 403) { + if (response.status === 403) { $state.go('403'); } }); // Load files - Restangular.one('file').getList('list', { id: $stateParams.documentId, share: $stateParams.shareId }) + Restangular.one('file/list').get({ id: $stateParams.documentId, share: $stateParams.shareId }) .then(function (data) { $scope.files = data.files; }); @@ -38,7 +38,7 @@ angular.module('share').controller('Share', function($scope, $state, $stateParam * Export the current document to PDF. */ $scope.exportPdf = function() { - $modal.open({ + $uibModal.open({ templateUrl: 'partial/share/share.pdf.html', controller: 'ShareModalPdf' }); diff --git a/docs-web/src/main/webapp/src/app/share/controller/ShareModalPdf.js b/docs-web/src/main/webapp/src/app/share/controller/ShareModalPdf.js index ff6b2cd9..65b49dcc 100644 --- a/docs-web/src/main/webapp/src/app/share/controller/ShareModalPdf.js +++ b/docs-web/src/main/webapp/src/app/share/controller/ShareModalPdf.js @@ -3,7 +3,7 @@ /** * Document modal PDF controller. */ -angular.module('share').controller('ShareModalPdf', function ($scope, $window, $stateParams, $modalInstance) { +angular.module('share').controller('ShareModalPdf', function ($scope, $window, $stateParams, $uibModalInstance) { $scope.export = { metadata: false, comments: false, @@ -20,11 +20,11 @@ angular.module('share').controller('ShareModalPdf', function ($scope, $window, $ + '&margin=' + $scope.export.margin + '&share=' + $stateParams.shareId); - $modalInstance.close(); + $uibModalInstance.close(); }; // Close the modal $scope.close = function () { - $modalInstance.close(); + $uibModalInstance.close(); } }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index 694c2508..f76a131d 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -36,8 +36,8 @@ - + @@ -89,7 +89,7 @@ - +