|
|
@ -10,11 +10,12 @@ import { |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectorRef, |
|
|
ChangeDetectorRef, |
|
|
Component, |
|
|
Component, |
|
|
|
|
|
DestroyRef, |
|
|
Input, |
|
|
Input, |
|
|
OnDestroy, |
|
|
|
|
|
OnInit, |
|
|
OnInit, |
|
|
ViewChild |
|
|
ViewChild |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
import { MatMenuModule } from '@angular/material/menu'; |
|
|
import { MatMenuModule } from '@angular/material/menu'; |
|
|
@ -31,7 +32,6 @@ import { |
|
|
} from 'ionicons/icons'; |
|
|
} from 'ionicons/icons'; |
|
|
import { get } from 'lodash'; |
|
|
import { get } from 'lodash'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { Subject, takeUntil } from 'rxjs'; |
|
|
|
|
|
|
|
|
|
|
|
import { GfCreateOrUpdateTagDialogComponent } from './create-or-update-tag-dialog/create-or-update-tag-dialog.component'; |
|
|
import { GfCreateOrUpdateTagDialogComponent } from './create-or-update-tag-dialog/create-or-update-tag-dialog.component'; |
|
|
import { CreateOrUpdateTagDialogParams } from './create-or-update-tag-dialog/interfaces/interfaces'; |
|
|
import { CreateOrUpdateTagDialogParams } from './create-or-update-tag-dialog/interfaces/interfaces'; |
|
|
@ -51,7 +51,7 @@ import { CreateOrUpdateTagDialogParams } from './create-or-update-tag-dialog/int |
|
|
styleUrls: ['./admin-tag.component.scss'], |
|
|
styleUrls: ['./admin-tag.component.scss'], |
|
|
templateUrl: './admin-tag.component.html' |
|
|
templateUrl: './admin-tag.component.html' |
|
|
}) |
|
|
}) |
|
|
export class GfAdminTagComponent implements OnDestroy, OnInit { |
|
|
export class GfAdminTagComponent implements OnInit { |
|
|
@Input() locale = getLocale(); |
|
|
@Input() locale = getLocale(); |
|
|
|
|
|
|
|
|
@ViewChild(MatSort) sort: MatSort; |
|
|
@ViewChild(MatSort) sort: MatSort; |
|
|
@ -61,11 +61,10 @@ export class GfAdminTagComponent implements OnDestroy, OnInit { |
|
|
public displayedColumns = ['name', 'userId', 'activities', 'actions']; |
|
|
public displayedColumns = ['name', 'userId', 'activities', 'actions']; |
|
|
public tags: Tag[]; |
|
|
public tags: Tag[]; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
|
|
|
private destroyRef: DestroyRef, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private dialog: MatDialog, |
|
|
private dialog: MatDialog, |
|
|
private notificationService: NotificationService, |
|
|
private notificationService: NotificationService, |
|
|
@ -74,7 +73,7 @@ export class GfAdminTagComponent implements OnDestroy, OnInit { |
|
|
private userService: UserService |
|
|
private userService: UserService |
|
|
) { |
|
|
) { |
|
|
this.route.queryParams |
|
|
this.route.queryParams |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((params) => { |
|
|
.subscribe((params) => { |
|
|
if (params['createTagDialog']) { |
|
|
if (params['createTagDialog']) { |
|
|
this.openCreateTagDialog(); |
|
|
this.openCreateTagDialog(); |
|
|
@ -116,20 +115,15 @@ export class GfAdminTagComponent implements OnDestroy, OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private deleteTag(aId: string) { |
|
|
private deleteTag(aId: string) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.deleteTag(aId) |
|
|
.deleteTag(aId) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe({ |
|
|
.subscribe({ |
|
|
next: () => { |
|
|
next: () => { |
|
|
this.userService |
|
|
this.userService |
|
|
.get(true) |
|
|
.get(true) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(); |
|
|
.subscribe(); |
|
|
|
|
|
|
|
|
this.fetchTags(); |
|
|
this.fetchTags(); |
|
|
@ -140,7 +134,7 @@ export class GfAdminTagComponent implements OnDestroy, OnInit { |
|
|
private fetchTags() { |
|
|
private fetchTags() { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.fetchTags() |
|
|
.fetchTags() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((tags) => { |
|
|
.subscribe((tags) => { |
|
|
this.tags = tags; |
|
|
this.tags = tags; |
|
|
|
|
|
|
|
|
@ -171,17 +165,17 @@ export class GfAdminTagComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
dialogRef |
|
|
dialogRef |
|
|
.afterClosed() |
|
|
.afterClosed() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((tag: CreateTagDto | null) => { |
|
|
.subscribe((tag: CreateTagDto | null) => { |
|
|
if (tag) { |
|
|
if (tag) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.postTag(tag) |
|
|
.postTag(tag) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe({ |
|
|
.subscribe({ |
|
|
next: () => { |
|
|
next: () => { |
|
|
this.userService |
|
|
this.userService |
|
|
.get(true) |
|
|
.get(true) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(); |
|
|
.subscribe(); |
|
|
|
|
|
|
|
|
this.fetchTags(); |
|
|
this.fetchTags(); |
|
|
@ -210,17 +204,17 @@ export class GfAdminTagComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
dialogRef |
|
|
dialogRef |
|
|
.afterClosed() |
|
|
.afterClosed() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((tag: UpdateTagDto | null) => { |
|
|
.subscribe((tag: UpdateTagDto | null) => { |
|
|
if (tag) { |
|
|
if (tag) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.putTag(tag) |
|
|
.putTag(tag) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe({ |
|
|
.subscribe({ |
|
|
next: () => { |
|
|
next: () => { |
|
|
this.userService |
|
|
this.userService |
|
|
.get(true) |
|
|
.get(true) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(); |
|
|
.subscribe(); |
|
|
|
|
|
|
|
|
this.fetchTags(); |
|
|
this.fetchTags(); |
|
|
|