sensor in progress

This commit is contained in:
insanity 2018-05-28 14:32:04 +09:00
parent 2cce12ea37
commit 3ffc66a6e4
10 changed files with 31 additions and 19 deletions

View File

@ -1,7 +1,9 @@
import { SensorListComponent } from './list/list.component';
import { SensorDetailComponent } from './detail/detail.component';
import { SensorSettingComponent } from './setting/setting.component';
export const COMPONENTS = [
SensorListComponent,
SensorDetailComponent,
SensorSettingComponent,
];

View File

@ -21,7 +21,7 @@
<div class="ui-g-12">
<div class="ui-g">
<div class="ui-g-12 ui-md-5 ui-g-nopad">
<button type="button" label="Add Sensor" icon="ui-icon-add" pButton class="ui-button-large ui-button-width-fit" (click)="onAddSensor()"></button>
<button type="button" label="Add Sensor" icon="ui-icon-add" pButton class="ui-button-large ui-button-width-fit" (click)="addSensor.emit()"></button>
</div>
<div class="ui-g-12 ui-md-7 ui-g-nopad">
<div style="float: right; margin-top: 30px;">
@ -82,7 +82,7 @@
</div>
<div class="ui-g-2" style="text-align: center !important">
<div style="width:14px; height:14px; margin: auto;">
<button type="button" pButton icon="ui-icon-add" (click)="onAddSensorWithTarget(item.target)"></button>
<button type="button" pButton icon="ui-icon-add" (click)="addSensor.emit(item.target)"></button>
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
import { Component, Input, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { Component, Input, OnInit, OnChanges, SimpleChanges, Output, EventEmitter } from '@angular/core';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
import { Page } from '@overflow/commons-typescript/model/commons/Page';
import { Target } from '@overflow/commons-typescript/model/target';
@ -10,6 +10,7 @@ import { Target } from '@overflow/commons-typescript/model/target';
export class SensorListComponent implements OnChanges {
@Input() page: Page<Sensor>;
@Output() addSensor = new EventEmitter();
totalLength: number;
targetSensors: Object;
@ -55,6 +56,7 @@ export class SensorListComponent implements OnChanges {
return targetNode;
}
// generateTargetFilter() {
// if (this.targetOptions) {
// return;

View File

@ -4,7 +4,7 @@ import { Component } from '@angular/core';
selector: 'of-sensor-setting',
templateUrl: './setting.component.html',
})
export class SettingComponent {
export class SensorSettingComponent {
constructor(

View File

@ -1 +1 @@
<of-sensor-list [page]="page$ | async"></of-sensor-list>
<of-sensor-list [page]="page$ | async" (addSensor)="addSensor.emit($event)"></of-sensor-list>

View File

@ -8,6 +8,7 @@ import { AuthSelector } from '../../member/store';
import { Domain } from '@overflow/commons-typescript/model/domain';
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
import { Page } from '@overflow/commons-typescript/model/commons/Page';
import { Target } from '@overflow/commons-typescript/model/target';
@Component({
selector: 'of-sensor-list-container',
@ -17,6 +18,7 @@ export class SensorListContainerComponent implements OnInit {
page$: Observable<Page<Sensor>>;
@Output() select = new EventEmitter<Sensor>();
@Output() addSensor = new EventEmitter();
constructor(private store: Store<SensorEntityStore.State>) {
this.page$ = store.pipe(select(SensorPageSelector));
@ -38,4 +40,5 @@ export class SensorListContainerComponent implements OnInit {
}
);
}
}

View File

@ -1 +1 @@
<div>SENSOR_ADD_CONTAINER</div>
<of-sensor-setting></of-sensor-setting>

View File

@ -28,7 +28,7 @@ export class SensorTabPageComponent implements OnDestroy {
generateTabMenu(event: NavigationEnd) {
try {
const parsedUrl = event.url.split('sensor/')[1].split('/')[0];
this.tabs = parsedUrl === 'list' ? null : [
this.tabs = parsedUrl === 'list' || 'setting' ? null : [
{ label: 'INFO', routerLink: ['/sensor/', parsedUrl, 'info'] },
{ label: 'HISTORY', path: ['/sensor/', parsedUrl, 'history'], disabled: true },
];

View File

@ -1,11 +1,8 @@
<div *ngIf="!isDetail; else detailView">
<of-sensor-list-container (select)="onSensorSelect($event)"></of-sensor-list-container>
<of-sensor-list-container *ngIf="router.url === '/sensor/list'" (select)="onSensorSelect($event)" (addSensor)="onAddSensor($event)"> </of-sensor-list-container>
<of-sensor-setting-container *ngIf="router.url === '/sensor/setting'"></of-sensor-setting-container>
</div>
<ng-template #detailView>
<of-sensor-detail-container></of-sensor-detail-container>
<!-- <of-probe-detail-container [probeHostID]="probeHostID"
(targetSelect)="onTargetSelect($event)"
(discovery)="onDiscovery($event)"
></of-probe-detail-container> -->
</ng-template>

View File

@ -1,8 +1,8 @@
import { Component, OnDestroy } from '@angular/core';
import { Component } from '@angular/core';
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
import { Subscription } from 'rxjs/Subscription';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
import { BreadcrumbService } from '@app/commons/service/breadcrumb.service';
import { Target } from '@overflow/commons-typescript/model/target';
@Component({
selector: 'of-pages-sensor',
@ -22,14 +22,12 @@ export class SensorPageComponent {
if (params['id']) {
this.onDetailContainer(params['id']);
} else {
console.log('?');
console.log(params);
this.onListContainer();
this.onListSettingContainer();
}
});
}
onListContainer() {
onListSettingContainer() {
this.breadcrumbService.setItems([
{ label: 'Sensor', routerLink: ['/sensor/list'], }
]);
@ -49,4 +47,14 @@ export class SensorPageComponent {
this.router.navigate(['sensor', sensor.id, 'info']);
}
onAddSensor(target?: Target) {
const queryParams = target ? {
target : target.id,
mode : 'NEW',
} : {
mode : 'NEW',
};
this.router.navigate(['sensor/setting'], { queryParams: queryParams });
}
}