16
ui/src/app/services/confirm/confirm.service.spec.ts
Normal file
16
ui/src/app/services/confirm/confirm.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ConfirmService } from './confirm.service';
|
||||
|
||||
describe('ConfirmService', () => {
|
||||
let service: ConfirmService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ConfirmService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
28
ui/src/app/services/confirm/confirm.service.ts
Normal file
28
ui/src/app/services/confirm/confirm.service.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dialog';
|
||||
import { map, Observable, take } from 'rxjs';
|
||||
import { ConfirmDialogComponent } from '../../components/confirm-dialog/confirm-dialog.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ConfirmService {
|
||||
|
||||
dialogRef!: MatDialogRef<ConfirmDialogComponent>;
|
||||
|
||||
constructor(
|
||||
private dialog: MatDialog
|
||||
) { }
|
||||
|
||||
|
||||
public open(options: MatDialogConfig) {
|
||||
this.dialogRef = this.dialog.open(ConfirmDialogComponent, options);
|
||||
}
|
||||
|
||||
public confirmed(): Observable<any> {
|
||||
return this.dialogRef.afterClosed().pipe(take(1), map(res => {
|
||||
return res;
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
16
ui/src/app/services/message/message.service.spec.ts
Normal file
16
ui/src/app/services/message/message.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MessageService } from './message.service';
|
||||
|
||||
describe('MessageService', () => {
|
||||
let message: MessageService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
message = TestBed.inject(MessageService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(message).toBeTruthy();
|
||||
});
|
||||
});
|
22
ui/src/app/services/message/message.service.ts
Normal file
22
ui/src/app/services/message/message.service.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MessageService {
|
||||
|
||||
constructor(
|
||||
private snackbar: MatSnackBar,
|
||||
) {
|
||||
}
|
||||
|
||||
showMessage(message: string, action?: string, config?: MatSnackBarConfig) {
|
||||
let cfg = config
|
||||
if (!cfg) {
|
||||
cfg = { duration: 2000 }
|
||||
}
|
||||
this.snackbar.open(message, action, cfg);
|
||||
}
|
||||
}
|
16
ui/src/app/services/packages/packages.service.spec.ts
Normal file
16
ui/src/app/services/packages/packages.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ServicesService } from './packages.service';
|
||||
|
||||
describe('ServicesService', () => {
|
||||
let service: ServicesService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ServicesService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
28
ui/src/app/services/packages/packages.service.ts
Normal file
28
ui/src/app/services/packages/packages.service.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dialog';
|
||||
import { map, Observable, take } from 'rxjs';
|
||||
import { PackageDialogComponent } from '../../components/package-dialog/package-dialog.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PackagesService {
|
||||
|
||||
dialogRef!: MatDialogRef<PackageDialogComponent>;
|
||||
|
||||
constructor(
|
||||
private dialog: MatDialog
|
||||
) { }
|
||||
|
||||
|
||||
public open(options: MatDialogConfig) {
|
||||
this.dialogRef = this.dialog.open(PackageDialogComponent, options);
|
||||
}
|
||||
|
||||
public confirmed(): Observable<any> {
|
||||
return this.dialogRef.afterClosed().pipe(take(1), map(res => {
|
||||
return res;
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user