From 2fd514d946a10d1184b85920c7513717f37aa613 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Wed, 21 Jun 2023 10:20:10 +0530 Subject: [PATCH] admin module work --- .../components/header/header.component.ts | 5 +- src/app/@theme/styles/styles.scss | 14 + src/app/app-routing.module.ts | 16 +- src/app/pages/_guard/auth.guard.ts | 6 +- src/app/pages/auth/auth/auth.component.html | 1 + src/app/pages/auth/auth/auth.component.scss | 0 .../pages/auth/auth/auth.component.spec.ts | 23 ++ src/app/pages/auth/auth/auth.component.ts | 15 + src/app/pages/auth/login/login.component.scss | 9 +- src/app/pages/auth/login/login.component.ts | 1 + src/app/pages/customer/customer.component.ts | 3 +- .../pages/dashboard/dashboard.component.ts | 13 + src/app/pages/driver/driver.component.ts | 4 +- .../assign-form/assign-form.component.html | 34 ++ .../assign-form/assign-form.component.scss | 10 + .../assign-form/assign-form.component.spec.ts | 23 ++ .../assign-form/assign-form.component.ts | 81 ++++ .../cancel-form/cancel-form.component.html | 27 ++ .../cancel-form/cancel-form.component.scss | 10 + .../cancel-form/cancel-form.component.spec.ts | 23 ++ .../cancel-form/cancel-form.component.ts | 51 +++ .../mixed-form/mixed-form.component.html | 49 +++ .../mixed-form/mixed-form.component.scss | 5 + .../mixed-form/mixed-form.component.spec.ts | 23 ++ .../order/mixed-form/mixed-form.component.ts | 52 +++ .../order-form/order-form.component.html | 129 ++++++ .../order-form/order-form.component.scss | 54 +++ .../order-form/order-form.component.spec.ts | 23 ++ .../order/order-form/order-form.component.ts | 239 +++++++++++ .../order-summary-form.component.html | 77 ++++ .../order-summary-form.component.scss | 3 + .../order-summary-form.component.spec.ts | 23 ++ .../order-summary-form.component.ts | 74 ++++ src/app/pages/order/order.component.html | 62 +++ src/app/pages/order/order.component.scss | 23 ++ src/app/pages/order/order.component.spec.ts | 23 ++ src/app/pages/order/order.component.ts | 376 ++++++++++++++++++ src/app/pages/pageapi.service.ts | 22 +- src/app/pages/pages-menu.ts | 8 +- src/app/pages/pages-routing.module.ts | 24 +- src/app/pages/pages.component.scss | 1 + src/app/pages/pages.module.ts | 22 +- src/app/pages/product/product.component.ts | 3 +- src/app/pages/profile/profile.component.html | 77 ++++ src/app/pages/profile/profile.component.scss | 27 ++ .../pages/profile/profile.component.spec.ts | 23 ++ src/app/pages/profile/profile.component.ts | 89 +++++ src/app/pages/users/users.component.ts | 3 +- src/environments/environment.ts | 2 +- src/index.html | 2 +- 50 files changed, 1875 insertions(+), 32 deletions(-) create mode 100644 src/app/pages/auth/auth/auth.component.html create mode 100644 src/app/pages/auth/auth/auth.component.scss create mode 100644 src/app/pages/auth/auth/auth.component.spec.ts create mode 100644 src/app/pages/auth/auth/auth.component.ts create mode 100644 src/app/pages/order/assign-form/assign-form.component.html create mode 100644 src/app/pages/order/assign-form/assign-form.component.scss create mode 100644 src/app/pages/order/assign-form/assign-form.component.spec.ts create mode 100644 src/app/pages/order/assign-form/assign-form.component.ts create mode 100644 src/app/pages/order/cancel-form/cancel-form.component.html create mode 100644 src/app/pages/order/cancel-form/cancel-form.component.scss create mode 100644 src/app/pages/order/cancel-form/cancel-form.component.spec.ts create mode 100644 src/app/pages/order/cancel-form/cancel-form.component.ts create mode 100644 src/app/pages/order/mixed-form/mixed-form.component.html create mode 100644 src/app/pages/order/mixed-form/mixed-form.component.scss create mode 100644 src/app/pages/order/mixed-form/mixed-form.component.spec.ts create mode 100644 src/app/pages/order/mixed-form/mixed-form.component.ts create mode 100644 src/app/pages/order/order-form/order-form.component.html create mode 100644 src/app/pages/order/order-form/order-form.component.scss create mode 100644 src/app/pages/order/order-form/order-form.component.spec.ts create mode 100644 src/app/pages/order/order-form/order-form.component.ts create mode 100644 src/app/pages/order/order-summary-form/order-summary-form.component.html create mode 100644 src/app/pages/order/order-summary-form/order-summary-form.component.scss create mode 100644 src/app/pages/order/order-summary-form/order-summary-form.component.spec.ts create mode 100644 src/app/pages/order/order-summary-form/order-summary-form.component.ts create mode 100644 src/app/pages/order/order.component.html create mode 100644 src/app/pages/order/order.component.scss create mode 100644 src/app/pages/order/order.component.spec.ts create mode 100644 src/app/pages/order/order.component.ts create mode 100644 src/app/pages/profile/profile.component.html create mode 100644 src/app/pages/profile/profile.component.scss create mode 100644 src/app/pages/profile/profile.component.spec.ts create mode 100644 src/app/pages/profile/profile.component.ts diff --git a/src/app/@theme/components/header/header.component.ts b/src/app/@theme/components/header/header.component.ts index 65ba742..20ed8e8 100644 --- a/src/app/@theme/components/header/header.component.ts +++ b/src/app/@theme/components/header/header.component.ts @@ -39,7 +39,7 @@ export class HeaderComponent implements OnInit, OnDestroy { currentTheme = 'default'; - userMenu = [ { title: 'Profile' }, { title: 'Log out' } ]; + userMenu = [ { title: 'Profile' },{ title: 'Log out' } ]; constructor(private sidebarService: NbSidebarService, private menuService: NbMenuService, @@ -77,7 +77,10 @@ export class HeaderComponent implements OnInit, OnDestroy { let passData = event.item.title if(passData == 'Log out'){ + localStorage.clear(); this.router.navigate(['/auth/login']) + }else if(passData == 'Profile'){ + this.router.navigate(['/pages/profile']) } //this.onItemSelection(event.item.title); }) diff --git a/src/app/@theme/styles/styles.scss b/src/app/@theme/styles/styles.scss index 5b3be87..3872aa3 100644 --- a/src/app/@theme/styles/styles.scss +++ b/src/app/@theme/styles/styles.scss @@ -18,6 +18,13 @@ @import './layout'; @import './overrides'; + +.navigation .link nb-icon { + display: none !important; +} + + + // install the framework and custom global styles @include nb-install() { @@ -31,3 +38,10 @@ @include nb-overrides(); }; +// .layout-container .content .columns nb-layout-column { +// background-image: url('../../../assets/images/login.jpg') !important; +// background-repeat: no-repeat; +// background-attachment: fixed; +// background-size: cover; +// } + \ No newline at end of file diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index ee1d3c7..6796e36 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -10,8 +10,22 @@ import { } from '@nebular/auth'; import { LoginComponent } from '../app/pages/auth/login/login.component'; import { AuthGuard } from './pages/_guard/auth.guard'; -export const routes: Routes = [ + +const token = localStorage.getItem('user_token'); +console.log(token) +let param; +if(token != '' && token != undefined && token != null){ + param = 'page' +}else{ + param = 'auth' +} +export const routes: Routes = [ + { + path: '', + redirectTo: param, + pathMatch: 'full', + }, { path: 'pages', canActivateChild:[AuthGuard], diff --git a/src/app/pages/_guard/auth.guard.ts b/src/app/pages/_guard/auth.guard.ts index ef44f72..e86f90e 100644 --- a/src/app/pages/_guard/auth.guard.ts +++ b/src/app/pages/_guard/auth.guard.ts @@ -14,7 +14,7 @@ export class AuthGuard implements CanActivate, CanActivateChild { if(token != '' && token != undefined && token != null){ return true }else{ - alert("else"); + // alert("else"); // this.router.navigate(['auth/login']); this.router.navigate(['/auth/login']) return false; @@ -38,10 +38,10 @@ export class AuthGuard implements CanActivate, CanActivateChild { if(token != '' && token != undefined && token != null){ return true }else{ - setTimeout(() => { + // setTimeout(() => { this.router.navigate(['/auth/login']); return false; - },1000); + // },1000); } // if (this.shared.getCurrentUser() != null && this.shared.getToken()) { diff --git a/src/app/pages/auth/auth/auth.component.html b/src/app/pages/auth/auth/auth.component.html new file mode 100644 index 0000000..f66eb69 --- /dev/null +++ b/src/app/pages/auth/auth/auth.component.html @@ -0,0 +1 @@ +

auth works!

diff --git a/src/app/pages/auth/auth/auth.component.scss b/src/app/pages/auth/auth/auth.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/auth/auth/auth.component.spec.ts b/src/app/pages/auth/auth/auth.component.spec.ts new file mode 100644 index 0000000..ce78535 --- /dev/null +++ b/src/app/pages/auth/auth/auth.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AuthComponent } from './auth.component'; + +describe('AuthComponent', () => { + let component: AuthComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ AuthComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(AuthComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/auth/auth/auth.component.ts b/src/app/pages/auth/auth/auth.component.ts new file mode 100644 index 0000000..b26519e --- /dev/null +++ b/src/app/pages/auth/auth/auth.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'ngx-auth', + templateUrl: './auth.component.html', + styleUrls: ['./auth.component.scss'] +}) +export class AuthComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/pages/auth/login/login.component.scss b/src/app/pages/auth/login/login.component.scss index 1a0b711..173e4e0 100644 --- a/src/app/pages/auth/login/login.component.scss +++ b/src/app/pages/auth/login/login.component.scss @@ -20,11 +20,8 @@ nb-checkbox { // ::ng-deep .nb-theme-default nb-card-header { // display: none !important; // } + - .layout-container .content .columns nb-layout-column { - background-image: url('../../../../assets/images/login.jpg') !important; - background-repeat: no-repeat; - background-attachment: fixed; - background-size: cover; - } + + \ No newline at end of file diff --git a/src/app/pages/auth/login/login.component.ts b/src/app/pages/auth/login/login.component.ts index 498c516..b74715e 100644 --- a/src/app/pages/auth/login/login.component.ts +++ b/src/app/pages/auth/login/login.component.ts @@ -52,6 +52,7 @@ export class LoginComponent implements OnInit { if (res.token !== '') { localStorage.setItem('user_token',res.token); localStorage.setItem('user_role',res.role); + localStorage.setItem('roleId',res.roleId); localStorage.setItem('email',JSON.stringify(auth)) this.showToast('success', 'Login Successfully', 'Welcome..!'); diff --git a/src/app/pages/customer/customer.component.ts b/src/app/pages/customer/customer.component.ts index abddff4..140a4ae 100644 --- a/src/app/pages/customer/customer.component.ts +++ b/src/app/pages/customer/customer.component.ts @@ -209,7 +209,8 @@ export class CustomerComponent { getuserlistApi(){ - this._api.getusers().subscribe(res => { + let param ={} + this._api.getusers(param).subscribe(res => { console.log(res) if(res.status == 200){ diff --git a/src/app/pages/dashboard/dashboard.component.ts b/src/app/pages/dashboard/dashboard.component.ts index 6ae4216..27af176 100644 --- a/src/app/pages/dashboard/dashboard.component.ts +++ b/src/app/pages/dashboard/dashboard.component.ts @@ -1,8 +1,21 @@ import { Component } from '@angular/core'; +import { Router } from '@angular/router'; @Component({ selector: 'ngx-dashboard', templateUrl: './dashboard.component.html', }) export class DashboardComponent { + + + constructor(private router: Router){ + const token = localStorage.getItem('user_token'); + console.log(token) + + if(!token){ + this.router.navigate(['/auth/login']); + } + + + } } diff --git a/src/app/pages/driver/driver.component.ts b/src/app/pages/driver/driver.component.ts index 92fcbd8..bb4efe3 100644 --- a/src/app/pages/driver/driver.component.ts +++ b/src/app/pages/driver/driver.component.ts @@ -128,6 +128,7 @@ export class DriverComponent { width: '500px', height: '300px', } + const windowRef: NbWindowRef = this.windowService.open(DriverFormComponent, { title: `New Driver`, buttons: buttonsConfig , }); @@ -179,7 +180,8 @@ export class DriverComponent { getuserlistApi(){ - this._api.getusers().subscribe(res => { + let param ={} + this._api.getusers(param).subscribe(res => { console.log(res) if(res.status == 200){ diff --git a/src/app/pages/order/assign-form/assign-form.component.html b/src/app/pages/order/assign-form/assign-form.component.html new file mode 100644 index 0000000..14317f4 --- /dev/null +++ b/src/app/pages/order/assign-form/assign-form.component.html @@ -0,0 +1,34 @@ +
+ + +
+ + + + {{user.userName }} + + + + +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ + +
+
\ No newline at end of file diff --git a/src/app/pages/order/assign-form/assign-form.component.scss b/src/app/pages/order/assign-form/assign-form.component.scss new file mode 100644 index 0000000..ad2e921 --- /dev/null +++ b/src/app/pages/order/assign-form/assign-form.component.scss @@ -0,0 +1,10 @@ +@import '../../../@theme/styles/themes'; + +@include nb-install-component() { + ::ng-deep .form { + display: flex; + flex-direction: column; + + + } +} diff --git a/src/app/pages/order/assign-form/assign-form.component.spec.ts b/src/app/pages/order/assign-form/assign-form.component.spec.ts new file mode 100644 index 0000000..8a2cc98 --- /dev/null +++ b/src/app/pages/order/assign-form/assign-form.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssignFormComponent } from './assign-form.component'; + +describe('AssignFormComponent', () => { + let component: AssignFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ AssignFormComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssignFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/order/assign-form/assign-form.component.ts b/src/app/pages/order/assign-form/assign-form.component.ts new file mode 100644 index 0000000..8e153c4 --- /dev/null +++ b/src/app/pages/order/assign-form/assign-form.component.ts @@ -0,0 +1,81 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { NB_WINDOW_CONTEXT, NbWindowRef, NbWindowService } from '@nebular/theme'; +import { PageapiService } from '../../pageapi.service'; + +@Component({ + selector: 'ngx-assign-form', + templateUrl: './assign-form.component.html', + styleUrls: ['./assign-form.component.scss'] +}) +export class AssignFormComponent { + + + driverForm:any; + drivers:any=[]; + constructor(@Inject(NB_WINDOW_CONTEXT) public data: any,public _api:PageapiService,private windowService: NbWindowService, private windowRef: NbWindowRef) { + console.log(this.data) + this.driverForm = new FormGroup({ + + + driver: new FormControl('', [ Validators.required]) + + }); + + this.getDriverlistApi() + } + + close() { + this.windowRef.close(); + } + onSubmit(){ + console.log( this.data , this.driverForm.value) + let tmp=[]; + this.data.forEach(element => { + tmp.push({id:element.id ,driverId: this.driverForm.value.driver , status:'Out For Delivery' }) + + }); + + let param ={driver:tmp} + + + + + + + + this._api.CreateOrder (param).subscribe(res => { + if (res.status == 200) { + console.log(res) + this.windowRef.close(1); + }else{ + this.windowRef.close(0); + } + }) + + } + + getDriverlistApi(){ + let param ={} + this._api.getusers(param).subscribe(res => { + console.log(res) + if(res.status == 200){ + + let passData = res.data + let driver = passData.filter(arr=>{return arr.role == 'DRIVER'}) + driver.forEach((element:any, index) => { + element.index = index +1 + + }); + + this.drivers = driver + // console.log(data) + + } + }) + } + checkType(data){ + console.log(data) + } + +} diff --git a/src/app/pages/order/cancel-form/cancel-form.component.html b/src/app/pages/order/cancel-form/cancel-form.component.html new file mode 100644 index 0000000..48814f2 --- /dev/null +++ b/src/app/pages/order/cancel-form/cancel-form.component.html @@ -0,0 +1,27 @@ +
+ + + + + +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ + +
+
\ No newline at end of file diff --git a/src/app/pages/order/cancel-form/cancel-form.component.scss b/src/app/pages/order/cancel-form/cancel-form.component.scss new file mode 100644 index 0000000..ad2e921 --- /dev/null +++ b/src/app/pages/order/cancel-form/cancel-form.component.scss @@ -0,0 +1,10 @@ +@import '../../../@theme/styles/themes'; + +@include nb-install-component() { + ::ng-deep .form { + display: flex; + flex-direction: column; + + + } +} diff --git a/src/app/pages/order/cancel-form/cancel-form.component.spec.ts b/src/app/pages/order/cancel-form/cancel-form.component.spec.ts new file mode 100644 index 0000000..0a889bb --- /dev/null +++ b/src/app/pages/order/cancel-form/cancel-form.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CancelFormComponent } from './cancel-form.component'; + +describe('CancelFormComponent', () => { + let component: CancelFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ CancelFormComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(CancelFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/order/cancel-form/cancel-form.component.ts b/src/app/pages/order/cancel-form/cancel-form.component.ts new file mode 100644 index 0000000..29249b0 --- /dev/null +++ b/src/app/pages/order/cancel-form/cancel-form.component.ts @@ -0,0 +1,51 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { NB_WINDOW_CONTEXT, NbWindowRef, NbWindowService } from '@nebular/theme'; +import { PageapiService } from '../../pageapi.service'; + +@Component({ + selector: 'ngx-cancel-form', + templateUrl: './cancel-form.component.html', + styleUrls: ['./cancel-form.component.scss'] +}) +export class CancelFormComponent { + + cancelForm:any; + + constructor(@Inject(NB_WINDOW_CONTEXT) public data: any,public _api:PageapiService,private windowService: NbWindowService, private windowRef: NbWindowRef) { + + this.cancelForm = new FormGroup({ + + + reason: new FormControl('', [ Validators.required]) + + }); + } + + close() { + this.windowRef.close(); + } + onSubmit(){ + console.log( this.data , this.cancelForm.value) + + + let param ={id:this.data.id, reason: this.cancelForm.value.reason, status:'canceled'} + + + + + + + + this._api.CreateOrder (param).subscribe(res => { + if (res.status == 200) { + console.log(res) + this.windowRef.close(1); + }else{ + this.windowRef.close(0); + } + }) + + } + +} diff --git a/src/app/pages/order/mixed-form/mixed-form.component.html b/src/app/pages/order/mixed-form/mixed-form.component.html new file mode 100644 index 0000000..884de92 --- /dev/null +++ b/src/app/pages/order/mixed-form/mixed-form.component.html @@ -0,0 +1,49 @@ + + +
+
+ + + + + + +
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + + + + + + + +
+
+ + +
+ +
+
\ No newline at end of file diff --git a/src/app/pages/order/mixed-form/mixed-form.component.scss b/src/app/pages/order/mixed-form/mixed-form.component.scss new file mode 100644 index 0000000..a97cfd0 --- /dev/null +++ b/src/app/pages/order/mixed-form/mixed-form.component.scss @@ -0,0 +1,5 @@ +div{ + margin-top: 1rem; +} + + \ No newline at end of file diff --git a/src/app/pages/order/mixed-form/mixed-form.component.spec.ts b/src/app/pages/order/mixed-form/mixed-form.component.spec.ts new file mode 100644 index 0000000..f1024d3 --- /dev/null +++ b/src/app/pages/order/mixed-form/mixed-form.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MixedFormComponent } from './mixed-form.component'; + +describe('MixedFormComponent', () => { + let component: MixedFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ MixedFormComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(MixedFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/order/mixed-form/mixed-form.component.ts b/src/app/pages/order/mixed-form/mixed-form.component.ts new file mode 100644 index 0000000..d14f984 --- /dev/null +++ b/src/app/pages/order/mixed-form/mixed-form.component.ts @@ -0,0 +1,52 @@ +import { Component, EventEmitter, OnInit, Output } from '@angular/core'; +import { PageapiService } from '../../pageapi.service'; + +@Component({ + selector: 'ngx-mixed-form', + templateUrl: './mixed-form.component.html', + styleUrls: ['./mixed-form.component.scss'] +}) +export class MixedFormComponent implements OnInit { + + setData:any =[]; + + @Output() childButtonEvent = new EventEmitter(); + + inputFieldGroups: { qty: string, productSpec: string }[] = [{ qty: '0', productSpec: '' }]; // Array to hold input field groups + constructor(public _api:PageapiService) { + + this._api.orderDetails_observable$.subscribe((res) => { + console.log('booked', res); + + if(res){ + this. setData = res.data + if( this. setData['ProductDetails.productName'] == "Mixed Gas"){ + + + this.inputFieldGroups[0].qty = this. setData.qty + this.inputFieldGroups[0].productSpec = this. setData.productSpec +// this.inputFieldGroups.push({ qty: this. setData.qty, productSpec: this. setData.productSpec }); +} + } + + }) + } + + ngOnInit(): void { + } + addInputFieldGroup() { + this.inputFieldGroups.push({ qty: '0', productSpec: '' }); // Add a new input field group to the array + this.childButtonEvent.emit( this.inputFieldGroups); + } + + removeInputFieldGroup(index: number) { + console.log( this.inputFieldGroups) + this.inputFieldGroups.splice(index, 1); // Remove the input field group at the specified index + this.childButtonEvent.emit( this.inputFieldGroups); + } + + pass(){ + this.childButtonEvent.emit( this.inputFieldGroups); + } + +} diff --git a/src/app/pages/order/order-form/order-form.component.html b/src/app/pages/order/order-form/order-form.component.html new file mode 100644 index 0000000..313d306 --- /dev/null +++ b/src/app/pages/order/order-form/order-form.component.html @@ -0,0 +1,129 @@ + + + + +
+
+
{{fieldTitle}}
+
+
+
+ +
+
+
+
+ + + +
+
+
+ + + + + {{user['CusDetails.cusName'] + }} + + + +
+
+
+
+ +
+
+
+
+ +
+
+
+ + + +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ +
+
+
+ + +
+ + + +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + +
+
+
+ + +
+
+
diff --git a/src/app/pages/order/order-form/order-form.component.scss b/src/app/pages/order/order-form/order-form.component.scss new file mode 100644 index 0000000..ceb375c --- /dev/null +++ b/src/app/pages/order/order-form/order-form.component.scss @@ -0,0 +1,54 @@ +nb-card-body { + overflow: visible; + padding-top: 0; + + > * { + margin-top: 1rem; + } + } + + .full-name-inputs, + .validation-checkboxes { + display: flex; + margin: 0 -0.5rem; + + > * { + margin: 0 0.5rem; + } + } + + .checkbox-radio { + display: flex; + } + + .demo-items { + flex: 1 0 33%; + } + + nb-select{ + width: 100%; + } + @import '../../../@theme/styles/themes'; + + @include nb-install-component() { + .list-card { + nb-card-header { + border-bottom: none; + } + + nb-card-body { + padding: 0; + } + } + } + nb-card-body{ + min-height: 100%; + } + + input[type=number]::-webkit-inner-spin-button, +input[type=number]::-webkit-outer-spin-button { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + margin: 0; +} \ No newline at end of file diff --git a/src/app/pages/order/order-form/order-form.component.spec.ts b/src/app/pages/order/order-form/order-form.component.spec.ts new file mode 100644 index 0000000..6f276bf --- /dev/null +++ b/src/app/pages/order/order-form/order-form.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { OrderFormComponent } from './order-form.component'; + +describe('OrderFormComponent', () => { + let component: OrderFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ OrderFormComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(OrderFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/order/order-form/order-form.component.ts b/src/app/pages/order/order-form/order-form.component.ts new file mode 100644 index 0000000..b8768ec --- /dev/null +++ b/src/app/pages/order/order-form/order-form.component.ts @@ -0,0 +1,239 @@ +import { Component, OnInit } from '@angular/core'; +import { PageapiService } from '../../pageapi.service'; +import { NbComponentStatus, NbGlobalPhysicalPosition, NbGlobalPosition, NbToastrService, NbWindowControlButtonsConfig, NbWindowRef, NbWindowService } from '@nebular/theme'; +import { SmartTableData } from '../../../@core/data/smart-table'; +import { OrderSummaryFormComponent } from '../order-summary-form/order-summary-form.component'; +import { ActivatedRoute, Router } from '@angular/router'; + +@Component({ + selector: 'ngx-order-form', + templateUrl: './order-form.component.html', + styleUrls: ['./order-form.component.scss'] +}) +export class OrderFormComponent implements OnInit { + customer:any =[]; + product:any =[]; + mixedGas:any =[]; + selectCustomer:any =""; + items = [ + { label: 'Item 1', quantity: 0 }, + { label: 'Item 2', quantity: 0 }, + { label: 'Item 3', quantity: 0 } + ]; +fieldTitle:any =' New Order' + minimize = false; + maximize = false; + fullScreen = true; + close = true; + formData:any=[] + index = 1; + destroyByClick = true; + duration = 2000; + hasIcon = true; + setData:any =[]; + position: NbGlobalPosition = NbGlobalPhysicalPosition.TOP_RIGHT; + preventDuplicates = false; + status: NbComponentStatus = 'primary'; + selectCustomerData :any =[]; + constructor(private route :ActivatedRoute,private router: Router,public _api:PageapiService,private toastrService: NbToastrService,private service: SmartTableData ,private windowService: NbWindowService) { + + this._api.orderDetails_observable$.subscribe((res) => { + console.log('booked', res); + + if(res){ + this. setData = res.data + + + } + + }) + + } + receivedMessageHandler(res){ + console.log(res, this.product) + let tmp =[]; + this.product.forEach(element => { + if(element.productName == "Mixed Gas"){ + + tmp.push(element) + } + + }); + let tmp2 = []; + res.forEach(element => { + tmp2.push({"productName": tmp[0].productName , id: tmp[0].id ,qty:element.qty, productSpec:element.productSpec}) + }); + this.mixedGas = tmp2 + console.log(tmp2) + } + receiveAutoMsgHandler(p) { + console.log(p) + } + ngOnInit(): void { + console.log(this.setData) + if(this.setData != undefined){ + + + if( Object.keys(this.setData).length != 0){ + this.fieldTitle = 'Edit Order' + } + } + this.getuserlistApi() + + } + + + getuserlistApi(){ + let param={} + this._api.getusers(param).subscribe(res => { + + if(res.status == 200){ + + let passData = res.data + + let customer = passData.filter(arr=>{return arr.role == 'CUSTOMER'}) + customer.forEach((element:any, index) => { + element.index = index +1 + + }); + console.log(customer) + this.customer = customer + if( Object.keys(this.setData).length != 0){ + this.selectCustomer = this.setData['OrderDetails.CusDetails.cusName'] + this.setData['OrderDetails.CusDetails.cusType'] + this.getProductlistApi( this.setData['OrderDetails.CusDetails.cusType']) + // console.log(data) + } + } + }) + } + + getProductlistApi(param){ + let data ={type : param} + this._api.getProducts(data).subscribe(res => { + console.log(res) + if(res.status == 200){ + + let passData = res.data + let product = passData + + product.forEach((element:any, index) => { + element.index = index +1 + element.qty = 0; + }); + + this.product = product + if(this.setData != undefined){ + if( Object.keys(this.setData).length != 0){ + + + this.product.forEach(element => { + if(element.productName == this.setData['ProductDetails.productName'] ){ + element.qty = this.setData.qty + } + }); + } + } + // console.log(data) + + }else{ + this.product = []; + } + }) + } + + checkType(data){ + console.log(data) + this.selectCustomerData = data + let productType = data['CusDetails.cusType'] + console.log(productType) + this. getProductlistApi(productType) + + } + cancel(){ + + } + + save(){ + + console.log(this.selectCustomer) + let product= this.product.filter(arr=>{return arr.qty != 0}) + + console.log( product) + if(this.setData != undefined){ + + + if( Object.keys(this.setData).length != 0){ + product.forEach(element => { + element.productSpec = this. setData.productSpec + }); + } +} + + + const buttonsConfig: NbWindowControlButtonsConfig = { + minimize: this.minimize, + maximize: this.maximize, + fullScreen: this.fullScreen, + close: this.close, + }; + let config= { + hasBackdrop: true, + width: '500px', + height: '300px', + } + + + let results = [ ...this.mixedGas, ...product]; + + if(results.length>0){ + + + + let passData = {name:this.selectCustomer,product:results,customerData:this.selectCustomerData} + + const windowRef: NbWindowRef = this.windowService.open(OrderSummaryFormComponent, { title: ` Order Summary (`+this.selectCustomer+`)`, context:passData,buttons: buttonsConfig , }); + + + + // Subscribe to the afterClosed event + windowRef.onClose.subscribe((data) => { + // Handle the window closure + console.log(data); + if(data == 1){ + this.showToast('success', 'Data Saved Successfully', 'New Order Placed..!'); + // this.getuserlistApi(); + setTimeout(() => { + this.router.navigate(['../'], { relativeTo: this.route }); + }, 500); + console.log('Window closed 123'); + }else if(data == 0){ + this.showToast('warning', 'Somthing is Wrong...!', 'Order Placed Failed..!'); + } + }); + }else{ + this.showToast('warning', 'Please Fill Request Fields...!', ''); + } + } + private showToast(type: NbComponentStatus, title: string, body: string) { + const config = { + status: type, + destroyByClick: this.destroyByClick, + duration: this.duration, + hasIcon: this.hasIcon, + position: this.position, + preventDuplicates: this.preventDuplicates, + }; + const titleContent = title ? ` ${title}` : ''; + + this.index += 1; + this.toastrService.show( + body, + `${titleContent}`, + config); + } + + back(){ + this.router.navigate(['../'], { relativeTo: this.route }); + } +} diff --git a/src/app/pages/order/order-summary-form/order-summary-form.component.html b/src/app/pages/order/order-summary-form/order-summary-form.component.html new file mode 100644 index 0000000..080364e --- /dev/null +++ b/src/app/pages/order/order-summary-form/order-summary-form.component.html @@ -0,0 +1,77 @@ +
+
+ +
+
+
+ +
    +
    +
    +
    + Products +
    +
    +
    +
    + Qty +
    +
    +
    +
    + Specification +
    +
    +
    +
  • + + +
    +
    +
    + {{ item.productName }} +
    +
    +
    +
    + {{ item.qty }} + +
    +
    +
    +
    + {{ item.productSpec }} + +
    +
    +
    + + + +
  • +
+ +
+
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+
diff --git a/src/app/pages/order/order-summary-form/order-summary-form.component.scss b/src/app/pages/order/order-summary-form/order-summary-form.component.scss new file mode 100644 index 0000000..b0216ca --- /dev/null +++ b/src/app/pages/order/order-summary-form/order-summary-form.component.scss @@ -0,0 +1,3 @@ +div{ + padding: 1px; +} \ No newline at end of file diff --git a/src/app/pages/order/order-summary-form/order-summary-form.component.spec.ts b/src/app/pages/order/order-summary-form/order-summary-form.component.spec.ts new file mode 100644 index 0000000..9adfa37 --- /dev/null +++ b/src/app/pages/order/order-summary-form/order-summary-form.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { OrderSummaryFormComponent } from './order-summary-form.component'; + +describe('OrderSummaryFormComponent', () => { + let component: OrderSummaryFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ OrderSummaryFormComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(OrderSummaryFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/order/order-summary-form/order-summary-form.component.ts b/src/app/pages/order/order-summary-form/order-summary-form.component.ts new file mode 100644 index 0000000..f4dc7a8 --- /dev/null +++ b/src/app/pages/order/order-summary-form/order-summary-form.component.ts @@ -0,0 +1,74 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { NB_WINDOW_CONTEXT, NbWindowRef, NbWindowService } from '@nebular/theme'; +import { PageapiService } from '../../pageapi.service'; + +@Component({ + selector: 'ngx-order-summary-form', + templateUrl: './order-summary-form.component.html', + styleUrls: ['./order-summary-form.component.scss'] +}) +export class OrderSummaryFormComponent implements OnInit { + customer:any =[]; + product:any =[]; + setData:any =[]; + constructor(@Inject(NB_WINDOW_CONTEXT) public data: any,public _api:PageapiService,private windowService: NbWindowService, private windowRef: NbWindowRef) { + + console.log(this.data) + this.customer = this.data.name + this.product = this.data.product + + this._api.orderDetails_observable$.subscribe((res) => { + console.log('booked', res); + + if(res){ + this. setData = res.data + + + } + + }) + + + } + + ngOnInit() { + + this.customer = this.data.name + this.product = this.data.product + } + + save(){ + console.log(this.data) + let cus = this.data.customerData['CusDetails.id'] + let role = localStorage.getItem('user_role') + let param; + if(this.setData != undefined){ + if(this.setData.hasOwnProperty('id')){ + param ={id:this.setData.id,customerId:cus,status:'ordered' , product: this.data.product ,createdBy:role } + }else{ + param ={customerId:cus,status:'ordered' , product: this.data.product ,createdBy:role } + } +}else{ + param ={customerId:cus,status:'ordered' , product: this.data.product ,createdBy:role } +} + + + + + + + this._api.CreateOrder (param).subscribe(res => { + if (res.status == 200) { +console.log(res) + this.windowRef.close(1); + }else{ + this.windowRef.close(0); + } + }) + } + cancel(){ + this.windowService + console.log( this.windowService) + this.windowRef.close(); + } +} diff --git a/src/app/pages/order/order.component.html b/src/app/pages/order/order.component.html new file mode 100644 index 0000000..f1282e2 --- /dev/null +++ b/src/app/pages/order/order.component.html @@ -0,0 +1,62 @@ + + + +
+
+
Order Management
+
+
+
+ + +
+
+
+
+ + + + + + + + +
+
+
+
+ + +
+
+
+
+ + + + Select Drivers + + {{user.userName }} + + + +
+
+
+
+ +
+
+
+
+
+ +
\ No newline at end of file diff --git a/src/app/pages/order/order.component.scss b/src/app/pages/order/order.component.scss new file mode 100644 index 0000000..267e7bb --- /dev/null +++ b/src/app/pages/order/order.component.scss @@ -0,0 +1,23 @@ + + td ,input[type="checkbox"] { + font-size: 1px !important; + } + + .highlight-cell { + background-color: yellow; + /* Add any other styling properties as desired */ + } + + ::ng-deep .ng2-smart-action-multiple-select{ + text-align: center; + } + + ::ng-deep .ng2-smart-action-multiple-select > input{ + width:15px; + height:15px; + display: unset; + } + + ::ng-deep .desired-value-row{ +color: red !important; + } \ No newline at end of file diff --git a/src/app/pages/order/order.component.spec.ts b/src/app/pages/order/order.component.spec.ts new file mode 100644 index 0000000..ad8c750 --- /dev/null +++ b/src/app/pages/order/order.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { OrderComponent } from './order.component'; + +describe('OrderComponent', () => { + let component: OrderComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ OrderComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(OrderComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/order/order.component.ts b/src/app/pages/order/order.component.ts new file mode 100644 index 0000000..6e13005 --- /dev/null +++ b/src/app/pages/order/order.component.ts @@ -0,0 +1,376 @@ +import { Component, OnInit } from '@angular/core'; +import { DomSanitizer } from '@angular/platform-browser'; + +import { LocalDataSource } from 'ng2-smart-table'; +import { SmartTableData } from '../../@core/data/smart-table'; +import { PageapiService } from '../pageapi.service'; +import { NbToastrService, NbWindowControlButtonsConfig, NbWindowRef, NbWindowService } from '@nebular/theme'; + + + +import { + NbComponentStatus, + NbGlobalLogicalPosition, + NbGlobalPhysicalPosition, + NbGlobalPosition, + + NbToastrConfig, +} from '@nebular/theme'; +import { Router } from '@angular/router'; +import { CancelFormComponent } from './cancel-form/cancel-form.component'; +import { AssignFormComponent } from './assign-form/assign-form.component'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; + +@Component({ + selector: 'ngx-order', + templateUrl: './order.component.html', + styleUrls: ['./order.component.scss'] +}) +export class OrderComponent { + + settings:any =[]; + source: LocalDataSource = new LocalDataSource(); + minimize = false; + maximize = false; + fullScreen = true; + close = true; + formData:any=[] + index = 1; + destroyByClick = true; + duration = 2000; + selectedRows:any=[]; + hasIcon = true; + position: NbGlobalPosition = NbGlobalPhysicalPosition.TOP_RIGHT; + preventDuplicates = false; + drivers:any=[]; + status: NbComponentStatus = 'primary'; + driverForm:any =[]; + constructor(private domSanitizer: DomSanitizer, private router:Router,private toastrService: NbToastrService,private service: SmartTableData,public _api:PageapiService,private windowService: NbWindowService) { + const data = this.service.getData(); + + this.settings = { + selectMode: 'multi', + + actions: { + + position: 'right', // left|right + }, + mode: 'external', + userRowSelect: (selectedRows: any[]) => { + this.handleRowSelection(selectedRows); + }, + add: { + addButtonContent: '', + createButtonContent: '', + cancelButtonContent: '', + }, + edit: { + editButtonContent: '', + saveButtonContent: '', + cancelButtonContent: '', + }, + delete: { + deleteButtonContent: '', + confirmDelete: true, + }, + columns: { + + index: { + title: 'ID', + type: 'number', + width:"10px" + }, + orderId: { + title: 'Order ID', + type: 'string', + + }, + 'OrderDetails.CusDetails.cusName': { + title: 'Customer Name', + type: 'string', + width:"40px" + }, + 'ProductDetails.productName': { + title: 'Product', + type: 'string', + + }, + qty: { + title: 'Qty', + type: 'string', + width:"10px", + rowClass: (row) => { + // Function to determine the row class based on the value of a specific column + const columnName = 'qty'; // Specify the name of the desired column + const desiredValue = 'qty'; // Specify the desired value for the row color + + if (row[columnName] === desiredValue) { + return 'desired-value-row'; // CSS class for rows with the desired value + } else { + return ''; // CSS class for other rows + } + } + }, + status: { + title: 'Status', + type: 'string', + valuePrepareFunction: (cell, row) => { + // Add a string value to the column + + if(cell == "Out For Delivery"){ + return cell + " ("+ row["UserDetails.userName"]+")"; + + }else{ + + } + return cell ; // Modify this as per your requirement + } + + }, + reason: { + title: 'Cancel Reason', + type: 'string', + width:"25px" + }, + + }, + }; + + + this.getorderlistApi() + + this. getDriverlistApi() + + this.driverForm = new FormGroup({ + + + driver: new FormControl('', [ Validators.required]) + + }); + + + } + + onDeleteConfirm(event): void { + console.log(event) + let passData = event.data + + const buttonsConfig: NbWindowControlButtonsConfig = { + minimize: this.minimize, + maximize: this.maximize, + fullScreen: this.fullScreen, + close: this.close, + }; + const windowRef: NbWindowRef = this.windowService.open(CancelFormComponent, { title: `Cancel Product`, context: event.data + , buttons: buttonsConfig }); + + + + // Subscribe to the afterClosed event + windowRef.onClose.subscribe((data) => { + // Handle the window closure + console.log(data); + if(data == 1){ + this.showToast('success', 'Data Changed Successfully', 'Order Cancel Completed..!'); + this.getorderlistApi(); + console.log('Window closed 123'); + }else if(data == 0){ + this.showToast('warning', 'Somthing is Wrong...!', 'Order Cancel Failed..!'); + } + + + }); + + } + + getFuelColor(w){ + console.log(w) + } + onCreateConfirm(event) { + console.log("Create Event In Console") + console.log(event); + const buttonsConfig: NbWindowControlButtonsConfig = { + minimize: this.minimize, + maximize: this.maximize, + fullScreen: this.fullScreen, + close: this.close, + }; + let config= { + hasBackdrop: true, + width: '500px', + height: '300px', + } + this.addOrder() + } + + onSaveConfirm(event) { + console.log("Edit Event In Console") + console.log(event); + + const buttonsConfig: NbWindowControlButtonsConfig = { + minimize: this.minimize, + maximize: this.maximize, + fullScreen: this.fullScreen, + close: this.close, + }; + console.log("add") + this._api.orderDetails.next(event) + + + + this.router.navigate(['/pages/order/add']) + } + + + getorderlistApi(){ + let param ={} + this._api.getOrders(param).subscribe(res => { + console.log(res) + if(res.status == 200){ + + let passData = res.data + passData.sort((a: any, b: any) => { + return b.id - a.id; + }); + passData.forEach((element:any, index) => { + element.index = index +1 + + }); + // console.log(data) + this.source.load(passData); + } + }) + } + + + private showToast(type: NbComponentStatus, title: string, body: string) { + const config = { + status: type, + destroyByClick: this.destroyByClick, + duration: this.duration, + hasIcon: this.hasIcon, + position: this.position, + preventDuplicates: this.preventDuplicates, + }; + const titleContent = title ? ` ${title}` : ''; + + this.index += 1; + this.toastrService.show( + body, + `${titleContent}`, + config); + } + + addOrder(){ + console.log("add") + this._api.orderDetails.next(null) + this.router.navigate(['/pages/order/add']) + } + + handleRowSelection(selectedRows: any[]) { + // Get the selected row data + const selectedData = selectedRows.map(row => row.data); + console.log(selectedData); + } + onUserRowSelect(event) { + console.log(event) + this.selectedRows = event.selected; +} + +Assign(){ + console.log(1) + if(this.selectedRows.length>0){ + + + const buttonsConfig: NbWindowControlButtonsConfig = { + minimize: this.minimize, + maximize: this.maximize, + fullScreen: this.fullScreen, + close: this.close, + }; + const windowRef: NbWindowRef = this.windowService.open(AssignFormComponent, { title: `Assign Driver`, context: this.selectedRows + + , buttons: buttonsConfig }); + + + + // Subscribe to the afterClosed event + windowRef.onClose.subscribe((data) => { + // Handle the window closure + console.log(data); + if(data == 1){ + this.showToast('success', 'Data Changed Successfully', 'Driver Assign Completed..!'); + this.getorderlistApi(); + console.log('Window closed 123'); + }else if(data == 0){ + this.showToast('warning', 'Somthing is Wrong...!', 'Driver Assign Failed..!'); + } + + + }); + }else{ + this.showToast('warning', 'Somthing is Wrong...!', 'Please Select Orders..!'); + } + +} + + +getDriverlistApi(){ + let param ={} + this._api.getusers(param).subscribe(res => { + console.log(res) + if(res.status == 200){ + + let passData = res.data + let driver = passData.filter(arr=>{return arr.role == 'DRIVER'}) + driver.sort((a: any, b: any) => { + return b.id - a.id; + }); + driver.forEach((element:any, index) => { + element.index = index +1 + + }); + + + + this.drivers = driver + // console.log(data) + + } + }) +} + +onSubmit(){ + if(this.selectedRows.length>0){ + + + console.log( this.selectedRows , this.driverForm.value) + let tmp=[]; + this.selectedRows.forEach(element => { + tmp.push({id:element.id ,driverId: this.driverForm.value.driver , status:'Out For Delivery' }) + + }); + + let param ={driver:tmp} + + + + + + + + this._api.CreateOrder (param).subscribe(res => { + if (res.status == 200) { + console.log(res) + this.showToast('success', 'Data Changed Successfully', 'Orders Assign Completed..!'); + this.getorderlistApi(); + }else{ + this.showToast('warning', 'Somthing is Wrong...!', 'Orders Assign Failed..!'); + } + }) + }else{ + this.showToast('warning', 'Somthing is Wrong...!', 'Please Select Orders..!'); + } +} + +} diff --git a/src/app/pages/pageapi.service.ts b/src/app/pages/pageapi.service.ts index bad3613..7e4c48f 100644 --- a/src/app/pages/pageapi.service.ts +++ b/src/app/pages/pageapi.service.ts @@ -10,18 +10,25 @@ import { environment } from '../../environments/environment'; providedIn: 'root' }) export class PageapiService { + public orderDetails:BehaviorSubject = new BehaviorSubject([]); +public orderDetails_observable$ = this.orderDetails.asObservable(); private apiUrl = environment.apiEndpoint; constructor(private _http: HttpClient) { } - - getusers(): Observable { + getusers(param): Observable { //console.log(params.email) - return this._http.get(this.apiUrl + "getusers") + return this._http.post(this.apiUrl + "getusers",param) } - getProducts(): Observable { + getProducts(param): Observable { //console.log(params.email) - return this._http.get(this.apiUrl + "getProducts") + return this._http.post(this.apiUrl + "getProducts",param) + + } + + getOrders(param): Observable { + //console.log(params.email) + return this._http.post(this.apiUrl + "getOrders",param) } addUserFormDetails(addParams): Observable { @@ -37,8 +44,11 @@ export class PageapiService { return this._http.post(this.apiUrl + 'CreateProducts', addParams) } + CreateOrder(addParams): Observable { + return this._http.post(this.apiUrl + 'CreateOrder', addParams) + + } - } diff --git a/src/app/pages/pages-menu.ts b/src/app/pages/pages-menu.ts index cba6e8d..8e9f1ee 100644 --- a/src/app/pages/pages-menu.ts +++ b/src/app/pages/pages-menu.ts @@ -10,7 +10,7 @@ export const MENU_ITEMS: NbMenuItem[] = [ { title: 'Orders', icon: 'shopping-bag-outline', - link: '/pages/dashboard', + link: '/pages/order', home: true, }, { @@ -49,6 +49,12 @@ export const MENU_ITEMS: NbMenuItem[] = [ link: '/pages/dashboard', home: true, }, + { + title: 'Settings', + icon: 'settings-2-outline', + link: '/pages/profile', + home: true, + }, // { // title: 'Auth', // icon: 'lock-outline', diff --git a/src/app/pages/pages-routing.module.ts b/src/app/pages/pages-routing.module.ts index 59c063e..b124070 100644 --- a/src/app/pages/pages-routing.module.ts +++ b/src/app/pages/pages-routing.module.ts @@ -7,9 +7,14 @@ import { UsersComponent } from './users/users.component'; import { CustomerComponent } from './customer/customer.component'; import { DriverComponent } from './driver/driver.component'; import { ProductComponent } from './product/product.component'; +import { AuthGuard } from './_guard/auth.guard'; +import { OrderComponent } from './order/order.component'; +import { OrderFormComponent } from './order/order-form/order-form.component'; +import { ProfileComponent } from './profile/profile.component'; const routes: Routes = [{ path: '', + component: PagesComponent, children: [ { @@ -34,14 +39,21 @@ const routes: Routes = [{ path: 'product', component: ProductComponent, }, - + { + path: 'order', + component: OrderComponent, + }, + { + path: 'profile', + component: ProfileComponent, + }, + { + path: 'order/add', + component: OrderFormComponent, + }, - { - path: '', - redirectTo: 'dashboard', - pathMatch: 'full', - }, + ], }]; diff --git a/src/app/pages/pages.component.scss b/src/app/pages/pages.component.scss index 6919809..5b7700a 100644 --- a/src/app/pages/pages.component.scss +++ b/src/app/pages/pages.component.scss @@ -16,3 +16,4 @@ } } } + \ No newline at end of file diff --git a/src/app/pages/pages.module.ts b/src/app/pages/pages.module.ts index 6869d66..caad04e 100644 --- a/src/app/pages/pages.module.ts +++ b/src/app/pages/pages.module.ts @@ -1,5 +1,5 @@ -import { NgModule } from '@angular/core'; -import { NbDialogModule, NbMenuModule } from '@nebular/theme'; +import { NgModule,NO_ERRORS_SCHEMA ,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { NbDialogModule, NbListModule, NbMenuModule } from '@nebular/theme'; import { ThemeModule } from '../@theme/theme.module'; import { PagesComponent } from './pages.component'; @@ -30,6 +30,14 @@ import { DriverComponent } from './driver/driver.component'; import { DriverFormComponent } from './driver/driver-form/driver-form.component'; import { ProductComponent } from './product/product.component'; import { ProductFormComponent } from './product/product-form/product-form.component'; +import { OrderComponent } from './order/order.component'; +import { OrderFormComponent } from './order/order-form/order-form.component'; +import { OrderSummaryFormComponent } from './order/order-summary-form/order-summary-form.component'; +import { CancelFormComponent } from './order/cancel-form/cancel-form.component'; +import { AssignFormComponent } from './order/assign-form/assign-form.component'; +import { ProfileComponent } from './profile/profile.component'; +import { MixedFormComponent } from './order/mixed-form/mixed-form.component'; +import { AuthComponent } from './auth/auth/auth.component'; @NgModule({ imports: [ PagesRoutingModule, @@ -54,6 +62,7 @@ import { ProductFormComponent } from './product/product-form/product-form.compon NbIconModule, NbInputModule, ThemeModule, + NbListModule, NbDialogModule.forChild(), Ng2SmartTableModule, ], @@ -68,7 +77,16 @@ import { ProductFormComponent } from './product/product-form/product-form.compon DriverFormComponent, ProductComponent, ProductFormComponent, + OrderComponent, + OrderFormComponent, + OrderSummaryFormComponent, + CancelFormComponent, + AssignFormComponent, + ProfileComponent, + MixedFormComponent, + AuthComponent, ], + schemas: [CUSTOM_ELEMENTS_SCHEMA,NO_ERRORS_SCHEMA], }) export class PagesModule { } diff --git a/src/app/pages/product/product.component.ts b/src/app/pages/product/product.component.ts index d8d4532..1e69b49 100644 --- a/src/app/pages/product/product.component.ts +++ b/src/app/pages/product/product.component.ts @@ -169,7 +169,8 @@ export class ProductComponent { getProductlistApi(){ - this._api.getProducts().subscribe(res => { + let param ={} + this._api.getProducts(param).subscribe(res => { console.log(res) if(res.status == 200){ diff --git a/src/app/pages/profile/profile.component.html b/src/app/pages/profile/profile.component.html new file mode 100644 index 0000000..c476c2e --- /dev/null +++ b/src/app/pages/profile/profile.component.html @@ -0,0 +1,77 @@ +
+
+
+ + Profile Settings + + + +
Name is required.
+ + +
+
+ + + + + +
+ Password is required +
+
+ + + + + +
+ Confirm Password is required +
+
+
+ + +
Email is required.
+ +
+ Please enter a valid email address +
+
+ + +
Mobile No is required.
+ + +
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ +
\ No newline at end of file diff --git a/src/app/pages/profile/profile.component.scss b/src/app/pages/profile/profile.component.scss new file mode 100644 index 0000000..1854d8c --- /dev/null +++ b/src/app/pages/profile/profile.component.scss @@ -0,0 +1,27 @@ +nb-card-body { + overflow: visible; + padding-top: 0; + + > * { + margin-top: 1rem; + } + } + + .full-name-inputs, + .validation-checkboxes { + display: flex; + margin: 0 -0.5rem; + + > * { + margin: 0 0.5rem; + } + } + + .checkbox-radio { + display: flex; + } + + .demo-items { + flex: 1 0 33%; + } + \ No newline at end of file diff --git a/src/app/pages/profile/profile.component.spec.ts b/src/app/pages/profile/profile.component.spec.ts new file mode 100644 index 0000000..246039d --- /dev/null +++ b/src/app/pages/profile/profile.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProfileComponent } from './profile.component'; + +describe('ProfileComponent', () => { + let component: ProfileComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ProfileComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ProfileComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/profile/profile.component.ts b/src/app/pages/profile/profile.component.ts new file mode 100644 index 0000000..4892d88 --- /dev/null +++ b/src/app/pages/profile/profile.component.ts @@ -0,0 +1,89 @@ +import { Component, OnInit } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { PageapiService } from '../pageapi.service'; + +@Component({ + selector: 'ngx-profile', + templateUrl: './profile.component.html', + styleUrls: ['./profile.component.scss'] +}) +export class ProfileComponent implements OnInit { + userForm: FormGroup | any; formData:any =[] + constructor(public _api:PageapiService) { } + + ngOnInit(): void { + + this.userForm = new FormGroup({ + + + + + + // role: new FormControl('', [Validators.required]), + userName: new FormControl('', [Validators.required]), + // contactNo: new FormControl('', [Validators.required, Validators.maxLength(20)]), + mobileNo: new FormControl('', [Validators.required, Validators.minLength(10),Validators.maxLength(10)]), + // lastName: new FormControl('', [Validators.required, Validators.maxLength(20)]), + email: new FormControl('', [Validators.required, Validators.email,Validators.pattern( + '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$', + )]), + // password: new FormControl('', [Validators.required, Validators.minLength(6)]), + password: new FormControl('', [Validators.required,Validators.pattern( + '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*_=+-]).{8,16}$' + )]), + password2: new FormControl('', [Validators.required,Validators.pattern( + '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*_=+-]).{8,16}$' + )]), + }); + let userRole = localStorage.getItem('roleId'); + + this. getuserlistApi(userRole) + } + close(){ + + } + + onSubmit(){ + this.formData =[] + this.formData= new FormData(); + let tmp = this.userForm .value + let userRole = localStorage.getItem('roleId'); + this.formData.append('id', userRole); + + + this.formData.append('userName',tmp.userName) + this.formData.append('email', tmp.email); + if(tmp.password != null && tmp.password2 != null){ + if(tmp.password == tmp.password2){ + this.formData.append('password', tmp.password); + } + } + + + + this.formData.append('mobileNo', tmp.mobileNo); + + this._api.addUserFormDetails (this.formData).subscribe(res => { + if (res.status == 200) { +console.log(res) + + }else{ + + } + }) + } + + getuserlistApi(id){ + let param={id:id} + this._api.getusers(param).subscribe(res => { + console.log(res) + if(res.status == 200){ + + let passData = res.data[0] + passData.password = null + this.userForm.patchValue(passData) + + } + }) + } +} diff --git a/src/app/pages/users/users.component.ts b/src/app/pages/users/users.component.ts index 751b646..c5e9270 100644 --- a/src/app/pages/users/users.component.ts +++ b/src/app/pages/users/users.component.ts @@ -177,7 +177,8 @@ export class UsersComponent { getuserlistApi(){ - this._api.getusers().subscribe(res => { + let param ={} + this._api.getusers(param).subscribe(res => { console.log(res) if(res.status == 200){ diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 121b72c..8a17549 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -9,6 +9,6 @@ // The list of which env maps to which file can be found in `.angular-cli.json`. export const environment = { - apiEndpoint:'http://192.168.1.29:8081/api/', + apiEndpoint:'http://192.168.1.200:8081/api/', production: false, }; diff --git a/src/index.html b/src/index.html index 5b44ce0..98d7313 100644 --- a/src/index.html +++ b/src/index.html @@ -4,7 +4,7 @@ VNMS - +