Commit c76f1c05 authored by Moises Sacal's avatar Moises Sacal

added reducer for checking links for issue #27

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