diff --git a/src/app/app.interceptor.ts b/src/app/app.interceptor.ts index 1469890c15d888623463506ffec2c3ec1adf22da..a3db39b83e0213829dccb09f63f6decb2175d23b 100644 --- a/src/app/app.interceptor.ts +++ b/src/app/app.interceptor.ts @@ -25,7 +25,6 @@ export class AuthInterceptor implements HttpInterceptor { } }); - console.log('### # app.interceptor >' + requestA.headers.get('AuthToken')); return next.handle(requestA); } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 284ef6464a90f4478fa3fcdbb51c35052ff62e1d..fe0a9212a9d702d067c315dbd97e03e1984746f0 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -18,6 +18,7 @@ import { WorkspaceModule } from './workspace'; import { StartComponent } from './start/start.component'; import { SuperadminModule } from './superadmin'; import { FlexLayoutModule } from "@angular/flex-layout"; +import { httpInterceptorProviders } from './app.interceptor'; @NgModule({ declarations: [ @@ -55,7 +56,8 @@ import { FlexLayoutModule } from "@angular/flex-layout"; provide: LocationStrategy, useClass: HashLocationStrategy }, - BackendService + BackendService, + httpInterceptorProviders ], bootstrap: [AppComponent] }) diff --git a/src/app/maindata.service.ts b/src/app/maindata.service.ts index b9cc217f9108bdaf1ed8df2dd5c60c04ed096130..705612326e11d439c91b03987a7109c4b7853125 100644 --- a/src/app/maindata.service.ts +++ b/src/app/maindata.service.ts @@ -14,6 +14,16 @@ export class MainDataService { is_superadmin: false }; + public get adminToken() : string { + const myLoginData = this.loginData$.getValue(); + if (myLoginData) { + return myLoginData.admintoken; + } else { + return ''; + } + } + + public loginData$ = new BehaviorSubject<LoginData>(MainDataService.defaultLoginData); public globalErrorMsg$ = new BehaviorSubject<ServerError>(null); diff --git a/src/app/workspace/backend.service.ts b/src/app/workspace/backend.service.ts index 9d77a07197e0f19b074491920845e3d4fee45e22..4c8146082ee0043e1cb1d65f90fd755b34a13bb9 100644 --- a/src/app/workspace/backend.service.ts +++ b/src/app/workspace/backend.service.ts @@ -37,15 +37,9 @@ export class BackendService { } // ******************************************************************* - // Fehlerbehandlung beim Aufrufer getFiles(): Observable<GetFileResponseData[] | ServerError> { - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; return this.http - .post<GetFileResponseData[]>(this.serverUrl + 'getFileList.php', {}, httpOptions) + .get<GetFileResponseData[]>(this.serverUrlSlim + 'filelist') .pipe( catchError(ErrorHandler.handle) ); diff --git a/src/app/workspace/files/files.component.html b/src/app/workspace/files/files.component.html index 36056c9ebf4176c643d8a2240fe6e543f433140a..a4989ec2067865a937953f9de2931b0ebefda717 100644 --- a/src/app/workspace/files/files.component.html +++ b/src/app/workspace/files/files.component.html @@ -5,7 +5,7 @@ <!-- ============================================= --> <div class="filelist"> - <mat-table #table *ngIf="isAdmin" [dataSource]="serverfiles" matSort> + <mat-table #table [dataSource]="serverfiles" matSort> <ng-container matColumnDef="checked"> <mat-header-cell *matHeaderCellDef class="checkboxcell"> <mat-checkbox (change)="checkAll($event.checked)"></mat-checkbox> @@ -42,7 +42,7 @@ </div> <!-- ============================================= --> - <div class="uploads" *ngIf="isAdmin"> + <div class="uploads"> <button mat-raised-button (click)="deleteFiles()" matTooltip="Markierte Dateien löschen" matTooltipPosition="above"> <mat-icon>delete</mat-icon> </button> diff --git a/src/app/workspace/files/files.component.ts b/src/app/workspace/files/files.component.ts index 295a62989d6eb2656fbe5fb0062fccd412d730ae..0beafb6e8a5994e26aaf55b95cc702939765d120 100644 --- a/src/app/workspace/files/files.component.ts +++ b/src/app/workspace/files/files.component.ts @@ -1,14 +1,16 @@ +import { LoginData } from './../../app.interfaces'; +import { MainDataService } from './../../maindata.service'; import { ServerError } from './../../backend.service'; import { WorkspaceDataService } from './../workspacedata.service'; import { GetFileResponseData, CheckWorkspaceResponseData } from './../workspace.interfaces'; import { ConfirmDialogComponent, ConfirmDialogData, MessageDialogComponent, MessageDialogData, MessageType } from '../../iqb-common'; import { DataSource } from '@angular/cdk/collections'; -import { Observable, BehaviorSubject } from 'rxjs'; +import { Observable, BehaviorSubject, Subscription, merge } from 'rxjs'; import { MatTableDataSource } from '@angular/material/table'; import { MatSnackBar } from '@angular/material'; import { BackendService } from '../backend.service'; -import { Input, Output, EventEmitter, Component, OnInit, Inject, ElementRef } from '@angular/core'; +import { Input, Output, EventEmitter, Component, OnInit, Inject, ElementRef, OnDestroy } from '@angular/core'; import { NgModule, ViewChild } from '@angular/core'; import { MatSort, MatDialog } from '@angular/material'; import { HttpEventType, HttpErrorResponse, HttpEvent } from '@angular/common/http'; @@ -19,12 +21,13 @@ import { IqbFilesUploadQueueComponent, IqbFilesUploadInputForDirective } from '. templateUrl: './files.component.html', styleUrls: ['./files.component.css'] }) -export class FilesComponent implements OnInit { +export class FilesComponent implements OnInit, OnDestroy { public serverfiles: MatTableDataSource<GetFileResponseData>; public displayedColumns = ['checked', 'filename', 'typelabel', 'filesize', 'filedatetime']; public uploadUrl = ''; public fileNameAlias = 'fileforvo'; public dataLoading = false; + private logindataSubscription: Subscription = null; // for workspace-check public checkErrors = []; @@ -36,6 +39,7 @@ export class FilesComponent implements OnInit { constructor( @Inject('SERVER_URL') private serverUrl: string, private bs: BackendService, + private mds: MainDataService, private wds: WorkspaceDataService, public confirmDialog: MatDialog, public messsageDialog: MatDialog, @@ -45,7 +49,11 @@ export class FilesComponent implements OnInit { } ngOnInit() { - this.updateFileList(); + this.logindataSubscription = this.mds.loginData$.subscribe(ld => { + const ws = this.wds.ws; + let at = ld ? ld.admintoken : ''; + this.updateFileList((ws <= 0) || (at.length === 0)); + }); } // *********************************************************************************** @@ -119,23 +127,27 @@ export class FilesComponent implements OnInit { } // *********************************************************************************** - updateFileList() { + updateFileList(empty = false) { this.checkErrors = []; this.checkWarnings = []; this.checkInfos = []; - this.dataLoading = true; - this.bs.getFiles().subscribe( - (filedataresponse: GetFileResponseData[]) => { - this.serverfiles = new MatTableDataSource(filedataresponse); - this.serverfiles.sort = this.sort; - this.dataLoading = false; - this.wds.setNewErrorMsg(); - }, (err: ServerError) => { - this.wds.setNewErrorMsg(err); - this.dataLoading = false; - } - ); + if (empty) { + this.serverfiles = new MatTableDataSource([]); + } else { + this.dataLoading = true; + this.bs.getFiles().subscribe( + (filedataresponse: GetFileResponseData[]) => { + this.serverfiles = new MatTableDataSource(filedataresponse); + this.serverfiles.sort = this.sort; + this.dataLoading = false; + this.wds.setNewErrorMsg(); + }, (err: ServerError) => { + this.wds.setNewErrorMsg(err); + this.dataLoading = false; + } + ); + } } // *********************************************************************************** @@ -167,4 +179,11 @@ export class FilesComponent implements OnInit { } ); } + + // % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % + ngOnDestroy() { + if (this.logindataSubscription !== null) { + this.logindataSubscription.unsubscribe(); + } + } } diff --git a/src/app/workspace/workspace-routing.module.ts b/src/app/workspace/workspace-routing.module.ts index f88d869b2f3a9bf573434d02f5d6b26acb65e0da..0761950b8766a9909714eabb091cdae0ff2f4e7d 100644 --- a/src/app/workspace/workspace-routing.module.ts +++ b/src/app/workspace/workspace-routing.module.ts @@ -11,7 +11,7 @@ const routes: Routes = [ path: 'ws/:ws', component: WorkspaceComponent, children: [ - {path: '', redirectTo: 'myfiles', pathMatch: 'full'}, + {path: '', redirectTo: 'files', pathMatch: 'full'}, {path: 'files', component: FilesComponent}, {path: 'syscheck', component: SyscheckComponent}, {path: 'monitor', component: MonitorComponent}, diff --git a/src/app/workspace/workspace.component.css b/src/app/workspace/workspace.component.css index aef1123eabdf67df48e02ab02b6a9a81925a4ca6..c695d220cec2d4010f3201155a1d90ffac8c917b 100644 --- a/src/app/workspace/workspace.component.css +++ b/src/app/workspace/workspace.component.css @@ -1,10 +1,7 @@ /* --------------------------------------------- */ #buttonsContainer { - position: absolute; - right: 5px; - top: 2px; - left: 5px; color: white; + padding: 0 10px 0 0; } #buttonsContainer .material-icons { font-size: 2.0rem; diff --git a/src/app/workspace/workspace.component.html b/src/app/workspace/workspace.component.html index 09939a755305d0446bc40041448c8c5c26224270..b162d5216d53e15b991eac91f4cd7966c01f6612 100644 --- a/src/app/workspace/workspace.component.html +++ b/src/app/workspace/workspace.component.html @@ -3,7 +3,7 @@ <img src="assets/IQB-LogoA.png" matTooltip="Startseite"/> </a> <div fxLayout="row" fxLayoutAlign="end center"> - <p>{{ wds?.wsName }} ({{wds?.wsRole}})</p> + <p>{{ pageTitle }}</p> </div> </div> <div class="page-body"> diff --git a/src/app/workspace/workspace.component.ts b/src/app/workspace/workspace.component.ts index ac196ef315719487b28f400a5d5f922dc0bae81a..2700ee2573e5486fb959e9e7688733d5ebea07be 100644 --- a/src/app/workspace/workspace.component.ts +++ b/src/app/workspace/workspace.component.ts @@ -20,6 +20,7 @@ export class WorkspaceComponent implements OnInit, OnDestroy { public pageTitle = ''; private routingSubscription: Subscription = null; + private logindataSubscription: Subscription = null; // CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC constructor( @@ -31,7 +32,22 @@ export class WorkspaceComponent implements OnInit, OnDestroy { // CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC ngOnInit() { this.routingSubscription = this.route.params.subscribe(params => { - this.wds.setWorkspaceId(Number(params['ws'])); + const ws = Number(params['ws']); + this.wds.setWorkspaceId(ws); + if ((this.mds.adminToken.length > 0) && (ws > 0)) { + this.pageTitle = this.mds.getWorkspaceName(ws) + ' (' + this.mds.getWorkspaceRole(ws) + ')'; + } else { + this.pageTitle = ''; + } + }); + + this.logindataSubscription = this.mds.loginData$.subscribe(ld => { + const ws = this.wds.ws; + if (ws > 0) { + this.pageTitle = this.mds.getWorkspaceName(ws) + ' (' + this.mds.getWorkspaceRole(ws) + ')'; + } else { + this.pageTitle = ''; + } }); } @@ -40,5 +56,8 @@ export class WorkspaceComponent implements OnInit, OnDestroy { if (this.routingSubscription !== null) { this.routingSubscription.unsubscribe(); } + if (this.logindataSubscription !== null) { + this.logindataSubscription.unsubscribe(); + } } } diff --git a/src/app/workspace/workspace.interceptor.ts b/src/app/workspace/workspace.interceptor.ts index 06dec6bca06a3b2d74ed0e45d87ddf524e543765..01876554a3aaaf629d912760e06601bd1a868171 100644 --- a/src/app/workspace/workspace.interceptor.ts +++ b/src/app/workspace/workspace.interceptor.ts @@ -25,7 +25,6 @@ export class WorkspaceInterceptor implements HttpInterceptor { } }); - console.log('### # workspace.interceptor >' + requestA.headers.get('AuthToken')); return next.handle(requestA); } } diff --git a/src/app/workspace/workspace.module.ts b/src/app/workspace/workspace.module.ts index 10808ec90776e9325fd3b7b360d6f84dc8396489..01832629f0954ce34ef9e70c1a1b54bd1516fb57 100644 --- a/src/app/workspace/workspace.module.ts +++ b/src/app/workspace/workspace.module.ts @@ -23,6 +23,7 @@ import { MonitorComponent } from './monitor/monitor.component'; import { MatExpansionModule } from '@angular/material/expansion'; import {MatGridListModule} from '@angular/material/grid-list'; import { SyscheckComponent } from './syscheck/syscheck.component'; +import { httpInterceptorProviders } from './workspace.interceptor'; @NgModule({ imports: [ @@ -66,6 +67,7 @@ import { SyscheckComponent } from './syscheck/syscheck.component'; ], providers: [ BackendService, + httpInterceptorProviders, WorkspaceDataService ], }) diff --git a/src/app/workspace/workspacedata.service.ts b/src/app/workspace/workspacedata.service.ts index e0e8ac0bbf0360361197782f540fa3e55dbb8abd..3aee6f832ef889dab29245eb64fbe3f476960d9d 100644 --- a/src/app/workspace/workspacedata.service.ts +++ b/src/app/workspace/workspacedata.service.ts @@ -20,14 +20,8 @@ export class WorkspaceDataService { public workspaceId$ = new BehaviorSubject<number>(-1); public globalErrorMsg$ = new BehaviorSubject<ServerError>(null); - private _wsName : string; - public get wsName() : string { - return this._wsName; - } - - private _wsRole : string; - public get wsRole() : string { - return this._wsRole; + public get ws() : number { + return this.workspaceId$.getValue(); } @@ -74,7 +68,5 @@ export class WorkspaceDataService { // ******************************************************************************************************* setWorkspaceId(newId: number) { this.workspaceId$.next(newId); - this._wsName = this.mds.getWorkspaceName(newId); - this._wsRole = this.mds.getWorkspaceRole(newId); } } diff --git a/src/iqb-theme2.scss b/src/iqb-theme2.scss index c27f19130cab1d2674b37bfa0c4576d79b1b88c9..215f8b27c77f1f2d867bd7be5cd7a5ddf44db16b 100644 --- a/src/iqb-theme2.scss +++ b/src/iqb-theme2.scss @@ -12,5 +12,5 @@ body { height: 100%; margin: 0; font-family: "Orienta"; - background: #003333; + background: linear-gradient(to left, #003333, #045659, #0d7b84, #1aa2b2, #2acae5) } diff --git a/src/styles.css b/src/styles.css index 94b3577a53cb3b234c91da7fbfb872d68a6b5aee..5f1fdb8420eccc2fa86d9cfcedef0c2fdfcdaf50 100644 --- a/src/styles.css +++ b/src/styles.css @@ -12,15 +12,8 @@ overflow-x: auto; position: absolute; width: 100%; - top: 70px; + top: 50px; bottom: 0; - background: linear-gradient(to left, #003333, #045659, #0d7b84, #1aa2b2, #2acae5) - /* background-image: linear-gradient(to bottom, #003333, #00465d, #005791, #005ebe, #8854d0); */ - /* display: flex; - flex-direction: row; - flex-wrap: nowrap; - align-items: flex-start; - justify-content: left; */ } @@ -37,3 +30,6 @@ right: 0; } +.logo img { + width: 100px; +}