This commit is contained in:
snoop 2018-02-05 15:04:29 +09:00
commit 0392e886e4
27 changed files with 253 additions and 59 deletions

View File

@ -13,7 +13,13 @@ describe('APIService', () => {
expect(service).toBeTruthy(); expect(service).toBeTruthy();
})); }));
it('should be created', inject([APIService], (service: APIService) => { it('apiService connect to server', inject([APIService], (service: APIService) => {
service.connect();
service.getConnectionStatus().subscribe(
(isConnected: boolean) => {
console.log('isConnected:' + isConnected);
}
);
expect(service).toBeTruthy(); expect(service).toBeTruthy();
})); }));

View File

@ -1,15 +1,17 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { RxWebsocketSubject } from 'app/commons/core/rx/websocket/rx-websocket-subject';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { RxWebsocketSubject } from 'app/core/rx/websocket/rx-websocket-subject';
import { RPCRegistry } from 'app/core/rpc/registry/rpc-registry';
@Injectable() @Injectable()
export class APIService { export class APIService {
private wsSocketSubject: RxWebsocketSubject<Object>; private wsSocketSubject: RxWebsocketSubject<Object>;
private rpcRegistry: RPCRegistry;
constructor() { constructor() {
this.wsSocketSubject = new RxWebsocketSubject<Object>(''); this.wsSocketSubject = new RxWebsocketSubject<Object>('ws://127.0.0.1:19090/webapp');
} }
public connect(): void { public connect(): void {
@ -22,24 +24,35 @@ export class APIService {
this.onError(error); this.onError(error);
}, },
() => { () => {
this.onDisconnected();
} }
); );
} }
public call<T>(method: string, ...args: any[]): Observable<T> {
return undefined;
}
public send(method: string, ...args: any[]): void {
}
public getConnectionStatus(): Observable<boolean> { public getConnectionStatus(): Observable<boolean> {
return this.wsSocketSubject.connectionStatus; return this.wsSocketSubject.connectionStatus;
} }
private onMessage(message: Object): void { private onMessage(message: Object): void {
// //
console.log(message);
} }
private onError(error: any): void { private onError(error: any): void {
// //
console.log(error);
} }
private onDisconnected(): void { private onDisconnected(): void {
// //
console.log('disconnected');
} }
} }

View File

