2019-03-22 10:13:56 +01:00
|
|
|
var app = angular.module('mdstoreManagerApp', []);
|
|
|
|
|
|
|
|
app.controller('mdstoreManagerController', function($scope, $http) {
|
|
|
|
$scope.mdstores = [];
|
2019-03-22 15:15:57 +01:00
|
|
|
$scope.versions = [];
|
2019-04-01 10:40:09 +02:00
|
|
|
$scope.openMdstore = '';
|
|
|
|
$scope.openCurrentVersion = ''
|
|
|
|
|
2019-03-22 15:15:57 +01:00
|
|
|
$scope.forceVersionDelete = false;
|
|
|
|
|
|
|
|
$scope.reload = function() {
|
2019-03-25 11:54:18 +01:00
|
|
|
$http.get('/mdstores/?' + $.now()).success(function(data) {
|
2019-03-22 15:15:57 +01:00
|
|
|
$scope.mdstores = data;
|
|
|
|
}).error(function() {
|
|
|
|
alert("error");
|
|
|
|
});
|
|
|
|
};
|
2019-03-25 11:54:18 +01:00
|
|
|
|
|
|
|
$scope.newMdstore = function(format, layout, interpretation, dsName, dsId, apiId) {
|
|
|
|
var url = '/mdstores/new/' + encodeURIComponent(format) + '/' + encodeURIComponent(layout) + '/' + encodeURIComponent(interpretation);
|
|
|
|
if (dsName || dsId || apiId) {
|
|
|
|
url += '?dsName=' + encodeURIComponent(dsName) + '&dsId=' + encodeURIComponent(dsId) + '&apiId=' + encodeURIComponent(apiId);
|
|
|
|
}
|
2019-04-03 10:53:54 +02:00
|
|
|
$http.get(url).success(function(data) {
|
2019-03-25 11:54:18 +01:00
|
|
|
$scope.reload();
|
2019-03-22 15:15:57 +01:00
|
|
|
}).error(function() {
|
|
|
|
alert("error");
|
|
|
|
});
|
|
|
|
};
|
2019-03-25 11:54:18 +01:00
|
|
|
|
2019-03-22 15:15:57 +01:00
|
|
|
$scope.deleteMdstore = function(mdId) {
|
|
|
|
if (confirm("Are you sure ?")) {
|
|
|
|
$http.delete('/mdstores/mdstore/' + mdId).success(function(data) {
|
2019-04-01 10:40:09 +02:00
|
|
|
$scope.reload();
|
2019-03-22 15:15:57 +01:00
|
|
|
}).error(function() {
|
|
|
|
alert("error");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.prepareVersion = function(mdId, currentVersion) {
|
|
|
|
$scope.versions = [];
|
2019-03-25 11:54:18 +01:00
|
|
|
$http.get('/mdstores/mdstore/' + mdId + '/newVersion?' + $.now()).success(function(data) {
|
2019-03-22 15:15:57 +01:00
|
|
|
$scope.reload();
|
|
|
|
$scope.listVersions(mdId, currentVersion);
|
|
|
|
}).error(function() {
|
|
|
|
alert("error");
|
|
|
|
});
|
|
|
|
};
|
2019-03-25 11:54:18 +01:00
|
|
|
|
2019-03-22 15:15:57 +01:00
|
|
|
$scope.commitVersion = function(versionId) {
|
|
|
|
var size = parseInt(prompt("New Size", "0"));
|
|
|
|
if (size >= 0) {
|
2019-03-25 11:54:18 +01:00
|
|
|
$http.get("/mdstores/version/" + versionId + "/commit/" + size + '?' + $.now()).success(function(data) {
|
2019-04-01 10:40:09 +02:00
|
|
|
$scope.reload();
|
|
|
|
$scope.openCurrentVersion = versionId;
|
|
|
|
$scope.refreshVersions();
|
2019-03-22 15:15:57 +01:00
|
|
|
}).error(function() {
|
|
|
|
alert("error");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-03-25 11:54:18 +01:00
|
|
|
$scope.listVersions = function(mdId, current) {
|
2019-04-01 10:40:09 +02:00
|
|
|
$scope.openMdstore = mdId;
|
|
|
|
$scope.openCurrentVersion = current;
|
2019-03-25 11:54:18 +01:00
|
|
|
$scope.versions = [];
|
2019-04-01 10:40:09 +02:00
|
|
|
$scope.refreshVersions();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.refreshVersions = function() {
|
|
|
|
$http.get('/mdstores/mdstore/' + $scope.openMdstore + '/versions?' + $.now()).success(function(data) {
|
2019-03-25 11:54:18 +01:00
|
|
|
angular.forEach(data, function(value, key) {
|
2019-04-01 10:40:09 +02:00
|
|
|
value.current = (value.id == $scope.openCurrentVersion);
|
2019-03-25 11:54:18 +01:00
|
|
|
});
|
|
|
|
$scope.versions = data;
|
|
|
|
}).error(function() {
|
|
|
|
alert("error");
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-03-22 15:15:57 +01:00
|
|
|
$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) {
|
2019-03-25 11:54:18 +01:00
|
|
|
$scope.reload();
|
2019-04-01 10:40:09 +02:00
|
|
|
$scope.refreshVersions();
|
2019-03-22 15:15:57 +01:00
|
|
|
}).error(function() {
|
|
|
|
alert("error");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.reload();
|
2019-03-22 10:13:56 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|