Conversation
DrunkenToast
left a comment
There was a problem hiding this comment.
Focus on getting API communication working but made some comments none-the-less.
| @@ -0,0 +1,55 @@ | |||
| export class Cust { | |||
There was a problem hiding this comment.
Use interfaces instead of classes
| {path: 'ticketing/:userType', component: TicketingComponent}, | ||
| {path: 'graphs', component: GraphsComponent}, | ||
| {path: 'statuscode/:statusCode', component: StatuscodepageComponent}, | ||
| {path: 'workerapp', component: WorkerappComponent}, |
There was a problem hiding this comment.
It's not really an app. It's just a site.
Cant you name this to something like manage-meters or similar?
| @@ -0,0 +1,3 @@ | |||
| <div class="bg-slate-300 m-3 drop-shadow-md h-fit rounded-lg p-3" id="list"> | |||
| <app-list-element [parent]="this"></app-list-element> | |||
There was a problem hiding this comment.
hmm? Use ngFor for list items. Passing a parent like this is strange.
| /* | ||
| // Get planning | ||
| this.service.getPlanning() | ||
| .subscribe(plannings => | ||
| { this.planningList = plannings as Planning[]; }) | ||
|
|
||
| // Add each customer to the list | ||
| this.planningList.forEach(planning => | ||
| { | ||
| if (planning.Date == this.today) | ||
| this.service.getCustomer(planning.CustomerID).subscribe(customer => | ||
| { this.tempCustomer = customer as Customer; }) | ||
|
|
||
| this.service.getAddress(this.tempCustomer.AdressID).subscribe(address => | ||
| { this.tempAddress = address as Address; }) | ||
|
|
||
| this.service.getInvoices().subscribe(invoices => | ||
| { this.invoicesList = invoices as Invoice[]; }) | ||
|
|
||
| this.invoicesList.reverse(); | ||
|
|
||
| // Add all necesary data to a temporary cust variable | ||
| tempCust: new Cust(this.employeeID); | ||
|
|
||
| this.name = this.tempCustomer.LastName + ', ' + this.tempCustomer.FirstName; | ||
| this.address = this.tempAddress.Street + ' ' + this.tempAddress.HouseNumber + ', ' + this.tempAddress.City + ' ' + this.tempAddress.PostalCode + ', ' + this.tempAddress.Country; | ||
|
|
||
| // Assign other variables to tempCust | ||
| this.tempCust.setCid(planning.CustomerID); | ||
| this.tempCust.setName(this.name); | ||
| this.tempCust.setAddress(this.address); | ||
| this.tempCust.setCurrentDate(planning.Date); | ||
|
|
||
| // Status | ||
| if (planning.Status == 0) { this.tempCust.setStatus('Not completed'); } | ||
| else { this.tempCust.setStatus('Completed'); } | ||
|
|
||
| // Meter type & last values | ||
| if (this.tempCustomer.GasType == 1 && this.tempCustomer.Electricitytype == 1) | ||
| { | ||
| this.tempCust.setType(2); | ||
| this.tempCust.setLastG(this.invoicesList[0].GasAmount); | ||
| this.tempCust.setLastE(this.invoicesList[0].ElectricityType); | ||
|
|
||
| } else if (this.tempCustomer.GasType == 1 && this.tempCustomer.Electricitytype == 0) | ||
| { | ||
| this.tempCust.setType(0); | ||
| this.tempCust.setLastG(this.invoicesList[0].GasAmount); | ||
|
|
||
| } else | ||
| { | ||
| this.tempCust.setType(1); | ||
| this.tempCust.setLastE(this.invoicesList[0].ElectricityType); | ||
|
|
||
| } | ||
|
|
||
| this.custArr.push(this.tempCust); | ||
|
|
||
|
|
||
| }); | ||
|
|
||
| this.service.clientList = this.custArr; | ||
| */ | ||
| } | ||
| } |
| @@ -0,0 +1,16 @@ | |||
| <div *ngFor="let customer of custArr; let i = index" class="md:flex m-4 p-2 pl-4 pr-4 rounded-2xl bg-slate-200 text-slate-300 drop-shadow-md block items-center justify-between"> | |||
| <div class="bg-slate-500 drop-shadow-md rounded-2xl p-2 pr-4 pl-4 mr-2"> | |||
| <p>{{custArr[i].name}}</p> | |||
There was a problem hiding this comment.
customer.name and remove let i = index
| selectCustomer(i : number): void{ | ||
| this.cData.selectedCust = i; | ||
| if(this.cData.custData[i].status != "done")this.cData.custData[i].status = "in progress" | ||
| for (let i = 0; i < this.cData.custData.length; i++) { | ||
| if(this.cData.custData[i] != this.cData.custData[this.cData.selectedCust]){ | ||
| if(this.cData.custData[i].status != "done") this.cData.custData[i].status = "not done"; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Output event to parent
| if(this.cData.custData[i] != this.cData.custData[this.cData.selectedCust]){ | ||
| if(this.cData.custData[i].status != "done") this.cData.custData[i].status = "not done"; |
There was a problem hiding this comment.
&& and use enums for statuses.
| name : string; | ||
| adr : string; | ||
| mtype : number; | ||
|
|
||
| gMeter : number; | ||
| eMeter : number; | ||
| nDate : any; | ||
|
|
||
| fixedDateE: any = new Date(); | ||
| fixedDateG: any = new Date(); | ||
| isDone:boolean; |
There was a problem hiding this comment.
use interfaces for meters
| <div class="h-screen border-2 border-purple-600 flex justify-center items-center"> | ||
| <div class="w-full max-w-xs"> | ||
| <form class="bg-slate-300 shadow-md rounded px-8 pt-6 pb-8"> | ||
| <div class="mb-4"> | ||
| <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight" id="username" type="text" placeholder="Username"> | ||
| </div> | ||
| <div class="mb-6"> | ||
| <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight" id="password" type="password" placeholder="Password"> | ||
| </div> | ||
| <div class="flex items-center justify-center"> | ||
| <button (click)="login()" class="bg-slate-600 hover:bg-slate-200 text-white font-bold py-2 px-4 rounded" type="button"> | ||
| Sign In | ||
| </button> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </div> No newline at end of file |
There was a problem hiding this comment.
We already have a login page for literally everybody to use. Do not make your own.
| goPage1(): void{ | ||
| this.displayPage = 1; | ||
| } | ||
| goPage2(): void{ | ||
| this.displayPage = 2; | ||
| } | ||
| } |
There was a problem hiding this comment.
Dont make pages this way.
New interfaces used for the data Update some of the page to work with the worker app service
This reverts commit 4c43dcb.
Stuff to interact with the api It's all commented cuz it doesn't work.
Prepare the routes for the api. I don't think these are good tho, please someone else take a look
| export class | ||
| { | ||
| planningID: number; | ||
| contractID: number; | ||
| planningStatus: number; | ||
|
|
||
|
|
||
| } No newline at end of file |
There was a problem hiding this comment.
Use interfaces instead
| <div class="bg-slate-500 drop-shadow-md rounded-2xl p-2 pr-4 pl-4 mr-2"> | ||
| {{custArr[i].planningStatus}} | ||
| </div> | ||
| <button (click)="selectCustomer(i); this.parent?.parent?.goPage2();" class="bg-slate-500 drop-shadow-md rounded-2xl md:mt-0 mt-2 p-2 pr-4 pl-4">Go ></button> |
There was a problem hiding this comment.
Instead of these functions, make separate components and routes like we saw in the angular course.
| }) | ||
|
|
||
| export class CientPageComponent implements OnInit { | ||
| @Input() parent ?: WorkerappComponent; |
There was a problem hiding this comment.
this seems like a horrible idea
| let valid = true; | ||
| //0 = gas 1 = elek 2 = both | ||
| if(this.nDate != 'Invalid Date'){ | ||
| this.cData.custData[this.cData.selectedCust].nextDate = this.nDate; | ||
| console.log("Next meeting: " + this.cData.custData[this.cData.selectedCust].nextDate); | ||
| } | ||
| else console.log("Automatically plan next check-up") | ||
| this.cData.custData[this.cData.selectedCust].nextDate = this.nDate; | ||
| switch (this.cData.custData[this.cData.selectedCust].meterType) { | ||
| case 0: | ||
| if((this.eMeter >= this.cData.custData[this.cData.selectedCust].lastMetingE) && (this.eMeter != 0)){ | ||
| console.log("submitted " + this.eMeter); | ||
| this.cData.custData[this.cData.selectedCust].newMetingE = this.eMeter; | ||
| } | ||
| else{ | ||
| console.log("no valid data"); | ||
| valid = false; | ||
| } | ||
| break; | ||
| case 1: | ||
| if((this.gMeter >= this.cData.custData[this.cData.selectedCust].lastMetingG) && (this.gMeter != 0)){ | ||
| console.log("submitted " + this.gMeter); | ||
| this.cData.custData[this.cData.selectedCust].newMetingG = this.gMeter; | ||
| } | ||
| else{ | ||
| console.log("no valid data"); | ||
| valid = false; | ||
| } | ||
| break; | ||
| case 2: | ||
| if((this.gMeter >= this.cData.custData[this.cData.selectedCust].lastMetingG) && (this.gMeter != 0)){ | ||
| console.log("submitted " + "elek: " + this.eMeter + " gas: " + this.gMeter); | ||
| this.cData.custData[this.cData.selectedCust].newMetingG = this.gMeter; | ||
| } | ||
| else if((this.eMeter >= this.cData.custData[this.cData.selectedCust].lastMetingE) && (this.eMeter != 0)){ | ||
| console.log("submitted " + "elek: " + this.eMeter + " gas: " + this.gMeter); | ||
| this.cData.custData[this.cData.selectedCust].newMetingE = this.eMeter; | ||
| } | ||
| else{ | ||
| console.log("no valid data") | ||
| valid = false; | ||
| } | ||
| break; | ||
| default: | ||
| console.log("broken"); | ||
| break; | ||
| } | ||
| if(valid){ | ||
| this.cData.custData[this.cData.selectedCust].status = 'done'; | ||
| }; | ||
|
|
||
| */ | ||
| } | ||
| } | ||
|
|
I've updated the api stuff a bit Feel like this code will fall apart rather quickly tho
Updated the routes again
Added the postNewConsumption function to the service
don't use it so don't need it ey
also moved some stuff and added some comments on the worker-app.service.ts file
idk man, this is all just a lot of bullshit tbh
still few fixes to do