diff --git a/dhp-applications/dhp-mdstore-manager-app/src/main/resources/schema.sql b/dhp-applications/dhp-mdstore-manager-app/src/main/resources/schema.sql index 136bcd637..56e970d1b 100644 --- a/dhp-applications/dhp-mdstore-manager-app/src/main/resources/schema.sql +++ b/dhp-applications/dhp-mdstore-manager-app/src/main/resources/schema.sql @@ -43,7 +43,7 @@ FROM mdstores md LEFT OUTER JOIN mdstore_current_versions cv ON (md.id = cv.mdstore) LEFT OUTER JOIN mdstore_versions v1 ON (cv.current_version = v1.id) - LEFT OUTER JOIN mdstore_versions v2 ON (md.id = v2.id) + LEFT OUTER JOIN mdstore_versions v2 ON (md.id = v2.mdstore) GROUP BY md.id, md.format, md.layout, diff --git a/dhp-applications/dhp-mdstore-manager-app/src/main/resources/static/index.html b/dhp-applications/dhp-mdstore-manager-app/src/main/resources/static/index.html index 85a460b1c..5e3590950 100644 --- a/dhp-applications/dhp-mdstore-manager-app/src/main/resources/static/index.html +++ b/dhp-applications/dhp-mdstore-manager-app/src/main/resources/static/index.html @@ -12,39 +12,97 @@ + +
+
+

Metadata Store Manager

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
IDFormat / Layout / InterpretationDatasourceLast UpdateSizeVersionsOperations
{{md.id}}{{md.format}} / {{md.layout}} / {{md.interpretation}} + + {{md.datasourceName}}
+ + id: {{md.datasourceId}} + api: {{md.apiId}} + +
+
{{md.lastUpdate | date:"MMM dd, yyyy 'at' HH:mm"}}{{md.size}} + {{md.numberOfVersions}} version(s) + + + +
+
+
+ + - - - - - - - - - - - - - - - - - - - - - - - - -
IDFormat / Layout / InterpretationDatasourceCurrent VersionAll versionsLast UpdateSize
{{md.id}}{{md.format}} / {{md.layout}} / {{md.interpretation}} - - {{md.datasourceName}}
- - id: {{md.datasourceId}} - api: {{md.apiId}} - -
-
{{md.apiId}}{{md.currentVersion}}{{md.numberOfVersions}}{{md.lastUpdate}}{{md.size}}
\ No newline at end of file diff --git a/dhp-applications/dhp-mdstore-manager-app/src/main/resources/static/js/mdstoremanager.js b/dhp-applications/dhp-mdstore-manager-app/src/main/resources/static/js/mdstoremanager.js index 168734145..51643a56d 100644 --- a/dhp-applications/dhp-mdstore-manager-app/src/main/resources/static/js/mdstoremanager.js +++ b/dhp-applications/dhp-mdstore-manager-app/src/main/resources/static/js/mdstoremanager.js @@ -2,11 +2,89 @@ var app = angular.module('mdstoreManagerApp', []); app.controller('mdstoreManagerController', function($scope, $http) { $scope.mdstores = []; + $scope.versions = []; + $scope.forceVersionDelete = false; + + $scope.reload = function() { + $http.get('/mdstores/').success(function(data) { + $scope.mdstores = data; + }).error(function() { + alert("error"); + }); + }; + + $scope.listVersions = function(mdId, current) { + $scope.versions = []; + $http.get('/mdstores/mdstore/' + mdId + '/versions').success(function(data) { + angular.forEach(data, function(value, key) { + value.current = (value.id == current); + }); + $scope.versions = data; + }).error(function() { + alert("error"); + }); + }; + + $scope.deleteMdstore = function(mdId) { + if (confirm("Are you sure ?")) { + $http.delete('/mdstores/mdstore/' + mdId).success(function(data) { + $scope.reload(); + }).error(function() { + alert("error"); + }); + } + }; + + $scope.prepareVersion = function(mdId, currentVersion) { + $scope.versions = []; + $http.get('/mdstores/mdstore/' + mdId + '/newVersion').success(function(data) { + $scope.reload(); + $scope.listVersions(mdId, currentVersion); + }).error(function() { + alert("error"); + }); + }; + + + $scope.commitVersion = function(versionId) { + var size = parseInt(prompt("New Size", "0")); + if (size >= 0) { + $http.get("/mdstores/version/" + versionId + "/commit/" + size).success(function(data) { + angular.forEach($scope.versions, function(value, key) { + if (value.id == versionId) { + value.current = true; + value.writing = false; + value.size = size; + } else { + value.current = false; + } + }); + }).error(function() { + alert("error"); + }); + } + }; + + $scope.deleteVersion = function(versionId, force) { + if (confirm("Are you sure ?")) { + var url = '/mdstores/version/' + versionId; + if (force) { url += '?force=true'; } + + $http.delete(url).success(function(data) { + var nv = []; + angular.forEach($scope.versions, function(value, key) { + if (value.id != versionId) { + nv.push(value); + } + }); + $scope.versions = nv; + }).error(function() { + alert("error"); + }); + } + }; + + $scope.reload(); - $http.get('/mdstores/').success(function(data) { - $scope.mdstores = data; - }).error(function() { - alert("error"); - }); });