@ -7,7 +7,6 @@ import {
} from 'rxjs/observable/dom/WebSocketSubject'; } from 'rxjs/observable/dom/WebSocketSubject';
import 'rxjs/add/operator/distinctUntilChanged'; import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/interval';
import 'rxjs/add/operator/share'; import 'rxjs/add/operator/share';
import 'rxjs/add/operator/takeWhile'; import 'rxjs/add/operator/takeWhile';
import 'rxjs/add/observable/interval'; import 'rxjs/add/observable/interval';
@ -112,7 +111,8 @@ export class RxWebsocketSubject<T> extends Subject<T> {
this.complete(); this.complete();
this.connectionObserver.complete(); this.connectionObserver.complete();
} }
}); }
);
} }
public send(data: any): void { public send(data: any): void {

View File

@ -1,37 +0,0 @@
$gray-lighter: #eceeef !default;
$image_path: "/assets/images/" !default;
$prefix: 'sigin';
.#{$prefix} {
&-conainer {
min-height: 100%;
background-size: cover;
padding: 100px;
}
&-main {
position: relative;
margin: 0 auto;
width: 500px;
}
}
.full-width {
width: 100%;
}
.help {
}
.is-danger {
}
.redirect {
font-size: 14px;
margin-left: 10px;
color: #00AAAA;
}

View File

@ -1,11 +1,23 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { APIService } from 'app/commons/service/api.service';
import { Member } from '../model/member';
@Injectable() @Injectable()
export class MemberService { export class MemberService {
constructor() { } public constructor(
private apiService: APIService,
) { }
signin(email: string, password: string) { public signin(email: string, password: string) {
this.apiService.call<Member>('MemberService.signin', email, password).subscribe(
(member: Member) => {
},
(error: any) => {
} }
);
}
} }

View File

@ -0,0 +1,43 @@
<div fxLayout="column" fxLayoutWrap style=" padding: 8px;">
<div fxLayout="column" fxLayout.xs="column" style="background-color: white;padding: 10px;">
<div class="mat-headline" style="margin: 20px; border-bottom: 1px solid #dddddd;">
TARGET ALIAS
</div>
<div fxLayoutAlign="end">
<button mat-raised-button>Check Alive</button>
<button mat-raised-button>Traceroute</button>
</div>
<div fxLayout="row" fxLayout.xs="column">
<div fxFlex.gt-xs="35" style="padding-top: 10px;">
info
</div>
<div fxFlex.gt-xs="10"></div>
<div style="padding: 5px 10px;" fxFlex.gt-xs="55">
<div style="height: 300px;">
<table class="table">
<tr *ngFor="let detail of tableData">
<td class="mat-subheading-1">{{ detail?.country }}</td>
<td class="text-right mat-subheading-1">{{ detail?.sales }}</td>
<td class="text-right mat-subheading-1">{{ detail?.percentage }}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,27 @@
.table {
width: 100%;
max-width: 100%;
border-collapse: collapse;
}
.table tr:first-child td {
border-top: none;
}
.text-right {
text-align: right;
}
th, td {
padding: 8px;
text-align: left;
border-top: 1px solid #ddd;
}
.nav-item {
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
cursor: default;
&:hover {
transform: translate(0, -8px);
box-shadow: 0 20px 20px rgba(0, 0, 0, .16)
}
}

View File

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

View File

@ -0,0 +1,17 @@
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'of-target-detail',
templateUrl: './detail.component.html',
styleUrls: ['./detail.component.scss']
})
export class DetailComponent implements OnInit {
@Input() sensors = [];
constructor() { }
ngOnInit() {
}
}

View File

@ -1,7 +1,7 @@
<div fxLayout="row" fxLayoutWrap fxLayoutAlign="left"> <div fxLayout="row" fxLayoutWrap fxLayoutAlign="left">
<!-- Filter --> <!-- Filter -->
<div fxFlex="30%" fxFlex.lt-sm="30" fxFlex.sm="30"> <div fxFlex="30%" fxFlex.lt-sm="30" fxFlex.sm="30" >
Filter Area Filter Area
</div> </div>

View File

@ -35,7 +35,7 @@ export class ListComponent implements OnInit, AfterContentInit {
const data: Probe[] = new Array(); const data: Probe[] = new Array();
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
const p: Probe = { const p: Probe = {
id: String('id' + i), id: String(i),
name: String('name' + i), name: String('name' + i),
ip: String('ip' + i), ip: String('ip' + i),
os: String('os' + i), os: String('os' + i),
@ -57,6 +57,6 @@ export class ListComponent implements OnInit, AfterContentInit {
} }
handleRowClick(obj: Probe) { handleRowClick(obj: Probe) {
this.router.navigate(['probe', obj.id]); this.router.navigate(['target', obj.id]);
} }
} }

View File

@ -2,15 +2,19 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ListComponent } from 'app/packages/target/component/list/list.component'; import { ListComponent } from 'app/packages/target/component/list/list.component';
import { MaterialModule } from 'app/commons/ui/material/material.module'; import { MaterialModule } from 'app/commons/ui/material/material.module';
import { DetailComponent } from './component/detail/detail.component';
import { InfoTableModule } from 'app/commons/component/info-table/info-table.module';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
MaterialModule MaterialModule,
InfoTableModule
], ],
declarations: [ListComponent], declarations: [ListComponent, DetailComponent],
exports: [ exports: [
ListComponent ListComponent,
DetailComponent
] ]
}) })
export class TargetModule { } export class TargetModule { }

View File

