aboutsummaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/myhttp.service.ts
blob: 09f13a49f3c32b97ebf3a8f20a95c9b359239d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { homeData, homeVmLineData, servicesSelectData, servicesTableData, onboardTableData} from './dataInterface';



@Injectable()
export class MyhttpService {

  constructor(private http: HttpClient) { }
  
  baseUrl = "./assets/json";
  url={
    allhome:this.baseUrl + "/homeAllData.json",
    homeLineData:this.baseUrl + "/homePerformanceChartData.json",
    serviceSelectList:this.baseUrl + "/servicesList.json",   //customer、serviceType
    servicesTableData:this.baseUrl + "/servicesTableData.json",
    onboardTableData:this.baseUrl + "/onboardTableData.json",

    customers:this.baseUrl + "/customers.json?",
    serviceType:this.baseUrl + "/serviceTypes.json?*_*",
    servicesCategory:this.baseUrl + "/configuration_files/servicesCategory.json?",
    serviceInstanceList:this.baseUrl + "/instanceTableData4.json?",
    serviceTemplates:this.baseUrl + "/serviceTemplates2.json?",
    templateCategory:this.baseUrl + "/configuration_files/templateCategory.json?",
    templateParameters:this.baseUrl + "/*_*" + "ServiceTemplateParameters.json?",
    addressData: this.baseUrl + "/siteAddressData.json?",
    createService:this.baseUrl + "/createService.json?",
    inputNamesTransform: this.baseUrl + "/configuration_files/inputNamesTranslate.json?",
    deleteService: this.baseUrl + "/deleteService.json?",
    progress:this.baseUrl + "/progress.json?",

    allottedResource:this.baseUrl + "/allotted-resources2.json?",
    pnfDetail:this.baseUrl + "/pnfdetail-domain.json?",
    connectivity:this.baseUrl + "/sotn-connectivity2.json?",
    vpnBinding:this.baseUrl + "/vpnbinding.json?",
    alarmFormData:this.baseUrl + "/alarmFormData.json?"
  }

  // baseUrl = 'http://172.19.44.223/api/usecaseui-server/v1';
  // baseUrl = '/api/usecaseui-server/v1';
  // url={
  //   allhome:this.baseUrl + "/alarm/getAlarmDataByStatus/0",
  //   homeLineData:this.baseUrl + "/...........",
  //   serviceSelectList:this.baseUrl + "/xxxxxxxxxxxxx",
  //   servicesTableData:this.baseUrl + "/xxxxxxxx.json",
  //   onboardTableData:this.baseUrl + "/xxxxxxx.json",


  //   customers:this.baseUrl + "/uui-lcm/customers",
  //   serviceType:this.baseUrl + "/uui-lcm/customers/" + "*_*" + "/service-subscriptions",
  //   servicesCategory: "./assets/json/configuration_files/servicesCategory.json",
  //   serviceInstanceList:this.baseUrl + '/uui-sotn/getServiceInstanceList',
  //   serviceTemplates:this.baseUrl + "/uui-lcm/service-templates",
  //   templateCategory: "./assets/json/configuration_files/templateCategory.json",
  //   templateParameters:this.baseUrl + "/uui-lcm/service-templates/" + "*_*" +"?toscaModelPath=",
  //   addressData: this.baseUrl + "/uui-sotn/getOssInvenory",
  //   createService:this.baseUrl + "/uui-lcm/services",
  //   inputNamesTransform: "./assets/json/configuration_files/inputNamesTranslate.json?",
  //   deleteService: this.baseUrl + "/uui-lcm/services/",
  //   progress:this.baseUrl + "/uui-lcm/services/" + "*_*" + "/operations/",

  //   allottedResource:this.baseUrl + "/uui-sotn/getAllottedResources",
  //   pnfDetail:this.baseUrl + "/uui-sotn/getPnfInfo/",
  //   connectivity:this.baseUrl + "/uui-sotn/getConnectivityInfo/",
  //   vpnBinding:this.baseUrl + "/uui-sotn/getPinterfaceByVpnId/"
  // }

  // home页数据
  getAllHomeData() {
    return this.http.get<homeData>(this.url.allhome);
  }
  //home页折线图数据
  getHomePerformanceChartData(paramsObj){
    let params = new HttpParams({fromObject:paramsObj});
    return this.http.get<homeVmLineData>(this.url.homeLineData,{params});
  }

  // servicesList数据
  // getServicesSelectData():Observable<HttpResponse<servicesSelectData>>{
  //   return this.http.get<servicesSelectData>(this.url.serviceSelectList,{observe:'response'});
  // }
  getServicesTableData(paramsObj):Observable<HttpResponse<servicesTableData>>{
    let params = new HttpParams({fromObject:paramsObj});
    return this.http.get<servicesTableData>(this.url.servicesTableData,{observe:'response',params});
  }

  // onboard数据
  getOnboardTableData(paramsObj):Observable<HttpResponse<onboardTableData>>{
    let params = new HttpParams({fromObject:paramsObj});
    return this.http.get<onboardTableData>(this.url.onboardTableData,{observe:'response',params});
  }





