feat: Added file formatting
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
:host {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
mat-paginator {
|
||||
margin-top: auto;
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
mat-form-field {
|
||||
flex-grow: 1;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
#upper-bar {
|
||||
display: flex;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
button[mat-icon-button] {
|
||||
margin-left: 4pt;
|
||||
margin-right: 4pt;
|
||||
margin-top: 4pt;
|
||||
}
|
||||
margin-left: 4pt;
|
||||
margin-right: 4pt;
|
||||
margin-top: 4pt;
|
||||
}
|
||||
|
||||
@@ -1,52 +1,50 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { AccountMgmtComponent } from './account-mgmt.component';
|
||||
import { AdminCommService } from '../admin-comm.service';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { of } from 'rxjs';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { AccountMgmtComponent } from './account-mgmt.component'
|
||||
import { AdminCommService } from '../admin-comm.service'
|
||||
import { MatDialogModule } from '@angular/material/dialog'
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar'
|
||||
import { MatFormFieldModule } from '@angular/material/form-field'
|
||||
import { MatIconModule } from '@angular/material/icon'
|
||||
import { MatPaginatorModule } from '@angular/material/paginator'
|
||||
import { of } from 'rxjs'
|
||||
import { MatTableModule } from '@angular/material/table'
|
||||
import { MatInputModule } from '@angular/material/input'
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'
|
||||
|
||||
describe('AccountMgmtComponent', () => {
|
||||
let component: AccountMgmtComponent;
|
||||
let fixture: ComponentFixture<AccountMgmtComponent>;
|
||||
let component: AccountMgmtComponent
|
||||
let fixture: ComponentFixture<AccountMgmtComponent>
|
||||
let acMock
|
||||
|
||||
beforeEach(async () => {
|
||||
acMock = {
|
||||
accs: {
|
||||
getAccs: jasmine.createSpy("getAccs").and.returnValue(of())
|
||||
}
|
||||
getAccs: jasmine.createSpy('getAccs').and.returnValue(of()),
|
||||
},
|
||||
}
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [AccountMgmtComponent],
|
||||
providers: [
|
||||
{provide: AdminCommService, useValue: acMock}
|
||||
],
|
||||
providers: [{ provide: AdminCommService, useValue: acMock }],
|
||||
imports: [
|
||||
MatDialogModule,
|
||||
MatSnackBarModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatPaginatorModule,
|
||||
MatTableModule,
|
||||
MatInputModule,
|
||||
MatDialogModule,
|
||||
MatSnackBarModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatPaginatorModule,
|
||||
MatTableModule,
|
||||
MatInputModule,
|
||||
BrowserAnimationsModule,
|
||||
MatProgressSpinnerModule
|
||||
]
|
||||
}).compileComponents();
|
||||
fixture = TestBed.createComponent(AccountMgmtComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
MatProgressSpinnerModule,
|
||||
],
|
||||
}).compileComponents()
|
||||
fixture = TestBed.createComponent(AccountMgmtComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,49 +1,57 @@
|
||||
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { AdminCommService } from '../admin-comm.service';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { UserEditComponent } from './user-edit/user-edit.component';
|
||||
import { LocalStorageService } from 'src/app/services/local-storage.service';
|
||||
import { Group } from 'src/app/types/group';
|
||||
import User from 'src/app/types/user';
|
||||
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core'
|
||||
import { AdminCommService } from '../admin-comm.service'
|
||||
import { MatDialog } from '@angular/material/dialog'
|
||||
import { MatTableDataSource } from '@angular/material/table'
|
||||
import { MatPaginator } from '@angular/material/paginator'
|
||||
import { MatSnackBar } from '@angular/material/snack-bar'
|
||||
import { UserEditComponent } from './user-edit/user-edit.component'
|
||||
import { LocalStorageService } from 'src/app/services/local-storage.service'
|
||||
import { Group } from 'src/app/types/group'
|
||||
import User from 'src/app/types/user'
|
||||
|
||||
@Component({
|
||||
selector: 'app-account-mgmt',
|
||||
templateUrl: './account-mgmt.component.html',
|
||||
styleUrls: ['./account-mgmt.component.scss'],
|
||||
standalone: false
|
||||
selector: 'app-account-mgmt',
|
||||
templateUrl: './account-mgmt.component.html',
|
||||
styleUrls: ['./account-mgmt.component.scss'],
|
||||
standalone: false,
|
||||
})
|
||||
|
||||
|
||||
export class AccountMgmtComponent implements OnInit, AfterViewInit {
|
||||
protected groups: Group[] = []
|
||||
users: MatTableDataSource<Omit<User, "pass">>
|
||||
users: MatTableDataSource<Omit<User, 'pass'>>
|
||||
loading = false
|
||||
@ViewChild(MatPaginator) paginator!: MatPaginator
|
||||
|
||||
constructor(readonly ac:AdminCommService, private dialog: MatDialog, private sb: MatSnackBar, protected readonly ls: LocalStorageService) {
|
||||
this.users = new MatTableDataSource<Omit<User, "pass">>();
|
||||
this.users.filterPredicate = (data: Record<string, any>, filter: string): boolean => {
|
||||
const dataStr = Object.keys(data).reduce((curr: string, key: string) => {
|
||||
if (["_id", "admin", "groups", "__v", "locked"].find(v => v == key)) {
|
||||
return curr + ''
|
||||
}
|
||||
return curr + data[key] + '⫂'
|
||||
}, '').toLowerCase()
|
||||
constructor(
|
||||
readonly ac: AdminCommService,
|
||||
private dialog: MatDialog,
|
||||
private sb: MatSnackBar,
|
||||
protected readonly ls: LocalStorageService
|
||||
) {
|
||||
this.users = new MatTableDataSource<Omit<User, 'pass'>>()
|
||||
this.users.filterPredicate = (
|
||||
data: Record<string, any>,
|
||||
filter: string
|
||||
): boolean => {
|
||||
const dataStr = Object.keys(data)
|
||||
.reduce((curr: string, key: string) => {
|
||||
if (['_id', 'admin', 'groups', '__v', 'locked'].find(v => v == key)) {
|
||||
return curr + ''
|
||||
}
|
||||
return curr + data[key] + '⫂'
|
||||
}, '')
|
||||
.toLowerCase()
|
||||
const filternew = filter.trim().toLowerCase()
|
||||
return dataStr.indexOf(filternew) != -1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.users.paginator = this.paginator
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.loading = true
|
||||
this.ac.accs.getAccs().subscribe((data)=>{
|
||||
this.ac.accs.getAccs().subscribe(data => {
|
||||
this.loading = false
|
||||
this.users.data = data.users
|
||||
this.groups = data.groups
|
||||
@@ -56,9 +64,18 @@ export class AccountMgmtComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
openUserCard(id?: string) {
|
||||
this.dialog.open<UserEditComponent, UserEditComponent.InputData, UserEditComponent.ReturnData>(UserEditComponent, {data: {id: id, type: id ? "edit" : "new", groups: this.groups}}).afterClosed().subscribe(r => {
|
||||
if (r) this.ngOnInit()
|
||||
})
|
||||
this.dialog
|
||||
.open<
|
||||
UserEditComponent,
|
||||
UserEditComponent.InputData,
|
||||
UserEditComponent.ReturnData
|
||||
>(UserEditComponent, {
|
||||
data: { id: id, type: id ? 'edit' : 'new', groups: this.groups },
|
||||
})
|
||||
.afterClosed()
|
||||
.subscribe(r => {
|
||||
if (r) this.ngOnInit()
|
||||
})
|
||||
}
|
||||
|
||||
collumns = ['name', 'surname', 'uname', 'actions']
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { UserDeleteComponent } from './user-delete.component';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { UserDeleteComponent } from './user-delete.component'
|
||||
import { MatDialogModule } from '@angular/material/dialog'
|
||||
|
||||
describe('UserDeleteComponent', () => {
|
||||
let component: UserDeleteComponent;
|
||||
let fixture: ComponentFixture<UserDeleteComponent>;
|
||||
let component: UserDeleteComponent
|
||||
let fixture: ComponentFixture<UserDeleteComponent>
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserDeleteComponent],
|
||||
imports: [MatDialogModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(UserDeleteComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
imports: [MatDialogModule],
|
||||
})
|
||||
fixture = TestBed.createComponent(UserDeleteComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component } from '@angular/core'
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-delete',
|
||||
templateUrl: './user-delete.component.html',
|
||||
styleUrls: ['./user-delete.component.scss'],
|
||||
standalone: false
|
||||
selector: 'app-user-delete',
|
||||
templateUrl: './user-delete.component.html',
|
||||
styleUrls: ['./user-delete.component.scss'],
|
||||
standalone: false,
|
||||
})
|
||||
export class UserDeleteComponent {
|
||||
|
||||
}
|
||||
export class UserDeleteComponent {}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
:host {
|
||||
padding: 8pt;
|
||||
display: block;
|
||||
padding: 8pt;
|
||||
display: block;
|
||||
}
|
||||
|
||||
form {
|
||||
margin-top: 1ch !important;
|
||||
display: flex;
|
||||
grid-auto-flow: column;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 1ch !important;
|
||||
display: flex;
|
||||
grid-auto-flow: column;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
column-gap: 3ch;
|
||||
div {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: repeat(5, 1fr);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
column-gap: 3ch;
|
||||
div {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: repeat(5, 1fr);
|
||||
align-items: center;
|
||||
button {
|
||||
align-self: stretch;
|
||||
justify-self: stretch;
|
||||
height: auto;
|
||||
margin-bottom: 1lh;
|
||||
}
|
||||
button {
|
||||
align-self: stretch;
|
||||
justify-self: stretch;
|
||||
height: auto;
|
||||
margin-bottom: 1lh;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mat-dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { UserEditComponent } from './user-edit.component';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { AdminCommService } from '../../admin-comm.service';
|
||||
import { forwardRef } from '@angular/core';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { UserEditComponent } from './user-edit.component'
|
||||
import {
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialogModule,
|
||||
MatDialogRef,
|
||||
} from '@angular/material/dialog'
|
||||
import { MatFormFieldModule } from '@angular/material/form-field'
|
||||
import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms'
|
||||
import { MatInputModule } from '@angular/material/input'
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'
|
||||
import { AdminCommService } from '../../admin-comm.service'
|
||||
import { forwardRef } from '@angular/core'
|
||||
import { MatSelectModule } from '@angular/material/select'
|
||||
|
||||
describe('UserEditComponent', () => {
|
||||
let component: UserEditComponent;
|
||||
let fixture: ComponentFixture<UserEditComponent>;
|
||||
let component: UserEditComponent
|
||||
let fixture: ComponentFixture<UserEditComponent>
|
||||
let acMock
|
||||
|
||||
beforeEach(async () => {
|
||||
acMock = {
|
||||
|
||||
}
|
||||
acMock = {}
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [UserEditComponent],
|
||||
imports: [
|
||||
@@ -27,20 +29,20 @@ describe('UserEditComponent', () => {
|
||||
ReactiveFormsModule,
|
||||
MatInputModule,
|
||||
NoopAnimationsModule,
|
||||
MatSelectModule
|
||||
MatSelectModule,
|
||||
],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: {} },
|
||||
{ provide: MAT_DIALOG_DATA, useValue: { groups: [] } },
|
||||
{ provide: AdminCommService, useValue: acMock },
|
||||
]
|
||||
}).compileComponents();
|
||||
fixture = TestBed.createComponent(UserEditComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
],
|
||||
}).compileComponents()
|
||||
fixture = TestBed.createComponent(UserEditComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,53 +1,57 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { LocalStorageService } from 'src/app/services/local-storage.service';
|
||||
import { Group } from 'src/app/types/group';
|
||||
import { AdminCommService } from '../../admin-comm.service';
|
||||
import { UserDeleteComponent } from '../user-delete/user-delete.component';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { UserResetComponent } from '../user-reset/user-reset.component';
|
||||
import { catchError, throwError } from 'rxjs';
|
||||
import { DateTime } from 'luxon';
|
||||
import { Component, Inject } from '@angular/core'
|
||||
import {
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialog,
|
||||
MatDialogRef,
|
||||
} from '@angular/material/dialog'
|
||||
import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { LocalStorageService } from 'src/app/services/local-storage.service'
|
||||
import { Group } from 'src/app/types/group'
|
||||
import { AdminCommService } from '../../admin-comm.service'
|
||||
import { UserDeleteComponent } from '../user-delete/user-delete.component'
|
||||
import { MatSnackBar } from '@angular/material/snack-bar'
|
||||
import { UserResetComponent } from '../user-reset/user-reset.component'
|
||||
import { catchError, throwError } from 'rxjs'
|
||||
import { DateTime } from 'luxon'
|
||||
|
||||
export namespace UserEditComponent {
|
||||
export type InputData = {type: "new" | "edit", id?: string, groups: Group[]}
|
||||
export type InputData = { type: 'new' | 'edit'; id?: string; groups: Group[] }
|
||||
export type ReturnData = true | undefined
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-edit',
|
||||
templateUrl: './user-edit.component.html',
|
||||
styleUrls: ['./user-edit.component.scss'],
|
||||
standalone: false
|
||||
selector: 'app-user-edit',
|
||||
templateUrl: './user-edit.component.html',
|
||||
styleUrls: ['./user-edit.component.scss'],
|
||||
standalone: false,
|
||||
})
|
||||
export class UserEditComponent {
|
||||
lockout = false;
|
||||
locked = false;
|
||||
loading = false;
|
||||
export class UserEditComponent {
|
||||
lockout = false
|
||||
locked = false
|
||||
loading = false
|
||||
form: FormGroup = new FormGroup({
|
||||
fname: new FormControl<string>(""),
|
||||
surname: new FormControl<string>(""),
|
||||
room: new FormControl<string>(""),
|
||||
uname: new FormControl<string>(""),
|
||||
fname: new FormControl<string>(''),
|
||||
surname: new FormControl<string>(''),
|
||||
room: new FormControl<string>(''),
|
||||
uname: new FormControl<string>(''),
|
||||
groups: new FormControl<Array<string>>([]),
|
||||
flags: new FormControl<Array<number>>([]),
|
||||
})
|
||||
groups: Group[]
|
||||
id?: string
|
||||
regDate?: DateTime;
|
||||
constructor (
|
||||
public dialogRef: MatDialogRef<UserEditComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: UserEditComponent.InputData,
|
||||
readonly ls: LocalStorageService,
|
||||
readonly acu: AdminCommService,
|
||||
regDate?: DateTime
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<UserEditComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: UserEditComponent.InputData,
|
||||
readonly ls: LocalStorageService,
|
||||
readonly acu: AdminCommService,
|
||||
private dialog: MatDialog,
|
||||
private sb: MatSnackBar
|
||||
) {
|
||||
this.groups = data.groups
|
||||
if (data.type == "edit") {
|
||||
if (data.type == 'edit') {
|
||||
this.id = data.id
|
||||
this.acu.accs.getUser(data.id!).subscribe((r) => {
|
||||
this.acu.accs.getUser(data.id!).subscribe(r => {
|
||||
this.regDate = DateTime.fromISO(r.regDate)
|
||||
var flags: Array<number> = []
|
||||
if (r.admin) {
|
||||
@@ -62,64 +66,83 @@ export class UserEditComponent {
|
||||
}
|
||||
this.locked = r.locked ? true : false
|
||||
this.lockout = r.lockout
|
||||
this.form.get("fname")?.setValue(r.fname)
|
||||
this.form.get("surname")?.setValue(r.surname)
|
||||
this.form.get("room")?.setValue(r.room)
|
||||
this.form.get("uname")?.setValue(r.uname)
|
||||
this.form.get("groups")?.setValue(r.groups)
|
||||
this.form.get("flags")?.setValue(flags)
|
||||
this.form.get('fname')?.setValue(r.fname)
|
||||
this.form.get('surname')?.setValue(r.surname)
|
||||
this.form.get('room')?.setValue(r.room)
|
||||
this.form.get('uname')?.setValue(r.uname)
|
||||
this.form.get('groups')?.setValue(r.groups)
|
||||
this.form.get('flags')?.setValue(flags)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
protected submit() {
|
||||
this.loading = true
|
||||
if (this.data.type == "edit") {
|
||||
this.acu.accs.putAcc(this.id!, this.getForm()).pipe(catchError((err)=>{
|
||||
this.sb.open("Wystąpił błąd. Skontaktuj się z obsługą programu.")
|
||||
return throwError(()=> new Error(err.message))
|
||||
})).subscribe((data)=> {
|
||||
if (data.status == 200) {
|
||||
this.sb.open("Użytkownik został zmodyfikowany.", undefined, {duration: 2500})
|
||||
this.dialogRef.close(true)
|
||||
} else {
|
||||
this.sb.open("Wystąpił błąd. Skontaktuj się z obsługą programu.")
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
if (this.data.type == 'edit') {
|
||||
this.acu.accs
|
||||
.putAcc(this.id!, this.getForm())
|
||||
.pipe(
|
||||
catchError(err => {
|
||||
this.sb.open('Wystąpił błąd. Skontaktuj się z obsługą programu.')
|
||||
return throwError(() => new Error(err.message))
|
||||
})
|
||||
)
|
||||
.subscribe(data => {
|
||||
if (data.status == 200) {
|
||||
this.sb.open('Użytkownik został zmodyfikowany.', undefined, {
|
||||
duration: 2500,
|
||||
})
|
||||
this.dialogRef.close(true)
|
||||
} else {
|
||||
this.sb.open('Wystąpił błąd. Skontaktuj się z obsługą programu.')
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.acu.accs.postAcc(this.getForm()).pipe(catchError((err)=>{
|
||||
this.sb.open("Wystąpił błąd. Skontaktuj się z obsługą programu.")
|
||||
return throwError(()=> new Error(err.message))
|
||||
})).subscribe((data)=> {
|
||||
if (data.status == 201) {
|
||||
this.sb.open("Użytkownik został utworzony.", undefined, {duration: 2500})
|
||||
this.dialogRef.close(true)
|
||||
} else {
|
||||
this.sb.open("Wystąpił błąd. Skontaktuj się z obsługą programu.")
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
this.acu.accs
|
||||
.postAcc(this.getForm())
|
||||
.pipe(
|
||||
catchError(err => {
|
||||
this.sb.open('Wystąpił błąd. Skontaktuj się z obsługą programu.')
|
||||
return throwError(() => new Error(err.message))
|
||||
})
|
||||
)
|
||||
.subscribe(data => {
|
||||
if (data.status == 201) {
|
||||
this.sb.open('Użytkownik został utworzony.', undefined, {
|
||||
duration: 2500,
|
||||
})
|
||||
this.dialogRef.close(true)
|
||||
} else {
|
||||
this.sb.open('Wystąpił błąd. Skontaktuj się z obsługą programu.')
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
protected disableLockout() {
|
||||
this.loading = true
|
||||
this.acu.accs.clearLockout(this.id!).pipe(catchError((err)=>{
|
||||
this.sb.open("Wystąpił błąd. Skontaktuj się z obsługą programu.")
|
||||
return throwError(()=> new Error(err.message))
|
||||
})).subscribe((s) => {
|
||||
if (s.status == 200) {
|
||||
this.loading = false
|
||||
this.lockout = false
|
||||
} else {
|
||||
this.sb.open("Wystąpił błąd. Skontaktuj się z obsługą programu.")
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
this.acu.accs
|
||||
.clearLockout(this.id!)
|
||||
.pipe(
|
||||
catchError(err => {
|
||||
this.sb.open('Wystąpił błąd. Skontaktuj się z obsługą programu.')
|
||||
return throwError(() => new Error(err.message))
|
||||
})
|
||||
)
|
||||
.subscribe(s => {
|
||||
if (s.status == 200) {
|
||||
this.loading = false
|
||||
this.lockout = false
|
||||
} else {
|
||||
this.sb.open('Wystąpił błąd. Skontaktuj się z obsługą programu.')
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
protected getForm() {
|
||||
protected getForm() {
|
||||
return {
|
||||
fname: this.form.get('fname')?.value,
|
||||
surname: this.form.get('surname')?.value,
|
||||
@@ -127,48 +150,60 @@ export class UserEditComponent {
|
||||
uname: this.form.get('uname')?.value,
|
||||
groups: this.form.get('groups')?.value,
|
||||
flags: (() => {
|
||||
var value = this.form.get('flags')?.value.reduce((a: number,b: number)=>a+b,0)
|
||||
var value = this.form
|
||||
.get('flags')
|
||||
?.value.reduce((a: number, b: number) => a + b, 0)
|
||||
if (this.ls.capCheck(32)) {
|
||||
return value
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
})()
|
||||
})(),
|
||||
}
|
||||
}
|
||||
|
||||
protected delete() {
|
||||
this.dialog.open(UserDeleteComponent).afterClosed().subscribe(reply => {
|
||||
if (reply) {
|
||||
this.acu.accs.deleteAcc(this.id!).subscribe((res) => {
|
||||
if (res.status == 200) {
|
||||
this.sb.open("Użytkownik został usunięty.", undefined, {duration: 2500})
|
||||
this.dialogRef.close()
|
||||
} else {
|
||||
this.sb.open("Wystąpił błąd. Skontaktuj się z obsługą programu.")
|
||||
console.error(res);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
this.dialog
|
||||
.open(UserDeleteComponent)
|
||||
.afterClosed()
|
||||
.subscribe(reply => {
|
||||
if (reply) {
|
||||
this.acu.accs.deleteAcc(this.id!).subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.sb.open('Użytkownik został usunięty.', undefined, {
|
||||
duration: 2500,
|
||||
})
|
||||
this.dialogRef.close()
|
||||
} else {
|
||||
this.sb.open('Wystąpił błąd. Skontaktuj się z obsługą programu.')
|
||||
console.error(res)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
protected resetPass() {
|
||||
this.loading = true
|
||||
this.dialog.open(UserResetComponent).afterClosed().subscribe((res) => {
|
||||
if (res == true) {
|
||||
this.acu.accs.resetPass(this.id!).subscribe((patch)=>{
|
||||
if (patch.status == 200) {
|
||||
this.sb.open("Hasło zostało zresetowane", undefined, {duration: 2500})
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
this.dialog
|
||||
.open(UserResetComponent)
|
||||
.afterClosed()
|
||||
.subscribe(res => {
|
||||
if (res == true) {
|
||||
this.acu.accs.resetPass(this.id!).subscribe(patch => {
|
||||
if (patch.status == 200) {
|
||||
this.sb.open('Hasło zostało zresetowane', undefined, {
|
||||
duration: 2500,
|
||||
})
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
protected toggleLock(state: boolean) {
|
||||
this.acu.accs.putAcc(this.id!, {locked: state}).subscribe((res) => {
|
||||
this.acu.accs.putAcc(this.id!, { locked: state }).subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.locked = state
|
||||
}
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { UserResetComponent } from './user-reset.component';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { UserResetComponent } from './user-reset.component'
|
||||
import { MatDialogModule } from '@angular/material/dialog'
|
||||
|
||||
describe('UserResetComponent', () => {
|
||||
let component: UserResetComponent;
|
||||
let fixture: ComponentFixture<UserResetComponent>;
|
||||
let component: UserResetComponent
|
||||
let fixture: ComponentFixture<UserResetComponent>
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserResetComponent],
|
||||
imports: [
|
||||
MatDialogModule
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(UserResetComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
imports: [MatDialogModule],
|
||||
})
|
||||
fixture = TestBed.createComponent(UserResetComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component } from '@angular/core'
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-reset',
|
||||
templateUrl: './user-reset.component.html',
|
||||
styleUrls: ['./user-reset.component.scss'],
|
||||
standalone: false
|
||||
selector: 'app-user-reset',
|
||||
templateUrl: './user-reset.component.html',
|
||||
styleUrls: ['./user-reset.component.scss'],
|
||||
standalone: false,
|
||||
})
|
||||
export class UserResetComponent {
|
||||
|
||||
}
|
||||
export class UserResetComponent {}
|
||||
|
||||
Reference in New Issue
Block a user