change lock service

This commit is contained in:
amentis 2023-12-11 18:55:20 +02:00
parent 28fad3ccc4
commit 2a00fe7ec1
9 changed files with 29 additions and 21 deletions

View File

@ -51,13 +51,13 @@ export class LockService {
}
//ToDo change Parameters
checkLockStatus(id: string): Observable<boolean> {
return this.http.get(`${this.apiBase}/target/status/${id}`, { headers: this.headers });
checkLockStatus(targetId: Guid): Observable<boolean> {
return this.http.get(`${this.apiBase}/target/status/${targetId}`, { headers: this.headers });
}
//ToDo change Parameters
unlockTarget(id: string): Observable<any> {
return this.http.delete(`${this.apiBase}/target/unlock/${id}`, { headers: this.headers });
unlockTarget(targetId: Guid): Observable<any> {
return this.http.delete(`${this.apiBase}/target/unlock/${targetId}`, { headers: this.headers });
}
getSingleWithTarget(targetId: Guid, reqFields: string[] = []): Observable<Lock> {

View File

@ -197,7 +197,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.datasetWizardService.getSingle(this.itemId)
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockService.checkLockStatus(Guid.parse(data.id)).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockStatus = lockStatus;
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex;
@ -343,7 +343,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.datasetWizardService.getSingle(this.itemId)
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockService.checkLockStatus(Guid.parse(data.id)).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockStatus = lockStatus;
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex;
@ -610,7 +610,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
public cancel(): void {
if (!isNullOrUndefined(this.lock)) {
this.lockService.unlockTarget(this.datasetWizardModel.id).pipe(takeUntil(this._destroyed)).subscribe(
this.lockService.unlockTarget(Guid.parse(this.datasetWizardModel.id)).pipe(takeUntil(this._destroyed)).subscribe(
complete => {
this.publicMode ? this.router.navigate(['/explore-descriptions']) : this.router.navigate(['/datasets']);
},

View File

@ -21,6 +21,7 @@ import { takeUntil } from 'rxjs/operators';
import { DatasetStatus } from '../../../../core/common/enum/dataset-status';
import { DatasetListingModel } from '../../../../core/model/dataset/dataset-listing';
import { DatasetCopyDialogueComponent } from '../../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component';
import { Guid } from '@common/types/guid';
@Component({
selector: 'app-dataset-listing-item-component',
@ -168,7 +169,7 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
}
deleteClicked(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
this.lockService.checkLockStatus(Guid.parse(id)).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDialog(id);

View File

@ -32,6 +32,7 @@ import { TranslateService } from '@ngx-translate/core';
import * as FileSaver from 'file-saver';
import { filter, takeUntil } from 'rxjs/operators';
import { DatasetCopyDialogueComponent } from '../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component';
import { Guid } from '@common/types/guid';
@Component({
@ -137,7 +138,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
}
checkLockStatus(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
this.lockService.checkLockStatus(Guid.parse(id)).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
this.lockStatus = lockStatus
if (lockStatus) {

View File

@ -181,7 +181,7 @@ export class DescriptionListingItemComponent extends BaseComponent implements On
}
deleteClicked(id: Guid) {
this.lockService.checkLockStatus(id.toString()).pipe(takeUntil(this._destroyed))
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDialog(id);

View File

@ -16,7 +16,7 @@ import { DmpDatasetProfile } from '@app/core/model/dmp/dmp-dataset-profile/dmp-d
import { DmpDatasetProfileSectionsFormModel } from '@app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile-sections-form.model';
import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item';
import { LanguageInfo } from '@app/core/model/language-info';
import { LockModel } from '@app/core/model/lock/lock.model';
import { Lock, LockPersist } from '@app/core/model/lock/lock.model';
import { UserModel } from '@app/core/model/user/user';
import { UserInfoListingModel } from '@app/core/model/user/user-info-listing';
import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria';
@ -58,6 +58,7 @@ import { ProjectFormModel } from '../editor/grant-tab/project-form-model';
import { ReferenceSearchDefinitionLookup, ReferenceSearchLookup } from '@app/core/query/reference-search.lookup';
import { Reference } from '@app/core/model/reference/reference';
import { ReferenceTypeEditorResolver } from '@app/ui/admin/reference-type/editor/reference-type-editor.resolver';
import { LockTargetType } from '@app/core/common/enum/lock-target-type';
interface Visible {
value: boolean;
@ -99,7 +100,8 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
associatedUsers: Array<UserModel>;
people: Array<UserInfoListingModel>;
lock: LockModel;
lock: Lock;
lockPersist: LockPersist;
lockStatus: Boolean = false;
step: number = 0;
@ -181,7 +183,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
this.dmpService.getSingle(itemId).pipe(map(data => data as DmpModel))
.pipe(takeUntil(this._destroyed))
.subscribe(async data => {
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockService.checkLockStatus(Guid.parse(data.id)).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockStatus = lockStatus;
this.dmp = new DmpEditorModel();
@ -228,10 +230,14 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
if (this.authService.currentAccountIsAuthenticated()) {
if (!lockStatus) {
this.lock = new LockModel(data.id, this.getUserFromDMP());
const persist : LockPersist = null;
persist.target = Guid.parse(data.id);
persist.targetType = LockTargetType.Dmp;
persist.lockedBy = this.getUserFromDMP();
// this.lock = new LockModel(data.id, this.getUserFromDMP());
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock.id = Guid.parse(result);
this.lockService.persist(persist).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock = result;
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
});
}
@ -351,7 +357,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
private pumpLock() {
this.lock.touchedAt = new Date();
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => this.lock.id = Guid.parse(result));
//his.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => this.lock.id = Guid.parse(result));
}
public isDirty(): boolean {

View File

@ -159,7 +159,7 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
this.dmpService.getSingle(itemId).pipe(map(data => data as DmpModel))
.pipe(takeUntil(this._destroyed))
.subscribe(async data => {
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockService.checkLockStatus(Guid.parse(data.id)).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockStatus = lockStatus;
this.dmpModel = data;
@ -591,7 +591,7 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
public cancel(id: String): void {
if (id != null) {
this.lockService.unlockTarget(this.dmp.id).pipe(takeUntil(this._destroyed)).subscribe(
this.lockService.unlockTarget(Guid.parse(this.dmp.id)).pipe(takeUntil(this._destroyed)).subscribe(
complete => {
this.router.navigate(['/plans/overview/' + id]);
},

View File

@ -237,7 +237,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
// }
deleteClicked(id: Guid) {
this.lockService.checkLockStatus(id.toString()).pipe(takeUntil(this._destroyed))
this.lockService.checkLockStatus(Guid.parse(id.toString())).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDialog(id);

View File

@ -695,7 +695,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
}
checkLockStatus(id: Guid) {
this.lockService.checkLockStatus(id.toString()).pipe(takeUntil(this._destroyed))
this.lockService.checkLockStatus(Guid.parse(id.toString())).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
this.lockStatus = lockStatus
if (lockStatus) {