79 lines
2.0 KiB
TypeScript
79 lines
2.0 KiB
TypeScript
import { Component, OnInit, AfterContentInit } from '@angular/core';
|
|
import { Infra, InfraHost, InfraOSApplication } from '../../model';
|
|
import { Store, select } from '@ngrx/store';
|
|
import { RPCError } from 'packages/core/rpc/error';
|
|
import { AuthSelector } from 'packages/member/store';
|
|
import * as ListStore from '../../store/list';
|
|
import { ListSelector } from '../../store';
|
|
import { Page, PageParams } from 'app/commons/model';
|
|
import { Domain } from '../../../domain/model';
|
|
import { MatDialog } from '@angular/material';
|
|
import { SettingComponent } from '../../../sensor/component/setting/setting.component';
|
|
|
|
@Component({
|
|
selector: 'of-infra-map',
|
|
templateUrl: './map.component.html',
|
|
styleUrls: ['./map.component.scss']
|
|
})
|
|
export class MapComponent implements OnInit, AfterContentInit {
|
|
|
|
infras$ = this.listStore.pipe(select(ListSelector.select('page')));
|
|
infras: Infra[];
|
|
|
|
constructor(
|
|
private listStore: Store<ListStore.State>,
|
|
public dialog: MatDialog
|
|
) { }
|
|
|
|
ngOnInit() {
|
|
this.infras$.subscribe(
|
|
(page: Page) => {
|
|
if (page !== null) {
|
|
console.log(page);
|
|
this.infras = page.content;
|
|
}
|
|
},
|
|
(error: RPCError) => {
|
|
console.log(error.response.message);
|
|
}
|
|
);
|
|
}
|
|
|
|
ngAfterContentInit() {
|
|
this.getInfraList();
|
|
}
|
|
|
|
getInfraList() {
|
|
this.listStore.select(AuthSelector.select('domain')).subscribe(
|
|
(domain: Domain) => {
|
|
const pageParams: PageParams = {
|
|
pageNo: '0',
|
|
countPerPage: '9999999',
|
|
sortCol: 'id',
|
|
sortDirection: 'descending'
|
|
};
|
|
this.listStore.dispatch(new ListStore.ReadAllByDomain({domain, pageParams}));
|
|
},
|
|
(error) => {
|
|
console.log(error);
|
|
}
|
|
);
|
|
}
|
|
|
|
addSensor(infra: Infra) {
|
|
const targetId = infra.target.id;
|
|
console.log(targetId);
|
|
|
|
const dialogRef = this.dialog.open(SettingComponent, {
|
|
width: '80%',
|
|
data: { }
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe(result => {
|
|
console.log('The dialog was closed');
|
|
});
|
|
|
|
}
|
|
|
|
}
|