@ -14,6 +14,7 @@ const routes: Routes = [
{ path: 'discovery', loadChildren: './discovery/discovery-page.module#DiscoveryPageModule' }, { path: 'discovery', loadChildren: './discovery/discovery-page.module#DiscoveryPageModule' },
{ path: 'map', loadChildren: './infra/infra-page.module#InfraPageModule' }, { path: 'map', loadChildren: './infra/infra-page.module#InfraPageModule' },
{ path: 'sensor-setting', loadChildren: './sensor-setting/sensor-setting-page.module#SensorSettingPageModule' }, { path: 'sensor-setting', loadChildren: './sensor-setting/sensor-setting-page.module#SensorSettingPageModule' },
{ path: 'target', loadChildren: './target/target-page.module#TargetPageModule' },
] ]
} }
]; ];

View File

@ -20,4 +20,4 @@ const routes: Routes = [
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
exports: [RouterModule] exports: [RouterModule]
}) })
export class ProbesPageRoutingModule { } export class ProbePageRoutingModule { }

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
@Component({ @Component({
selector: 'of-pages-probe', selector: 'of-pages-probe',
@ -10,14 +10,16 @@ export class ProbePageComponent implements OnInit {
tabs = undefined; tabs = undefined;
constructor(private router: Router) { constructor(private route: ActivatedRoute, private router: Router) {
} }
ngOnInit() { ngOnInit() {
const id = this.router.url.split('probe/')[1].split('/')[0];
this.tabs = [ this.tabs = [
{ label: 'Info', path: this.router.url }, { label: 'Info', path: '/probe/' + id },
{ label: 'Targets', path: this.router.url + '/targets' }, { label: 'Targets', path: '/probe/' + id + '/targets' },
{ label: 'History', path: this.router.url + '/history' }, { label: 'History', path: '/probe/' + id + '/history' },
]; ];
} }

View File

@ -1,7 +1,7 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ProbePageComponent } from './probe-page.component'; import { ProbePageComponent } from './probe-page.component';
import { ProbesPageRoutingModule } from './probe-page-routing.module'; import { ProbePageRoutingModule } from './probe-page-routing.module';
import { MaterialModule } from 'app/commons/ui/material/material.module'; import { MaterialModule } from 'app/commons/ui/material/material.module';
import { ProbeModule } from 'app/packages/probe/probe.module'; import { ProbeModule } from 'app/packages/probe/probe.module';
import { SubMenubarModule } from 'app/commons/component/sub-menubar/sub-menubar.module'; import { SubMenubarModule } from 'app/commons/component/sub-menubar/sub-menubar.module';
@ -9,7 +9,7 @@ import { SubMenubarModule } from 'app/commons/component/sub-menubar/sub-menubar.
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
ProbesPageRoutingModule, ProbePageRoutingModule,
MaterialModule, MaterialModule,
ProbeModule, ProbeModule,
SubMenubarModule, SubMenubarModule,

View File

@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { TargetPageComponent } from './target-page.component';
const routes: Routes = [
{
path: ':id',
component: TargetPageComponent,
children: [
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class TargetPageRoutingModule { }

View File

@ -0,0 +1 @@
<of-target-detail></of-target-detail>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TargetPageComponent } from './target-page.component';
describe('ProbeComponent', () => {
let component: TargetPageComponent;
let fixture: ComponentFixture<TargetPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TargetPageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TargetPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,16 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'of-pages-target',
templateUrl: './target-page.component.html',
styleUrls: ['./target-page.component.scss']
})
export class TargetPageComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View File

@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TargetPageComponent } from './target-page.component';
import { TargetPageRoutingModule } from './target-page-routing.module';
import { MaterialModule } from 'app/commons/ui/material/material.module';
import { TargetModule } from 'app/packages/target/target.module';
import { SubMenubarModule } from 'app/commons/component/sub-menubar/sub-menubar.module';
@NgModule({
imports: [
CommonModule,
TargetPageRoutingModule,
MaterialModule,
TargetModule,
SubMenubarModule,
],
declarations: [
TargetPageComponent,
]
})
export class TargetPageModule { }