Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3303 PID registration #3360

Merged
merged 13 commits into from
Oct 23, 2024
Merged
Prev Previous commit
Next Next commit
#3303 added resource to frontend, added download button in administra…
…tion panel
moellerth committed Jul 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit c3a59fd89524115d274907d46bca621eda298d32
Original file line number Diff line number Diff line change
@@ -26,7 +26,8 @@ angular.module('metadatamanagementApp').config([
'dara': 'Dara',
'messageBroker': 'Message Broker (für Websockets)',
'rabbit': 'RabbitMQ',
'seo4Ajax': 'Seo4Ajax (Prerender as a Service)'
'seo4Ajax': 'Seo4Ajax (Prerender as a Service)',
'pid': 'PID'
},
'table': {
'service': 'Servicename',
@@ -45,6 +46,9 @@ angular.module('metadatamanagementApp').config([
'update': 'Aktualisieren',
'update-success': 'DARA erfolgreich aktualisiert',
'update-failure': 'Es sind Fehler beim Aktualisieren von DARA aufgetreten! (Siehe Details)'
},
'pid': {
'download': 'Daten herunterladen'
}
},
'logs': {
Original file line number Diff line number Diff line change
@@ -26,7 +26,8 @@ angular.module('metadatamanagementApp').config([
'dara': 'Dara',
'messageBroker': 'Message Broker (for Websockets)',
'rabbit': 'RabbitMQ',
'seo4Ajax': 'Seo4Ajax (Prerender as a Service)'
'seo4Ajax': 'Seo4Ajax (Prerender as a Service)',
'pid': 'PID'
},
'table': {
'service': 'Service name',
@@ -45,6 +46,9 @@ angular.module('metadatamanagementApp').config([
'update': 'Update',
'update-success': 'DARA update successful',
'update-failure': 'Errors occurred during DARA update! (see details)'
},
'pid': {
'download': 'Download data'
}
},
'logs': {
Original file line number Diff line number Diff line change
@@ -10,8 +10,9 @@ angular.module('metadatamanagementApp').controller('HealthController', [
'BreadcrumbService',
'SimpleMessageToastService',
'DaraReleaseCustomResource',
'ExportAllVariablesResource',
function($scope, MonitoringService, $uibModal, ElasticSearchAdminService,
PageMetadataService, $state, BreadcrumbService, SimpleMessageToastService, DaraReleaseCustomResource) {
PageMetadataService, $state, BreadcrumbService, SimpleMessageToastService, DaraReleaseCustomResource, ExportAllVariablesResource) {
PageMetadataService.setPageTitle('administration.health.title');
$scope.isRecreatingIndices = false;
$scope.updatingHealth = true;
@@ -70,6 +71,25 @@ angular.module('metadatamanagementApp').controller('HealthController', [
});
}

/**
* Method to download all variable metadata as needed for PID registration.
* Data will be downloaded as a JSON file.
*/
$scope.downloadPidData = function() {
$scope.isDownloadingData = true;
ExportAllVariablesResource.exportAll().then(function(res) {
var blob = new Blob([angular.toJson(res, true)],{
type: "application/json;charset=utf-8;"
});
var downloadLink = document.createElement('a');
downloadLink.setAttribute('download', 'variable_pid_mdm_export.json');
downloadLink.setAttribute('href', window.URL.createObjectURL(blob));
downloadLink.click();
console.log("Download", res);
$scope.isDownloadingData = false;
})
}

$scope.refresh();

$scope.getLabelClass = function(statusState) {
12 changes: 12 additions & 0 deletions mdm-frontend/src/app/legacy/administration/health/health.html.tmpl
Original file line number Diff line number Diff line change
@@ -44,6 +44,18 @@
</a>
</td>
</tr>
<tr>
<td>{{'administration.health.indicator.pid' | translate}}</td>
<td class="text-center">
<button class="btn btn-danger btn-xs" data-translate="administration.health.pid.download"
ng-click="downloadPidData()" ng-disabled="isDownloadingData" type="button">
</button>
</td>
<td class="text-center">
</td>
<td class="text-center">
</td>
</tr>
</tbody>
</table>
</div>
Original file line number Diff line number Diff line change
@@ -17,3 +17,21 @@ angular.module('metadatamanagementApp')
});
}]);

/**
* Method to request the endpoint that downloads all variables as a PID-formatted json file.
* The response is a list (List<String>) of variable metadata.
* We could not put this into the "VariableResource"-schema (above), because the URLs would not match.
*/
angular.module('metadatamanagementApp').factory('ExportAllVariablesResource', ['$http',
function($http) {
return {
exportAll: function() {
return $http.post('/api/variables/exportAll').then(function(response) {
return response.data;
var blob = new Blob([ response.data ], { type : 'application/json' });
return blob; //{ blob: response.data, filename: "filename.json" };
});
}
}
}]);