  testObservable(){
    let myObservable = new Observable((observer)=>{
      observer.next(1);
      observer.next((n)=>{
        console.log(3+n);
      })
      setTimeout(()=>{
        observer.next(66666)
      },100)
      observer.next(()=>{
        setTimeout((n)=>{
          console.log("9999---" + n);
        },10)        
      })
      // observer.error(2);
      // observer.complete();
    });

    myObservable.subscribe((e)=>{
      if(typeof e == "function"){
        e(5)
      }
      console.log(e);
    },(err)=>{
      console.log(err);
    },()=>{
      console.log(555);
    })
  }

  //---------------------------------------------------------------------------------

  // 获取所有customers
  getAllCustomers(){
    return this.http.get<any>(this.url.customers);
    // return this.http.jsonp<Object[]>('http://127.0.0.1:5500/customers.json',"callback");// 测试用 :请求数据需要用回调函数包裹
  }

  // 获取相应的serviceType
  getServiceTypes(customer){
    let url = this.url.serviceType.replace("*_*",customer.id);
    return this.http.get<any>(url);
  }
  // 获取服务分类信息,本地配置文件
  getServicesCategory(){
    return this.http.get<any>(this.url.servicesCategory);
  }
  // list表格数据
  getInstanceTableData(paramsObj){
    let params = new HttpParams({fromObject:paramsObj});
    return this.http.get<any>(this.url.serviceInstanceList,{params});
  }

  // // 服务详情数据 
  // getInstanceDetails(id){
  //   let url = this.baseUrl + "/detailsData.json?id=" + id;
  //   return this.http.get<instanceDetail>(url);
  // }

  // 获取所有模板类型
  getAllServiceTemplates(){
    return this.http.get<any>(this.url.serviceTemplates);
  }

  // 获取模板分类信息,本地配置文件
  getTemplateCategory(){
    return this.http.get<any>(this.url.servicesCategory);
  }
  // 获取模板输入项参数
  getTemplateParameters(type,template){
    let url = this.url.templateParameters.replace("*_*",type) + template.toscaModelURL;  //本地模拟
    // let url = this.url.templateParameters.replace("*_*",template.uuid) + template.toscaModelURL;
    return this.http.get<any>(url);
  }
  // siteAddress 地址
  getSiteAddress(){
    return this.http.get<any>(this.url.addressData);
  }

  // 创建接口
  createInstance(requestBody){
    return this.http.get<any>(this.url.createService);  //本地模拟
    // return this.http.post<any>(this.url.createService,requestBody);
  }

  // 输入参数名字转换
  inputNamesTransform(){
    return this.http.get(this.url.inputNamesTransform);
  }

  // 删除接口
  deleteInstance(obj){
    let httpOptions = {
      headers: new HttpHeaders({
        'Content-Type':  'application/json',
        'Accept':'application/json',
        'Authorization':'Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=='
      }),
      body:{
        'globalSubscriberId': obj.globalSubscriberId,
        'serviceType': obj.serviceType
      }
    };
    return this.http.get<any>(this.url.deleteService);  //本地模拟
    // return this.http.delete<any>(this.url.deleteService + obj.serviceInstanceId, httpOptions);
  }

  // 查询进度接口
  getProgress(obj){
    let url = this.url.progress.replace("*_*",obj.serviceId) + obj.operationId;
    return this.http.get<any>(url);
  }

  // 获取allotted-resource  能获取tp和pnf值
  getAllottedResource(obj){
    let params = new HttpParams({fromObject:obj});
    let url = this.url.allottedResource;
    return this.http.get<any>(url,{params});
  }
  //通过pnf值获取对应的domain (network-resource)
  getPnfDetail(name){
    let url = this.url.pnfDetail + name;
    return this.http.get<any>(url);
  }
  //通过sotn 获取connectivity ,查找vpn-id
  getSotnConnectivity(id){
    let url = this.url.connectivity + id;
    return this.http.get<any>(url);
  }
  //通过vpn-id 查找tp和pnf
  getVpnBinding(id){
    let url = this.url.vpnBinding + id;
    return this.http.get<any>(url);
  }
  // 时间格式化 毫秒转正常值
  dateformater(vmstime){
    if(!vmstime){
        return ''
    }
    let mstime = Number((vmstime + '').slice(0,13));  
    let time = new Date(mstime);
    let year = time.getFullYear();
    let month = time.getMonth() + 1;
    let day = time.getDate();
    let hours = time.getHours();
    let minutes = time.getMinutes();
    let seconds = time.getSeconds();
    let formattime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
    return formattime;
  }

  // alarm表格数据
  // getAlarmFormData(pageNumber:number,pageSaze:number,name?:string,Priority?:string,Status?:string,Report?:string){
  //   return this.http.post<any>(this.url.alarmFormData,{
  //     pageNumber:pageNumber,
  //     pageSaze:pageSaze,
  //     name:name,
  //     Priority:Priority,
  //     Status:Status,
  //     Report:Report 
  //   });
  // }


  getAlarmFormData(pageNumber:number,pageSaze:number,name?:string,Priority?:string,Status?:string,Report?:string){
    return this.http.get<any>(this.url.alarmFormData+'?pageNumber='+pageNumber+'?pageSaze'+pageSaze+'?name'+name+'?Priority'+Priority+'?Status'+Status+'?Report'+Report);
  }
}