Commit 85c6d97d authored by Gerrit Hübbers's avatar Gerrit Hübbers 🃏

Merge branch '73-improve-publications-sources-page' into 'master'

Resolve "Improve publications sources page"

Closes #73

See merge request !11
parents d1dfd0d3 06f696f2
......@@ -95,7 +95,6 @@ public class XmlFile implements Serializable {
return "XmlFile{" +
"id=" + id +
", name='" + name + "'" +
", data='" + data + "'" +
'}';
}
}
......@@ -13,6 +13,6 @@ import org.springframework.data.jpa.repository.Query;
public interface XmlFileRepository extends JpaRepository<XmlFile,Long> {
@Query("select xmlFile from XmlFile xmlFile where xmlFile.bundlesSource.owner.login = ?#{principal.username}")
List<File> findAllByOwnerIsCurrentUser();
List<XmlFile> findAllByOwnerIsCurrentUser();
}
......@@ -18,6 +18,7 @@ import org.gesis.dda.wizard.domain.enumeration.BundlesSourceType;
import org.gesis.dda.wizard.repository.BundlesSourceRepository;
import org.gesis.dda.wizard.repository.MetadataTransformerRepository;
import org.gesis.dda.wizard.repository.UserRepository;
import org.gesis.dda.wizard.security.AuthoritiesConstants;
import org.gesis.dda.wizard.security.SecurityUtils;
import org.gesis.dda.wizard.service.FeederService;
import org.gesis.dda.wizard.web.rest.util.HeaderUtil;
......@@ -136,7 +137,13 @@ public class BundlesSourceResource {
public ResponseEntity<List<BundlesSource>> getAllBundlesSourcesForCurrentUser()
throws URISyntaxException {
log.debug("REST request to get a page of BundlesSources");
List<BundlesSource> result = bundlesSourceRepository.findByOwnerIsCurrentUser();
List<BundlesSource> result;
if ( SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN) ) {
result = bundlesSourceRepository.findAll();
}
else {
result = bundlesSourceRepository.findByOwnerIsCurrentUser();
}
return new ResponseEntity<>(result, HttpStatus.OK);
}
......@@ -226,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.
*/
......
package org.gesis.dda.wizard.web.rest;
import com.codahale.metrics.annotation.Timed;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
import javax.inject.Inject;
import javax.validation.Valid;
import org.gesis.dda.wizard.domain.File;
import org.gesis.dda.wizard.repository.FileRepository;
import org.gesis.dda.wizard.security.AuthoritiesConstants;
import org.gesis.dda.wizard.security.SecurityUtils;
import org.gesis.dda.wizard.web.rest.util.HeaderUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.inject.Inject;
import javax.validation.Valid;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
import com.codahale.metrics.annotation.Timed;
/**
* REST controller for managing File.
......@@ -74,8 +82,15 @@ public class FileResource {
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<File> getAllFiles() {
List<File> result;
log.debug("REST request to get all Files");
return fileRepository.findAllByOwnerIsCurrentUser();
if ( SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN) ) {
result = fileRepository.findAll();
}
else {
result = fileRepository.findAllByOwnerIsCurrentUser();
}
return result;
}
/**
......
package org.gesis.dda.wizard.web.rest;
import com.codahale.metrics.annotation.Timed;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
import javax.inject.Inject;
import org.gesis.dda.wizard.domain.BundlesSource;
import org.gesis.dda.wizard.domain.Repository;
import org.gesis.dda.wizard.domain.enumeration.BundlesSourceState;
......@@ -8,6 +14,7 @@ import org.gesis.dda.wizard.domain.enumeration.BundlesSourceType;
import org.gesis.dda.wizard.repository.BundlesSourceRepository;
import org.gesis.dda.wizard.repository.RepositoryRepository;
import org.gesis.dda.wizard.repository.UserRepository;
import org.gesis.dda.wizard.security.AuthoritiesConstants;
import org.gesis.dda.wizard.security.SecurityUtils;
import org.gesis.dda.wizard.web.rest.util.HeaderUtil;
import org.gesis.yoai.client.OaiClient;
......@@ -18,13 +25,13 @@ import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.inject.Inject;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
import com.codahale.metrics.annotation.Timed;
/**
* REST controller for managing Repository.
......@@ -101,8 +108,15 @@ public class RepositoryResource {
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<Repository> getAllRepositorys() {
List<Repository> result;
log.debug("REST request to get all Repositorys");
return repositoryRepository.findAllByOwnerIsCurrentUser();
if ( SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN) ) {
result = repositoryRepository.findAll();
}
else {
result = repositoryRepository.findAllByOwnerIsCurrentUser();
}
return result;
}
/**
......
......@@ -19,6 +19,7 @@ import org.gesis.dda.wizard.domain.enumeration.BundlesSourceType;
import org.gesis.dda.wizard.repository.BundlesSourceRepository;
import org.gesis.dda.wizard.repository.UserRepository;
import org.gesis.dda.wizard.repository.XmlFileRepository;
import org.gesis.dda.wizard.security.AuthoritiesConstants;
import org.gesis.dda.wizard.security.SecurityUtils;
import org.gesis.dda.wizard.web.rest.util.HeaderUtil;
import org.gesis.dda.xml2metadata.MetadataNode;
......@@ -146,7 +147,16 @@ public class XmlFileResource {
@Timed
public List<XmlFile> getAllXmlFiles() {
log.debug("REST request to get all XmlFiles");
return xmlFileRepository.findAll();
List<XmlFile> result;
//User currentUser = SecurityUtils.getCurrentUser();
//if ( currentUser != null && currentUser.getAuthorities().contains(arg0)
if ( SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN) ) {
result = xmlFileRepository.findAll();
}
else {
result = xmlFileRepository.findAllByOwnerIsCurrentUser();
}
return result;
}
/**
......
......@@ -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>
......@@ -43,13 +43,13 @@
<span class="glyphicon glyphicon-eye-open"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ng-click="harvest({id:file.bundlesSource.id})"
class="btn btn-warning btn-sm">
<span class="glyphicon glyphicon-apple"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ui-sref="userRepositories.deleteTemplate({id:file.id})"
class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-circle"></span>
......@@ -103,20 +103,20 @@
<span class="glyphicon glyphicon-eye-open"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ui-sref="userRepositories.editXmlFile({id:xmlFile.id})"
class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ng-click="harvest({id:xmlFile.bundlesSource.id})"
class="btn btn-warning btn-sm">
<span class="glyphicon glyphicon-apple"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ui-sref="userRepositories.deleteXmlFile({id:xmlFile.id})"
class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-circle"></span>
......@@ -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,13 +165,19 @@
<span class="glyphicon glyphicon-eye-open"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<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">
<span class="glyphicon glyphicon-apple"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ui-sref="userRepositories.deleteOaiAddress({id:oaiPmhAddress.id})"
class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-circle"></span>
......@@ -225,25 +231,25 @@
<span class="glyphicon glyphicon-eye-open"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ui-sref="userRepositories.editUnapiSource({id: unapiSource.id})"
class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ui-sref="userRepositories.addIdentifierToUnapiSource({id: unapiSource.id})"
class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ng-click="harvest({id:unapiSource.id})"
class="btn btn-warning btn-sm">
<span class="glyphicon glyphicon-apple"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button type="submit"
<button has-authority="ROLE_ADMIN" type="submit"
ui-sref="userRepositories.deleteUnapiSource({id:unapiSource.id})"
class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-circle"></span>
......
......@@ -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'
......
......@@ -71,9 +71,9 @@
&#xA0;<span >Messages</span></a></li>
<li ui-sref-active="active" has-authority="ROLE_DEVELOPER"><a ui-sref="elementOption" data-toggle="collapse" data-target=".navbar-collapse.in"><span class="glyphicon glyphicon-asterisk"></span>
&#xA0;<span >Element option</span></a></li>
<li ui-sref-active="active" ><a ui-sref="xmlFile" data-toggle="collapse" data-target=".navbar-collapse.in"><span class="glyphicon glyphicon-asterisk"></span>
<li ui-sref-active="active" has-authority="ROLE_ADMIN"><a ui-sref="xmlFile" data-toggle="collapse" data-target=".navbar-collapse.in"><span class="glyphicon glyphicon-asterisk"></span>
&#xA0;<span >Xml file</span></a></li>
<li ui-sref-active="active" ><a ui-sref="metadataTransformer" data-toggle="collapse" data-target=".navbar-collapse.in"><span class="glyphicon glyphicon-asterisk"></span>
<li ui-sref-active="active" has-authority="ROLE_ADMIN"><a ui-sref="metadataTransformer" data-toggle="collapse" data-target=".navbar-collapse.in"><span class="glyphicon glyphicon-asterisk"></span>
&#xA0;<span >Metadata transformer</span></a></li>
<!-- jhipster-needle-add-entity-to-menu - JHipster will add entities to the menu here -->
</ul>
......
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