Commit f1673f15 authored by Gerrit Hübbers's avatar Gerrit Hübbers 🃏
Browse files

Bring bibtex to Angular frontend

parent df019ecf
......@@ -85,6 +85,10 @@ public class BundlesSourceResource {
result.setReference("xmlxslt-bundlessource-" + result.getId() );
result = bundlesSourceRepository.save(result);
}
else if ( result.getType().equals(BundlesSourceType.BIBTEX_SOURCE) ) {
result.setReference("bibtex-bundlessource-" + result.getId() );
result = bundlesSourceRepository.save(result);
}
return ResponseEntity.created(new URI("/api/bundlesSources/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert("bundlesSource", result.getId().toString()))
.body(result);
......
......@@ -189,6 +189,10 @@
<script src="scripts/app/account/userRepositories/publicationsSources-xmlxsltsource-edit-dialog.controller.js"></script>
<script src="scripts/app/account/userRepositories/publicationsSources-xmlxsltsource-delete-dialog.controller.js"></script>
<script src="scripts/app/account/userRepositories/publicationsSources-bibtexsource-create-dialog.controller.js"></script>
<script src="scripts/app/account/userRepositories/publicationsSources-bibtexsource-edit-dialog.controller.js"></script>
<script src="scripts/app/account/userRepositories/publicationsSources-bibtexsource-delete-dialog.controller.js"></script>
<script src="scripts/app/account/userRepositories/userRepositories.js"></script>
<script src="scripts/app/account/userRepositories/userRepositories.controller.js"></script>
<script src="scripts/components/wizardEditor/oaiPmhLinkImporter/oaiPmhLinkImporter.controller.js"></script>
......
'use strict';
angular.module('ddaApp').controller('PublicationsSourcesBibtexSourceCreateDialogController',
['$scope', '$stateParams', '$uibModalInstance', '$state', 'BundlesSource',
function($scope, $stateParams, $uibModalInstance, $state, BundlesSource) {
$scope.bibtexFile = {};
$scope.clear = function() {
$uibModalInstance.dismiss('cancel');
};
var onSaveSuccess = function (result) {
$uibModalInstance.close(result);
};
var onSaveError = function (result) {
};
$scope.save = function () {
var dataObject = {
bibtexFile: $scope.bibtexFile
};
console.log(dataObject);
BundlesSource.createForCurrentUser(
{
'data': angular.toJson(dataObject),
'type': 'BIBTEX_SOURCE',
},
onSaveSuccess,
onSaveError
);
};
}]);
<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">Create a new Bibtex publications source</h4>
</div>
<div class="modal-body">
<label>Bibtex file
<input type="file" name="bibtexFile" fileread="bibtexFile">
</label>
</div>
<div>{{message}}</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>
'use strict';
angular.module('ddaApp')
.controller('PublicationsSourcesBibtexSourceDeleteDialogController', function($scope, $uibModalInstance, entity, BundlesSource) {
$scope.entity = entity;
$scope.clear = function() {
$uibModalInstance.dismiss('cancel');
};
$scope.confirmDelete = function(id) {
BundlesSource.delete({id: entity.id},
function () {
$uibModalInstance.close(true);
});
};
});
<form name="deleteForm" ng-submit="confirmDelete(xmlFile.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title">Confirm delete operation</h4>
</div>
<div class="modal-body">
<jh-alert-error></jh-alert-error>
<p>Are you sure you want to delete Bibtex publication source <i>{{entity.reference}}</i>?</p>
</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>Cancel</span>
</button>
<button type="submit" ng-disabled="deleteForm.$invalid" class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span>Delete</span>
</button>
</div>
</form>
'use strict';
angular.module('ddaApp').controller('PublicationsSourcesBibtexSourceEditDialogController',
['$scope', '$stateParams', '$uibModalInstance', 'entity', '$state', 'BundlesSource', 'MetadataTransformer',
function($scope, $stateParams, $uibModalInstance, entity, $state, BundlesSource, MetadataTransformer) {
$scope.entity = entity;
$scope.dataDto = {
bibtexFile: {
name: angular.fromJson(entity.data).bibtexFile.name,
content: angular.fromJson(entity.data).bibtexFile.content
}
};
$scope.clear = function() {
$uibModalInstance.dismiss('cancel');
};
var onSaveSuccess = function (result) {
$uibModalInstance.close(result);
};
var onSaveError = function (result) {
};
$scope.save = function () {
console.log($scope.dataDto);
BundlesSource.updateData({id: $scope.entity.id}, $scope.dataDto, onSaveSuccess, onSaveError);
};
}]);
<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 Bibtex publication source</h4>
</div>
<div class="modal-body">
<div>
<label>XML file name
<input type="text" name="bibtexName" ng-model="dataDto.bibtexFile.name">
</label>
</div>
<div>
<label>XML content
<textarea name="bibtexContent" cols=80 rows=10 ng-model="dataDto.bibtexFile.content"></textarea>
</label>
</div>
</div>
<div>{{message}}</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>
......@@ -4,7 +4,7 @@
<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">Create a new XSLT-based OAI-PMH publications source</h4>
<h4 class="modal-title" id="myFileLabel">Create a new XSLT-transformed XML publications source</h4>
</div>
<div class="modal-body">
<label>XML file
......
......@@ -9,6 +9,7 @@ angular.module('ddaApp')
$scope.unapiSources = [];
$scope.xsltOaiPmhAddresses = [];
$scope.xmlXsltSources = [];
$scope.bibtexSources = [];
$scope.bundles = [];
$scope.page = 1;
......@@ -33,6 +34,9 @@ angular.module('ddaApp')
$scope.unapiSources = result.filter( function(bundlesSource) {
return bundlesSource.type === 'UNAPI';
});
$scope.bibtexSources = result.filter( function(bundlesSource) {
return bundlesSource.type === 'BIBTEX_SOURCE';
});
})
};
......
......@@ -191,6 +191,64 @@
</div>
<h3>Bibtex files</h3>
<div class="container-fluid">
<div class="row">
<div class="col-xs-4 no-padding-left">
<button class="btn btn-primary" ui-sref="userRepositories.newBibtexSource">
<span class="glyphicon glyphicon-plus"></span>
<span>Add Bibtex file source</span>
</button>
</div>
</div>
</div>
<div class="table-responsive">
<table class="jh-table table table-striped">
<thead>
<tr>
<th><span>Reference</span></th>
<th><span>Bibtex file name</span></th>
<th><span>State</span></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="bibtexSource in bibtexSources track by bibtexSource.id">
<td>{{bibtexSource.reference}}</td>
<td>{{bibtexSource.data | jsonstring2object:"bibtexFile" | jsonstring2object:"name"}}</td>
<td>{{bibtexSource.bundlesSourceState}}</td>
<td translate="{{'ddaApp.BundlesSourceState.' + bundlesSource.bundlesSourceState}}">{{bibtexSource.bundlesSource.bundlesSourceState}}</td>
<td class="text-right">
<div class="btn-group flex-btn-group-container">
<button type="submit"
ng-click="showBundles(bibtexSource.id)"
class="btn btn-info btn-sm">
<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.editBibtexSource({id:bibtexSource.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:bibtexSource.id})"
class="btn btn-warning btn-sm">
<span class="glyphicon glyphicon-apple"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
<button has-authority="ROLE_ADMIN" type="submit"
ui-sref="userRepositories.deleteBibtexSource({id:bibtexSource.id})"
class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-circle"></span>
<span class="hidden-xs hidden-sm"></span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<h3>unAPI</h3>
......
......@@ -473,5 +473,79 @@ angular.module('ddaApp')
}]
})
.state('userRepositories.newBibtexSource', {
parent: 'userRepositories',
url: '/newBibtexSource',
data: {
authorities: ['ROLE_USER'],
},
onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) {
$uibModal.open({
templateUrl: 'scripts/app/account/userRepositories/publicationsSources-bibtexsource-create-dialog.html',
controller: 'PublicationsSourcesBibtexSourceCreateDialogController',
size: 'lg',
resolve: {
entity: function () {
return {
bibtexFile: null,
};
}
}
}).result.then(function(result) {
$state.go('userRepositories', null, { reload: true });
}, function() {
$state.go('userRepositories', null, { reload: true });
})
}]
})
.state('userRepositories.editBibtexSource', {
parent: 'userRepositories',
url: '/{id}/editBibtexSource',
data: {
authorities: ['ROLE_USER'],
},
onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) {
$uibModal.open({
templateUrl: 'scripts/app/account/userRepositories/publicationsSources-bibtexsource-edit-dialog.html',
controller: 'PublicationsSourcesBibtexSourceEditDialogController',
size: 'lg',
resolve: {
entity: ['BundlesSource', function(BundlesSource) {
var result = BundlesSource.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.deleteBibtexSource', {
parent: 'userRepositories',
url: '/{id}/deleteBibtexSource',
data: {
authorities: ['ROLE_USER'],
},
onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) {
$uibModal.open({
templateUrl: 'scripts/app/account/userRepositories/publicationsSources-bibtexsource-delete-dialog.html',
controller: 'PublicationsSourcesBibtexSourceDeleteDialogController',
size: 'md',
resolve: {
entity: ['BundlesSource', function(BundlesSource) {
return BundlesSource.get({id : $stateParams.id});
}]
}
}).result.then(function(result) {
$state.go('userRepositories', null, { reload: true });
}, function() {
$state.go('^');
})
}]
})
;
});
Supports Markdown
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