2 ============LICENSE_START=======================================================
3 Copyright (C) 2018 Ericsson. All rights reserved.
4 ================================================================================
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
17 SPDX-License-Identifier: Apache-2.0
18 ============LICENSE_END=========================================================
20 @authors: ronan.kenny@ericsson.com, waqas.ikram@ericsson.com
23 import { Component, OnInit } from '@angular/core';
24 import { DataService } from '../data.service';
25 import { ActivatedRoute, Router } from "@angular/router";
26 import { Process } from '../model/process.model';
28 import { ProcessInstanceId } from '../model/processInstanceId.model';
29 import { ToastrNotificationService } from '../toastr-notification-service.service';
30 import { MatSelectModule } from '@angular/material/select';
31 import { ViewEncapsulation } from '@angular/core';
32 import { FormsModule } from '@angular/forms';
33 import { MatFormFieldModule, MatInputModule } from '@angular/material';
34 import { SearchData } from '../model/searchData.model';
35 import { MatDatepickerModule } from '@angular/material/datepicker';
36 import { FormControl } from '@angular/forms';
37 import { SearchRequest } from '../model/SearchRequest.model';
38 import { ViewChild } from '@angular/core';
39 import { ElementRef } from '@angular/core';
40 import { Input } from '@angular/core';
44 templateUrl: './home.component.html',
45 styleUrls: ['./home.component.scss'],
46 encapsulation: ViewEncapsulation.None
49 export class HomeComponent implements OnInit {
57 percentageComplete = 0;
60 options = [{ name: "EQUAL", value: "EQ" }, { name: "NOT EQUAL", value: "NEQ" }, { name: "LIKE", value: "LIKE" }];
61 statusOptions = [{ name: "ALL", value: "ALL" }, { name: "COMPLETE", value: "COMPLETE" }, { name: "IN_PROGRESS", value: "IN_PROGRESS" },
62 { name: "FAILED", value: "FAILED" }, { name: "PENDING", value: "PENDING" }, { name: "UNLOCKED", value: "UNLOCKED" }];
64 hourOptions = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11",
65 "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"];
67 minuteOptions = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15",
68 "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35",
69 "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55",
70 "56", "57", "58", "59"];
72 processData: Process[];
73 searchData: SearchData;
77 displayedColumns = ['requestId', 'serviceInstanceId', 'serviceIstanceName', 'networkId', 'requestStatus', 'serviceType', 'startTime', 'endTime'];
79 constructor(private route: ActivatedRoute, private data: DataService,
80 private router: Router, private popup: ToastrNotificationService) {
81 this.searchData = new SearchData();
85 var search = this.searchData.getSearchRequest().subscribe((result: SearchRequest) => {
87 this.data.retrieveInstance(result.getFilters(), result.getStartTimeInMilliseconds(), result.getEndTimeInMilliseconds())
88 .subscribe((data: Process[]) => {
89 this.processData = data;
90 this.popup.info("Number of records found: " + data.length);
91 // Calculate Statistics for Service Statistics tab
92 this.completeVal = this.processData.filter(i => i.requestStatus === "COMPLETE").length;
93 this.inProgressVal = this.processData.filter(i => i.requestStatus === "IN_PROGRESS").length;
94 this.failedVal = this.processData.filter(i => i.requestStatus === "FAILED").length;
95 this.pendingVal = this.processData.filter(i => i.requestStatus === "PENDING").length;
96 this.unlockedVal = this.processData.filter(i => i.requestStatus === "UNLOCKED").length;
97 this.totalVal = this.processData.length;
98 this.percentageComplete = Math.round(((this.completeVal / this.totalVal) * 100) * 100) / 100;
99 this.percentageFailed = Math.round(((this.failedVal / this.totalVal) * 100) * 100) / 100;
101 console.log("COMPLETE: " + this.completeVal);
102 console.log("FAILED: " + this.failedVal);
105 this.popup.error("Unable to perform search Error code:" + error.status);
108 console.log("Data validation error " + error);
109 this.popup.error(error);
113 getProcessIsntanceId(requestId: string) {
114 var response = this.data.getProcessInstanceId(requestId).subscribe((data) => {
115 if (data.status == 200) {
116 var processInstanceId = (data.body as ProcessInstanceId).processInstanceId;
117 this.router.navigate(['/details/' + processInstanceId]);
119 this.popup.error('No process instance id found: ' + requestId);
120 console.log('No process instance id found: ' + requestId);