Skip to content

Commit

Permalink
Merge pull request #16 from QXIP/develop
Browse files Browse the repository at this point in the history
added to RTP-streams / the Graph
  • Loading branch information
RFbkak37y3kIY authored May 13, 2024
2 parents 8ab2405 + f4654e6 commit e04d9bc
Show file tree
Hide file tree
Showing 14 changed files with 787 additions and 116 deletions.
Binary file added .nx/cache/18.3.4-nx.win32-x64-msvc.node
Binary file not shown.
7 changes: 7 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
},
"configurations": {
"production": {
"optimization": false,
"sourceMap": true,
"namedChunks": false,
"aot": false,
"extractLicenses": false,
"vendorChunk": false,
"buildOptimizer": false,
"budgets": [
{
"type": "initial",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class="this-table"
>
<ng-container
*ngFor="let item of columns; let i = index"
*ngFor="let item of columnsValue; let i = index"
[matColumnDef]="item"
>
<ng-container>
Expand All @@ -37,16 +37,16 @@
</div>
</th>
<td *matCellDef="let element">
{{ element[item] }}
{{ element[getKeyBy(item)] }}
</td>
</ng-container>
</ng-container>

<tbody>
<tr mat-header-row *matHeaderRowDef="columns"></tr>
<tr mat-header-row *matHeaderRowDef="columnsValue"></tr>
<tr
mat-row
*matRowDef="let row; index as i; columns: columns"
*matRowDef="let row; index as i; columns: columnsValue"
[style.background-color]="
getSelected(i) ? '#3f51b5' : row.bg && '#' + row.bg
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ import { TableVirtualScrollDataSource } from 'ng-table-virtual-scroll';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class CustomTableComponent {
@Input() columns: any[] = [];
@Input() columns: any = [];
@Input() isDictionary: boolean = false;
@Input() columnsFilter: any[] = [];
@Input() isSelectedByClick: boolean = false;

get columnsValue(): any {
return this.isDictionary ?
Object.values(this.columns) : this.columns;
}
getKeyBy(value: any): any {
return this.isDictionary ? Object.entries(this.columns).find(([key, val]) => val === value)?.[0] : value;
}
selectedRowIndex: number = -1; // -1 is selected nothings

@Output() rowClick: EventEmitter<any> = new EventEmitter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<div style="width:100%; height:100%;">
<canvas style="width:100%; height:100%;"
<div style="width: 100%; height: 100%; display: block">
<canvas
style="width: 100%; height: 100%"
(mousemove)="mouseEvent($event)"
(mousedown)="mouseEvent($event)"
(mouseup)="mouseEvent($event)"
(mouseout)="mouseEvent($event)"
(mouseover)="mouseEvent($event)"
(mouseoutside)="mouseEvent($event)"
#canvas></canvas>
#canvas
></canvas>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ export interface ChartData {
})
export class FlexibleChartComponent implements OnInit, AfterViewInit, OnDestroy {
exampleData: ChartData[] = [];
@Input() globalMinMax: boolean = false
mousePosition: any = {
inside: false,
mousedown: false,
x: 0,
y: 0
};
@Input() fullToolTip = false;
@Input() isRange = true;
@Input() startXAxisNumber = 0;
@Input() options: any = {
axisX: false,
axisY: false
Expand Down Expand Up @@ -89,7 +92,7 @@ export class FlexibleChartComponent implements OnInit, AfterViewInit, OnDestroy
// const { layerX = 0, layerY = 0 }:any = {};
const { offsetWidth, offsetHeight, offsetLeft, offsetTop } = this.canvas.nativeElement;
const dX = layerX - offsetLeft;
const dY = layerX - offsetTop;
const dY = layerX - offsetTop;

switch (event.type) {
case 'mousemove':
Expand Down Expand Up @@ -152,10 +155,10 @@ export class FlexibleChartComponent implements OnInit, AfterViewInit, OnDestroy
const index = Math.ceil((this.mousePosition.x) / stepX);
return index;
}
tooltip(ctx: any, text: string) {
tooltip(ctx: any, text: string, index = 0) {
const padding = 4;
ctx.font = `14px monospace`;
const textElement = ctx.measureText(text);
const textElement = ctx.measureText(text.split('\n')[0]);
const w = textElement.width;
const x = Math.max(0, Math.min(
ctx.canvas.clientWidth - w - padding * 2,
Expand All @@ -165,10 +168,13 @@ export class FlexibleChartComponent implements OnInit, AfterViewInit, OnDestroy

ctx.fillStyle = 'rgba(255, 255, 255, 0.8)';
ctx.fillStyle = 'black';
this.drawText(ctx, text, {
x, y,
bgColor: 'rgba(255, 255, 255, 0.8)',
color: 'black'
text.split('\n').forEach((line, k) => {

this.drawText(ctx, line, {
x, y: y + k * 20,
bgColor: 'rgba(255, 255, 255, 0.8)',
color: 'black'
})
})

}
Expand Down Expand Up @@ -206,18 +212,38 @@ export class FlexibleChartComponent implements OnInit, AfterViewInit, OnDestroy
ctx.lineWidth = 1;
}
draw(ctx: any) {

let minData = Number.MAX_VALUE, maxData = Number.MIN_VALUE;
if (this.globalMinMax) {
this.exampleData.forEach(({ data }: any) => {
minData = Math.min(...data, minData, 0);
maxData = Math.max(...data, maxData);
});
}
this.exampleData.forEach(({ data, color, typeOfChart }: any) => {
this.drawChart(ctx, data, color, typeOfChart);
this.drawChart(ctx, data, color, typeOfChart, [minData, maxData]);
})
if (this.isRange) {
this.drawRange(ctx);

if (this.mousePosition.inside) {
this.drawTarget(ctx);
this.tooltip(ctx, JSON.stringify(
!this.mousePosition.mousedown ?
this.getIndexOfData() :
this.сalcRangeByData()));
if (this.fullToolTip) {

const idx = this.getIndexOfData() - 1;
console.log({ exampleData: this.exampleData });
this.tooltip(ctx,

this.exampleData.map(i => i.data[idx] ? `${i.name}: ${i.data[idx]}` : '').filter(i => !!i).join('\n')

)
} else {

this.tooltip(ctx, JSON.stringify(
!this.mousePosition.mousedown ?
this.getIndexOfData() :
this.сalcRangeByData()));
}
}
}

Expand Down Expand Up @@ -282,7 +308,7 @@ export class FlexibleChartComponent implements OnInit, AfterViewInit, OnDestroy
ctx.moveTo(x, y - 5);
ctx.lineTo(x, y + 3);
ctx.stroke();
this.drawText(ctx, `${(data.length * (i + 1) / L).toFixed(0)}`, {
this.drawText(ctx, `${(this.startXAxisNumber + data.length * (i + 1) / L).toFixed(0)}`, {
x: x - 10,
y: y,
bgColor: 'rgba(255, 255, 255, 0)',
Expand All @@ -307,11 +333,21 @@ export class FlexibleChartComponent implements OnInit, AfterViewInit, OnDestroy
ctx.stroke();
}
}
drawChart(ctx: any, data: any[], color = 'rgba(0,255,255,0.5)', type: TypeOfChart = this.typeOfChart) {
drawChart(ctx: any, data: any[], color = 'rgba(0,255,255,0.5)', type: TypeOfChart = this.typeOfChart, [min, max]: any) {
data = Functions.cloneObject(data);
const pudding = { x: 10, y: this.options.axisX ? 40 : 0 }; // px
const minY = Math.min(...data, 0);
const maxY = Math.max(...data);
let minY;
let maxY;
if (this.globalMinMax) {
minY = min;
maxY = max;

} else {

minY = Math.min(...data, 0);
maxY = Math.max(...data);
}

let stepX = ((ctx.canvas.offsetWidth - pudding.x * 2) / (data.length));
const stepY = ((ctx.canvas.offsetHeight - pudding.y * 2) / maxY);

Expand Down Expand Up @@ -380,7 +416,7 @@ export class FlexibleChartComponent implements OnInit, AfterViewInit, OnDestroy
const c = this.canvas.nativeElement;

c.width = `${c.offsetWidth}`;
c.height = `${c.offsetHeight}`;
c.height = `${c.offsetHeight - 5}`;

if (c.getContext) {
var ctx = c.getContext('2d');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<modal-resizable [title]="titleId" (close)="onClose()">
<div class="top-container">
<mat-card
class="player-card"
(click)="setRecActive()"
[class.active]="rec.isActive"
>
<div class="player-card-data">
<div>
CurrentTime:
{{ rec.player?.getCurrentTime() || 0 | number : "1.3-3" }}s
</div>
<div>Duration: {{ rec.player?.getDuration() || 0 }}</div>
<div>PlaybackRate: {{ rec.player?.getPlaybackRate() || 0 }}</div>
</div>
<div
[id]="rec.id"
*ngIf="!rec.noData"
style="cursor: ew-resize"
(wheel)="onZoomAudio($event, rec.player)"
></div>
<div *ngIf="rec.noData">
<h2>Audio file is empty (size : 0b)</h2>
</div>
<div class="player-controls" *ngIf="!rec.noData">
<!-- <button
mat-mini-fab
color="primary"
(click)="seekAndCenter(rec.player, -0.05)"
aria-label="rewind"
>
<mat-icon>fast_rewind</mat-icon>
</button> -->
<a [href]="rec.mp3" download="rec.mp3" style="float: right">
<button mat-icon-button><mat-icon>download</mat-icon></button>
</a>
<button
mat-icon-button
color="primary"
aria-label="play/stop"
(click)="rec.player.playPause()"
>
<mat-icon *ngIf="!rec.player?.isPlaying()">play_arrow</mat-icon>
<mat-icon *ngIf="rec.player?.isPlaying()">pause</mat-icon>
</button>

<!-- <button
mat-mini-fab
color="primary"
(click)="seekAndCenter(rec.player, 0.05)"
aria-label="forward"
>
<mat-icon>fast_forward</mat-icon>
</button> -->
</div>
</mat-card>
</div>

<mat-card *ngIf="selectedColumns?.length">
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="start">
<mat-tab label="TableData">
<app-custom-table
[details]="selectedStreams"
[columns]="columnDictionary"
[isDictionary]="true"
[isSelectedByClick]="true"
[isPaginator]="false"
style="min-height: 50vh"
#dataGridTable
></app-custom-table>
</mat-tab>
<mat-tab label="Chart">
<div
style="
height: 50vh;
min-height: 500px;
position: relative;
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: stretch;
align-content: stretch;
flex-wrap: nowrap;
"
>
<section style="display: flex; flex: 0">
<mat-checkbox
class="labels"
*ngFor="let item of chartFilter"
color="primary"
[(ngModel)]="item.value"
(click)="onFilterChart()"
>
<div style="display: flex; align-items: center; margin: 0.5rem;">
<div
style="
display: inline-block;
width: 40px;
height: 10px;
margin: 4px;
border-radius: 50rem;
border: 1px solid;
"
[style.backgroundColor]="item.value ? item.color : 'transparent'"
[style.borderColor]="!item.value ? item.color : 'transparent'"
></div>
{{ item.title }}
</div>
</mat-checkbox>
</section>
<mat-radio-group aria-label="Select an option" [(ngModel)]="typeOfChartRadio">
<mat-radio-button color="primary" value="line">Line</mat-radio-button>
<mat-radio-button color="primary" value="bar">Bar</mat-radio-button>
<mat-radio-button color="primary" value="area">Area</mat-radio-button>
</mat-radio-group>
<flexible-chart
style="flex: 1; background: rgb(217, 217, 217); height: 300px"
[data]="rangeChartData"
[typeOfChart]="typeOfChartRadio"
[globalMinMax]="false"
[fullToolTip]="true"
[isRange]="true"
[startXAxisNumber]="lastRange?.start || 0"
[options]="{
axisX: true,
axisY: false
}"
></flexible-chart>
<flexible-chart
style="flex: 0; background: rgb(172, 172, 172); height: 100px"
[data]="chartData"
[typeOfChart]="typeOfChartRadio"
[isRange]="true"
[globalMinMax]="false"
(range)="onRange($event)"
[options]="{
axisX: false,
axisY: false
}"
></flexible-chart>
</div>
</mat-tab>
</mat-tab-group>

<!-- <cdk-virtual-scroll-viewport
[itemSize]="18"
style="height: 200px; width: 100%"
> -->
<!-- <div style="display: flex">
<div *ngFor="let col of selectedColumns" style="flex: 1; height: 18px">
<strong>{{ columnDictionary[col] }}</strong>
</div>
</div>
<div *ngFor="let item of selectedStreams" style="display: flex">
<div *ngFor="let col of selectedColumns" style="flex: 1; height: 18px">
<span>{{ item[col] }}</span>
</div>
</div> -->
<!-- </cdk-virtual-scroll-viewport> -->
</mat-card>
</modal-resizable>
Loading

0 comments on commit e04d9bc

Please sign in to comment.