diff --git a/docs-parent/TODO b/docs-parent/TODO index fddeffdb..413e0ed8 100644 --- a/docs-parent/TODO +++ b/docs-parent/TODO @@ -1,4 +1,3 @@ -- Add language on document (client) - Index title and description (server) - Use Lucene for title and description searching (server) - Index OCR-ized content (server) diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java index 38509e0c..1ca40807 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java @@ -89,6 +89,7 @@ public class DocumentResource extends BaseResource { document.put("title", documentDb.getTitle()); document.put("description", documentDb.getDescription()); document.put("create_date", documentDb.getCreateDate().getTime()); + document.put("language", documentDb.getLanguage()); // Add tags TagDao tagDao = new TagDao(); diff --git a/docs-web/src/main/webapp/app/docs/controller/Document.js b/docs-web/src/main/webapp/app/docs/controller/Document.js index f8b9d95e..4e642fe2 100644 --- a/docs-web/src/main/webapp/app/docs/controller/Document.js +++ b/docs-web/src/main/webapp/app/docs/controller/Document.js @@ -3,7 +3,7 @@ /** * Document controller. */ -App.controller('Document', function($scope, $state, Restangular) { +App.controller('Document', function($scope, $timeout, $state, Restangular) { /** * Documents table sort status. */ @@ -13,24 +13,28 @@ App.controller('Document', function($scope, $state, Restangular) { $scope.currentPage = 1; $scope.limit = 10; $scope.search = ''; + + // A timeout promise is used to slow down search requests to the server + // We keep track of it for cancellation purpose + var timeoutPromise; /** * Load new documents page. */ $scope.pageDocuments = function() { Restangular.one('document') - .getList('list', { - offset: $scope.offset, - limit: $scope.limit, - sort_column: $scope.sortColumn, - asc: $scope.asc, - search: $scope.search - }) - .then(function(data) { - $scope.documents = data.documents; - $scope.totalDocuments = data.total; - $scope.numPages = Math.ceil(data.total / $scope.limit); - }); + .getList('list', { + offset: $scope.offset, + limit: $scope.limit, + sort_column: $scope.sortColumn, + asc: $scope.asc, + search: $scope.search + }) + .then(function (data) { + $scope.documents = data.documents; + $scope.totalDocuments = data.total; + $scope.numPages = Math.ceil(data.total / $scope.limit); + }); }; /** @@ -57,7 +61,15 @@ App.controller('Document', function($scope, $state, Restangular) { * Watch for search scope change. */ $scope.$watch('search', function(prev, next) { - $scope.loadDocuments(); + if (timeoutPromise) { + // Cancel previous timeout + $timeout.cancel(timeoutPromise); + } + + // Call API later + timeoutPromise = $timeout(function () { + $scope.loadDocuments(); + }, 200); }, true); /** diff --git a/docs-web/src/main/webapp/app/docs/controller/DocumentEdit.js b/docs-web/src/main/webapp/app/docs/controller/DocumentEdit.js index 08807ff8..89615192 100644 --- a/docs-web/src/main/webapp/app/docs/controller/DocumentEdit.js +++ b/docs-web/src/main/webapp/app/docs/controller/DocumentEdit.js @@ -46,7 +46,10 @@ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams, $scope.document = data; }); } else { - $scope.document = { tags: [] }; + $scope.document = { + tags: [], + language: 'fra' + }; } /** diff --git a/docs-web/src/main/webapp/img/flag/eng.png b/docs-web/src/main/webapp/img/flag/eng.png new file mode 100644 index 00000000..ff701e19 Binary files /dev/null and b/docs-web/src/main/webapp/img/flag/eng.png differ diff --git a/docs-web/src/main/webapp/img/flag/fra.png b/docs-web/src/main/webapp/img/flag/fra.png new file mode 100644 index 00000000..8332c4ec Binary files /dev/null and b/docs-web/src/main/webapp/img/flag/fra.png differ diff --git a/docs-web/src/main/webapp/partial/docs/document.edit.html b/docs-web/src/main/webapp/partial/docs/document.edit.html index fb8c2b57..ea83944c 100644 --- a/docs-web/src/main/webapp/partial/docs/document.edit.html +++ b/docs-web/src/main/webapp/partial/docs/document.edit.html @@ -20,6 +20,15 @@ +
+ +
+ +
+
diff --git a/docs-web/src/main/webapp/partial/docs/document.view.html b/docs-web/src/main/webapp/partial/docs/document.view.html index 23441a8c..b26c3dee 100644 --- a/docs-web/src/main/webapp/partial/docs/document.view.html +++ b/docs-web/src/main/webapp/partial/docs/document.view.html @@ -1,6 +1,6 @@ - + -
+
@@ -9,7 +9,7 @@