See the License for the specific language governing permissions and
limitations under the License.
*/
-import { Component, OnInit, ViewChild } from '@angular/core'
-import { ManagemencsService } from '../../../core/services/managemencs.service'
-import { Observable } from 'rxjs'
+import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
+import { ManagemencsService } from '../../../core/services/managemencs.service';
+import { Observable } from 'rxjs';
+import {NzMessageService} from "ng-zorro-antd";
@Component({
selector: 'app-customer',
public chose = ''
resizeMark
- constructor (private managemencs: ManagemencsService) {}
-
+ constructor(
+ private managemencs: ManagemencsService,
+ private message: NzMessageService,
+ ) {
+ }
+ @Output() closeCustomer = new EventEmitter();
ngOnInit () {
this.getAllCustomers()
this.resizeMark = Observable.fromEvent(window, 'resize').subscribe(
ngOnDestroy () {
this.resizeMark.unsubscribe()
}
-
+ isCustomerEmpty = false;
AllCustomersdata = []
AllServiceTypes = []
customerber = []
deleteCustomerModelVisible = false
deleteServiceTypeModelVisible = false
getAllCustomers () {
- this.managemencs.getAllCustomers().subscribe(data => {
- this.AllCustomersdata = data.map(item => {
- return { name: item['subscriber-name'], id: item['global-customer-id'] }
- })
- this.selectCustomer = this.AllCustomersdata[0]
- this.serviceInit['customer'] = this.AllCustomersdata[0].name
- this.getCustomersPie()
- this.getServiceTypes(this.selectCustomer)
- this.getCustomersColumn(this.selectCustomer)
- })
+ this.managemencs.getAllCustomers().subscribe((data) => {
+ if(data.length!==0){
+ this.AllCustomersdata = data.map((item) => {
+ return { name: item["subscriber-name"], id: item["global-customer-id"] }
+ });
+ this.selectCustomer = this.AllCustomersdata[0];
+ this.serviceInit["customer"] = this.AllCustomersdata[0].name;
+ this.getCustomersPie();
+ this.getServiceTypes(this.selectCustomer);
+ this.getCustomersColumn(this.selectCustomer);
+ }else {
+ this.message.info('Customer has not been created in ONAP.' +
+ 'Please create customer and its service type!');
+ setTimeout(()=>{
+ this.closeCustomer.emit(this.isCustomerEmpty = true);
+ },1000)
+ }
+ })
}
// Get all servicetype
See the License for the specific language governing permissions and
limitations under the License.
*/
-import { Component, OnInit, HostBinding } from '@angular/core'
-import { showHideAnimate, slideToRight } from '../../shared/utils/animates'
-import { ManagemencsService } from '../../core/services/managemencs.service'
+import { Component, OnInit, HostBinding } from '@angular/core';
+import { showHideAnimate, slideToRight } from '../../shared/utils/animates';
+import { ManagemencsService } from '../../core/services/managemencs.service';
+import {NzMessageService} from "ng-zorro-antd";
@Component({
selector: 'app-management',
export class ManagementComponent implements OnInit {
@HostBinding('@routerAnimate') routerAnimateState //Routing animation
- nocuster: boolean
- firstCustomer: string
+ nocuster: boolean = true;
+ firstCustomer: string = "";
- constructor (private managemencs: ManagemencsService) {}
+ constructor(
+ private managemencs: ManagemencsService,
+ private message: NzMessageService,
+ ) { }
ngOnInit () {
this.getAllCustomers()
// Get all customers
getAllCustomers () {
this.managemencs.getAllCustomers().subscribe(data => {
- this.nocuster = data.length > 0 ? false : true
+ this.nocuster = data.length !== 0 ? false : true;
})
}
createNewCustomer (customer) {
this.managemencs.createCustomer(customer, createParams).subscribe(data => {
if (data['status'] == 'SUCCESS') {
this.nocuster = false
- } else {
- this.nocuster = true
- console.log(data, 'Interface returned error')
+ } else {
+ this.nocuster = true;
+ this.clearCustomerInput();
+ this.message.error(data["errorMessage"]);
}
})
}
clearCustomerInput () {
this.firstCustomer = ''
}
+ closeCustomer(isClose){
+ this.nocuster = isClose;
+ }
}