dashboard

This commit is contained in:
insanity 2018-02-22 19:09:48 +09:00
parent 48d038610e
commit 243826905b
4 changed files with 110 additions and 29 deletions

View File

@ -1,12 +1,22 @@
<mat-form-field> <mat-form-field>
<input matInput placeholder="Search"> <input matInput type="text" placeholder="Search" [(ngModel)]="searchWord" (ngModelChange)="handleSearch($event)">
<button mat-button *ngIf="searchWord" matSuffix mat-icon-button aria-label="Clear" (click)="handleCleanSearch()">
<mat-icon>close</mat-icon>
</button>
</mat-form-field> </mat-form-field>
<p *ngIf="dashboards == null || dashboards.length == 0">No dashboards found.</p>
<div *ngFor="let dashboard of dashboards"> <perfect-scrollbar style="height: 200px">
<p *ngIf="dashboards == null || dashboards.length == 0">No dashboards found.</p>
<div *ngFor="let dashboard of dashboards">
<button mat-button>{{dashboard.name}}</button> <button mat-button>{{dashboard.name}}</button>
</div> </div>
</perfect-scrollbar>
<mat-divider></mat-divider> <mat-divider></mat-divider>
<mat-form-field> <mat-form-field>
<input matInput placeholder="New Dashboard"> <input matInput placeholder="New Dashboard" [(ngModel)]="newDashName">
<mat-error>
test
</mat-error>
</mat-form-field> </mat-form-field>
<button mat-raised-button color="accent">OK</button> <button mat-raised-button color="accent" (click)="handleNewDashboard(newDashName)">OK</button>

View File

@ -7,7 +7,46 @@ import { Component, OnInit, Input } from '@angular/core';
}) })
export class AddDashboardDialogComponent implements OnInit { export class AddDashboardDialogComponent implements OnInit {
dashboards = [ private searchWord;
private dashboards;
private staticDashboards;
constructor() { }
ngOnInit() {
this.staticDashboards = [
{
id: '0',
name: 'Dashboard1',
},
{
id: '1',
name: 'Dashboard2',
},
{
id: '2',
name: 'Dashboard3',
},
{
id: '3',
name: 'Dashboard4',
},
{
id: '0',
name: 'Dashboard1',
},
{
id: '1',
name: 'Dashboard2',
},
{
id: '2',
name: 'Dashboard3',
},
{
id: '3',
name: 'Dashboard4',
},
{ {
id: '0', id: '0',
name: 'Dashboard1', name: 'Dashboard1',
@ -25,10 +64,38 @@ export class AddDashboardDialogComponent implements OnInit {
name: 'Dashboard4', name: 'Dashboard4',
}, },
]; ];
this.dashboards = this.staticDashboards;
constructor() { }
ngOnInit() {
} }
handleSearch(v: any) {
const tempArr = new Array();
for (const dashboard of this.staticDashboards) {
if (dashboard.name.indexOf(v) !== -1) {
tempArr.push(dashboard);
}
}
this.dashboards = tempArr;
}
handleNewDashboard(v: any) {
this.searchWord = '';
for (const dashboard of this.staticDashboards) {
if (dashboard.name === v) {
return;
}
}
// temporary
const newDash = {
id: '5',
name: v
};
this.staticDashboards.push(newDash);
this.handleSearch('');
}
handleCleanSearch() {
this.searchWord = '';
this.handleSearch('');
}
} }

View File

@ -1,5 +1,4 @@
<div fxLayout="row" fxLayoutAlign="space-between stretch" fxFlexFil fxFill fxLayoutGap="1px"> <div fxLayout="row" fxLayoutAlign="space-between stretch" fxFlexFil fxFill fxLayoutGap="1px">
<div fxFlex="70" fxLayout="column" class="mat-elevation-z2 activity-list-container"> <div fxFlex="70" fxLayout="column" class="mat-elevation-z2 activity-list-container">
<div fxLayout="row" fxLayoutAlign="space-between center"> <div fxLayout="row" fxLayoutAlign="space-between center">
@ -18,9 +17,13 @@
<of-sensor-item-filter></of-sensor-item-filter> <of-sensor-item-filter></of-sensor-item-filter>
</div> </div>
<div fxLayout="row" fxLayoutWrap fxLayoutAlign="end">
<button mat-raised-button (click)="openDialog()">대시보드에 추가</button>
</div> </div>
<div fxFlex="30" fxLayout="column" class="mat-elevation-z2 activity-add" > </div>
<div fxFlex="30" fxLayout="column" class="mat-elevation-z2 activity-add">
<div fxFlex="10" fxLayout="row" fxLayoutAlign="space-between center"> <div fxFlex="10" fxLayout="row" fxLayoutAlign="space-between center">
<h3 class="mat-headline" fxFlex="80">Activities</h3> <h3 class="mat-headline" fxFlex="80">Activities</h3>
</div> </div>
@ -41,5 +44,4 @@
</div> </div>
</div> </div>
<div> <div>
<!-- <button mat-raised-button (click)="openDialog()">Pick one</button> -->
</div> </div>

View File

@ -12,6 +12,7 @@ import { SensorItemFilterComponent } from '../../commons/component/sensor-item-f
import { NgxChartsModule } from '@swimlane/ngx-charts'; import { NgxChartsModule } from '@swimlane/ngx-charts';
import { HostSummaryCardComponent } from '../../commons/component/host-summary-card/host-summary-card.component'; import { HostSummaryCardComponent } from '../../commons/component/host-summary-card/host-summary-card.component';
import { AppSummaryCardComponent } from '../../commons/component/app-summary-card/app-summary-card.component'; import { AppSummaryCardComponent } from '../../commons/component/app-summary-card/app-summary-card.component';
import { FormsModule } from '@angular/forms';
@NgModule({ @NgModule({
imports: [ imports: [
@ -20,7 +21,8 @@ import { AppSummaryCardComponent } from '../../commons/component/app-summary-car
DashboardCardModule, DashboardCardModule,
MaterialModule, MaterialModule,
PerfectScrollbarModule, PerfectScrollbarModule,
NgxChartsModule NgxChartsModule,
FormsModule
], ],
declarations: [ declarations: [
OverviewPageComponent, OverviewPageComponent,