Commit c76f1c05 authored by Moises Sacal's avatar Moises Sacal
Browse files

added reducer for checking links for issue #27

parent ba3d887a
This diff is collapsed.
...@@ -67,7 +67,7 @@ export class LabarchivesListField extends FieldBase<any> { ...@@ -67,7 +67,7 @@ export class LabarchivesListField extends FieldBase<any> {
return { return {
id: nb['id'], id: nb['id'],
name: nb['name'], name: nb['name'],
isDefault: nb['is-default']['_'] == 'true' ? this.defaultNotebookLabel : '', isDefault: nb['is-default']['_'] == 'true' ? this.defaultNotebookLabel : '',
rdmp: {info: ''} rdmp: {info: ''}
} }
}); });
...@@ -90,25 +90,26 @@ export class LabarchivesListField extends FieldBase<any> { ...@@ -90,25 +90,26 @@ export class LabarchivesListField extends FieldBase<any> {
} }
checkLinks() { checkLinks() {
//this.workspaces[index]['linkedState'] == 'check'; // Possible values: linked, another, link this.workspaces.reduce((promise, w, index) => {
this.workspaces.map((w, index) => { return promise.then(() => {
this.labarchivesService.checkLink(this.rdmp, w['id']) return this.labarchivesService.checkLink(this.rdmp, w['id'])
.then((response) => { .then((response) => {
if (!response.status) { if (!response.status) {
throw new Error('Error checking workspace'); throw new Error('Error checking workspace');
} else {
const check = response['check'];
if (check['link'] === 'linked') {
this.workspaces[index]['linkedState'] = 'linked';
} else { } else {
this.workspaces[index]['linkedState'] = 'link'; const check = response['check'];
if (check['link'] === 'linked') {
this.workspaces[index]['linkedState'] = 'linked';
} else {
this.workspaces[index]['linkedState'] = 'link';
}
} }
} })
}) .catch((error) => {
.catch((error) => { this.workspaces[index]['linkedState'] = 'problem';
this.workspaces[index]['linkedState'] = 'problem'; });
}); });
}); }, Promise.resolve());
} }
} }
......
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