Skip to content
Snippets Groups Projects
Commit 411dcbad authored by Chris Hines's avatar Chris Hines
Browse files

add logging code

parent a441d340
No related branches found
No related tags found
3 merge requests!106if stat fails, display the error instead of immediately refreshing...,!99Dev,!45Dev
Pipeline #9613 passed
...@@ -10,11 +10,14 @@ import { Injectable } from '@angular/core'; ...@@ -10,11 +10,14 @@ import { Injectable } from '@angular/core';
import { Job } from './job'; import { Job } from './job';
import { AppAction, Strudelapp, StrudelappInstance } from './strudelapp'; import { AppAction, Strudelapp, StrudelappInstance } from './strudelapp';
import {BackendSelectionService} from './backend-selection.service'; import {BackendSelectionService} from './backend-selection.service';
import {repeat, take, takeUntil, filter} from 'rxjs/operators'; import {repeat, take, takeUntil, filter, catchError} from 'rxjs/operators';
import {timer, interval, Subject, BehaviorSubject} from 'rxjs'; import {timer, interval, Subject, BehaviorSubject, of} from 'rxjs';
import { ModaldialogComponent } from './modaldialog/modaldialog.component'; import { ModaldialogComponent } from './modaldialog/modaldialog.component';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material';
import {NotificationsService } from './notifications.service'; import {NotificationsService } from './notifications.service';
import { HttpClientModule, HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { environment } from '../environments/environment';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -26,12 +29,16 @@ export class BrowserWindowService { ...@@ -26,12 +29,16 @@ export class BrowserWindowService {
private openapps: any[]; private openapps: any[];
public cancelJob$: Subject<Job>; public cancelJob$: Subject<Job>;
constructor(private backendSelectionService: BackendSelectionService, public dialog: MatDialog, private notifications: NotificationsService) { constructor(private backendSelectionService: BackendSelectionService,
public dialog: MatDialog,
private notifications: NotificationsService,
private http: HttpClient) {
this.backendSelectionService.apiserver.subscribe( (value) => { if (value != null) {this.twsproxy = value.tws ; this.Base = value.tes }}); this.backendSelectionService.apiserver.subscribe( (value) => { if (value != null) {this.twsproxy = value.tws ; this.Base = value.tes }});
this.authdone$ = new Subject<boolean>(); this.authdone$ = new Subject<boolean>();
this.openapps = []; this.openapps = [];
this.cancelJob$ = new Subject<Job>(); this.cancelJob$ = new Subject<Job>();
timer(500).pipe(repeat()).subscribe(() => this.checkWindows()); timer(500).pipe(repeat()).subscribe(() => this.checkWindows());
timer(environment.loginterval).pipe(repeat()).subscribe(() => this.logUsage());
} }
...@@ -64,6 +71,22 @@ export class BrowserWindowService { ...@@ -64,6 +71,22 @@ export class BrowserWindowService {
} }
} }
public logUsage() {
var app: any;
console.log('in log usage');
this.openapps.forEach( (app,index) => {
if (!app.window.closed) {
if (app.job.state == 'RUNNING') {
console.log('logging',app.job);
this.http.get<any>(environment.logserver+"/"+app.job.identity.site.name+"/"+app.job.identity.username+"/"+app.job.app.name+"/"+app.job.jobid).pipe( //We're expecting 404 not founds
catchError((e) => {console.log(e) ; return of([]);})
).subscribe((_) => {return})
}
}
})
}
public checkWindows() { public checkWindows() {
var app: any; var app: any;
this.openapps.forEach( (app,index) => { this.openapps.forEach( (app,index) => {
......
...@@ -9,16 +9,30 @@ export class SettingsService { ...@@ -9,16 +9,30 @@ export class SettingsService {
public menuToggle$: BehaviorSubject<boolean>; public menuToggle$: BehaviorSubject<boolean>;
public useMenu$: BehaviorSubject<boolean>; public useMenu$: BehaviorSubject<boolean>;
public appdesc: boolean; public appdesc: boolean;
public logging: boolean;
constructor() { constructor() {
this.menuToggle$ = new BehaviorSubject<boolean>(true); this.menuToggle$ = new BehaviorSubject<boolean>(true);
this.theme$ = new BehaviorSubject<string>('strudel-light-theme'); this.theme$ = new BehaviorSubject<string>('strudel-light-theme');
this.useMenu$ = new BehaviorSubject<boolean>(true); this.useMenu$ = new BehaviorSubject<boolean>(true);
this.logging = true;
this.appdesc = true; this.appdesc = true;
this.getTheme(); this.getTheme();
this.getAppDesc(); this.getAppDesc();
this.getLogging();
} }
getLogging() {
let storedvalue = JSON.parse(localStorage.getItem('strudel-logging'));
if (storedvalue !== null) {
this.logging = storedvalue;
}
}
setLogging(event) {
this.logging = event.checked;
localStorage.setItem('strudel-logging',JSON.stringify(this.logging));
}
getAppDesc() { getAppDesc() {
console.log('loading appdesc setting'); console.log('loading appdesc setting');
......
...@@ -13,8 +13,14 @@ ...@@ -13,8 +13,14 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<div > <div>
<mat-slide-toggle color=primary [checked]="settingsService.appdesc" (change)="settingsService.setAppDesc($event)">Show Appliction Descriptions</mat-slide-toggle> <div >
<mat-slide-toggle color=primary [checked]="settingsService.appdesc" (change)="settingsService.setAppDesc($event)">Show Appliction Descriptions</mat-slide-toggle>
</div>
<div>
<mat-slide-toggle color=primary [checked]="settingsService.logging" (change)="settingsService.setLogging($event)">Allow usage logs to be collected</mat-slide-toggle>
</div>
<div class="heading"><h2>Advanced</h2></div> <div class="heading"><h2>Advanced</h2></div>
<div> <div>
......
export const environment = { export const environment = {
production: true, production: true,
contact: ["<STRUDEL Developers> chris.hines@monash.edu"] contact: ["<STRUDEL Developers> chris.hines@monash.edu"],
logserver: "https://strudel2-api-dev.cloud.cvl.org.au/logging",
loginterval: 1000000
......
...@@ -5,5 +5,7 @@ ...@@ -5,5 +5,7 @@
export const environment = { export const environment = {
production: false, production: false,
contact: ["<STRUDEL Developers> chris.hines@monash.edu"] contact: ["<STRUDEL Developers> chris.hines@monash.edu"],
logserver: "https://strudel2-dev.cloud.cvl.org.au/logging",
loginterval: 10000
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment