sensor setting - target list
This commit is contained in:
parent
52848505e8
commit
43d1f4ccc6
|
@ -24,7 +24,7 @@
|
|||
<span matTooltip="showHostInfo(infra)">IP : {{infra.host.ip}}</span>
|
||||
<span class="pull-right"></span>
|
||||
<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>
|
||||
<button mat-raised-button color="primary" fxLayoutAlign="end" (click)="addSensor(infra)">Add Sensor</button>
|
||||
</mat-toolbar-row>
|
||||
|
@ -46,7 +46,7 @@
|
|||
</mat-grid-tile>
|
||||
<mat-grid-tile [colspan]="3" style="background-color: lightgreen">
|
||||
<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>
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
|
|
|
@ -175,8 +175,6 @@ export class MapComponent implements OnInit, AfterContentInit {
|
|||
}
|
||||
|
||||
addSensor(infra: Infra) {
|
||||
const targetId = infra.target.id;
|
||||
|
||||
const dialogRef = this.dialog.open(SettingComponent, {
|
||||
width: '80%',
|
||||
data: {
|
||||
|
|
|
@ -32,6 +32,6 @@
|
|||
<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)="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>
|
|
@ -9,7 +9,7 @@
|
|||
<perfect-scrollbar style="height: 150px">
|
||||
|
||||
<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}}
|
||||
</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
|
|
|
@ -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 { MatRadioButton } from '@angular/material';
|
||||
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({
|
||||
selector: 'of-target-selector',
|
||||
|
@ -11,11 +17,16 @@ import { Target } from 'packages/target/model';
|
|||
})
|
||||
export class TargetSelectorComponent implements OnInit {
|
||||
|
||||
targets$ = this.store.pipe(select(ListSelector.select('page')));
|
||||
|
||||
@Input() target: Target = null;
|
||||
@Output() targetSelectEvent = new EventEmitter<Target>();
|
||||
targets: Target[] = null;
|
||||
|
||||
constructor(private router: Router) { }
|
||||
constructor(
|
||||
private router: Router,
|
||||
private store: Store<ListStore.State>
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.targets = new Array();
|
||||
|
@ -24,10 +35,40 @@ export class TargetSelectorComponent implements OnInit {
|
|||
} else {
|
||||
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() {
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user