Skip to content

Commit 8180abe

Browse files
committed
route management service
1 parent 8fdb078 commit 8180abe

12 files changed

Lines changed: 263 additions & 25 deletions

File tree

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"/api/*":{
3-
"target":"http://127.0.0.1:8080",
3+
"target":"http://192.168.31.221:8080",
44
"secure": false,
55
"pathRewrite": {"/api" : ""}
6+
},
7+
"/route/*":{
8+
"target":"http://127.0.0.1:8080",
9+
"secure": false,
10+
"pathRewrite": {"/route" : ""}
611
}
712
}

public/API Management System/src/app/dashboard/dashboard.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { HttpModule, JsonpModule } from '@angular/http';
2929
import { ApiService } from '../APIs/api.service';
3030
import { creatAtomAPIComponent } from '../creatAtomAPI/createAtomAPI.compoment';
3131
import { flowControlComponent } from '../flowControl/flowControl.component';
32+
import { RouteService } from 'app/routeManagement/route.service';
3233

3334

3435
const tablesRoutes: Routes = [
@@ -104,6 +105,6 @@ const tablesRoutes: Routes = [
104105
flowControlComponent,
105106
PageComponent
106107
],
107-
providers: [ApiService]
108+
providers: [ApiService,RouteService]
108109
})
109110
export class DashboardModule { }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export class Province {
2+
code: string;
3+
province: string;
4+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Province } from './province';
2+
3+
export const PROVINCE: Province[] = [
4+
{ code: "100", province: "北京" },
5+
{ code: "551", province: "安徽" },
6+
{ code: "230", province: "重庆" },
7+
{ code: "591", province: "福建" },
8+
{ code: "200", province: "广东" },
9+
{ code: "771", province: "广西" },
10+
{ code: "931", province: "甘肃" },
11+
{ code: "851", province: "贵州" },
12+
{ code: "311", province: "河北" },
13+
{ code: "371", province: "河南" },
14+
{ code: "898", province: "海南" },
15+
{ code: "270", province: "湖北" },
16+
{ code: "731", province: "湖南" },
17+
{ code: "451", province: "黑龙江" },
18+
{ code: "250", province: "江苏" },
19+
{ code: "431", province: "吉林" },
20+
{ code: "791", province: "江西" },
21+
{ code: "240", province: "辽宁" },
22+
{ code: "471", province: "内蒙古" },
23+
{ code: "951", province: "宁夏" },
24+
{ code: "971", province: "青海" },
25+
{ code: "210", province: "上海" },
26+
{ code: "280", province: "四川" },
27+
{ code: "531", province: "山东" },
28+
{ code: "351", province: "山西" },
29+
{ code: "290", province: "陕西" },
30+
{ code: "220", province: "天津" },
31+
{ code: "991", province: "新疆" },
32+
{ code: "891", province: "西藏" },
33+
{ code: "871", province: "云南" },
34+
{ code: "571", province: "浙江" },
35+
{ code: "886", province: "台湾" },
36+
{ code: "852", province: "香港特别行政区" },
37+
{ code: "853", province: "澳门特别行政区" }
38+
];
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { TestBed, inject } from '@angular/core/testing';
2+
3+
import { RouteService } from './route.service';
4+
5+
describe('RouteService', () => {
6+
beforeEach(() => {
7+
TestBed.configureTestingModule({
8+
providers: [RouteService]
9+
});
10+
});
11+
12+
it('should be created', inject([RouteService], (service: RouteService) => {
13+
expect(service).toBeTruthy();
14+
}));
15+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Injectable } from '@angular/core';
2+
import { Http, Jsonp, Headers, URLSearchParams } from '@angular/http';
3+
// import { HttpClient, HttpHeaders } from '@angular/common/http';
4+
import "rxjs/add/operator/map";
5+
import { Observable } from 'rxjs';
6+
//差错处理
7+
import { catchError, map, tap } from 'rxjs/operators';
8+
import { Options } from 'selenium-webdriver/edge';
9+
import { Route } from '../routeManagement/route';
10+
11+
const httpOptions = {
12+
headers: new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' })
13+
};
14+
15+
@Injectable()
16+
export class RouteService {
17+
18+
constructor(public http: Http) { }
19+
20+
getAllRoutes() {
21+
return this.http.get('/route/route/getAll')
22+
.map(res => {
23+
console.log(JSON.stringify(res));
24+
return res;
25+
});
26+
}
27+
28+
//错误处理
29+
private handleError<T>(operation = 'operation', result?: T) {
30+
return (error: any): Observable<T> => {
31+
console.error(error);
32+
return Observable.of(result as T);
33+
};
34+
}
35+
36+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export class Route {
2+
user: string;
3+
service: string;
4+
}

public/API Management System/src/app/routeManagement/routeManagement.component.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33
}
44
table{
55
font-size: 15px;
6+
margin-bottom: 0px;
7+
}
8+
.scroll{
9+
overflow-y: scroll;
10+
height: 550px;
611
}

public/API Management System/src/app/routeManagement/routeManagement.component.html

Lines changed: 94 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<button (click)="goBack()" class="btn btn-default btn-sm">返回</button>
2-
<br/><br/>
2+
<br/>
3+
<br/>
34
<!-- Nav tabs -->
45
<ul class="nav nav-tabs" role="tablist">
56
<li role="presentation" class="active">
@@ -25,30 +26,107 @@
2526
</tr>
2627
</thead>
2728
<tbody>
28-
<tr>
29-
<td>/callControl</td>
29+
<tr *ngFor="let route of route_page">
30+
<td>{{route.user}}</td>
3031
<td>
31-
<textarea class="form-control" rows="1" disabled="disabled">www.baidu.com</textarea>
32+
<textarea class="form-control" rows="1" disabled="disabled">{{route.service}}</textarea>
3233
</td>
3334
<td>
3435
<a class="blue" (click)="modify($event)">修改</a>&nbsp;
35-
<a class="blue" (click)="yes($event)">确认</a>
36-
</td>
37-
</tr>
38-
<tr>
39-
<td>/message</td>
40-
<td>
41-
<textarea class="form-control" rows="1" disabled="disabled">www.sina.com</textarea>
42-
</td>
43-
<td>
44-
<a class="blue" (click)="modify($event)">修改</a>&nbsp;
45-
<a class="blue" (click)="yes($event)">确认</a>
36+
<a class="blue" (click)="yes($event,route)">确认</a>
4637
</td>
4738
</tr>
4839
</tbody>
4940
</table>
41+
<page [(pagination)]="pagination"> </page>
5042
</div>
5143
<div role="tabpanel" class="tab-pane" id="roles">
52-
路由分发规则
44+
<br/>
45+
<div class="col-sm-8">
46+
<table class="table table-bordered">
47+
<thead>
48+
<tr>
49+
<th>序号</th>
50+
<th>API类别</th>
51+
<th>路由分发规则</th>
52+
</tr>
53+
</thead>
54+
<tbody>
55+
<tr>
56+
<td>01</td>
57+
<td>呼叫控制类</td>
58+
<td>
59+
按照用户号码分发到归属省二级网络能力开放平台
60+
</td>
61+
</tr>
62+
<tr>
63+
<td>02</td>
64+
<td>号码翻译类</td>
65+
<td>
66+
按照要被翻译的用户号码分发到归属省二级网络能力开放平台
67+
</td>
68+
</tr>
69+
<tr>
70+
<td>03</td>
71+
<td>外呼类</td>
72+
<td>
73+
外呼一方按照被叫方号码分发到归属省二级网络能力开放平台;
74+
<br/>外呼两方按照通话主叫方号码分发到归属省二级网络能力开放平台
75+
</td>
76+
</tr>
77+
<tr>
78+
<td>04</td>
79+
<td>多方通话类</td>
80+
<td>
81+
多方通话发起按照发起方号码分发到归属省二级网络能力开放平台;
82+
<br/>加入一方,退出一方,多方通话状态通知和结束多方通话按照已建立的会话路径进行转发
83+
</td>
84+
</tr>
85+
<tr>
86+
<td>05</td>
87+
<td>IVR类</td>
88+
<td>
89+
按照已建立的会话路径进行转发
90+
</td>
91+
</tr>
92+
<tr>
93+
<td>06</td>
94+
<td>消息类</td>
95+
<td>
96+
按照接收方号码分发到归属省二级网络能力开放平台
97+
</td>
98+
</tr>
99+
<tr>
100+
<td>07</td>
101+
<td>管道类</td>
102+
<td>
103+
下发QoS按照用户终端公网IP地址分发到归属省二级网络能力开放平台
104+
</td>
105+
</tr>
106+
</tbody>
107+
</table>
108+
</div>
109+
<div class="col-sm-4">
110+
<div>
111+
<table class="table table-bordered">
112+
<thead>
113+
<tr>
114+
<th style="width:94px;">代号</th>
115+
<th>归属省二级网络能力开放平台</th>
116+
</tr>
117+
</thead>
118+
</table>
119+
</div>
120+
<div class="scroll">
121+
<table class="table table-bordered" id="data">
122+
<tbody>
123+
<tr *ngFor="let province of provinces">
124+
<td style="width:94px;">{{province.code}}</td>
125+
<td>{{province.province}}</td>
126+
</tr>
127+
</tbody>
128+
</table>
129+
</div>
130+
</div>
53131
</div>
54132
</div>

public/API Management System/src/app/routeManagement/routeManagement.component.ts

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, Output } from '@angular/core';
22
import { NavComponent } from '../dashboard/nav.component';
33
import { Router, ActivatedRoute, Params } from '@angular/router';
44
import { NgClass } from '@angular/common';
55
import { Location } from '@angular/common';
6+
import { PROVINCE } from '../provincedata';
7+
import { Route } from './route';
8+
//import { ROUTE } from './routedata';
9+
import { Pagination } from '../pagination/pagination';
10+
import { RouteService } from '../routeManagement/route.service';
611
declare var $: any;
712

