diff --git a/webui/.angular-cli.json b/webui/.angular-cli.json index 145265719..dc1419956 100644 --- a/webui/.angular-cli.json +++ b/webui/.angular-cli.json @@ -8,7 +8,7 @@ "root": "src", "outDir": "dist", "assets": [ - "assets", + "assets/images", "favicon.ico" ], "index": "index.html", @@ -19,7 +19,7 @@ "testTsconfig": "tsconfig.spec.json", "prefix": "app", "styles": [ - "styles/app.sass" + "app.sass" ], "scripts": [ "../node_modules/@fortawesome/fontawesome/index.js", diff --git a/webui/package.json b/webui/package.json index 9dec23f21..b52a59d60 100644 --- a/webui/package.json +++ b/webui/package.json @@ -27,7 +27,7 @@ "@angular/router": "^5.2.0", "@fortawesome/fontawesome": "^1.1.5", "@fortawesome/fontawesome-free-solid": "^5.0.10", - "bulma": "^0.6.2", + "bulma": "^0.7.0", "core-js": "^2.4.1", "d3": "^4.13.0", "date-fns": "^1.29.0", diff --git a/webui/src/app.sass b/webui/src/app.sass new file mode 100644 index 000000000..64a380502 --- /dev/null +++ b/webui/src/app.sass @@ -0,0 +1,27 @@ +@charset "utf-8" + +@import 'styles/typography' +@import 'styles/variables' +@import 'styles/colors' +@import '~bulma/sass/utilities/all' +@import '~bulma/sass/base/all' +@import '~bulma/sass/grid/all' +@import '~bulma/sass/elements/container' +@import '~bulma/sass/elements/tag' +@import '~bulma/sass/elements/other' +@import '~bulma/sass/elements/box' +@import '~bulma/sass/elements/form' +@import '~bulma/sass/elements/table' +@import '~bulma/sass/components/navbar' +@import '~bulma/sass/components/tabs' +@import '~bulma/sass/elements/notification' +@import 'styles/nav' +@import 'styles/content' +@import 'styles/message' +@import 'styles/charts' +@import 'styles/helper' + +html + font-family: $open-sans + height: 100% + background: $background diff --git a/webui/src/app/app.component.spec.ts b/webui/src/app/app.component.spec.ts index 16c7679ce..8836204f4 100644 --- a/webui/src/app/app.component.spec.ts +++ b/webui/src/app/app.component.spec.ts @@ -1,4 +1,4 @@ -import { TestBed, async } from '@angular/core/testing'; +import { async, TestBed } from '@angular/core/testing'; import { AppComponent } from './app.component'; describe('AppComponent', () => { diff --git a/webui/src/app/app.module.ts b/webui/src/app/app.module.ts index a544f385f..c9ba2741a 100644 --- a/webui/src/app/app.module.ts +++ b/webui/src/app/app.module.ts @@ -1,18 +1,21 @@ -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; import { CommonModule } from '@angular/common'; -import { RouterModule } from '@angular/router'; import { HttpClientModule } from '@angular/common/http'; +import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; +import { BrowserModule } from '@angular/platform-browser'; +import { RouterModule } from '@angular/router'; +import { AppComponent } from './app.component'; +import { BarChartComponent } from './charts/bar-chart/bar-chart.component'; +import { LineChartComponent } from './charts/line-chart/line-chart.component'; +import { HeaderComponent } from './components/header/header.component'; +import { HealthComponent } from './components/health/health.component'; +import { ProvidersComponent } from './components/providers/providers.component'; +import { LetDirective } from './directives/let.directive'; +import { BackendFilterPipe } from './pipes/backend.filter.pipe'; +import { FrontendFilterPipe } from './pipes/frontend.filter.pipe'; +import { KeysPipe } from './pipes/keys.pipe'; import { ApiService } from './services/api.service'; import { WindowService } from './services/window.service'; -import { AppComponent } from './app.component'; -import { HeaderComponent } from './components/header/header.component'; -import { ProvidersComponent } from './components/providers/providers.component'; -import { HealthComponent } from './components/health/health.component'; -import { LineChartComponent } from './charts/line-chart/line-chart.component'; -import { BarChartComponent } from './charts/bar-chart/bar-chart.component'; -import { KeysPipe } from './pipes/keys.pipe'; @NgModule({ declarations: [ @@ -22,7 +25,10 @@ import { KeysPipe } from './pipes/keys.pipe'; HealthComponent, LineChartComponent, BarChartComponent, - KeysPipe + KeysPipe, + FrontendFilterPipe, + BackendFilterPipe, + LetDirective ], imports: [ BrowserModule, @@ -30,8 +36,8 @@ import { KeysPipe } from './pipes/keys.pipe'; HttpClientModule, FormsModule, RouterModule.forRoot([ - { path: '', component: ProvidersComponent, pathMatch: 'full' }, - { path: 'status', component: HealthComponent } + {path: '', component: ProvidersComponent, pathMatch: 'full'}, + {path: 'status', component: HealthComponent} ]) ], providers: [ diff --git a/webui/src/app/charts/bar-chart/bar-chart.component.ts b/webui/src/app/charts/bar-chart/bar-chart.component.ts index 8d130c4fb..47946d9ae 100644 --- a/webui/src/app/charts/bar-chart/bar-chart.component.ts +++ b/webui/src/app/charts/bar-chart/bar-chart.component.ts @@ -1,15 +1,7 @@ -import { Component, Input, OnInit, ElementRef, OnChanges, SimpleChanges } from '@angular/core'; +import { Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; +import { axisBottom, axisLeft, easeLinear, max, min, scaleBand, scaleLinear, select } from 'd3'; +import * as _ from 'lodash'; import { WindowService } from '../../services/window.service'; -import { - min, - max, - easeLinear, - select, - axisLeft, - axisBottom, - scaleBand, - scaleLinear -} from 'd3'; @Component({ selector: 'app-bar-chart', @@ -23,12 +15,12 @@ export class BarChartComponent implements OnInit, OnChanges { x: any; y: any; g: any; - bars: any; width: number; height: number; - margin = { top: 40, right: 40, bottom: 40, left: 40 }; + margin = {top: 40, right: 40, bottom: 40, left: 40}; loading: boolean; data: any[]; + previousData: any[]; constructor(public elementRef: ElementRef, public windowService: WindowService) { this.loading = true; @@ -37,7 +29,7 @@ export class BarChartComponent implements OnInit, OnChanges { ngOnInit() { this.barChartEl = this.elementRef.nativeElement.querySelector('.bar-chart'); this.setup(); - setTimeout(() => this.loading = false, 4000); + setTimeout(() => this.loading = false, 1000); this.windowService.resize.subscribe(w => this.draw()); } @@ -47,15 +39,20 @@ export class BarChartComponent implements OnInit, OnChanges { return; } - this.data = this.value; - this.draw(); + if (!_.isEqual(this.previousData, this.value)) { + this.previousData = _.cloneDeep(this.value); + this.data = this.value; + + this.draw(); + } } setup(): void { this.width = this.barChartEl.clientWidth - this.margin.left - this.margin.right; this.height = this.barChartEl.clientHeight - this.margin.top - this.margin.bottom; - this.svg = select(this.barChartEl).append('svg') + this.svg = select(this.barChartEl) + .append('svg') .attr('width', this.width + this.margin.left + this.margin.right) .attr('height', this.height + this.margin.top + this.margin.bottom); @@ -73,11 +70,16 @@ export class BarChartComponent implements OnInit, OnChanges { } draw(): void { + if (this.barChartEl.clientWidth === 0 || this.barChartEl.clientHeight === 0) { + this.previousData = []; + } else { + this.width = this.barChartEl.clientWidth - this.margin.left - this.margin.right; + this.height = this.barChartEl.clientHeight - this.margin.top - this.margin.bottom; + } + this.x.domain(this.data.map((d: any) => d.code)); this.y.domain([0, max(this.data, (d: any) => d.count)]); - this.width = this.barChartEl.clientWidth - this.margin.left - this.margin.right; - this.height = this.barChartEl.clientHeight - this.margin.top - this.margin.bottom; this.svg .attr('width', this.width + this.margin.left + this.margin.right) @@ -93,17 +95,16 @@ export class BarChartComponent implements OnInit, OnChanges { this.g.select('.axis--y') .call(axisLeft(this.y).tickSize(-this.width)); + // Clean previous graph + this.g.selectAll('.bar').remove(); + const bars = this.g.selectAll('.bar').data(this.data); bars.enter() .append('rect') .attr('class', 'bar') - .attr('x', (d: any) => d.code) - .attr('y', (d: any) => d.count) - .attr('width', this.x.bandwidth()) - .attr('height', (d: any) => (this.height - this.y(d.count)) < 0 ? 0 : this.height - this.y(d.count)); - - bars.attr('x', (d: any) => this.x(d.code)) + .style('fill', (d: any) => 'hsl(' + Math.floor(((d.code - 100) * 310 / 427) + 50) + ', 50%, 50%)') + .attr('x', (d: any) => this.x(d.code)) .attr('y', (d: any) => this.y(d.count)) .attr('width', this.x.bandwidth()) .attr('height', (d: any) => (this.height - this.y(d.count)) < 0 ? 0 : this.height - this.y(d.count)); diff --git a/webui/src/app/charts/line-chart/line-chart.component.html b/webui/src/app/charts/line-chart/line-chart.component.html index 929411c3e..f216459d8 100644 --- a/webui/src/app/charts/line-chart/line-chart.component.html +++ b/webui/src/app/charts/line-chart/line-chart.component.html @@ -1,5 +1,5 @@
-