lockStatus check and icon added to all components

This commit is contained in:
gpapavgeri 2020-07-23 12:35:08 +03:00
parent 3d1b0adc6e
commit 4b267f2f84
14 changed files with 77 additions and 15 deletions

View File

@ -34,6 +34,8 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col">{{'DATASET-LISTING.COLUMNS.GRANT' | translate}}: {{activity.grant}}</span>
</div>
<div class="d-flex flex-direction-row pt-3 pb-3">
@ -54,7 +56,7 @@
<button mat-menu-item (click)="openDmpSearchDialogue(activity.id)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button>
<button mat-menu-item (click)="openConfirm(activity.id)" class="menu-item">
<button mat-menu-item *ngIf="isUserOwner(activity) && !lockStatusMap.get(activity.id)" (click)="openConfirm(activity.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -23,6 +23,8 @@ import { UiNotificationService } from '@app/core/services/notification/ui-notifi
import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component';
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
import { Location } from '@angular/common';
import { Role } from '@app/core/common/enum/role';
import { LockService } from '@app/core/services/lock/lock.service';
@Component({
selector: 'app-drafts',
@ -37,6 +39,7 @@ export class DraftsComponent extends BaseComponent implements OnInit {
datasetDrafts: DatasetListingModel[];
datasetDraftsTypeEnum = RecentActivityType;
status: number;
lockStatusMap = new Map();
totalCount: number;
startIndex: number = 0;
@ -57,7 +60,8 @@ export class DraftsComponent extends BaseComponent implements OnInit {
private datasetWizardService: DatasetWizardService,
public enumUtils: EnumUtils,
private uiNotificationService: UiNotificationService,
private location: Location
private location: Location,
private lockService: LockService
) {
super();
}
@ -74,6 +78,14 @@ export class DraftsComponent extends BaseComponent implements OnInit {
this.datasetDrafts = response.data;
this.totalCount = response.totalCount;
this.totalCountDraftDatasets.emit(this.datasetDrafts.length);
this.datasetDrafts.forEach(recentActivity => {
let lockStatus: Boolean;
this.lockService.checkLockStatus(recentActivity.id).pipe(takeUntil(this._destroyed))
.subscribe(status => {
lockStatus = status;
this.lockStatusMap.set(recentActivity.id, lockStatus);
});
});
});
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed))
@ -191,6 +203,11 @@ export class DraftsComponent extends BaseComponent implements OnInit {
});
}
isUserOwner(activity: DatasetListingModel): boolean {
const principal: Principal = this.authentication.current();
if (principal) return principal.id === activity.users.find(x => x.role === Role.Owner).id;
}
onCallbackSuccess(id?: String): void {
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
id ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', id]); }) : this.router.navigate(['/datasets']);

View File

@ -35,6 +35,8 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col-auto">{{'DMP-LISTING.VERSION' | translate}} {{activity.version}}</span>
<span>.</span>
<span class="col">{{ 'DMP-LISTING.GRANT' | translate }}: {{activity.grant}}</span>
@ -82,7 +84,7 @@
<button mat-menu-item (click)="viewVersions(getGroupId(activity), activity.title)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button>
<button mat-menu-item *ngIf="isUserOwner(activity)" (click)="deleteClicked(activity)" class="menu-item">
<button mat-menu-item *ngIf="isUserOwner(activity) && !lockStatusMap.get(activity.id)" (click)="deleteClicked(activity)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
</button>
</mat-menu>
@ -103,6 +105,8 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col">{{'DATASET-LISTING.COLUMNS.GRANT' | translate}}: {{activity.grant}}</span>
</div>
<div class="d-flex flex-direction-row pt-3 pb-3">
@ -123,7 +127,7 @@
<button mat-menu-item (click)="openDmpSearchDialogue(activity)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button>
<button mat-menu-item (click)="openConfirm(activity.id)" class="menu-item">
<button mat-menu-item *ngIf="isUserOwner(activity) && !lockStatusMap.get(activity.id)" (click)="openConfirm(activity.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -31,6 +31,7 @@ import { FormControl, FormBuilder } from '@angular/forms';
import { DatasetCopyDialogueComponent } from '@app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component';
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
import { Location } from '@angular/common';
import { LockService } from '@app/core/services/lock/lock.service';
@Component({
selector: 'app-recent-edited-activity',
@ -44,6 +45,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
allRecentActivities: RecentActivityModel[];
recentActivityTypeEnum = RecentActivityType;
isDraft: boolean;
lockStatusMap = new Map();
totalCount: number;
startIndex: number = 0;
dmpOffset: number = 0;
@ -66,7 +68,8 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
private dialog: MatDialog,
private uiNotificationService: UiNotificationService,
private datasetWizardService: DatasetWizardService,
private location: Location
private location: Location,
private lockService: LockService
) {
super();
}
@ -85,6 +88,12 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
.subscribe(response => {
this.allRecentActivities = response;
this.allRecentActivities.forEach(recentActivity => {
let lockStatus: Boolean;
this.lockService.checkLockStatus(recentActivity.id).pipe(takeUntil(this._destroyed))
.subscribe(status => {
lockStatus = status;
this.lockStatusMap.set(recentActivity.id, lockStatus);
});
if (recentActivity.type === RecentActivityType.Dataset) {
this.datasetOffset = this.datasetOffset + 1;
} else if (recentActivity.type === RecentActivityType.Dmp) {

View File

@ -34,6 +34,8 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col">{{'DATASET-LISTING.COLUMNS.GRANT' | translate}}: {{activity.grant}}</span>
</div>
<div class="d-flex flex-direction-row pt-3 pb-3">
@ -54,7 +56,7 @@
<button mat-menu-item *ngIf="isAuthenticated()" (click)="openDmpSearchDialogue(activity.id)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button>
<button mat-menu-item *ngIf="isUserOwner(activity)" (click)="openConfirm(activity.id)" class="menu-item">
<button mat-menu-item *ngIf="isUserOwner(activity) && !lockStatusMap.get(activity.id)" (click)="openConfirm(activity.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -24,6 +24,7 @@ import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitat
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
import { Role } from '@app/core/common/enum/role';
import { Location } from '@angular/common';
import { LockService } from '@app/core/services/lock/lock.service';
@Component({
selector: 'app-recent-edited-dataset-activity',
@ -45,6 +46,7 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
// publicMode = false;
order = RecentActivityOrder;
lockStatusMap = new Map();
constructor(
private authentication: AuthService,
@ -55,7 +57,8 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
public router: Router,
private datasetWizardService: DatasetWizardService,
private uiNotificationService: UiNotificationService,
private location: Location
private location: Location,
private lockService: LockService
) {
super();
}
@ -72,6 +75,14 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
.getPaged(datasetDataTableRequest)
.subscribe(response => {
this.datasetActivities = response.data;
this.datasetActivities.forEach(recentActivity => {
let lockStatus: Boolean;
this.lockService.checkLockStatus(recentActivity.id).pipe(takeUntil(this._destroyed))
.subscribe(status => {
lockStatus = status;
this.lockStatusMap.set(recentActivity.id, lockStatus);
});
});
this.totalCount = response.totalCount;
this.totalCountDatasets.emit(this.datasetActivities.length);
});

View File

@ -34,6 +34,8 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col-auto">{{'DMP-LISTING.VERSION' | translate}} {{activity.version}}</span>
<span>.</span>
<span class="col">{{ 'DMP-LISTING.GRANT' | translate }}: {{activity.grant}}</span>
@ -81,7 +83,7 @@
<button mat-menu-item (click)="viewVersions(activity.groupId, activity.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button>
<button mat-menu-item *ngIf="isUserOwner(activity)" (click)="deleteClicked()" class="menu-item">
<button mat-menu-item *ngIf="isUserOwner(activity) && !lockStatusMap.get(activity.id)" (click)="deleteClicked()" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
</button>
</mat-menu>

View File

@ -23,6 +23,7 @@ import { Role } from '@app/core/common/enum/role';
import { FormBuilder, FormControl } from '@angular/forms';
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
import { Location } from '@angular/common';
import { LockService } from '@app/core/services/lock/lock.service';
@Component({
selector: 'app-recent-edited-dmp-activity',
@ -37,6 +38,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
datasetActivities: DatasetListingModel[];
recentActivityTypeEnum = RecentActivityType;
isDraft: boolean;
lockStatusMap = new Map();
totalCount: number;
startIndex: number = 0;
@ -57,7 +59,8 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
private language: TranslateService,
private dialog: MatDialog,
private uiNotificationService: UiNotificationService,
private location: Location
private location: Location,
private lockService: LockService
) {
super();
}
@ -74,6 +77,14 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
.getPaged(dmpDataTableRequest, "listing")
.subscribe(response => {
this.dmpActivities = response.data;
this.dmpActivities.forEach(recentActivity => {
let lockStatus: Boolean;
this.lockService.checkLockStatus(recentActivity.id).pipe(takeUntil(this._destroyed))
.subscribe(status => {
lockStatus = status;
this.lockStatusMap.set(recentActivity.id, lockStatus);
});
});
this.totalCount = response.totalCount;
this.totalCountDmps.emit(this.dmpActivities.length);
// this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize);

View File

@ -12,6 +12,8 @@
<span *ngIf="dataset.status === 1 && dataset.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(dataset.status) }}</span>
<span *ngIf="dataset.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(dataset.status) }}</span>
<span>.</span>
<span *ngIf="lockStatus" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatus">.</span>
<span class="col">{{'DATASET-LISTING.COLUMNS.GRANT' | translate}}: {{dataset.grant}}</span>
</div>
<div class="d-flex flex-direction-row pt-3 pb-3">
@ -32,7 +34,7 @@
<button *ngIf="isAuthenticated()" mat-menu-item (click)="openDmpSearchDialogue(dataset)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button>
<button *ngIf="isUserOwner" mat-menu-item (click)="openConfirm(dataset.id)" class="menu-item">
<button *ngIf="isUserOwner && !lockStatus" mat-menu-item (click)="openConfirm(dataset.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -64,7 +64,6 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
else {
this.isDraft = false;
this.isDeleted = false;
this.checkLockStatus(this.dataset.id);
this.setIsUserOwner();
}
}

View File

@ -103,7 +103,7 @@
<hr class="hr-line">
</div>
</div>
<div *ngIf="hasReversableStatus(dataset) && !lockStatus" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center" (click)="reverse(dataset)">
<div *ngIf="hasReversableStatus(dataset)" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center" (click)="reverse(dataset)">
<button mat-mini-fab class="frame-btn">
<mat-icon class="mat-mini-fab-icon">unarchive</mat-icon>
</button>

View File

@ -148,7 +148,10 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
checkLockStatus(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => this.lockStatus = lockStatus);
.subscribe(lockStatus => {
this.lockStatus = lockStatus;
});
}
onFetchingDeletedCallbackError(redirectRoot: string) {

View File

@ -12,6 +12,8 @@
<span *ngIf="dmp.status === 1 && dmp.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(dmp.status) }}</span>
<span *ngIf="dmp.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(dmp.status) }}</span>
<span>.</span>
<span *ngIf="lockStatus" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatus">.</span>
<span class="col-auto">{{'DMP-LISTING.VERSION' | translate}} {{dmp.version}}</span>
<span>.</span>
<span class="col">{{ 'DMP-LISTING.GRANT' | translate }}: {{dmp.grant}}</span>
@ -59,7 +61,6 @@
<button mat-menu-item (click)="viewVersions(dmp.groupId, dmp.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button>
<!-- <button mat-menu-item *ngIf="isDraftDmp(dmp) && isUserOwner(dmp)" (click)="deleteClicked()" class="menu-item"> -->
<button mat-menu-item *ngIf="isUserOwner(dmp) && !lockStatus" (click)="deleteClicked(dmp)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
</button>

View File

@ -60,7 +60,6 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
this.isDraft = false;
this.isFinalized = true;
this.isPublished = false;
this.checkLockStatus(this.dmp.id);
if (this.dmp.public == true) { this.isPublished = true }
}
}