Skip to content

Commit f877794

Browse files
committed
Version 1.0.0
1 parent 9b75c91 commit f877794

File tree

8 files changed

+94
-45
lines changed

8 files changed

+94
-45
lines changed

backend/controllers/stockController.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export interface StockRequest {
2525
export default class StockController {
2626
public static async getStocks(req: Request, res: Response): Promise<void> {
2727
// Check for authorization
28-
await AccountController.authOrError(res, InventoryUserAccessRightsEnum.READ);
28+
await AccountController.authOrError(
29+
res,
30+
InventoryUserAccessRightsEnum.READ
31+
);
2932

3033
const entityManager: EntityManager = getManager();
3134

@@ -50,7 +53,10 @@ export default class StockController {
5053

5154
public static async addStock(req: Request, res: Response): Promise<void> {
5255
// Check for authorization
53-
await AccountController.authOrError(res, InventoryUserAccessRightsEnum.WRITE);
56+
await AccountController.authOrError(
57+
res,
58+
InventoryUserAccessRightsEnum.WRITE
59+
);
5460

5561
const entityManager: EntityManager = getManager();
5662

@@ -68,7 +74,8 @@ export default class StockController {
6874
const schema: string = process.env.EDM_SCHEMA || "edm_dev";
6975
const numberSuggestion: {
7076
the_number: number;
71-
}[] = await entityManager.query( // TODO add one more collumn (addedOn)
77+
}[] = await entityManager.query(
78+
// TODO add one more collumn (addedOn)
7279
// Get the first gap or 1
7380
`
7481
SELECT "number" + 1 AS the_number
@@ -157,25 +164,17 @@ export default class StockController {
157164
const entityManager: EntityManager = getManager();
158165
const stockToUpdate: Stock = res.locals.stock as Stock;
159166

160-
stockToUpdate.exDate = (req.body as StockRequest).exDate
161-
? new Date((req.body as StockRequest).exDate)
162-
: stockToUpdate.exDate;
167+
stockToUpdate.exDate = new Date((req.body as StockRequest).exDate);
163168

164-
stockToUpdate.openedOn = (req.body as StockRequest).openedOn
165-
? new Date((req.body as StockRequest).openedOn)
166-
: stockToUpdate.openedOn;
169+
// Set openedOn according to the value of percentLeft
170+
stockToUpdate.openedOn =
171+
(req.body as StockRequest).percentLeft === 100 ? null : new Date();
167172

168-
stockToUpdate.percentLeft = (req.body as StockRequest).percentLeft
169-
? (req.body as StockRequest).percentLeft
170-
: stockToUpdate.percentLeft;
173+
stockToUpdate.percentLeft = (req.body as StockRequest).percentLeft;
171174

172-
stockToUpdate.quantity = (req.body as StockRequest).quantity
173-
? (req.body as StockRequest).quantity
174-
: stockToUpdate.quantity;
175+
stockToUpdate.quantity = (req.body as StockRequest).quantity;
175176

176-
stockToUpdate.useUpIn = (req.body as StockRequest).useUpIn
177-
? (req.body as StockRequest).useUpIn
178-
: stockToUpdate.useUpIn;
177+
stockToUpdate.useUpIn = (req.body as StockRequest).useUpIn;
179178

180179
try {
181180
entityManager.save(stockToUpdate);
@@ -192,7 +191,10 @@ export default class StockController {
192191
}
193192

194193
public static async removeStock(req: Request, res: Response): Promise<void> {
195-
await AccountController.authOrError(res, InventoryUserAccessRightsEnum.WRITE);
194+
await AccountController.authOrError(
195+
res,
196+
InventoryUserAccessRightsEnum.WRITE
197+
);
196198

197199
const entityManager: EntityManager = getManager();
198200
const stockToUpdate: Stock = res.locals.stock as Stock;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ex-date-man",
3-
"version": "0.12.1",
3+
"version": "1.0.0",
44
"description": "Manages expiration dates",
55
"scripts": {
66
"ng": "ng",

src/app/app.component.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { Component } from '@angular/core';
2-
3-
@Component({
4-
selector: 'app-root',
5-
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.scss']
7-
})
8-
9-
export class AppComponent {
10-
title = 'Expiration date manager';
11-
}
1+
import { Component } from "@angular/core";
2+
3+
@Component({
4+
selector: "app-root",
5+
templateUrl: "./app.component.html",
6+
styleUrls: ["./app.component.scss"]
7+
})
8+
export class AppComponent {
9+
title: string = "Expiration date manager";
10+
}
Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,81 @@
11
<form [formGroup]="form" (ngSubmit)="onRegister()">
22
<mat-form-field appearance="outline">
33
<mat-label>Name</mat-label>
4-
<input matInput type="name" placeholder="Bob" formControlName="name" required>
4+
<input
5+
matInput
6+
type="name"
7+
placeholder="Bob"
8+
formControlName="name"
9+
required
10+
/>
511
<i matSuffix class="material-icons">person</i>
612
</mat-form-field>
7-
<br>
13+
<br />
814

915
<mat-form-field appearance="outline">
1016
<mat-label>Email</mat-label>
11-
<input matInput type="email" placeholder="[email protected]" formControlName="email" required>
17+
<input
18+
matInput
19+
type="email"
20+
placeholder="[email protected]"
21+
formControlName="email"
22+
required
23+
/>
1224
<i matSuffix class="material-icons">alternate_email</i>
1325
</mat-form-field>
14-
<br>
26+
<br />
1527

1628
<ng-container formGroupName="passwords">
1729
<mat-form-field appearance="outline">
1830
<mat-label>Password</mat-label>
19-
<input matInput type="password" placeholder="XWf%=7&eF8CxX_j^AC7x" formControlName="password" required>
31+
<input
32+
matInput
33+
type="password"
34+
placeholder="XWf%=7&eF8CxX_j^AC7x"
35+
formControlName="password"
36+
required
37+
/>
2038
<i matSuffix class="material-icons">vpn_key</i>
2139
</mat-form-field>
22-
<br>
40+
<br />
2341

2442
<mat-form-field appearance="outline">
2543
<mat-label>Repeat password</mat-label>
26-
<input matInput type="password" placeholder="XWf%=7&eF8CxX_j^AC7x" formControlName="repeat_password" required>
44+
<input
45+
matInput
46+
type="password"
47+
placeholder="XWf%=7&eF8CxX_j^AC7x"
48+
formControlName="repeat_password"
49+
required
50+
/>
2751
<i matSuffix class="material-icons">lock</i>
2852
</mat-form-field>
2953
</ng-container>
30-
<br>
54+
<br />
3155

32-
<button mat-raised-button type="submit" color="accent" [disabled]="!form.valid">Register</button>
56+
<div class="mat-typography">
57+
<h2>Important notice</h2>
58+
<p>
59+
This service is not meant to be used by the public. This is a private
60+
service used by a select group of people. Unauthorized usage (usage
61+
without express written permission) is not allowed!
62+
</p>
63+
</div>
64+
65+
<button
66+
mat-raised-button
67+
type="submit"
68+
color="accent"
69+
[disabled]="!form.valid"
70+
>
71+
Register
72+
</button>
3373
&nbsp;
34-
<button mat-stroked-button type="button" routerLink="/login/{{form.value.email}}">Login</button>
74+
<button
75+
mat-stroked-button
76+
type="button"
77+
routerLink="/login/{{ form.value.email }}"
78+
>
79+
Login
80+
</button>
3581
</form>

src/app/components/things/things.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h2>Loading things...</h2>
1616
<span *ngIf="!loading && !notFound">
1717

1818
<button mat-raised-button routerLink="/inventories/{{inventoryId}}/" color="accent">Edit inventory</button> &nbsp;
19-
<button mat-raised-button routerLink="../categories" color="primary">Categories</button> &nbsp;
19+
<!-- <button mat-raised-button routerLink="../categories" color="primary">Categories</button> &nbsp; -->
2020
<button mat-stroked-button routerLink="/inventories/">Go up</button> &nbsp;
2121
<br>
2222
<br>

src/app/components/welcome/welcome.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ <h3>Stock</h3>
111111
<li>Percentage left</li>
112112
</ul>
113113

114-
<h3>Category</h3>
114+
<!-- <h3>Category</h3>
115115
<p>
116116
Every inventory can have categories. Every category can be the parent of
117117
other categories, allowing for the formation of sub- and super-category
118118
structures.
119-
</p>
119+
</p> -->
120120

121121
<h2>GitHub repository</h2>
122122
<p>

src/app/services/stock/stock.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ export class StockService {
117117
}
118118

119119
calculateExDate(stock: Stock): Date {
120+
console.log(stock);
121+
120122
if (stock.useUpIn != null && stock.openedOn) {
121123
return (new Date().setDate(
122124
stock.openedOn.getDate() + stock.useUpIn

0 commit comments

Comments
 (0)