Removes unecessary requests from dataset overview

This commit is contained in:
apapachristou 2020-08-03 17:55:59 +03:00
parent 58b193ff20
commit 9ffa1a5a54
1 changed files with 29 additions and 27 deletions

View File

@ -28,8 +28,6 @@ import { DatasetCopyDialogueComponent } from '../dataset-wizard/dataset-copy-dia
import { DmpService } from '@app/core/services/dmp/dmp.service'; import { DmpService } from '@app/core/services/dmp/dmp.service';
import { ResearcherModel } from '@app/core/model/researcher/researcher'; import { ResearcherModel } from '@app/core/model/researcher/researcher';
import { LockService } from '@app/core/services/lock/lock.service'; import { LockService } from '@app/core/services/lock/lock.service';
import { DatasetsToBeFinalized } from '@app/core/model/dataset/datasets-toBeFinalized';
import { DatasetModel } from '@app/core/model/dataset/dataset';
import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard';
import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { DmpStatus } from '@app/core/common/enum/dmp-status';
@ -42,7 +40,7 @@ import { DmpStatus } from '@app/core/common/enum/dmp-status';
export class DatasetOverviewComponent extends BaseComponent implements OnInit { export class DatasetOverviewComponent extends BaseComponent implements OnInit {
dataset: DatasetOverviewModel; dataset: DatasetOverviewModel;
datasetWizardEditorModel: DatasetWizardEditorModel; // datasetWizardEditorModel: DatasetWizardEditorModel;
datasetWizardModel: DatasetWizardModel; datasetWizardModel: DatasetWizardModel;
isNew = true; isNew = true;
isFinalized = false; isFinalized = false;
@ -90,9 +88,11 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.dataset = data; this.dataset = data;
this.getDmpResearchers(); this.researchers = this.dataset.dmp.researchers;
this.getDmpUsers(); this.users = this.dataset.dmp.users;
this.getDatasetWizardModel(this.dataset.id); // this.getDmpResearchers();
// this.getDmpUsers();
// this.getDatasetWizardModel(this.dataset.id);
this.checkLockStatus(this.dataset.id); this.checkLockStatus(this.dataset.id);
this.setIsUserOwner(); this.setIsUserOwner();
const breadCrumbs = []; const breadCrumbs = [];
@ -116,9 +116,11 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.dataset = data; this.dataset = data;
this.getDmpResearchers(); this.researchers = this.dataset.dmp.researchers;
this.getDmpUsers(); this.users = this.dataset.dmp.users;
this.getDatasetWizardModel(this.dataset.id); // this.getDmpResearchers();
// this.getDmpUsers();
// this.getDatasetWizardModel(this.dataset.id);
// this.checkLockStatus(this.dataset.id); // this.checkLockStatus(this.dataset.id);
const breadCrumbs = []; const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" }); breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" });
@ -140,7 +142,6 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
this.datasetWizardService.getSingle(id) this.datasetWizardService.getSingle(id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.datasetWizardEditorModel = new DatasetWizardEditorModel().fromModel(data);
this.datasetWizardModel = data; this.datasetWizardModel = data;
}); });
} }
@ -169,19 +170,19 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => this.router.navigate([path])); this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => this.router.navigate([path]));
} }
getDmpResearchers() { // getDmpResearchers() {
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed)) // this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
.subscribe(data => { // .subscribe(data => {
this.researchers = data.researchers; // this.researchers = data.researchers;
}); // });
} // }
getDmpUsers() { // getDmpUsers() {
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed)) // this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
.subscribe(data => { // .subscribe(data => {
this.users = data.users; // this.users = data.users;
}); // });
} // }
setIsUserOwner() { setIsUserOwner() {
if (this.dataset) { if (this.dataset) {
@ -264,11 +265,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
editClicked(dataset: DatasetOverviewModel) { editClicked(dataset: DatasetOverviewModel) {
if (dataset.public) { if (dataset.public) {
let url = this.router.createUrlTree(['/datasets/publicEdit/', dataset.id]) let url = this.router.createUrlTree(['/datasets/publicEdit/', dataset.id]);
window.open(url.toString(), '_blank') window.open(url.toString(), '_blank');
} else { } else {
let url = this.router.createUrlTree(['/datasets/edit/', dataset.id]) // let url = this.router.createUrlTree(['/datasets/edit/', dataset.id]);
window.open(url.toString(), '_blank') let url = this.router.createUrlTree(['/dmp/edit/', dataset.id]);
window.open(url.toString(), '_blank');
} }
} }
@ -398,7 +400,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
data: { data: {
formControl: formControl, formControl: formControl,
datasetId: this.dataset.id, datasetId: this.dataset.id,
datasetProfileId: this.datasetWizardEditorModel.profile, datasetProfileId: this.dataset.datasetTemplate.id,
datasetProfileExist: false, datasetProfileExist: false,
confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'),
cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL')