Skip to content

Commit

Permalink
Check in for second one on one meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
Naveen-Golla-189 committed Mar 26, 2024
1 parent 2825953 commit a2d244e
Show file tree
Hide file tree
Showing 66 changed files with 1,095 additions and 93 deletions.
11 changes: 9 additions & 2 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthGaurd } from '../shared/services/AuthGaurd';
import { AppComponent } from './app.component';
import { BuyerGaurd } from 'src/shared/services/BuyerGaurd';
import { SupplierGaurd } from 'src/shared/services/SupplierGaurd';

const routes: Routes = [
{
Expand All @@ -12,17 +14,22 @@ const routes: Routes = [
},
{
path: "buyerHome",
canActivate: [AuthGaurd],
canActivate: [AuthGaurd, BuyerGaurd],
loadChildren: ()=> import('../buyer/buyer.module').then(m=>m.BuyerModule)
},
{
path: "supplierHome",
canActivate: [AuthGaurd],
canActivate: [AuthGaurd, SupplierGaurd],
loadChildren: ()=> import('../supplier/supplier.module').then(m=>m.SupplierModule)
},
{
path: 'auth',
loadChildren: ()=> import('../shared/login/login.module').then(m=> m.LoginModule)
},
{
path: "auction",
canActivate: [AuthGaurd],
loadChildren: ()=>import('../shared/auction/auction.module').then(m=>m.AuctionModule)
}
];

Expand Down
1 change: 1 addition & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<ngx-spinner bdColor = "rgba(0, 0, 0, 0.8)" size = "medium" color = "#621e72" type = "ball-scale-multiple" [fullScreen] = "true"></ngx-spinner>
<router-outlet class="min-h-screen"></router-outlet>
1 change: 1 addition & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ToastrModule } from 'ngx-toastr';
HttpClientModule,
NgxSpinnerModule,
BrowserAnimationsModule,
NgxSpinnerModule,
ToastrModule.forRoot()
],
exports: [NgxSpinnerModule],
Expand Down
Binary file added src/assets/icons/Contract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/buyer/bit-list/bit-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
<td mat-cell *matCellDef="let element"> <span class="text-black cursor-pointer hover:underline hover:font-medium" (click)="eventClicked(element)" [routerLink]="['../createauction']" [queryParams]="{ eventId: element.id }" skipLocationChange>{{element.name}}</span></td>
</ng-container>

<ng-container matColumnDef="status">
<ng-container matColumnDef="displayStatusCode">
<th mat-header-cell *matHeaderCellDef> Status </th>
<td mat-cell *matCellDef="let element"> {{element.statusCode}} </td>
<td mat-cell *matCellDef="let element"> {{element.displayStatusCode}} </td>
</ng-container>

<ng-container matColumnDef="action">
Expand Down
11 changes: 9 additions & 2 deletions src/buyer/bit-list/bit-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router';
import { NgxSpinnerService } from 'ngx-spinner';
import { Auction } from 'src/shared/models/Auction.model';
import { AuctionStatus } from 'src/shared/models/AuctionStatus.enum';
import { DataManagerService } from 'src/shared/services/DataManager.service';
import { EventService } from 'src/shared/services/EventService.service';

