Skip to content

Commit

Permalink
screen to view Processes (sessions) running on a server for a specifi…
Browse files Browse the repository at this point in the history
…c duration (#69)

* process screen

* process screen

---------

Co-authored-by: u$f <usf.alami@gmail.com>
  • Loading branch information
antonin77 and usfalami authored Jan 3, 2025
1 parent fa31b71 commit e61995e
Show file tree
Hide file tree
Showing 14 changed files with 341 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ import {ArchitectureView} from "./views/architecture/architecture.view";
import { NumberFormatterPipe } from './shared/pipe/number.pipe';
import { TreeView } from './views/tree/tree.view';
import {SizePipe} from "./shared/pipe/size.pipe";
import {DumpView} from "./views/dump/dump.view";


registerLocaleData(localeFr, 'fr-FR');
const routes: Route[] = [
{
path: 'session', children: [
{
path: ':app_name/dump',
component: DumpView
},
{
path: 'rest',
children: [
Expand Down
20 changes: 19 additions & 1 deletion src/app/service/router.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Injectable} from "@angular/core";
import {NavigationExtras, Router} from "@angular/router";
import {NavigationExtras, Router, UrlTree} from "@angular/router";
import {Observable} from "rxjs";

@Injectable()
Expand Down Expand Up @@ -41,6 +41,24 @@ export class EnvRouter {
// return Promise.resolve(true);
}

createUrlTree(commands: any[], extras?: NavigationExtras): UrlTree {
if (!extras?.queryParams?.env) {
if (this._env) {
if (!extras) {
extras = {}
}
if (!extras.queryParams) {
extras.queryParams = {}
}
extras.queryParams.env = this._env;
}
}
else {
this.env = extras.queryParams.env;
}
return this.router.createUrlTree(commands, extras);
}

open(url?: string | URL, target?: string, features?: string): WindowProxy | null {
return window.open(url, target, features);
}
Expand Down
18 changes: 18 additions & 0 deletions src/app/service/trace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export class TraceService {
return this.http.get<Array<InstanceRestSession>>(`${this.server}/session/rest`, { params: params });
}

getRestSessionsForDump(env: string, appName: string, start: Date, end: Date): Observable<Array<InstanceRestSession>> {
let params: any = {
'env': env,
'start': start.toISOString(),
'end': end.toISOString()
}
return this.http.get<Array<InstanceRestSession>>(`${this.server}/session/rest/${appName}/dump`, { params: params });
}

getRestSession(id: string): Observable<InstanceRestSession> {
return this.http.get<InstanceRestSession>(`${this.server}/session/rest/${id}`);
}
Expand All @@ -39,6 +48,15 @@ export class TraceService {
return this.http.get<Array<InstanceMainSession>>(`${this.server}/session/main`, { params: params });
}

getMainSessionsForDump(env: string, appName: string, start: Date, end: Date): Observable<Array<InstanceMainSession>> {
let params: any = {
'env': env,
'start': start.toISOString(),
'end': end.toISOString()
}
return this.http.get<Array<InstanceMainSession>>(`${this.server}/session/main/${appName}/dump`, { params: params });
}

getMainSession(id: string): Observable<InstanceMainSession> {
return this.http.get<InstanceMainSession>(`${this.server}/session/main/${id}`);
}
Expand Down
11 changes: 11 additions & 0 deletions src/app/shared/pipe/title-case.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {Pipe, PipeTransform} from "@angular/core";

@Pipe({
name:"titleCase"
})
export class TitleCasePipe implements PipeTransform {
transform(value: any): any {
if (!value) return value;
return value[0].toUpperCase() + value.substring(1).toLowerCase();
}
}
7 changes: 5 additions & 2 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AdvancedFilterComponent } from './_component/advanced-filter/advanced-f
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { DurationPipe } from './pipe/duration.pipe';
import { SizePipe } from './pipe/size.pipe';
import {TitleCasePipe} from "./pipe/title-case.pipe";

@NgModule({
imports: [
Expand All @@ -24,7 +25,8 @@ import { SizePipe } from './pipe/size.pipe';
AdvancedFilterTriggerComponent,
FilterRowPipe,
DurationPipe,
SizePipe
SizePipe,
TitleCasePipe
],
exports: [
MaterialModule,
Expand All @@ -33,7 +35,8 @@ import { SizePipe } from './pipe/size.pipe';
AdvancedFilterRecapComponent,
AdvancedFilterTriggerComponent,
DurationPipe,
SizePipe
SizePipe,
TitleCasePipe
]
})
export class SharedModule { }
10 changes: 6 additions & 4 deletions src/app/views/detail/session/main/detail-session-main.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@
</mat-card>
<mat-card style="width: 40vw;">
<mat-card-title>
<a style="display: flex; align-items: center; gap: 0.5em" *ngIf="session.type == 'VIEW'"
<a style="display: flex; align-items: center; gap: 0.5em; height: inherit;" *ngIf="session.type == 'VIEW'"
[routerLink]="'/dashboard/client/'+ instance.name"
[queryParams]="{'env': instance.env}" matTooltip="Statistiques Client">
<mat-icon>storage</mat-icon>
<div>{{instance.name}} <span style="font-size: 12px; font-style: italic; font-weight: normal;">{{instance.version}}</span></div>
</a>
<a style="display: flex; align-items: center; gap: 0.5em" *ngIf="session.type != 'VIEW'" [routerLink]="'/dashboard/server/'+ instance.name"
<a style="display: flex; align-items: center; gap: 0.5em; height: inherit;" *ngIf="session.type != 'VIEW'" [routerLink]="'/dashboard/server/'+ instance.name"
[queryParams]="{'env': instance.env}" matTooltip="Statistiques Serveur">
<mat-icon>storage</mat-icon>
<div>{{instance.name}} <span style="font-size: 12px; font-style: italic; font-weight: normal;">{{instance.version}}</span></div>
</a>
<div style="height: 48px">

<div class="right">
<button [hidden]="session.type == 'VIEW'" mat-icon-button (click)="onClickDump($event)" matTooltip="Processus">
<mat-icon>developer_board</mat-icon>
</button>
</div>
</mat-card-title>
<mat-card-content>
Expand Down
17 changes: 17 additions & 0 deletions src/app/views/detail/session/main/detail-session-main.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@ export class DetailSessionMainView implements OnInit, OnDestroy {
}
}

onClickDump(event: MouseEvent) {
let params: {fragments: string[], queryParams: any} = {
fragments: ['session', this.instance.name, 'dump'],
queryParams: { env: this.instance.env, date: new Date(this.session.start * 1000).toISOString() }
};
if (event.ctrlKey) {
let url = this._router.createUrlTree(params.fragments, {
queryParams: params.queryParams }
).toString();
this._router.open(`#/${url}`, '_blank');
} else {
this._router.navigate(params.fragments, {
queryParams: params.queryParams
});
}
}

ngOnDestroy() {
this.subscriptions.forEach(s => s.unsubscribe());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@
<div>{{instance.name}} <span style="font-size: 12px; font-style: italic; font-weight: normal;">{{instance.version}}</span></div>

</a>
<div style="height: 48px">

<div class="right">
<button mat-icon-button (click)="onClickDump($event)" matTooltip="Processus">
<mat-icon>developer_board</mat-icon>
</button>
</div>
</mat-card-title>
<mat-card-content>
Expand Down
21 changes: 19 additions & 2 deletions src/app/views/detail/session/rest/detail-session-rest.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ export class DetailSessionRestView implements OnInit, OnDestroy {
case "rest":
params.push('statistic', 'rest', this.session.name);
break;
case "app":
params.push('statistic', 'app', this.session.appName)
case "dump":
params.push('session', this.instance.name, 'dump')
break;
case "tree":
params.push('session', 'rest', this.session.id, 'tree')
Expand All @@ -182,6 +182,23 @@ export class DetailSessionRestView implements OnInit, OnDestroy {
}
}

onClickDump(event: MouseEvent) {
let params: {fragments: string[], queryParams: any} = {
fragments: ['session', this.instance.name, 'dump'],
queryParams: { env: this.instance.env, date: new Date(this.session.start * 1000).toISOString() }
};
if (event.ctrlKey) {
let url = this._router.createUrlTree(params.fragments, {
queryParams: params.queryParams }
).toString();
this._router.open(`#/${url}`, '_blank');
} else {
this._router.navigate(params.fragments, {
queryParams: params.queryParams
});
}
}

ngOnDestroy() {
this.subscriptions.forEach(s => s.unsubscribe());
}
Expand Down
24 changes: 24 additions & 0 deletions src/app/views/dump/dump.view.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<header-page style="height: 56px;" titleIcon="developer_board" [ui-title]="params.app | titleCase">
</header-page>

<div class="timeline">
<div style="display: flex; justify-content: flex-end;">
<button mat-icon-button matTooltip="Recule" [disabled]="loading()" (click)="previous()">
<mat-icon>keyboard_double_arrow_left</mat-icon>
</button>
<button mat-icon-button matTooltip="Dezoom" [disabled]="loading()" (click)="zoomOut()">
<mat-icon>zoom_out</mat-icon>
</button>
<button mat-icon-button matTooltip="Zoom" [disabled]="loading() || !zoomableIn()" (click)="zoomIn()">
<mat-icon>zoom_in</mat-icon>
</button>
<button mat-icon-button matTooltip="Avance" [disabled]="loading()" (click)="next()">
<mat-icon>keyboard_double_arrow_right</mat-icon>
</button>
</div>
<dump-timeline *ngIf="!loading()" [groups]="groups" [items]="items"></dump-timeline>
<div *ngIf="loading()" class="loading">
<span>Loading...</span>
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
</div>
17 changes: 17 additions & 0 deletions src/app/views/dump/dump.view.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.timeline {
height: calc(100vh - 56px - 48px - 1.5em);
display: flex;
flex-direction: column;
}

.loading {
height: 100%;
width: 15%;
display: flex;
flex-direction: column;
align-items: center;
align-self: center;
justify-content: center;
font-size: 14px;
color: #6c6c6c;
}
Loading

0 comments on commit e61995e

Please sign in to comment.