Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 1x | import { Injectable, Inject, SkipSelf } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { catchError } from 'rxjs/operators'; import { IdAndName, IdRoleData, UserData } from './superadmin.interfaces'; import { AppError, KeyValuePairs } from '../app.interfaces'; import { AppSettings } from '../shared/shared.module'; @Injectable({ providedIn: 'root' }) export class BackendService { constructor( @Inject('BACKEND_URL') private readonly serverUrl: string, @SkipSelf() private http: HttpClient ) { } getUsers(): Observable<UserData[]> { return this.http.get<UserData[]>(`${this.serverUrl}users`); } addUser(name: string, password: string): Observable<boolean> { return this.http.put<boolean>(`${this.serverUrl}user`, { n: name, p: password }); } setSuperUserStatus(userId: number, changeToSuperUser: boolean, password: string): Observable<void> { return this.http .patch<void>(`${this.serverUrl}user/${userId}/super-admin/${changeToSuperUser ? 'on' : 'off'}`, { p: password }) .pipe( catchError((err: AppError) => { Iif (err.code === 403) { throw new AppError({ type: 'warning', description: '', label: 'Bitte geben Sie zur Sicherheit *Ihr eigenes* Kennwort korrekt ein!' }); } throw err; }) ); } deleteUsers(users: string[]): Observable<boolean> { return this.http.request<boolean>('delete', `${this.serverUrl}users`, { body: { u: users } }); } getWorkspacesByUser(userId: number): Observable<IdRoleData[]> { return this.http.get<IdRoleData[]>(`${this.serverUrl}user/${userId}/workspaces`); } setWorkspacesByUser(userId: number, accessTo: IdRoleData[]): Observable<void> { return this.http.patch<void>(`${this.serverUrl}user/${userId}/workspaces`, { ws: accessTo }); } addWorkspace(name: string): Observable<void> { return this.http.put<void>(`${this.serverUrl}workspace`, { name }); } renameWorkspace(workspaceId: number, wsName: string): Observable<void> { return this.http.patch<void>(`${this.serverUrl}workspace/${workspaceId}`, { name: wsName }); } deleteWorkspaces(workspaces: number[]): Observable<void> { return this.http.request<void>('delete', `${this.serverUrl}workspaces`, { body: { ws: workspaces } }); } getUsersByWorkspace(workspaceId: number): Observable<IdRoleData[]> { return this.http.get<IdRoleData[]>(`${this.serverUrl}workspace/${workspaceId}/users`); } setUsersByWorkspace(workspaceId: number, accessing: IdRoleData[]): Observable<void> { return this.http.patch<void>(`${this.serverUrl}workspace/${workspaceId}/users`, { u: accessing }); } getWorkspaces(): Observable<IdAndName[]> { return this.http.get<IdAndName[]>(`${this.serverUrl}workspaces`); } setAppConfig(newConfig: AppSettings): Observable<void> { return this.http.patch<void>(`${this.serverUrl}system/config/app`, newConfig); } setCustomTexts(newCustomTexts: KeyValuePairs): Observable<void> { return this.http.patch<void>(`${this.serverUrl}system/config/custom-texts`, newCustomTexts); } } |