813
@Component({
@@ -11,29 +16,60 @@ declare var $: any;
1116
styleUrls: ['./routeManagement.component.css']
1217
})
1318
export class routeManagementComponent implements OnInit {
14-
15-
19+
provinces = PROVINCE;
20+
routes;//所有路由信息
21+
route_page;//当前页面路由信息
22+
clickroute: Route;
1623

1724
constructor(
1825
private parent: NavComponent,
1926
private route: ActivatedRoute,
2027
private router: Router,
21-
private location: Location
28+
private location: Location,
29+
public RouteService: RouteService
2230
) { }
2331

32+
@Output()
33+
public pagination: Pagination = Pagination.defaultPagination;
34+
35+
2436
ngOnInit() {
2537
this.parent.setActiveByPath(this.parent.routeManagement, "");
26-
//this.para = this.parent.para;
38+
39+
//得到所有的路由信息
40+
this.RouteService.getAllRoutes().subscribe(data => {
41+
//转换成对象,stringfy()转换成字符串
42+
this.routes = JSON.parse(data['_body']);
43+
44+
//分页
45+
this.initList();
46+
this.pagination.changePage = (() => {
47+
this.initList();
48+
});
49+
});
2750

2851
};
2952

53+
private initList(): void {
54+
let url: string = 'your-url';
55+
let page = this.pagination.currentPage - 1;
56+
this.pagination.totalItems = this.routes.length;
57+
let head = page * this.pagination.pageItems;
58+
let end = head + this.pagination.pageItems - 1;
59+
this.route_page = this.routes.slice(head, end);
60+
}
61+
62+
63+
3064
modify($event): void {
3165
$($event.target).parent().parent().children('td').eq(1).children('textarea').removeAttr("disabled");
3266
}
3367

34-
yes($event): void {
68+
yes($event, route): void {
3569
var newurl = $($event.target).parent().parent().children('td').eq(1).children('textarea').val();
3670
alert("修改成功!");
71+
this.clickroute = route;
72+
this.clickroute.service = newurl;
3773
$($event.target).parent().parent().children('td').eq(1).children('textarea').val(newurl);
3874
$($event.target).parent().parent().children('td').eq(1).children('textarea').attr("disabled", "disabled");
3975
}

0 commit comments

Comments
 (0)