From a2a3297986ae807e5d56d4f73c17db46ff8f1c29 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Thu, 31 Jan 2019 15:44:58 +0100 Subject: [PATCH] Closes #256: display version history --- README.md | 11 +++---- .../document/DocumentViewContent.js | 15 ++++++++++ .../docs/controller/document/FileModalView.js | 20 +++++++++---- .../controller/document/ModalFileVersions.js | 18 +++++++++++ docs-web/src/main/webapp/src/index.html | 1 + docs-web/src/main/webapp/src/locale/en.json | 10 ++++++- .../partial/docs/document.view.content.html | 16 +++++++++- .../src/partial/docs/file.versions.html | 30 +++++++++++++++++++ 8 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/document/ModalFileVersions.js create mode 100644 docs-web/src/main/webapp/src/partial/docs/file.versions.html diff --git a/README.md b/README.md index 21876f18..b6c087fe 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,16 @@ Features - Responsive user interface - Optical character recognition - Support image, PDF, ODT, DOCX, PPTX files -- Video file support ![New!](https://www.sismics.com/public/img/new.png) +- Video file support - Flexible search engine with suggestions and highlighting - Full text search in all supported files - All [Dublin Core](http://dublincore.org/) metadata - Workflow system ![New!](https://www.sismics.com/public/img/new.png) - 256-bit AES encryption of stored files +- File versioning ![New!](https://www.sismics.com/public/img/new.png) - Tag system with nesting -- Import document from email (EML format) ![New!](https://www.sismics.com/public/img/new.png) -- Automatic inbox scanning and importing ![New!](https://www.sismics.com/public/img/new.png) +- Import document from email (EML format) +- Automatic inbox scanning and importing - User/group permission system - 2-factor authentication - Hierarchical groups @@ -49,9 +50,9 @@ Features - Storage quota per user - Document sharing by URL - RESTful Web API -- Webhooks to trigger external service ![New!](https://www.sismics.com/public/img/new.png) +- Webhooks to trigger external service - Fully featured Android client -- [Bulk files importer](https://github.com/sismics/docs/tree/master/docs-importer) (single or scan mode) ![New!](https://www.sismics.com/public/img/new.png) +- [Bulk files importer](https://github.com/sismics/docs/tree/master/docs-importer) (single or scan mode) - Tested to one million documents Install with Docker 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 fa7061cf..0caa29fa 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 @@ -64,6 +64,9 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root }); }; + /** + * Upload a new version. + */ $scope.uploadNewVersion = function (files, file) { if (!$scope.document.writable || !files || files.length === 0) { return; @@ -182,4 +185,16 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root file.processing = true; }); }; + + $scope.openVersions = function (file) { + $uibModal.open({ + templateUrl: 'partial/docs/file.versions.html', + controller: 'ModalFileVersions', + resolve: { + file: function () { + return file; + } + } + }) + }; }); \ No newline at end of file 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 c5846aa4..87f3c0dc 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 @@ -4,17 +4,27 @@ * File modal view controller. */ angular.module('docs').controller('FileModalView', function ($uibModalInstance, $scope, $state, $stateParams, $sce, Restangular, $transitions) { - // Load files - Restangular.one('file/list').get({ id: $stateParams.id }).then(function (data) { - $scope.files = data.files; - + var setFile = function (files) { // Search current file - _.each($scope.files, function (value) { + _.each(files, function (value) { if (value.id === $stateParams.fileId) { $scope.file = value; $scope.trustedFileUrl = $sce.trustAsResourceUrl('../api/file/' + $stateParams.fileId + '/data'); } }); + }; + + // Load files + Restangular.one('file/list').get({ id: $stateParams.id }).then(function (data) { + $scope.files = data.files; + setFile(data.files); + + // File not found, maybe it's a version + if (!$scope.file) { + Restangular.one('file/' + $stateParams.fileId + '/versions').get().then(function (data) { + setFile(data.files); + }); + } }); /** diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/ModalFileVersions.js b/docs-web/src/main/webapp/src/app/docs/controller/document/ModalFileVersions.js new file mode 100644 index 00000000..dd2c3b2b --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/ModalFileVersions.js @@ -0,0 +1,18 @@ +'use strict'; + +/** + * Modal file versions controller. + */ +angular.module('docs').controller('ModalFileVersions', function ($scope, $state, $stateParams, $uibModalInstance, Restangular, file) { + Restangular.one('file/' + file.id + '/versions').get().then(function (data) { + $scope.files = data.files; + }); + + $scope.openFile = function (file) { + $state.go('document.view.content.file', { id: $stateParams.id, fileId: file.id }) + }; + + $scope.close = function() { + $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 4ae97981..c17f8f0d 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -72,6 +72,7 @@ + diff --git a/docs-web/src/main/webapp/src/locale/en.json b/docs-web/src/main/webapp/src/locale/en.json index 4a979096..7556e882 100644 --- a/docs-web/src/main/webapp/src/locale/en.json +++ b/docs-web/src/main/webapp/src/locale/en.json @@ -119,7 +119,8 @@ "add_files": "Add files", "file_processing_indicator": "This file is being processed. Searching will not be available before it is complete.", "reprocess_file": "Reprocess this file", - "upload_new_version": "Upload a new version" + "upload_new_version": "Upload a new version", + "open_versions": "Show version history" }, "workflow": { "workflow": "Workflow", @@ -204,6 +205,13 @@ "edit": { "title": "Edit file", "name": "Filename" + }, + "versions": { + "title": "Version history", + "filename": "Filename", + "mimetype": "Type", + "create_date": "Creation date", + "version": "Version" } }, "tag": { diff --git a/docs-web/src/main/webapp/src/partial/docs/document.view.content.html b/docs-web/src/main/webapp/src/partial/docs/document.view.content.html index e1d9a553..b136dc5c 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.view.content.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.view.content.html @@ -68,18 +68,32 @@ {{ 'rename' | translate }} + +
  • {{ 'document.view.content.reprocess_file' | translate }} +
  • + +
  • {{ 'document.view.content.upload_new_version' | translate }} +
  • +
  • + + + {{ 'document.view.content.open_versions' | translate }} + +
  • + +
  • - + {{ 'delete' | translate }}
  • diff --git a/docs-web/src/main/webapp/src/partial/docs/file.versions.html b/docs-web/src/main/webapp/src/partial/docs/file.versions.html new file mode 100644 index 00000000..4963c9c9 --- /dev/null +++ b/docs-web/src/main/webapp/src/partial/docs/file.versions.html @@ -0,0 +1,30 @@ + + + \ No newline at end of file