diff --git a/src/app/api/configuration.api.ts b/src/app/api/configuration.api.ts index 064fd8503d330dfd8f8e5a438860fbe2ba3e064c..b134ce55e56951497fbafb46c727d9739d27cad6 100644 --- a/src/app/api/configuration.api.ts +++ b/src/app/api/configuration.api.ts @@ -9,7 +9,7 @@ import { } from '../models/configuration'; import { ApiResponse } from '../models/api-response'; -export const CONFIGURATION_API_URL = '/api/v1/configuration'; +export const CONFIGURATION_API_URL = '/configurations'; @Injectable({ providedIn: 'root', diff --git a/src/app/api/dashboard.api.ts b/src/app/api/dashboard.api.ts index 3f08285d5be8adae1a1350da0cb15e29901dd36e..c6fe7e88f993baf6bd65ed6370cccb3482997987 100644 --- a/src/app/api/dashboard.api.ts +++ b/src/app/api/dashboard.api.ts @@ -1,8 +1,58 @@ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { ApiResponse } from '../models/api-response'; +import { ChartFrames } from '../models/chart-frames'; +import { map, Observable } from 'rxjs'; +import { ChartInformationRate } from '../models/chart-information-rate'; +import { ChartProtocol } from '../models/chart-protocol'; -export const DASHBOARD_API_URL = '/api/v1/dashboard'; +export const DASHBOARD_API_URL = '/statistics'; @Injectable({ providedIn: 'root', }) -export class DashboardApi {} +export class DashboardApi { + private readonly httpClient = inject(HttpClient); + + fetchFramesHistory(): Observable<ChartFrames[]> { + return this.httpClient + .get<ApiResponse<ChartFrames[]>>(`${DASHBOARD_API_URL}/frames/historical`) + .pipe(map(response => response.data)); + } + + fetchFrames(): Observable<ChartFrames> { + return this.httpClient + .get<ApiResponse<ChartFrames>>(`${DASHBOARD_API_URL}/frames/current`) + .pipe(map(response => response.data)); + } + + fetchInformationRateHistory(): Observable<ChartInformationRate[]> { + return this.httpClient + .get< + ApiResponse<ChartInformationRate[]> + >(`${DASHBOARD_API_URL}/information-rate/historical`) + .pipe(map(response => response.data)); + } + + fetchInformationRate(): Observable<ChartInformationRate> { + return this.httpClient + .get< + ApiResponse<ChartInformationRate> + >(`${DASHBOARD_API_URL}/information-rate/current`) + .pipe(map(response => response.data)); + } + + fetchProtocolHistory(): Observable<ChartProtocol[]> { + return this.httpClient + .get< + ApiResponse<ChartProtocol[]> + >(`${DASHBOARD_API_URL}/protocols/historical`) + .pipe(map(response => response.data)); + } + + fetchProtocol(): Observable<ChartProtocol> { + return this.httpClient + .get<ApiResponse<ChartProtocol>>(`${DASHBOARD_API_URL}/protocols/current`) + .pipe(map(response => response.data)); + } +} diff --git a/src/app/interceptor/interceptor.ts b/src/app/interceptor/interceptor.ts index 2dfdedf6c4fbf82c4cc97a526eb7533b346baef7..21905b02b2b875fa4dbfb9ede7656b5ba6ec3fa1 100644 --- a/src/app/interceptor/interceptor.ts +++ b/src/app/interceptor/interceptor.ts @@ -1,18 +1,48 @@ import * as configurationList from './mocks/configurations.json'; import * as configuration1 from './mocks/configuration-1.json'; import * as configuration2 from './mocks/configuration-2.json'; +import * as framesCurrent from './mocks/frames-current.json'; +import * as framesHistorical from './mocks/frames-historical.json'; +import * as irCurrent from './mocks/ir-current.json'; +import * as irHistorical from './mocks/ir-historical.json'; +import * as ipv4Current from './mocks/ipv4-current.json'; +import * as ipv4Historical from './mocks/ipv4-historical.json'; export const urls = [ { - url: '/api/v1/configuration/1abc', + url: '/configurations/1abc', json: configuration1, }, { - url: '/api/v1/configuration/2def', + url: '/configurations/2def', json: configuration2, }, { - url: '/api/v1/configuration', + url: '/configurations', json: configurationList, }, + { + url: '/statistics/frames/current', + json: framesCurrent, + }, + { + url: '/statistics/frames/historical', + json: framesHistorical, + }, + { + url: '/statistics/ir/current', + json: irCurrent, + }, + { + url: '/statistics/ir/historical', + json: irHistorical, + }, + { + url: '/statistics/ipv4/current', + json: ipv4Current, + }, + { + url: '/statistics/ipv4/historical', + json: ipv4Historical, + }, ]; diff --git a/src/app/interceptor/mocks/frames-current.json b/src/app/interceptor/mocks/frames-current.json new file mode 100644 index 0000000000000000000000000000000000000000..f336aa52d1f157a2349895600d72b08ce14323bc --- /dev/null +++ b/src/app/interceptor/mocks/frames-current.json @@ -0,0 +1,4 @@ +{ + "valid": 2345, + "invalid": 234 +} diff --git a/src/app/interceptor/mocks/frames-historical.json b/src/app/interceptor/mocks/frames-historical.json new file mode 100644 index 0000000000000000000000000000000000000000..134de06dfff8014c4600ad318640a62d7a43bfb6 --- /dev/null +++ b/src/app/interceptor/mocks/frames-historical.json @@ -0,0 +1,64 @@ +{ + "frames": [ + { + "valid": 1000, + "invalid": 15 + }, + { + "valid": 1500, + "invalid": 0 + }, + { + "valid": 100, + "invalid": 99 + }, + { + "valid": 1234, + "invalid": 123 + }, + { + "valid": 1555, + "invalid": 25 + }, + { + "valid": 1000, + "invalid": 15 + }, + { + "valid": 1500, + "invalid": 0 + }, + { + "valid": 100, + "invalid": 99 + }, + { + "valid": 1234, + "invalid": 123 + }, + { + "valid": 1555, + "invalid": 25 + }, + { + "valid": 1000, + "invalid": 15 + }, + { + "valid": 1500, + "invalid": 0 + }, + { + "valid": 100, + "invalid": 99 + }, + { + "valid": 1234, + "invalid": 123 + }, + { + "valid": 1555, + "invalid": 25 + } + ] +} diff --git a/src/app/interceptor/mocks/ipv4-current.json b/src/app/interceptor/mocks/ipv4-current.json new file mode 100644 index 0000000000000000000000000000000000000000..7b7508358d6d826d08c1d7c1166c929dd474612e --- /dev/null +++ b/src/app/interceptor/mocks/ipv4-current.json @@ -0,0 +1,4 @@ +{ + "bytes": 3000, + "packets": 58 +} diff --git a/src/app/interceptor/mocks/ipv4-historical.json b/src/app/interceptor/mocks/ipv4-historical.json new file mode 100644 index 0000000000000000000000000000000000000000..d57ce55ace16b85eb4a8ec5a2657573260add097 --- /dev/null +++ b/src/app/interceptor/mocks/ipv4-historical.json @@ -0,0 +1,68 @@ +{ + "statistics": [ + { + "bytes": 2048, + "packets": 24 + }, + { + "bytes": 1024, + "packets": 16 + }, + { + "bytes": 1526, + "packets": 32 + }, + { + "bytes": 1920, + "packets": 48 + }, + { + "bytes": 2048, + "packets": 24 + }, + { + "bytes": 1024, + "packets": 16 + }, + { + "bytes": 1526, + "packets": 32 + }, + { + "bytes": 1920, + "packets": 48 + }, + { + "bytes": 2048, + "packets": 24 + }, + { + "bytes": 1024, + "packets": 16 + }, + { + "bytes": 1526, + "packets": 32 + }, + { + "bytes": 1920, + "packets": 48 + }, + { + "bytes": 2048, + "packets": 24 + }, + { + "bytes": 1024, + "packets": 16 + }, + { + "bytes": 1526, + "packets": 32 + }, + { + "bytes": 1920, + "packets": 48 + } + ] +} diff --git a/src/app/interceptor/mocks/ir-current.json b/src/app/interceptor/mocks/ir-current.json new file mode 100644 index 0000000000000000000000000000000000000000..0aacc5849588ee1762066ce2e4769d1f30bcd1dd --- /dev/null +++ b/src/app/interceptor/mocks/ir-current.json @@ -0,0 +1,4 @@ +{ + "current": 123.45, + "average": 123.4 +} diff --git a/src/app/interceptor/mocks/ir-historical.json b/src/app/interceptor/mocks/ir-historical.json new file mode 100644 index 0000000000000000000000000000000000000000..593d6598505cfcea54948d87f7293600c50dc028 --- /dev/null +++ b/src/app/interceptor/mocks/ir-historical.json @@ -0,0 +1,52 @@ +{ + "statistics": [ + { + "current": 123.45, + "average": 134.6 + }, + { + "current": 103.45, + "average": 114.6 + }, + { + "current": 153.45, + "average": 124.6 + }, + { + "current": 193.45, + "average": 144.6 + }, + { + "current": 123.45, + "average": 134.6 + }, + { + "current": 103.45, + "average": 114.6 + }, + { + "current": 153.45, + "average": 124.6 + }, + { + "current": 193.45, + "average": 144.6 + }, + { + "current": 123.45, + "average": 134.6 + }, + { + "current": 103.45, + "average": 114.6 + }, + { + "current": 153.45, + "average": 124.6 + }, + { + "current": 193.45, + "average": 144.6 + } + ] +} diff --git a/src/app/models/chart-frames.ts b/src/app/models/chart-frames.ts new file mode 100644 index 0000000000000000000000000000000000000000..03956ce7a95779a5011bb0b094807d906e90cdb5 --- /dev/null +++ b/src/app/models/chart-frames.ts @@ -0,0 +1,4 @@ +export interface ChartFrames { + valid: number; + invalid: number; +} diff --git a/src/app/models/chart-information-rate.ts b/src/app/models/chart-information-rate.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee2919dd1e4b8a88963943f70eb749fd3e0fd5ea --- /dev/null +++ b/src/app/models/chart-information-rate.ts @@ -0,0 +1,4 @@ +export interface ChartInformationRate { + current: number; + average: number; +} diff --git a/src/app/models/chart-protocol.ts b/src/app/models/chart-protocol.ts new file mode 100644 index 0000000000000000000000000000000000000000..22844a0597a9f35b6354e6d49fa4197c00449056 --- /dev/null +++ b/src/app/models/chart-protocol.ts @@ -0,0 +1,4 @@ +export interface ChartProtocol { + bytes: number; + packets: number; +}