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

Feature client transfer #411

Merged
merged 16 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/abilities/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,20 @@ export default Ability.extend({
return false;
}
}),
canTransfer: computed('currentUser.role_id', function() {
switch (this.get('currentUser.role_id')) {
case 'staff_admin':
return true;
default:
return false;
}
}),
canMove: computed('currentUser.role_id', function() {
switch (this.get('currentUser.role_id')) {
case 'staff_admin':
return true;
default:
return false;
}
}),
});
67 changes: 67 additions & 0 deletions app/components/repository-dois-transfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';

export default Component.extend({
currentUser: service(),
store: service(),
flashMessages: service(),
intl: service(),

tagName: 'div',
classNames: [ 'row' ],
provider: null,
repository: null,
repositories: [],
isDisabled: true,

didReceiveAttrs() {
this._super(...arguments);

this.searchRepository(null);
},

searchRepository(query) {
let self = this;
if (this.currentUser.get('isAdmin')) {
this.store.query('repository', { query, sort: 'name', 'page[size]': 100 }).then(function(repositories) {
self.set('repositories', repositories);
}).catch(function(reason) {
console.debug(reason);
self.set('repositories', []);
});
} else if (this.currentUser.get('isProvider')) {
this.store.query('repository', { query, 'provider-id': this.currentUser.get('provider_id'), sort: 'name', 'page[size]': 100 }).then(function(repositories) {
self.set('repositories', repositories);
}).catch(function(reason) {
console.debug(reason);
self.set('repositories', []);
});
}
},
selectRepository(repository) {
this.set('repository', repository);
this.set('isDisabled', (repository === null) || (repository.id === this.get('model.id')));
this.model.set('targetId', repository.id);
},

actions: {
searchRepository(query) {
this.searchRepository(query);
},
selectRepository(repository) {
this.selectRepository(repository);
},
submit() {
this.model.save();
let count = this.model.get('meta.doiCount');
this.flashMessages.success('DOI transfer for ' + this.intl.formatNumber(count) + ' DOIs started, the transfer should take about ' + this.intl.formatNumber(Math.ceil(count / 5000) + 1) + ' minutes to complete.', {
timeout: 5000,
sticky: true,
});
this.router.transitionTo('repositories.show', this.model);
},
cancel() {
this.router.transitionTo('repositories.show.dois', this.model);
},
},
});
46 changes: 23 additions & 23 deletions app/components/repository-transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,45 @@ export default Component.extend({
classNames: [ 'row' ],
provider: null,
repository: null,
repositories: [],
providers: [],
isDisabled: true,

remainingProviders(providers) {
return providers.filter(function(item) {
console.log(item);
return [ 'direct_member', 'consortium_organization' ].includes(item.memberType);
});
},

didReceiveAttrs() {
this._super(...arguments);

this.searchRepository(null);
this.model.set('mode', 'transfer');
this.searchProvider(null);
},

searchRepository(query) {
searchProvider(query) {
let self = this;
if (this.currentUser.get('isAdmin')) {
this.store.query('repository', { query, sort: 'name', 'page[size]': 100 }).then(function(repositories) {
self.set('repositories', repositories);
this.store.query('provider', { query, sort: 'name', 'page[size]': 100 }).then(function(providers) {
self.set('providers', self.remainingProviders(providers));
}).catch(function(reason) {
console.debug(reason);
self.set('repositories', []);
});
} else if (this.currentUser.get('isProvider')) {
this.store.query('repository', { query, 'provider-id': this.currentUser.get('provider_id'), sort: 'name', 'page[size]': 100 }).then(function(repositories) {
self.set('repositories', repositories);
}).catch(function(reason) {
console.debug(reason);
self.set('repositories', []);
self.set('providers', []);
});
}
},
selectRepository(repository) {
this.set('repository', repository);
this.set('isDisabled', (repository === null) || (repository.id === this.get('model.id')));
this.model.set('targetId', repository.id);
selectProvider(provider) {
this.set('provider', provider);
this.set('isDisabled', false);
this.model.set('targetId', provider.uid);
},

actions: {
searchRepository(query) {
this.searchRepository(query);
searchProvider(query) {
this.searchProvider(query);
},
selectRepository(repository) {
this.selectRepository(repository);
selectProvider(provider) {
this.selectProvider(provider);
},
submit() {
this.model.save();
Expand All @@ -61,7 +61,7 @@ export default Component.extend({
this.router.transitionTo('repositories.show', this.model);
},
cancel() {
this.router.transitionTo('repositories.show.dois', this.model);
this.router.transitionTo('repositories.show', this.model);
},
},
});
4 changes: 4 additions & 0 deletions app/controllers/repositories/show/transfer-repository.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Controller from '@ember/controller';

export default Controller.extend({
});
2 changes: 1 addition & 1 deletion app/models/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { validator, buildValidations } from 'ember-cp-validations';
const Validations = buildValidations({
symbol: [
validator('presence', true),
validator('repository-id', true),
validator('unique-repository-id', {
presence: true,
disabled: computed('model', function() {
Expand Down Expand Up @@ -138,6 +137,7 @@ export default DS.Model.extend(Validations, {
updated: DS.attr('date'),

targetId: DS.attr(),
mode: DS.attr('string'),

domainList: computed('domains', function() {
return this.domains.split(',').map(function(item) {
Expand Down
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Router.map(function() {
this.route('change');
this.route('delete');
this.route('info');
this.route('transfer-repository');
this.route('dois', function() {
this.route('new');
this.route('upload');
Expand Down
4 changes: 4 additions & 0 deletions app/routes/repositories/show/transfer-repository.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Route from '@ember/routing/route';

export default Route.extend({
});
18 changes: 18 additions & 0 deletions app/templates/components/repository-dois-transfer.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="panel panel-transparent">
<div class="panel-body">
<div class="col-md-9 col-md-offset-3"><h3 class="edit">Transfer DOIs</h3></div>

<BsForm @formLayout="horizontal" @horizontalLabelGridClass="col-md-3" @model={{this}} @onSubmit={{action "submit"}} @submitOnEnter={{true}} as |form|>
<form.element @controlType="power-select" @property="repository" @label="Repository" @helpText="Transfer all DOIs to this repository. It can take up to one hour for the transfer to complete." @optionLabelPath="name" @options={{repositories}} @destination={{repository}} as |el|>
<el.control @onChange={{action "selectRepository"}} @search={{action "searchRepository"}} @searchField="name" @searchPlaceholder="Type to search..." @allowClear={{true}} as |item|>
{{item.name}}
</el.control>
</form.element>

<div class="col-md-9 col-md-offset-3">
<button {{action "submit"}} class="btn btn-sm btn-fill" disabled={{isDisabled}}>Transfer DOIs</button>
<button {{action "cancel"}} class="btn btn-sm">Cancel</button>
</div>
</BsForm>
</div>
</div>
33 changes: 25 additions & 8 deletions app/templates/components/repository-transfer.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
<div class="panel panel-transparent">
<div class="panel-body">
<div class="col-md-9 col-md-offset-3"><h3 class="edit">Transfer DOIs</h3></div>
<div class="col-md-9 col-md-offset-3">
<h3 class="edit">Transfer Repository</h3>
</div>

<BsForm @formLayout="horizontal" @horizontalLabelGridClass="col-md-3" @model={{this}} @onSubmit={{action "submit"}} @submitOnEnter={{true}} as |form|>
<form.element @controlType="power-select" @property="repository" @label="Repository" @helpText="Transfer all DOIs to this repository. It can take up to one hour for the transfer to complete." @optionLabelPath="name" @options={{repositories}} @destination={{repository}} as |el|>
<el.control @onChange={{action "selectRepository"}} @search={{action "searchRepository"}} @searchField="name" @searchPlaceholder="Type to search..." @allowClear={{true}} as |item|>
{{item.name}}
</el.control>
</form.element>
<BsForm @formLayout="horizontal" @horizontalLabelGridClass="col-md-3" @model={{this}} @onSubmit={{action "submit"}}
@submitOnEnter={{false}} data-test-transfer-select as |form|>
{{#form.element
controlType="power-select"
id="target-id"
label="Member/Consortium"
value=provider
helpText="Transfer this repository to another member/consortium. It can take up to one hour for the transfer to complete."
options=providers
destination=provider as |el|
}}
{{#el.control
onChange=(action "selectProvider")
allowClear=true
searchEnabled=true
search=(action "searchProvider")
placeholder="Type to search..."
as |item| }}
{{item.name}}
{{/el.control}}
{{/form.element}}

<div class="col-md-9 col-md-offset-3">
<button {{action "submit"}} class="btn btn-sm btn-fill" disabled={{isDisabled}}>Transfer DOIs</button>
<button {{action "submit"}} class="btn btn-sm btn-fill" disabled={{isDisabled}} data-test-transfer-button >Transfer Repository</button>
<button {{action "cancel"}} class="btn btn-sm">Cancel</button>
</div>
</BsForm>
Expand Down
4 changes: 4 additions & 0 deletions app/templates/repositories/show/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
{{#if (can "delete repository" model)}}
<LinkTo @route="repositories.show.delete" @model={{model.id}} class="btn btn-warning" @id="delete-repository">{{fa-icon "trash"}} Delete Repository</LinkTo>
{{/if}}

{{#if (can "transfer repository" model)}}
<LinkTo @route="repositories.show.transfer-repository" @model={{model.id}} class="btn btn-warning" @id="transfer-repository">{{fa-icon "arrow-circle-o-right"}}Transfer{{if media.isXl ' Repository'}}</LinkTo>
{{/if}}
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/templates/repositories/show/transfer-repository.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<RepositoryTransfer @model={{model}} />
2 changes: 1 addition & 1 deletion app/templates/repositories/show/transfer.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<RepositoryTransfer @model={{model}} />
<RepositoryDoisTransfer @model={{model}} />
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@
}
},
{
"_id": "25bb371a0a164acf9fa6857575b70ecb",
"_id": "de7157f9636b4756777cea9d637ba3e6",
"_order": 0,
"cache": {},
"request": {
"bodySize": 731,
"bodySize": 722,
"cookies": [],
"headers": [
{
Expand All @@ -280,7 +280,7 @@
"postData": {
"mimeType": "application/vnd.api+json;charset=utf-8",
"params": [],
"text": "{\"data\":{\"id\":\"10.0330/3nym-s568\",\"attributes\":{\"doi\":\"10.0330/3nym-s568\",\"confirmDoi\":null,\"url\":\"http://datacite18\",\"creators\":[{\"name\":\"\",\"givenName\":null,\"familyName\":null,\"nameType\":\"Personal\",\"nameIdentifiers\":[],\"affiliation\":[]}],\"titles\":[],\"publisher\":null,\"publicationYear\":null,\"subjects\":[],\"contributors\":[],\"alternateIdentifiers\":[],\"dates\":[],\"language\":null,\"types\":{},\"relatedIdentifiers\":[],\"sizes\":[],\"formats\":[],\"version\":null,\"rightsList\":[],\"descriptions\":[],\"geoLocations\":[],\"fundingReferences\":[],\"landingPage\":null,\"xml\":null,\"source\":\"fabricaForm\",\"state\":\"draft\",\"reason\":null,\"event\":null,\"mode\":\"edit\"},\"relationships\":{\"client\":{\"data\":{\"type\":\"repositories\",\"id\":\"datacite.test\"}}},\"type\":\"dois\"}}"
"text": "{\"data\":{\"id\":\"10.0330/3nym-s568\",\"attributes\":{\"doi\":\"10.0330/3nym-s568\",\"confirmDoi\":null,\"url\":\"http://datacite30\",\"creators\":[{\"name\":\"\",\"givenName\":null,\"familyName\":null,\"nameType\":\"Personal\",\"nameIdentifiers\":[],\"affiliation\":[]}],\"titles\":[],\"publisher\":null,\"publicationYear\":null,\"subjects\":[],\"contributors\":[],\"identifiers\":[],\"dates\":[],\"language\":null,\"types\":{},\"relatedIdentifiers\":[],\"sizes\":[],\"formats\":[],\"version\":null,\"rightsList\":[],\"descriptions\":[],\"geoLocations\":[],\"fundingReferences\":[],\"landingPage\":null,\"xml\":null,\"source\":\"fabricaForm\",\"state\":\"draft\",\"reason\":null,\"event\":null,\"mode\":\"edit\"},\"relationships\":{\"client\":{\"data\":{\"type\":\"repositories\",\"id\":\"datacite.test\"}}},\"type\":\"dois\"}}"
},
"queryString": [],
"url": "https://api.test.datacite.org/dois/10.0330%2F3nym-s568"
Expand All @@ -290,7 +290,7 @@
"content": {
"mimeType": "application/json; charset=utf-8",
"size": 2055,
"text": "{\"data\":{\"id\":\"10.0330/3nym-s568\",\"type\":\"dois\",\"attributes\":{\"doi\":\"10.0330/3nym-s568\",\"prefix\":\"10.0330\",\"suffix\":\"3nym-s568\",\"identifiers\":[],\"alternateIdentifiers\":[],\"creators\":[{\"nameType\":\"Personal\",\"nameIdentifiers\":[],\"name\":\"\",\"givenName\":null,\"familyName\":null,\"affiliation\":[]}],\"titles\":[],\"publisher\":null,\"container\":{},\"publicationYear\":null,\"subjects\":[],\"contributors\":[],\"dates\":[],\"language\":null,\"types\":{},\"relatedIdentifiers\":[],\"sizes\":[],\"formats\":[],\"version\":null,\"rightsList\":[],\"descriptions\":[],\"geoLocations\":[],\"fundingReferences\":[],\"xml\":\"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHJlc291cmNlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCIgeHNpOnNjaGVtYUxvY2F0aW9uPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCBodHRwOi8vc2NoZW1hLmRhdGFjaXRlLm9yZy9tZXRhL2tlcm5lbC00L21ldGFkYXRhLnhzZCI+CiAgPGlkZW50aWZpZXIgaWRlbnRpZmllclR5cGU9IkRPSSI+MTAuMDMzMC8zTllNLVM1Njg8L2lkZW50aWZpZXI+CiAgPGNyZWF0b3JzPgogICAgPGNyZWF0b3I+CiAgICAgIDxjcmVhdG9yTmFtZSBuYW1lVHlwZT0iUGVyc29uYWwiLz4KICAgIDwvY3JlYXRvcj4KICA8L2NyZWF0b3JzPgogIDx0aXRsZXMvPgogIDxwdWJsaXNoZXIvPgogIDxwdWJsaWNhdGlvblllYXIvPgogIDxzaXplcy8+CiAgPGZvcm1hdHMvPgogIDx2ZXJzaW9uLz4KPC9yZXNvdXJjZT4K\",\"url\":\"http://datacite18\",\"contentUrl\":null,\"metadataVersion\":1,\"schemaVersion\":\"http://datacite.org/schema/kernel-4\",\"source\":\"fabricaForm\",\"isActive\":false,\"state\":\"draft\",\"reason\":null,\"landingPage\":null,\"viewCount\":0,\"viewsOverTime\":[],\"downloadCount\":0,\"downloadsOverTime\":[],\"referenceCount\":0,\"citationCount\":0,\"citationsOverTime\":[],\"partCount\":0,\"partOfCount\":0,\"versionCount\":0,\"versionOfCount\":0,\"created\":\"2020-04-23T07:40:07.000Z\",\"registered\":null,\"published\":\"\",\"updated\":\"2020-05-04T16:41:45.000Z\"},\"relationships\":{\"client\":{\"data\":{\"id\":\"datacite.test\",\"type\":\"clients\"}},\"media\":{\"data\":{\"id\":\"10.0330/3nym-s568\",\"type\":\"media\"}},\"references\":{\"data\":[]},\"citations\":{\"data\":[]},\"parts\":{\"data\":[]},\"partOf\":{\"data\":[]},\"versions\":{\"data\":[]},\"versionOf\":{\"data\":[]}}}}"
"text": "{\"data\":{\"id\":\"10.0330/3nym-s568\",\"type\":\"dois\",\"attributes\":{\"doi\":\"10.0330/3nym-s568\",\"prefix\":\"10.0330\",\"suffix\":\"3nym-s568\",\"identifiers\":[],\"alternateIdentifiers\":[],\"creators\":[{\"nameType\":\"Personal\",\"nameIdentifiers\":[],\"name\":\"\",\"givenName\":null,\"familyName\":null,\"affiliation\":[]}],\"titles\":[],\"publisher\":null,\"container\":{},\"publicationYear\":null,\"subjects\":[],\"contributors\":[],\"dates\":[],\"language\":null,\"types\":{},\"relatedIdentifiers\":[],\"sizes\":[],\"formats\":[],\"version\":null,\"rightsList\":[],\"descriptions\":[],\"geoLocations\":[],\"fundingReferences\":[],\"xml\":\"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHJlc291cmNlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCIgeHNpOnNjaGVtYUxvY2F0aW9uPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCBodHRwOi8vc2NoZW1hLmRhdGFjaXRlLm9yZy9tZXRhL2tlcm5lbC00L21ldGFkYXRhLnhzZCI+CiAgPGlkZW50aWZpZXIgaWRlbnRpZmllclR5cGU9IkRPSSI+MTAuMDMzMC8zTllNLVM1Njg8L2lkZW50aWZpZXI+CiAgPGNyZWF0b3JzPgogICAgPGNyZWF0b3I+CiAgICAgIDxjcmVhdG9yTmFtZSBuYW1lVHlwZT0iUGVyc29uYWwiLz4KICAgIDwvY3JlYXRvcj4KICA8L2NyZWF0b3JzPgogIDx0aXRsZXMvPgogIDxwdWJsaXNoZXIvPgogIDxwdWJsaWNhdGlvblllYXIvPgogIDxzaXplcy8+CiAgPGZvcm1hdHMvPgogIDx2ZXJzaW9uLz4KPC9yZXNvdXJjZT4K\",\"url\":\"http://datacite30\",\"contentUrl\":null,\"metadataVersion\":1,\"schemaVersion\":\"http://datacite.org/schema/kernel-4\",\"source\":\"fabricaForm\",\"isActive\":false,\"state\":\"draft\",\"reason\":null,\"landingPage\":null,\"viewCount\":0,\"viewsOverTime\":[],\"downloadCount\":0,\"downloadsOverTime\":[],\"referenceCount\":0,\"citationCount\":0,\"citationsOverTime\":[],\"partCount\":0,\"partOfCount\":0,\"versionCount\":0,\"versionOfCount\":0,\"created\":\"2020-04-23T07:40:07.000Z\",\"registered\":null,\"published\":\"\",\"updated\":\"2020-05-15T09:40:40.000Z\"},\"relationships\":{\"client\":{\"data\":{\"id\":\"datacite.test\",\"type\":\"clients\"}},\"media\":{\"data\":{\"id\":\"10.0330/3nym-s568\",\"type\":\"media\"}},\"references\":{\"data\":[]},\"citations\":{\"data\":[]},\"parts\":{\"data\":[]},\"partOf\":{\"data\":[]},\"versions\":{\"data\":[]},\"versionOf\":{\"data\":[]}}}}"
},
"cookies": [],
"headers": [
Expand All @@ -309,16 +309,16 @@
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2020-05-04T16:41:45.156Z",
"time": 250,
"startedDateTime": "2020-05-15T09:40:40.408Z",
"time": 227,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 250
"wait": 227
}
}
],
Expand Down
Loading