sensor setting - target list

This commit is contained in:
insanity 2018-03-29 19:37:39 +09:00
parent 52848505e8
commit 43d1f4ccc6
5 changed files with 49 additions and 10 deletions

View File

@ -24,7 +24,7 @@
<span matTooltip="showHostInfo(infra)">IP : {{infra.host.ip}}</span> <span matTooltip="showHostInfo(infra)">IP : {{infra.host.ip}}</span>
<span class="pull-right"></span> <span class="pull-right"></span>
<span style="margin-right: 20px"> <span style="margin-right: 20px">
<of-sensor-name-tag [target]="infra.target"></of-sensor-name-tag> <!-- <of-sensor-name-tag [target]="infra.target"></of-sensor-name-tag> -->
</span> </span>
<button mat-raised-button color="primary" fxLayoutAlign="end" (click)="addSensor(infra)">Add Sensor</button> <button mat-raised-button color="primary" fxLayoutAlign="end" (click)="addSensor(infra)">Add Sensor</button>
</mat-toolbar-row> </mat-toolbar-row>
@ -46,7 +46,7 @@
</mat-grid-tile> </mat-grid-tile>
<mat-grid-tile [colspan]="3" style="background-color: lightgreen"> <mat-grid-tile [colspan]="3" style="background-color: lightgreen">
<div class="grid-left-align"> <div class="grid-left-align">
<of-sensor-name-tag [target]="service.target"></of-sensor-name-tag> <!-- <of-sensor-name-tag [target]="service.target"></of-sensor-name-tag> -->
</div> </div>
</mat-grid-tile> </mat-grid-tile>
</mat-grid-list> </mat-grid-list>

View File

@ -175,8 +175,6 @@ export class MapComponent implements OnInit, AfterContentInit {
} }
addSensor(infra: Infra) { addSensor(infra: Infra) {
const targetId = infra.target.id;
const dialogRef = this.dialog.open(SettingComponent, { const dialogRef = this.dialog.open(SettingComponent, {
width: '80%', width: '80%',
data: { data: {

View File

@ -32,6 +32,6 @@
<button mat-raised-button *ngIf="step === 2" (click)="onPrev()">Prev</button> <button mat-raised-button *ngIf="step === 2" (click)="onPrev()">Prev</button>
<button mat-raised-button color="primary" (click)="onNext()" *ngIf="step === 1" [disabled]="!nextable">Next</button> <button mat-raised-button color="primary" (click)="onNext()" *ngIf="step === 1" [disabled]="!nextable">Next</button>
<button mat-raised-button color="primary" (click)="onDone()" [mat-dialog-close]="true" *ngIf="step === 2">Done</button> <button mat-raised-button color="primary" [mat-dialog-close]="true" *ngIf="step === 2">Done</button>
</div> </div>
</div> </div>

View File

@ -9,7 +9,7 @@
<perfect-scrollbar style="height: 150px"> <perfect-scrollbar style="height: 150px">
<mat-radio-group class="radio-group" > <mat-radio-group class="radio-group" >
<mat-radio-button class="radio-button" *ngFor="let t of targets" value={{t.id}} (change)="targetSelected(t)" [checked]="t.id === target.id"> <mat-radio-button class="radio-button" *ngFor="let t of targets" value={{t.id}} (change)="targetSelected(t)" [checked]="targets.length === 0 && t.id === target.id">
{{t.displayName}} {{t.displayName}}
</mat-radio-button> </mat-radio-button>
</mat-radio-group> </mat-radio-group>

View File

@ -1,8 +1,14 @@
import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core'; import { Component, OnInit, Output, EventEmitter, Input, AfterContentInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { MatRadioButton } from '@angular/material'; import { MatRadioButton } from '@angular/material';
import { Target } from 'packages/target/model'; import { Target } from 'packages/target/model';
import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { Domain } from 'packages/domain/model';
import { AuthSelector } from 'packages/member/store';
import * as ListStore from 'packages/infra/store/list';
import { ListSelector } from 'packages/infra/store';
import { Store, select } from '@ngrx/store';
import { Page, PageParams } from 'app/commons/model';
@Component({ @Component({
selector: 'of-target-selector', selector: 'of-target-selector',
@ -11,11 +17,16 @@ import { Target } from 'packages/target/model';
}) })
export class TargetSelectorComponent implements OnInit { export class TargetSelectorComponent implements OnInit {
targets$ = this.store.pipe(select(ListSelector.select('page')));
@Input() target: Target = null; @Input() target: Target = null;
@Output() targetSelectEvent = new EventEmitter<Target>(); @Output() targetSelectEvent = new EventEmitter<Target>();
targets: Target[] = null; targets: Target[] = null;
constructor(private router: Router) { } constructor(
private router: Router,
private store: Store<ListStore.State>
) { }
ngOnInit() { ngOnInit() {
this.targets = new Array(); this.targets = new Array();
@ -24,10 +35,40 @@ export class TargetSelectorComponent implements OnInit {
} else { } else {
this.targets.push(this.target); this.targets.push(this.target);
} }
this.targets$.subscribe(
(page: Page) => {
if (page !== null) {
this.convertInfraToTarget(page);
}
},
(error: RPCClientError) => {
console.log(error.response.message);
}
);
}
convertInfraToTarget(page: Page) {
for (const infra of page.content) {
this.targets.push(infra.target);
}
} }
getTargetList() { getTargetList() {
console.log('go get infraService.readAllByDomain'); this.store.select(AuthSelector.select('domain')).subscribe(
(domain: Domain) => {
const pageParams: PageParams = {
pageNo: '0',
countPerPage: '9999',
sortCol: 'id',
sortDirection: 'descending'
};
this.store.dispatch(new ListStore.ReadAllByDomain({ domain, pageParams }));
},
(error) => {
console.log(error);
}
);
} }
targetSelected(t: Target) { targetSelected(t: Target) {