Commit 06f696f2 authored by Gerrit Hübbers's avatar Gerrit Hübbers 🃏

Introduce edit dialog for OAI-PMH-based publications sources

parent f48f6ff2
......@@ -233,6 +233,27 @@ public class BundlesSourceResource {
return result;
}
@RequestMapping(value = "/bundlesSources/{id}/reference",
method = RequestMethod.PUT,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<Void> updateBundlesSourceReference(@PathVariable Long id, @RequestBody String reference) {
log.debug("REST request to put new reference={} into BundlesSource={} ", reference, id);
ResponseEntity<Void> result;
BundlesSource bundlesSource = bundlesSourceRepository.findOne(id);
if (null != bundlesSource && null != bundlesSource.getType() ) {
bundlesSource.setReference(reference);
bundlesSource = bundlesSourceRepository.save(bundlesSource);
result = ResponseEntity.ok().build();
}
else {
result = ResponseEntity.notFound().build();
}
return result;
}
/**
* DELETE /bundlesSources/:id -> delete the "id" bundlesSource.
*/
......
......@@ -164,6 +164,7 @@
<script src="scripts/app/wizardRunner/wizardRunner.controller.js"></script>
<script src="scripts/app/account/userRepositories/repository-delete-dialog.controller.js"></script>
<script src="scripts/app/account/userRepositories/repository-dialog.controller.js"></script>
<script src="scripts/app/account/userRepositories/repository-edit-dialog.controller.js"></script>
<script src="scripts/app/account/userRepositories/template-delete-dialog.controller.js"></script>
<script src="scripts/app/account/userRepositories/template-dialog.controller.js"></script>
......
'use strict';
angular.module('ddaApp').controller('PublicationsSourcesRepositoryEditDialogController',
['$scope', '$stateParams', '$uibModalInstance', 'DataUtils', 'entity', 'BundlesSource', 'Repository', 'MetadataTransformer', '$state',
function($scope, $stateParams, $uibModalInstance, DataUtils, entity, BundlesSource, Repository, MetadataTransformer, $state) {
$scope.metadataTransformers = MetadataTransformer.query();
$scope.repository = entity;
$scope.selectedMetadataTransformer = '';
$scope.data = {};
BundlesSource.get({id: entity.bundlesSource.id}, function (entity) {
$scope.data = angular.fromJson(entity.data);
});
if (null != entity.bundlesSource.metadataTransformer) {
MetadataTransformer.get({id: entity.bundlesSource.metadataTransformer.id}, function (entity) {
$scope.selectedMetadataTransformer = entity;
});
}
$scope.clear = function() {
$uibModalInstance.dismiss('cancel');
};
var onSaveSuccess = function (result) {
$uibModalInstance.close(result);
$scope.isSaving = false;
};
var onSaveError = function (result) {
$scope.isSaving = false;
};
$scope.save = function () {
$scope.isSaving = true;
BundlesSource.updateData({id: $scope.repository.bundlesSource.id}, $scope.data, onSaveSuccess, onSaveError);
BundlesSource.updateMetadataTransformer({id: $scope.repository.bundlesSource.id}, $scope.selectedMetadataTransformer.id, onSaveSuccess, onSaveError);
BundlesSource.updateReference({id: $scope.repository.bundlesSource.id}, $scope.data.oaiPmhEndpoint, onSaveSuccess, onSaveError);
$scope.repository.address = $scope.data.oaiPmhEndpoint;
Repository.update($scope.repository);
};
}]);
<form name="editForm" role="form" novalidate ng-submit="save()" show-validation>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" id="myFileLabel">Edit OAI-PMH publications source</h4>
</div>
<div class="modal-body">
<div>
<label>OAI-PMH URL
<input type="text" name="input" ng-model="data.oaiPmhEndpoint">
</label>
</div>
<br><br>
<div class="form-group">
<label for="field_metadataTransformer">Metadata transformer</label>
<select class="form-control" id="field_metadataTransformer" name="metadataTransformer" ng-model="selectedMetadataTransformer" ng-options="metadataTransformer as metadataTransformer.name for metadataTransformer in metadataTransformers track by metadataTransformer.id">
<option value=""></option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span>Close</span>
</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="save()">
<span class="glyphicon glyphicon-save"></span>&nbsp;<span>Save</span>
</button>
</div>
</form>
......@@ -146,6 +146,7 @@
<tr>
<th><span>Address</span></th>
<th><span>Owner</span></th>
<th><span>Metadata transformer</span></th>
<th><span>State</span></th>
<th></th>
</tr>
......@@ -153,9 +154,8 @@
<tbody>
<tr ng-repeat="oaiPmhAddress in oaiPmhAddresses track by oaiPmhAddress.id">
<td>{{oaiPmhAddress.address}}</td>
<td>
{{oaiPmhAddress.bundlesSource.owner.login}}
</td>
<td>{{oaiPmhAddress.bundlesSource.owner.login}}</td>
<td>{{oaiPmhAddress.bundlesSource.metadataTransformer.name}}</td>
<td translate="{{'ddaApp.BundlesSourceState.' + bundlesSource.bundlesSourceState}}">{{oaiPmhAddress.bundlesSource.bundlesSourceState}}</td>
<td class="text-right">
<div class="btn-group flex-btn-group-container">
......@@ -165,6 +165,12 @@
<span class="glyphicon glyphicon-eye-open"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button has-authority="ROLE_ADMIN" type="submit"
ui-sref="userRepositories.editOaiAddress({id:oaiPmhAddress.id})"
class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button has-authority="ROLE_ADMIN" type="submit"
ng-click="harvest({id:oaiPmhAddress.bundlesSource.id})"
class="btn btn-warning btn-sm">
......
......@@ -173,6 +173,30 @@ angular.module('ddaApp')
})
}]
})
.state('userRepositories.editOaiAddress', {
parent: 'userRepositories',
url: '/{id}/editOaiAddress',
data: {
authorities: ['ROLE_USER'],
},
onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) {
$uibModal.open({
templateUrl: 'scripts/app/account/userRepositories/repository-edit-dialog.html',
controller: 'PublicationsSourcesRepositoryEditDialogController',
size: 'lg',
resolve: {
entity: ['Repository', function(Repository) {
var result = Repository.get({id : $stateParams.id}).$promise;
return result;
}]
}
}).result.then(function(result) {
$state.go('userRepositories', null, { reload: true });
}, function() {
$state.go('userRepositories', null, { reload: true });
})
}]
})
.state('userRepositories.deleteOaiAddress', {
parent: 'userRepositories',
url: '/{id}/deleteRepository',
......
......@@ -45,6 +45,11 @@ angular.module('ddaApp')
url: 'api/bundlesSources/:id/metadataTransformer',
params: { id: '@id' }
},
'updateReference': {
method: 'PUT',
url: 'api/bundlesSources/:id/reference',
params: { id: '@id' }
},
'createForCurrentUser': {
method: 'POST',
url: 'api/bundlesSources/forCurrentUser'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment