This commit is contained in:
geek 2018-06-21 20:10:18 +09:00
parent aa810aef68
commit b37da1441d
17 changed files with 1917 additions and 1923 deletions

View File

@ -1,9 +1,9 @@
import { DetailComponent } from './detail/detail.component'; import { TargetDetailComponent } from './target-detail.component';
import { ListComponent } from './list/list.component'; import { TargetListComponent } from './target-list.component';
import {FilterComponent} from './list/filter/filter.component'; import {TargetFilterComponent} from './target-filter.component';
export const COMPONENTS = [ export const COMPONENTS = [
ListComponent, TargetListComponent,
DetailComponent, TargetDetailComponent,
FilterComponent TargetFilterComponent
]; ];

View File

@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DetailComponent } from './detail.component'; import { TargetDetailComponent } from './detail.component';
describe('DetailComponent', () => { describe('DetailComponent', () => {
let component: DetailComponent; let component: TargetDetailComponent;
let fixture: ComponentFixture<DetailComponent>; let fixture: ComponentFixture<TargetDetailComponent>;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ DetailComponent ] declarations: [ TargetDetailComponent ]
}) })
.compileComponents(); .compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(DetailComponent); fixture = TestBed.createComponent(TargetDetailComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -1,6 +1,6 @@
import { Component, ViewChild, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { Target } from '@overflow/commons-typescript/model/target'; import { Target } from '@overflow/commons-typescript/model/target';
import {TargetService} from '../../service/target.service'; import {TargetService} from '../service/target.service';
import { import {
Observable, Observable,
@ -17,9 +17,9 @@ import {
@Component({ @Component({
selector: 'of-target-detail', selector: 'of-target-detail',
templateUrl: './detail.component.html', templateUrl: './target-detail.component.html',
}) })
export class DetailComponent implements OnInit { export class TargetDetailComponent implements OnInit {
@Input() targetID: number; @Input() targetID: number;

View File

@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FilterComponent } from './filter.component'; import { TargetFilterComponent } from './target-filter.component';
describe('FilterComponent', () => { describe('FilterComponent', () => {
let component: FilterComponent; let component: TargetFilterComponent;
let fixture: ComponentFixture<FilterComponent>; let fixture: ComponentFixture<TargetFilterComponent>;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ FilterComponent ] declarations: [ TargetFilterComponent ]
}) })
.compileComponents(); .compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(FilterComponent); fixture = TestBed.createComponent(TargetFilterComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -4,10 +4,10 @@ import { Router } from '@angular/router';
@Component({ @Component({
selector: 'of-target-filter', selector: 'of-target-filter',
templateUrl: './filter.component.html', templateUrl: './target-filter.component.html',
styleUrls: ['./filter.component.scss'] styleUrls: ['./target-filter.component.scss']
}) })
export class FilterComponent implements OnInit { export class TargetFilterComponent implements OnInit {
constructor(private router: Router) { } constructor(private router: Router) { }

View File

@ -1,10 +1,10 @@
<h1>Targets</h1> <h1>Targets</h1>
<div *ngIf="!targetPage; else content"> <div *ngIf="!targetList; else content">
No data No data
</div> </div>
<ng-template #content> <ng-template #content>
<p-table [value]="targetPage.content" selectionMode="single" (onRowSelect)="onRowSelect($event)" [resizableColumns]="true" > <p-table [value]="targetList" selectionMode="single" (onRowSelect)="onRowSelect($event)" [resizableColumns]="true" >
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th style="width: 4em">No.</th> <th style="width: 4em">No.</th>
@ -18,7 +18,7 @@
</ng-template> </ng-template>
<ng-template pTemplate="body" let-target let-rowIndex="rowIndex"> <ng-template pTemplate="body" let-target let-rowIndex="rowIndex">
<tr [pSelectableRow]="target"> <tr [pSelectableRow]="target">
<td>{{(rowIndex + 1) + ((pageIdx - 1) * countPerPage)}}</td> <td>{{(rowIndex + 1) }}</td>
<td></td> <td></td>
<td>{{target.infra.metaInfraType.name}}</td> <td>{{target.infra.metaInfraType.name}}</td>
<td>{{target.displayName}}</td> <td>{{target.displayName}}</td>
@ -30,8 +30,8 @@
</tr> </tr>
</ng-template> </ng-template>
</p-table> </p-table>
<p-paginator #paginator [rows]="targetPage.size" [totalRecords]="targetPage.totalElements" [first]="(pageIdx-1) * targetPage.size" <!--<p-paginator #paginator [rows]="targetPage.size" [totalRecords]="targetPage.totalElements" [first]="(pageIdx-1) * targetPage.size"-->
(onPageChange)="onPaginate($event)"></p-paginator> <!--(onPageChange)="onPaginate($event)"></p-paginator>-->
</ng-template> </ng-template>

View File

@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ListComponent } from './list.component'; import { TargetListComponent } from './list.component';
describe('ListComponent', () => { describe('ListComponent', () => {
let component: ListComponent; let component: TargetListComponent;
let fixture: ComponentFixture<ListComponent>; let fixture: ComponentFixture<TargetListComponent>;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ListComponent ] declarations: [ TargetListComponent ]
}) })
.compileComponents(); .compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ListComponent); fixture = TestBed.createComponent(TargetListComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -21,17 +21,16 @@ import {
} from 'rxjs/operators'; } from 'rxjs/operators';
import { Target } from '@overflow/commons-typescript/model/target'; import { Target } from '@overflow/commons-typescript/model/target';
import { TargetService } from '../../service/target.service'; import { TargetService } from '../service/target.service';
import { Paginator } from 'primeng/primeng'; import { Paginator } from 'primeng/primeng';
import { Page, PageParams} from '@overflow/commons-typescript';
import {PlatformLocation} from '@angular/common'; import {PlatformLocation} from '@angular/common';
@Component({ @Component({
selector: 'of-target-list', selector: 'of-target-list',
templateUrl: './list.component.html', templateUrl: './target-list.component.html',
}) })
export class ListComponent implements OnChanges { export class TargetListComponent implements OnChanges {
@Input() probeID; @Input() probeID;
@Input() pageIdx; @Input() pageIdx;
@ -40,18 +39,18 @@ export class ListComponent implements OnChanges {
@ViewChild('paginator') paginator: Paginator; @ViewChild('paginator') paginator: Paginator;
targetPage: Page<Target>; targetList: Target[];
pending$: Observable<boolean>; pending$: Observable<boolean>;
error$: Observable<any>; error$: Observable<any>;
countPerPage: number; // countPerPage: number;
constructor( constructor(
private store: Store<any>, private store: Store<any>,
private targetService: TargetService, private targetService: TargetService,
private location: PlatformLocation private location: PlatformLocation
) { ) {
this.countPerPage = 2; // this.countPerPage = 2;
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
@ -65,26 +64,27 @@ export class ListComponent implements OnChanges {
} }
private getTargetList() { private getTargetList() {
if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null || isNaN(this.pageIdx)) { // if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null || isNaN(this.pageIdx)) {
this.pageIdx = 1; // this.pageIdx = 1;
} // }
const p: number = this.pageIdx - 1; const p: number = this.pageIdx - 1;
const pageParams: PageParams = { // const pageParams: PageParams = {
pageNo: p, // pageNo: p,
countPerPage: this.countPerPage, // countPerPage: this.countPerPage,
sortCol: 'id', // sortCol: 'id',
sortDirection: 'descending', // sortDirection: 'descending',
}; // };
this.targetService.readAllByProbeID(this.probeID, pageParams) // this.targetService.readAllByProbeID(this.probeID, pageParams)
this.targetService.readAllByProbeID(this.probeID)
.pipe( .pipe(
tap(() => { tap(() => {
this.pending$ = of(true); this.pending$ = of(true);
}), }),
map((page: Page<Target>) => { map((targetList: Target[]) => {
this.targetPage = page; this.targetList = targetList;
}), }),
catchError(err => { catchError(err => {
console.log(err); console.log(err);

View File

@ -31,8 +31,8 @@ export class TargetService {
return this.rpcService.call<Target>('TargetService.read', id); return this.rpcService.call<Target>('TargetService.read', id);
} }
public readAllByProbeID(probeID: number, pageParams: PageParams): Observable<Page<Target>> { public readAllByProbeID(probeID: number): Observable<Target[]> {
return this.rpcService.call<Page<Target>>('TargetService.readAllByProbeID', probeID, pageParams); return this.rpcService.call<Target[]>('TargetService.readAllByProbeID', probeID);
} }
public readAllTargetByProbeID(probeID: number): Observable<Target[]> { public readAllTargetByProbeID(probeID: number): Observable<Target[]> {

View File

@ -5,8 +5,6 @@ import { UIModule } from '@overflow/shared/ui/ui.module';
import { COMPONENTS } from './component'; import { COMPONENTS } from './component';
import { SERVICES } from './service'; import { SERVICES } from './service';
import { SensorModule } from '../sensor/sensor.module';
import { InfraModule } from '../infra/infra.module';
@NgModule({ @NgModule({
imports: [ imports: [

3704
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,4 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { trigger, state, style, transition, animate } from '@angular/animations';
import { MenuItem } from 'primeng/primeng';
import { AppComponent } from '../../../../app.component';
import { PagesComponent } from '../../../../pages/pages.component'; import { PagesComponent } from '../../../../pages/pages.component';
@Component({ @Component({

View File

@ -1,7 +1,6 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input } from '@angular/core';
import { trigger, state, style, transition, animate } from '@angular/animations'; import { trigger, state, style, transition, animate } from '@angular/animations';
import { MenuItem } from 'primeng/primeng'; import { MenuItem } from 'primeng/primeng';
import { AppComponent } from '../../../../app.component';
import { PagesComponent } from '../../../../pages/pages.component'; import { PagesComponent } from '../../../../pages/pages.component';
@Component({ @Component({

View File

@ -18,19 +18,19 @@ export class TargetListPageComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.probeID = this.activatedRoute.snapshot.params['probeID']; this.probeID = this.activatedRoute.snapshot.params['probeID'];
this.activatedRoute.queryParams.subscribe(queryParams => { // this.activatedRoute.queryParams.subscribe(queryParams => {
this.pageIdx = Number(queryParams['page']); // this.pageIdx = Number(queryParams['page']);
if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null || isNaN(this.pageIdx)) { // if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null || isNaN(this.pageIdx)) {
this.pageIdx = 1; // this.pageIdx = 1;
} // }
}); // });
} }
onPageChange(pageNo: number) { // onPageChange(pageNo: number) {
this.pageIdx = pageNo + 1; // // this.pageIdx = pageNo + 1;
this.router.navigate(['/probe', this.probeID, 'target'], { queryParams: { page: this.pageIdx } }); // this.router.navigate(['/probe', this.probeID, 'target'], { queryParams: { page: this.pageIdx } });
} // }
onTargetSelect(target: Target) { onTargetSelect(target: Target) {
this.router.navigate(['probe', this.probeID, 'target', target.id, 'info'], { queryParams: { page: this.pageIdx } }); this.router.navigate(['probe', this.probeID, 'target', target.id, 'info'], { queryParams: { page: this.pageIdx } });