Expand All @@ -14,7 +16,7 @@ export class BitListComponent implements OnInit {

dataSource = new MatTableDataSource<Auction>();
auctions: Auction[] = [];
displayedColumns: string[] = ['name', 'status', "action"];
displayedColumns: string[] = ['name', 'displayStatusCode', "action"];

headerCofig: any = {
title: "Auctions",
Expand All @@ -24,18 +26,22 @@ export class BitListComponent implements OnInit {

constructor(private eventService: EventService,private router: Router,
private route: ActivatedRoute,
private dataService: DataManagerService) {
private dataService: DataManagerService,
private spinnerService: NgxSpinnerService) {

}

ngOnInit(): void {
this.spinnerService.show();
this.eventService.getAllEvents().subscribe((events: any) => {

if (events && events.length > 0) {
events.forEach((event: any) => {
var event_: Auction = {
name: event.name,
description : event.description,
statusCode : event.statusCode,
displayStatusCode: AuctionStatus[event.statusCode],
startdate: ",",
startTime: ",",
endTime: "",
Expand All @@ -46,6 +52,7 @@ export class BitListComponent implements OnInit {
})
}
this.dataSource.data = this.auctions;
this.spinnerService.hide();
})

}
Expand Down
1 change: 1 addition & 0 deletions src/buyer/buyer-home/buyer-home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ export class BuyerHomeComponent implements OnInit {
logOut() {
console.log("Logout clicked !!");
this.dataService.clearToken();
this.router.navigate(['/auth'], { relativeTo: this.route.parent});
}
}
1 change: 1 addition & 0 deletions src/buyer/buyer-live/buyer-live.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>buyer-live works!</p>
Empty file.
21 changes: 21 additions & 0 deletions src/buyer/buyer-live/buyer-live.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { BuyerLiveComponent } from './buyer-live.component';

describe('BuyerLiveComponent', () => {
let component: BuyerLiveComponent;
let fixture: ComponentFixture<BuyerLiveComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [BuyerLiveComponent]
});
fixture = TestBed.createComponent(BuyerLiveComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
10 changes: 10 additions & 0 deletions src/buyer/buyer-live/buyer-live.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-buyer-live',
templateUrl: './buyer-live.component.html',
styleUrls: ['./buyer-live.component.scss']
})
export class BuyerLiveComponent {

}
15 changes: 15 additions & 0 deletions src/buyer/buyer-live/buyer-live.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BuyerLiveComponent } from './buyer-live.component';



@NgModule({
declarations: [
BuyerLiveComponent
],
imports: [
CommonModule
]
})
export class BuyerLiveModule { }
91 changes: 51 additions & 40 deletions src/buyer/create-auction/create-auction.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { ActivatedRoute } from '@angular/router';
import { Auction } from 'src/shared/models/Auction.model';
import { NgxSpinnerService } from 'ngx-spinner';
import { ToastrService } from 'ngx-toastr';
import { AuctionStatus } from 'src/shared/models/AuctionStatus.enum';
import { AuctionStatus } from '../../shared/models/AuctionStatus.enum';
import { lastValueFrom } from 'rxjs';

@Component({
selector: 'app-create-auction',
Expand Down Expand Up @@ -60,7 +61,6 @@ export class CreateAuctionComponent implements OnInit {
})
}
this.dataSource.data = this.supplierList;
this.spinnerService.show();
}

initalizeAuction() {
Expand All @@ -82,6 +82,7 @@ export class CreateAuctionComponent implements OnInit {
}

getEventDetails() {
this.spinnerService.show();
this.eventService.getEventById(this.eventId).subscribe((result: any) => {
console.log(result);
var statusCode: number = Number(result.statusCode);
Expand All @@ -102,13 +103,15 @@ export class CreateAuctionComponent implements OnInit {
if (this.auction.statusCode != 1) {
this.isReadOnly = true;
}
this.spinnerService.hide();
});
}

async createEvent() {
let self = this;
this.spinnerService.show();
if (this.isNewAuction) {
this.eventService.createEvent({
var result: any = await this.eventService.createEvent({
"id": 0,
"name": this.auction.name,
"type": "1",
Expand All @@ -120,25 +123,27 @@ export class CreateAuctionComponent implements OnInit {
"endtime": this.auction.endTime,
"lots": [],
"suppliers": []
}).subscribe((result: any) => {
if (result) {
self.dms.setDataStoreValue("eventInfo", result);
self.eventId = result["id"];
self.auction.name = result["name"];
self.auction.statusCode = result.statusCode;
self.auction.displayStatus = AuctionStatus[result.statusCode]
self.isNewAuction = false;
self.headerConfig.title = this.auction.name;
this.headerConfig.subTitle = this.auction.displayStatus;
self.headerConfig.enableSubTitle = true;
this.dms.setDataStoreValue("eventId", this.eventId);
if (this.auction.statusCode != 1) {
this.isReadOnly = true;
}
}).toPromise();

// var result = lastValueFrom(resultPipe);

if (result) {
self.dms.setDataStoreValue("eventInfo", result);
self.eventId = result["id"];
self.auction.name = result["name"];
self.auction.statusCode = result.statusCode;
self.auction.displayStatus = AuctionStatus[result.statusCode]
self.isNewAuction = false;
self.headerConfig.title = this.auction.name;
this.headerConfig.subTitle = this.auction.displayStatus;
self.headerConfig.enableSubTitle = true;
this.dms.setDataStoreValue("eventId", this.eventId);
if (this.auction.statusCode != 1) {
}
});
}
this.spinnerService.hide();
} else {
this.eventService.updateEvent({
var result: any = await this.eventService.updateEvent({
"id": this.eventId,
"name": this.auction.name,
"type": "1",
Expand All @@ -150,27 +155,28 @@ export class CreateAuctionComponent implements OnInit {
"endtime": this.auction.endTime,
"lots": [],
"suppliers": []
}).subscribe((result: any) => {
if (result) {
self.dms.setDataStoreValue("eventInfo", result);
self.eventId = result["id"];
self.auction.name = result["name"];
self.auction.startdate = result["startdate"] ? result["startdate"] : "";
self.auction.startTime = result["starttime"] ? result["starttime"] : "";
self.auction.endDate = result["enddate"] ? result["enddate"] : "";
self.auction.endTime = result["endtime"] ? result["endtime"] : "";
self.auction.statusCode = result.statusCode;
self.auction.displayStatus = AuctionStatus[result.statusCode]
self.isNewAuction = false;
self.headerConfig.title = this.auction.name;
this.headerConfig.subTitle = this.auction.displayStatus;
self.headerConfig.enableSubTitle = true;
this.dms.setDataStoreValue("eventId", this.eventId);
if (this.auction.statusCode != 1) {
this.isReadOnly = true;
}
}).toPromise();

if (result) {
self.dms.setDataStoreValue("eventInfo", result);
self.eventId = result["id"];
self.auction.name = result["name"];
self.auction.startdate = result["startdate"] ? result["startdate"] : "";
self.auction.startTime = result["starttime"] ? result["starttime"] : "";
self.auction.endDate = result["enddate"] ? result["enddate"] : "";
self.auction.endTime = result["endtime"] ? result["endtime"] : "";
self.auction.statusCode = result.statusCode;
self.auction.displayStatus = AuctionStatus[result.statusCode]
self.isNewAuction = false;
self.headerConfig.title = this.auction.name;
this.headerConfig.subTitle = this.auction.displayStatus;
self.headerConfig.enableSubTitle = true;
this.dms.setDataStoreValue("eventId", this.eventId);
if (this.auction.statusCode != 1) {
this.isReadOnly = true;
}
});
this.spinnerService.hide();
}
}
}

Expand Down Expand Up @@ -212,13 +218,17 @@ export class CreateAuctionComponent implements OnInit {
} else if (!(this.auction.endDate && this.auction.endDate.length > 1)) {
// auction end data missing.
}
this.spinnerService.show();
await this.createEvent();
this.spinnerService.hide();
this.toastService.success(`Auction Saved to Draft`);
}

async submitAuction() {
// validate for whole auction ( A to Z).

var promise = await this.createEvent();
this.spinnerService.show();
this.eventService.submitAuction(this.eventId).subscribe((result: any) => {
if (result) {
if (result.isSubmitted) {
Expand All @@ -238,6 +248,7 @@ export class CreateAuctionComponent implements OnInit {
})
}
}
this.spinnerService.hide();
});
}
}
6 changes: 6 additions & 0 deletions src/buyer/create-auction/lot-details/lot-details.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { NgxSpinnerService } from 'ngx-spinner';
import { ToastrService } from 'ngx-toastr';
import { Item, Lot } from 'src/shared/models/Lot';
import { LotService } from 'src/shared/services/LotService.service';
Expand All @@ -18,6 +19,7 @@ export class LotDetailsComponent implements OnInit {
constructor(@Inject(MAT_DIALOG_DATA) public data: any,
public dialogRef: MatDialogRef<LotDetailsComponent>,
private toastService: ToastrService,
private spinnerService: NgxSpinnerService,
private lotService: LotService) {
this.lot = { id: 0, name: '', description: '', totalPrice: 0, items: [] }
}
Expand Down Expand Up @@ -87,13 +89,17 @@ export class LotDetailsComponent implements OnInit {
var index = this.lot.items.findIndex((i: any) => { return i.UiId == item.UiId });
this.lot.items.splice(index, 1);
if (item._id != 0) {
this.spinnerService.show();
await this.lotService.deleteItem(item._id).toPromise();
this.spinnerService.hide();
}
this.toastService.success(`${item.name} item deleted successfully`);
}

saveLot() {
this.spinnerService.show()
this.lotService.saveLot(this.lot).subscribe(result => {
this.spinnerService.hide();
console.log(result);
this.toastService.success(`Lot Saved Successfully`);
this.dialogRef.close();
Expand Down
Loading

0 comments on commit a2d244e

Please sign in to comment.