Loading src/app/p_product/admin/productCatalogManagement/edit-product-offerings/edit-product-offerings.component.html +1 −1 Original line number Diff line number Diff line Loading @@ -224,7 +224,7 @@ (change)="onValueToggle(char, val, $event)"> <ng-container *ngIf="val.value; else emptyValue"> <span *ngIf="val.value.alias"> <span *ngIf="val.value.alias" [ngClass]="{'font-weight-bold': val.isDefault}"> {{val.value.alias}}: {{val.value.value}} <span *ngIf="val.unitOfMeasure" class="text-muted"> - ({{val.unitOfMeasure}})</span> </span> Loading src/app/p_product/marketplace/product-marketplace.component.ts +45 −22 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ import { AppService } from 'src/app/shared/services/app.service'; import { TreeServiceMarketPlaceService } from './services/tree-service-market-place.service'; import { MatDialog } from '@angular/material/dialog'; import { SortingService } from 'src/app/shared/functions/sorting.service'; import { CatalogService, ProductOfferingService } from 'src/app/openApis/productCatalogManagement/services'; import { CatalogService, ProductOfferingService, CategoryService } from 'src/app/openApis/productCatalogManagement/services'; import { Catalog, Category, CategoryRef, ProductOffering, ProductOfferingRef } from 'src/app/openApis/productCatalogManagement/models'; import { UntypedFormControl } from '@angular/forms'; import { Observable, Subscription } from 'rxjs'; Loading @@ -19,7 +19,6 @@ import { ThemingService } from 'src/app/theming/theming.service'; templateUrl: './product-marketplace.component.html', styleUrls: ['./product-marketplace.component.scss'], animations: [ trigger('simpleFade', simpleFade()) ] }) export class ProductMarketplaceComponent implements OnInit { Loading @@ -27,6 +26,7 @@ export class ProductMarketplaceComponent implements OnInit { private appService: AppService, private catalogService: CatalogService, private productOfferingService: ProductOfferingService, private categoryService: CategoryService, private treeMarketPlaceService: TreeServiceMarketPlaceService, private dialog: MatDialog, private sortingService: SortingService, Loading @@ -37,7 +37,6 @@ export class ProductMarketplaceComponent implements OnInit { isCatalogsCollapsed: Boolean[] = [] selectedCategoryRef: CategoryRef selectedCategory: Category productOfferings: ProductOffering[] = [] Loading @@ -50,9 +49,14 @@ export class ProductMarketplaceComponent implements OnInit { resultsNotFound: boolean = false subscriptions = new Subscription() // key: Offering ID, value: array of Category References offeringCategoryMap: Map<string, CategoryRef[]> = new Map(); ngOnInit() { this.config = this.appService.config this.buildOfferingCategoryMap(); this.retrieveCatalogsList() this.treeMarketPlaceService.categorySelected$.subscribe( Loading @@ -70,6 +74,34 @@ export class ProductMarketplaceComponent implements OnInit { ) } buildOfferingCategoryMap() { this.categoryService.listCategory({}).subscribe( (allCategories: Category[]) => { allCategories.forEach(category => { if (category.productOffering && category.productOffering.length > 0) { category.productOffering.forEach(offeringRef => { const existingCategories = this.offeringCategoryMap.get(offeringRef.id) || []; const catRef: CategoryRef = { id: category.id, name: category.name, "@type": "CategoryRef" }; if (!existingCategories.some(c => c.id === catRef.id)) { existingCategories.push(catRef); } this.offeringCategoryMap.set(offeringRef.id, existingCategories); }); } }); }, error => console.error('Failed to build category map', error) ); } retrieveCatalogsList() { this.catalogService.listCatalog({}).subscribe( data => { this.productCatalogs = data }, Loading @@ -86,26 +118,17 @@ export class ProductMarketplaceComponent implements OnInit { data => { let productOffering: ProductOffering = data // offering.fetchingLogo = true productOffering['logo'] = this.themingService.getConfig().DEFAULT_SERVICE_LOGO_PATH //set Default App Image, path defined in theming.service.ts productOffering['logo'] = this.themingService.getConfig().DEFAULT_SERVICE_LOGO_PATH this.productOfferings.push(productOffering) // this.specificationService.getAttachment({id: data.serviceSpecification.id, attid:'logo'}).subscribe( // data => { // const reader = new FileReader(); // reader.readAsDataURL(data); // reader.onload = (__event) => { // const base64data = reader.result; // this.serviceCandidates.find(cand => cand.id === candidateRef.id).logo = base64data // candidate.fetchingLogo = false // } // }, // error => { // candidate.fetchingLogo = false // // console.error (error) // } // ) if (this.offeringCategoryMap.has(productOffering.id)) { if (!productOffering.category || productOffering.category.length === 0) { productOffering.category = this.offeringCategoryMap.get(productOffering.id); } else { productOffering.category = this.offeringCategoryMap.get(productOffering.id); } } this.productOfferings.push(productOffering) }, error => { console.error(error) }, () => { Loading src/app/p_product/orderCheckout/product-order-checkout/product-order-checkout.component.ts +91 −9 Original line number Diff line number Diff line Loading @@ -5,6 +5,11 @@ import { ProductOffering, ProductSpecificationCharacteristicRes } from 'src/app/ import { Subscription } from 'rxjs'; import { SortingService } from 'src/app/shared/functions/sorting.service'; import { ToastrService } from 'ngx-toastr'; import { ServiceOrderCreate, ServiceOrderItem } from 'src/app/openApis/serviceOrderingManagement/models'; import { AuthService } from 'src/app/shared/services/auth.service'; import { Router } from '@angular/router'; import { ServiceOrderService } from 'src/app/openApis/serviceOrderingManagement/services'; import { AppService } from 'src/app/shared/services/app.service'; const today = new Date(); Loading @@ -19,7 +24,11 @@ export class ProductOrderCheckoutComponent implements OnInit { constructor( private productRequesterService: ProductRequesterService, private sortingService: SortingService, private toastr: ToastrService private authService: AuthService, private router: Router, private orderService: ServiceOrderService, private toastr: ToastrService, private appService: AppService ) { } subscription = new Subscription Loading Loading @@ -150,14 +159,6 @@ export class ProductOrderCheckoutComponent implements OnInit { this.initValuesForm() } updateActiveProductInList() { this.orderedSpecsConfigurationList.find(listItem => listItem.spec.id === this.selectedOrderSpecToView.spec.id).specCharacteristics = this.specCharFormArray.value } submitOrder() { this.toastr.warning('NA GINEI LINK ME TO SERVICE ORDER'); } removeSpecFromCart(item: productSpecConfigurationListItem) { const toBeRemovedSpecIndex = this.orderedSpecsConfigurationList.findIndex(el => el.spec.id === item.spec.id) this.selectedOrderSpecToView = null Loading @@ -183,5 +184,86 @@ export class ProductOrderCheckoutComponent implements OnInit { localStorage.setItem('orderedProductSpecsList', JSON.stringify(orderArray)) } submitOrder() { this.updateActiveProductInList() let newOrder: ServiceOrderCreate = { orderItem:[], requestedStartDate: this.reqStartDate.value, requestedCompletionDate: this.reqCompletionDate.value } if (this.serviceNoteCtrl.value) { newOrder.note = [{ author:this.authService.portalUserJWT.preferred_username, text: this.serviceNoteCtrl.value, date: new Date().toISOString() }] } let newOrderItem: ServiceOrderItem this.orderedSpecsConfigurationList.forEach(serviceItem => { // console.log(serviceItem) if (!serviceItem.spec || !serviceItem.spec.serviceCandidate || !serviceItem.spec.serviceCandidate.id) { this.toastr.error('Not a valid product offering', 'Configuration Error'); return; } newOrderItem = { service: { serviceSpecification: { id: serviceItem.spec.serviceCandidate.id, name: serviceItem.spec.serviceCandidate.name, version: serviceItem.spec.version }, serviceCharacteristic: [] }, action: 'add'} // console.log(newOrderItem); serviceItem.specCharacteristics.forEach( (characteristic, index) => { newOrderItem.service.serviceCharacteristic.push({ name: characteristic.name, valueType: characteristic.valueType, value: undefined }) // if (characteristic.value.length > 1) { if (characteristic.valueType === "SET" || characteristic.valueType === "ARRAY") { newOrderItem.service.serviceCharacteristic[index].value = { value: JSON.stringify( characteristic.value.map(el => {return {'value': el.value.value, 'alias': el.value.alias}}) ) } } else { newOrderItem.service.serviceCharacteristic[index].value = characteristic.value[0].value } }) newOrder.orderItem.push(newOrderItem) }) // console.log(newOrderItem) // console.log(newOrder) this.orderService.createServiceOrder(newOrder).subscribe( response => { }, error => { console.error(error); this.toastr.error("An error occurred while processing your Service Order") }, () => { this.toastr.success("Service Order was successfully placed") // clear order lists this.orderedSpecsConfigurationList = [] this.productRequesterService.orderedProductSpecsList = [] localStorage.removeItem('orderedProductSpecsList') this.router.navigate(["services", 'service_order/'+newOrderItem.id]) } ) // this.router.navigate(["services", "service_orders"]); } updateActiveProductInList() { this.orderedSpecsConfigurationList.find(listItem => listItem.spec.id === this.selectedOrderSpecToView.spec.id).specCharacteristics = this.specCharFormArray.value } ngOnDestroy() { this.subscription.unsubscribe() } } Loading
src/app/p_product/admin/productCatalogManagement/edit-product-offerings/edit-product-offerings.component.html +1 −1 Original line number Diff line number Diff line Loading @@ -224,7 +224,7 @@ (change)="onValueToggle(char, val, $event)"> <ng-container *ngIf="val.value; else emptyValue"> <span *ngIf="val.value.alias"> <span *ngIf="val.value.alias" [ngClass]="{'font-weight-bold': val.isDefault}"> {{val.value.alias}}: {{val.value.value}} <span *ngIf="val.unitOfMeasure" class="text-muted"> - ({{val.unitOfMeasure}})</span> </span> Loading
src/app/p_product/marketplace/product-marketplace.component.ts +45 −22 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ import { AppService } from 'src/app/shared/services/app.service'; import { TreeServiceMarketPlaceService } from './services/tree-service-market-place.service'; import { MatDialog } from '@angular/material/dialog'; import { SortingService } from 'src/app/shared/functions/sorting.service'; import { CatalogService, ProductOfferingService } from 'src/app/openApis/productCatalogManagement/services'; import { CatalogService, ProductOfferingService, CategoryService } from 'src/app/openApis/productCatalogManagement/services'; import { Catalog, Category, CategoryRef, ProductOffering, ProductOfferingRef } from 'src/app/openApis/productCatalogManagement/models'; import { UntypedFormControl } from '@angular/forms'; import { Observable, Subscription } from 'rxjs'; Loading @@ -19,7 +19,6 @@ import { ThemingService } from 'src/app/theming/theming.service'; templateUrl: './product-marketplace.component.html', styleUrls: ['./product-marketplace.component.scss'], animations: [ trigger('simpleFade', simpleFade()) ] }) export class ProductMarketplaceComponent implements OnInit { Loading @@ -27,6 +26,7 @@ export class ProductMarketplaceComponent implements OnInit { private appService: AppService, private catalogService: CatalogService, private productOfferingService: ProductOfferingService, private categoryService: CategoryService, private treeMarketPlaceService: TreeServiceMarketPlaceService, private dialog: MatDialog, private sortingService: SortingService, Loading @@ -37,7 +37,6 @@ export class ProductMarketplaceComponent implements OnInit { isCatalogsCollapsed: Boolean[] = [] selectedCategoryRef: CategoryRef selectedCategory: Category productOfferings: ProductOffering[] = [] Loading @@ -50,9 +49,14 @@ export class ProductMarketplaceComponent implements OnInit { resultsNotFound: boolean = false subscriptions = new Subscription() // key: Offering ID, value: array of Category References offeringCategoryMap: Map<string, CategoryRef[]> = new Map(); ngOnInit() { this.config = this.appService.config this.buildOfferingCategoryMap(); this.retrieveCatalogsList() this.treeMarketPlaceService.categorySelected$.subscribe( Loading @@ -70,6 +74,34 @@ export class ProductMarketplaceComponent implements OnInit { ) } buildOfferingCategoryMap() { this.categoryService.listCategory({}).subscribe( (allCategories: Category[]) => { allCategories.forEach(category => { if (category.productOffering && category.productOffering.length > 0) { category.productOffering.forEach(offeringRef => { const existingCategories = this.offeringCategoryMap.get(offeringRef.id) || []; const catRef: CategoryRef = { id: category.id, name: category.name, "@type": "CategoryRef" }; if (!existingCategories.some(c => c.id === catRef.id)) { existingCategories.push(catRef); } this.offeringCategoryMap.set(offeringRef.id, existingCategories); }); } }); }, error => console.error('Failed to build category map', error) ); } retrieveCatalogsList() { this.catalogService.listCatalog({}).subscribe( data => { this.productCatalogs = data }, Loading @@ -86,26 +118,17 @@ export class ProductMarketplaceComponent implements OnInit { data => { let productOffering: ProductOffering = data // offering.fetchingLogo = true productOffering['logo'] = this.themingService.getConfig().DEFAULT_SERVICE_LOGO_PATH //set Default App Image, path defined in theming.service.ts productOffering['logo'] = this.themingService.getConfig().DEFAULT_SERVICE_LOGO_PATH this.productOfferings.push(productOffering) // this.specificationService.getAttachment({id: data.serviceSpecification.id, attid:'logo'}).subscribe( // data => { // const reader = new FileReader(); // reader.readAsDataURL(data); // reader.onload = (__event) => { // const base64data = reader.result; // this.serviceCandidates.find(cand => cand.id === candidateRef.id).logo = base64data // candidate.fetchingLogo = false // } // }, // error => { // candidate.fetchingLogo = false // // console.error (error) // } // ) if (this.offeringCategoryMap.has(productOffering.id)) { if (!productOffering.category || productOffering.category.length === 0) { productOffering.category = this.offeringCategoryMap.get(productOffering.id); } else { productOffering.category = this.offeringCategoryMap.get(productOffering.id); } } this.productOfferings.push(productOffering) }, error => { console.error(error) }, () => { Loading
src/app/p_product/orderCheckout/product-order-checkout/product-order-checkout.component.ts +91 −9 Original line number Diff line number Diff line Loading @@ -5,6 +5,11 @@ import { ProductOffering, ProductSpecificationCharacteristicRes } from 'src/app/ import { Subscription } from 'rxjs'; import { SortingService } from 'src/app/shared/functions/sorting.service'; import { ToastrService } from 'ngx-toastr'; import { ServiceOrderCreate, ServiceOrderItem } from 'src/app/openApis/serviceOrderingManagement/models'; import { AuthService } from 'src/app/shared/services/auth.service'; import { Router } from '@angular/router'; import { ServiceOrderService } from 'src/app/openApis/serviceOrderingManagement/services'; import { AppService } from 'src/app/shared/services/app.service'; const today = new Date(); Loading @@ -19,7 +24,11 @@ export class ProductOrderCheckoutComponent implements OnInit { constructor( private productRequesterService: ProductRequesterService, private sortingService: SortingService, private toastr: ToastrService private authService: AuthService, private router: Router, private orderService: ServiceOrderService, private toastr: ToastrService, private appService: AppService ) { } subscription = new Subscription Loading Loading @@ -150,14 +159,6 @@ export class ProductOrderCheckoutComponent implements OnInit { this.initValuesForm() } updateActiveProductInList() { this.orderedSpecsConfigurationList.find(listItem => listItem.spec.id === this.selectedOrderSpecToView.spec.id).specCharacteristics = this.specCharFormArray.value } submitOrder() { this.toastr.warning('NA GINEI LINK ME TO SERVICE ORDER'); } removeSpecFromCart(item: productSpecConfigurationListItem) { const toBeRemovedSpecIndex = this.orderedSpecsConfigurationList.findIndex(el => el.spec.id === item.spec.id) this.selectedOrderSpecToView = null Loading @@ -183,5 +184,86 @@ export class ProductOrderCheckoutComponent implements OnInit { localStorage.setItem('orderedProductSpecsList', JSON.stringify(orderArray)) } submitOrder() { this.updateActiveProductInList() let newOrder: ServiceOrderCreate = { orderItem:[], requestedStartDate: this.reqStartDate.value, requestedCompletionDate: this.reqCompletionDate.value } if (this.serviceNoteCtrl.value) { newOrder.note = [{ author:this.authService.portalUserJWT.preferred_username, text: this.serviceNoteCtrl.value, date: new Date().toISOString() }] } let newOrderItem: ServiceOrderItem this.orderedSpecsConfigurationList.forEach(serviceItem => { // console.log(serviceItem) if (!serviceItem.spec || !serviceItem.spec.serviceCandidate || !serviceItem.spec.serviceCandidate.id) { this.toastr.error('Not a valid product offering', 'Configuration Error'); return; } newOrderItem = { service: { serviceSpecification: { id: serviceItem.spec.serviceCandidate.id, name: serviceItem.spec.serviceCandidate.name, version: serviceItem.spec.version }, serviceCharacteristic: [] }, action: 'add'} // console.log(newOrderItem); serviceItem.specCharacteristics.forEach( (characteristic, index) => { newOrderItem.service.serviceCharacteristic.push({ name: characteristic.name, valueType: characteristic.valueType, value: undefined }) // if (characteristic.value.length > 1) { if (characteristic.valueType === "SET" || characteristic.valueType === "ARRAY") { newOrderItem.service.serviceCharacteristic[index].value = { value: JSON.stringify( characteristic.value.map(el => {return {'value': el.value.value, 'alias': el.value.alias}}) ) } } else { newOrderItem.service.serviceCharacteristic[index].value = characteristic.value[0].value } }) newOrder.orderItem.push(newOrderItem) }) // console.log(newOrderItem) // console.log(newOrder) this.orderService.createServiceOrder(newOrder).subscribe( response => { }, error => { console.error(error); this.toastr.error("An error occurred while processing your Service Order") }, () => { this.toastr.success("Service Order was successfully placed") // clear order lists this.orderedSpecsConfigurationList = [] this.productRequesterService.orderedProductSpecsList = [] localStorage.removeItem('orderedProductSpecsList') this.router.navigate(["services", 'service_order/'+newOrderItem.id]) } ) // this.router.navigate(["services", "service_orders"]); } updateActiveProductInList() { this.orderedSpecsConfigurationList.find(listItem => listItem.spec.id === this.selectedOrderSpecToView.spec.id).specCharacteristics = this.specCharFormArray.value } ngOnDestroy() { this.subscription.unsubscribe() } }