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';
import { Job } from './job';
import { AppAction, Strudelapp, StrudelappInstance } from './strudelapp';
import {BackendSelectionService} from './backend-selection.service';
import {repeat, take, takeUntil, filter} from 'rxjs/operators';
import {timer, interval, Subject, BehaviorSubject} from 'rxjs';
import {repeat, take, takeUntil, filter, catchError} from 'rxjs/operators';
import {timer, interval, Subject, BehaviorSubject, of} from 'rxjs';
import { ModaldialogComponent } from './modaldialog/modaldialog.component';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material';
import {NotificationsService } from './notifications.service';
import { HttpClientModule, HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { environment } from '../environments/environment';
@Injectable({
providedIn: 'root'
......@@ -26,12 +29,16 @@ export class BrowserWindowService {
private openapps: any[];
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.authdone$ = new Subject<boolean>();
this.openapps = [];
this.cancelJob$ = new Subject<Job>();
timer(500).pipe(repeat()).subscribe(() => this.checkWindows());
timer(environment.loginterval).pipe(repeat()).subscribe(() => this.logUsage());
}
......@@ -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() {
var app: any;
this.openapps.forEach( (app,index) => {
......
......@@ -9,16 +9,30 @@ export class SettingsService {
public menuToggle$: BehaviorSubject<boolean>;
public useMenu$: BehaviorSubject<boolean>;
public appdesc: boolean;
public logging: boolean;
constructor() {
this.menuToggle$ = new BehaviorSubject<boolean>(true);
this.theme$ = new BehaviorSubject<string>('strudel-light-theme');
this.useMenu$ = new BehaviorSubject<boolean>(true);
this.logging = true;
this.appdesc = true;
this.getTheme();
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() {
console.log('loading appdesc setting');
......
......@@ -13,8 +13,14 @@
</mat-select>
</mat-form-field>
</div>
<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.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>
......
export const environment = {
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 @@
export const environment = {
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