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 { ListComponent } from './list/list.component';
import {FilterComponent} from './list/filter/filter.component';
import { TargetDetailComponent } from './target-detail.component';
import { TargetListComponent } from './target-list.component';
import {TargetFilterComponent} from './target-filter.component';
export const COMPONENTS = [
ListComponent,
DetailComponent,
FilterComponent
TargetListComponent,
TargetDetailComponent,
TargetFilterComponent
];

View File

@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DetailComponent } from './detail.component';
import { TargetDetailComponent } from './detail.component';
describe('DetailComponent', () => {
let component: DetailComponent;
let fixture: ComponentFixture<DetailComponent>;
let component: TargetDetailComponent;
let fixture: ComponentFixture<TargetDetailComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DetailComponent ]
declarations: [ TargetDetailComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DetailComponent);
fixture = TestBed.createComponent(TargetDetailComponent);
component = fixture.componentInstance;
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 {TargetService} from '../../service/target.service';
import {TargetService} from '../service/target.service';
import {
Observable,
@ -17,9 +17,9 @@ import {
@Component({
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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,8 +31,8 @@ export class TargetService {
return this.rpcService.call<Target>('TargetService.read', id);
}
public readAllByProbeID(probeID: number, pageParams: PageParams): Observable<Page<Target>> {
return this.rpcService.call<Page<Target>>('TargetService.readAllByProbeID', probeID, pageParams);
public readAllByProbeID(probeID: number): Observable<Target[]> {
return this.rpcService.call<Target[]>('TargetService.readAllByProbeID', probeID);
}
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 { SERVICES } from './service';
import { SensorModule } from '../sensor/sensor.module';
import { InfraModule } from '../infra/infra.module';
@NgModule({
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 { trigger, state, style, transition, animate } from '@angular/animations';
import { MenuItem } from 'primeng/primeng';
import { AppComponent } from '../../../../app.component';
import { PagesComponent } from '../../../../pages/pages.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 { MenuItem } from 'primeng/primeng';
import { AppComponent } from '../../../../app.component';
import { PagesComponent } from '../../../../pages/pages.component';
@Component({

View File

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