Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Worker app - #93

Open
Azety wants to merge 47 commits into
mainfrom
workerApp
Open

Worker app#93
Azety wants to merge 47 commits into
mainfrom
workerApp

Conversation

@Azety

@Azety Azety commented May 17, 2022

Copy link
Copy Markdown
Contributor

still few fixes to do

@DrunkenToast DrunkenToast left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Focus on getting API communication working but made some comments none-the-less.

Comment thread src/app/Cust.ts Outdated
@@ -0,0 +1,55 @@
export class Cust {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use interfaces instead of classes

Comment thread src/app/app-routing.module.ts Outdated
{path: 'ticketing/:userType', component: TicketingComponent},
{path: 'graphs', component: GraphsComponent},
{path: 'statuscode/:statusCode', component: StatuscodepageComponent},
{path: 'workerapp', component: WorkerappComponent},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm? Use ngFor for list items. Passing a parent like this is strange.

Comment on lines +68 to +132
/*
// 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;
*/
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if unused

@@ -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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

customer.name and remove let i = index

Comment on lines +20 to +28
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";
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output event to parent

Comment on lines +24 to +25
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";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& and use enums for statuses.

Comment on lines +14 to +24
name : string;
adr : string;
mtype : number;

gMeter : number;
eMeter : number;
nDate : any;

fixedDateE: any = new Date();
fixedDateG: any = new Date();
isDone:boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use interfaces for meters

Comment on lines +1 to +17
<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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a login page for literally everybody to use. Do not make your own.

Comment on lines +20 to +26
goPage1(): void{
this.displayPage = 1;
}
goPage2(): void{
this.displayPage = 2;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont make pages this way.

sdd2001 and others added 6 commits May 18, 2022 17:05
New interfaces used for the data
Update some of the page to work with the worker app service
This reverts commit 4c43dcb.
Azety and others added 8 commits May 18, 2022 21:46
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
Comment thread src/app/models/worker-client.ts Outdated
Comment on lines +1 to +8
export class
{
planningID: number;
contractID: number;
planningStatus: number;


} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of these functions, make separate components and routes like we saw in the angular course.

})

export class CientPageComponent implements OnInit {
@Input() parent ?: WorkerappComponent;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a horrible idea

Comment on lines +88 to +142
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';
};

*/
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if unused

sdd2001 and others added 10 commits June 12, 2022 17:22
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
This reverts commit 3cd8a01, reversing
changes made to 214eb3c.
idk man, this is all just a lot of bullshit tbh
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants