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 { ResearcherModel } from '@app/core/model/researcher/researcher';
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 { 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 {
dataset: DatasetOverviewModel;
datasetWizardEditorModel: DatasetWizardEditorModel;
// datasetWizardEditorModel: DatasetWizardEditorModel;
datasetWizardModel: DatasetWizardModel;
isNew = true;
isFinalized = false;
@ -90,9 +88,11 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.dataset = data;
this.getDmpResearchers();
this.getDmpUsers();
this.getDatasetWizardModel(this.dataset.id);
this.researchers = this.dataset.dmp.researchers;
this.users = this.dataset.dmp.users;
// this.getDmpResearchers();
// this.getDmpUsers();
// this.getDatasetWizardModel(this.dataset.id);
this.checkLockStatus(this.dataset.id);
this.setIsUserOwner();
const breadCrumbs = [];
@ -116,9 +116,11 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.dataset = data;
this.getDmpResearchers();
this.getDmpUsers();
this.getDatasetWizardModel(this.dataset.id);
this.researchers = this.dataset.dmp.researchers;
this.users = this.dataset.dmp.users;
// this.getDmpResearchers();
// this.getDmpUsers();
// this.getDatasetWizardModel(this.dataset.id);
// this.checkLockStatus(this.dataset.id);
const breadCrumbs = [];
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)
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.datasetWizardEditorModel = new DatasetWizardEditorModel().fromModel(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]));
}
getDmpResearchers() {
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.researchers = data.researchers;
});
}
// getDmpResearchers() {
// this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
// .subscribe(data => {
// this.researchers = data.researchers;
// });
// }
getDmpUsers() {
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.users = data.users;
});
}
// getDmpUsers() {
// this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
// .subscribe(data => {
// this.users = data.users;
// });
// }
setIsUserOwner() {
if (this.dataset) {
@ -264,11 +265,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
editClicked(dataset: DatasetOverviewModel) {
if (dataset.public) {
let url = this.router.createUrlTree(['/datasets/publicEdit/', dataset.id])
window.open(url.toString(), '_blank')
let url = this.router.createUrlTree(['/datasets/publicEdit/', dataset.id]);
window.open(url.toString(), '_blank');
} else {
let url = this.router.createUrlTree(['/datasets/edit/', dataset.id])
window.open(url.toString(), '_blank')
// let url = this.router.createUrlTree(['/datasets/edit/', dataset.id]);
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: {
formControl: formControl,
datasetId: this.dataset.id,
datasetProfileId: this.datasetWizardEditorModel.profile,
datasetProfileId: this.dataset.datasetTemplate.id,
datasetProfileExist: false,
confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'),
cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL')