From d65379a068d26bccb1ac11630cb6b6d89e1e36e4 Mon Sep 17 00:00:00 2001 From: tanshu Date: Tue, 8 Dec 2020 18:50:46 +0530 Subject: [PATCH] Chore: ng lint using the recommended @angular-eslint style --- barker/barker/models/auth.py | 2 +- barker/barker/routers/login.py | 2 +- barker/barker/schemas/auth.py | 1 - barker/pyproject.toml | 10 +-- bookie/.eslintrc.js | 43 ----------- bookie/.eslintrc.json | 74 ++++++++++++++++++ bookie/angular.json | 11 +-- bookie/package.json | 68 ++++++++--------- bookie/src/app/auth/auth.service.ts | 2 +- .../beer-sale-report.service.ts | 8 +- .../bill-settlement-report.service.ts | 10 +-- .../cashier-report/cashier-report.service.ts | 20 ++--- bookie/src/app/core/error-logger.service.ts | 1 + bookie/src/app/core/http-auth-interceptor.ts | 4 +- bookie/src/app/devices/device.service.ts | 40 ++++------ .../discount-report.service.ts | 16 ++-- .../guest-book-list.component.ts | 8 +- .../src/app/guest-book/guest-book.service.ts | 40 ++++------ .../header-footer/header-footer.component.ts | 4 +- .../header-footer/header-footer.service.ts | 14 ++-- ...enu-category-list-resolver.service.spec.ts | 1 + .../menu-category-resolver.service.spec.ts | 1 + .../menu-category/menu-category.service.ts | 52 ++++++------- .../modifier-category.service.ts | 58 +++++++------- .../modifier-list/modifier-list-datasource.ts | 6 +- bookie/src/app/modifiers/modifier.service.ts | 40 ++++------ bookie/src/app/nav-bar/nav-bar.component.html | 2 +- bookie/src/app/printers/printer.service.ts | 40 ++++------ .../product-sale-report.service.ts | 8 +- .../product-updates-report.service.ts | 10 +-- .../product-list/product-list.component.html | 2 +- bookie/src/app/product/product.service.ts | 68 +++++++---------- bookie/src/app/roles/role.service.ts | 40 ++++------ ...ale-category-list-resolver.service.spec.ts | 1 + .../sale-category-resolver.service.spec.ts | 1 + .../sale-category/sale-category.service.ts | 52 ++++++------- .../app/sale-report/sale-report.service.ts | 16 ++-- .../sales/bill-type/bill-type.component.ts | 13 +++- bookie/src/app/sales/bill.service.ts | 46 +++++------ bookie/src/app/sales/bills/voucher.service.ts | 76 +++++++++---------- .../section-printer.service.ts | 32 ++++---- bookie/src/app/sections/section.service.ts | 40 ++++------ bookie/src/app/shared/clear.pipe.ts | 4 +- bookie/src/app/tables/table.service.ts | 58 ++++++-------- .../src/app/tax-report/tax-report.service.ts | 8 +- bookie/src/app/taxes/tax.service.ts | 38 ++++------ .../update-product-prices.component.ts | 4 +- .../update-product-prices.service.ts | 20 ++--- bookie/src/app/users/user.service.ts | 40 ++++------ bookie/tsconfig.spec.json | 5 +- 50 files changed, 524 insertions(+), 636 deletions(-) delete mode 100644 bookie/.eslintrc.js create mode 100644 bookie/.eslintrc.json diff --git a/barker/barker/models/auth.py b/barker/barker/models/auth.py index c45fbd9..f2dd76a 100644 --- a/barker/barker/models/auth.py +++ b/barker/barker/models/auth.py @@ -126,7 +126,7 @@ class User(Base): self.id = id_ @classmethod - def auth(cls, name, password, db: Session): + def auth(cls, name: str, password: str, db: Session): if password is None: return None user = db.query(User).filter(User.name.ilike(name)).first() diff --git a/barker/barker/routers/login.py b/barker/barker/routers/login.py index 49a973f..4ad2487 100644 --- a/barker/barker/routers/login.py +++ b/barker/barker/routers/login.py @@ -68,7 +68,7 @@ async def login_for_access_token( not_allowed_response = JSONResponse( status_code=status.HTTP_401_UNAUTHORIZED, headers={"WWW-Authenticate": "Bearer"}, - content={"detail": "Client is not registered"}, + content={"detail": "Device is not registered"}, ) not_allowed_response.set_cookie(key="device_id", value=str(device.id), max_age=10 * 365 * 24 * 60 * 60) not_allowed_response.set_cookie(key="device", value=device.name, max_age=10 * 365 * 24 * 60 * 60) diff --git a/barker/barker/schemas/auth.py b/barker/barker/schemas/auth.py index 47344e4..4a34db8 100644 --- a/barker/barker/schemas/auth.py +++ b/barker/barker/schemas/auth.py @@ -105,7 +105,6 @@ class UserList(BaseModel): last_date: Optional[datetime] class Config: - fields = {"id_": "id"} anystr_strip_whitespace = True alias_generator = to_camel json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M")} diff --git a/barker/pyproject.toml b/barker/pyproject.toml index 8d322d6..c0d4198 100644 --- a/barker/pyproject.toml +++ b/barker/pyproject.toml @@ -7,17 +7,17 @@ authors = ["tanshu "] [tool.poetry.dependencies] python = "^3.8" uvicorn = "^0.12.3" -fastapi = "^0.61.2" +fastapi = "^0.62.0" python-jose = {extras = ["cryptography"], version = "^3.2.0"} -passlib = {extras = ["bcrypt"], version = "^1.7.3"} +passlib = {extras = ["bcrypt"], version = "^1.7.4"} psycopg2-binary = "^2.8.6" -SQLAlchemy = "^1.3.19" +SQLAlchemy = "^1.3.20" python-multipart = "^0.0.5" PyJWT = "^1.7.1" alembic = "^1.4.3" itsdangerous = "^1.1.0" python-dotenv = "^0.14.0" -pydantic = {extras = ["dotenv"], version = "^1.7.2"} +pydantic = {extras = ["dotenv"], version = "^1.7.3"} starlette = "^0.13.6" arq = "^0.19.1" @@ -25,7 +25,7 @@ arq = "^0.19.1" flake8 = "^3.8.4" black = "^20.8b1" isort = "^5.6.2" -pre-commit = "^2.9.0" +pre-commit = "^2.9.3" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/bookie/.eslintrc.js b/bookie/.eslintrc.js deleted file mode 100644 index fe395d1..0000000 --- a/bookie/.eslintrc.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -We recommend eventually switching this configuration to extend from -the recommended rulesets in typescript-eslint. -https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md - -Happy linting! ๐Ÿ’– -*/ -module.exports = { - "extends": [ - "plugin:@angular-eslint/recommended", - // AirBnB Styleguide rules - "airbnb-typescript/base", - // Settings for Prettier - "prettier", - "prettier/@typescript-eslint", - "prettier/react", - ], - "env": { - "browser": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "ecmaVersion": 2020, - "sourceType": "module" - }, - "plugins": [ - "eslint-plugin-import", - "eslint-plugin-jsdoc", - "@angular-eslint/eslint-plugin", - "@typescript-eslint", - ], - "ignorePatterns": ["/src/**/*.spec.ts", "src/test.ts", "src/polyfills.ts"], - "rules": { - "import/prefer-default-export": "off", - "no-param-reassign": ["error", { "props": false }], - "@typescript-eslint/lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }], - "class-methods-use-this": ["error", {"exceptMethods": ["disconnect", "displayFn", "transform"]}], - "import/order": ["error", {"alphabetize": {"order": "asc", "caseInsensitive": true}, "newlines-between": "always"}], - "@typescript-eslint/no-explicit-any": "error", - } -}; diff --git a/bookie/.eslintrc.json b/bookie/.eslintrc.json new file mode 100644 index 0000000..8931adf --- /dev/null +++ b/bookie/.eslintrc.json @@ -0,0 +1,74 @@ +{ + "root": true, + "ignorePatterns": [ + "projects/**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "parserOptions": { + "project": [ + "tsconfig.json", + "e2e/tsconfig.json" + ], + "createDefaultProgram": true + }, + "extends": [ + "plugin:@angular-eslint/ng-cli-compat", + "plugin:@angular-eslint/ng-cli-compat--formatting-add-on", + "plugin:@angular-eslint/template/process-inline-templates" + ], + "rules": { + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "app", + "style": "kebab-case" + } + ], + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "app", + "style": "camelCase" + } + ], + "@typescript-eslint/lines-between-class-members": [ + "error", + "always", + { + "exceptAfterSingleLine": true + } + ], + "import/order": [ + "error", + { + "alphabetize": {"order": "asc", "caseInsensitive": true}, + "newlines-between": "always" + } + ], + "@typescript-eslint/naming-convention": [ + "off" + ], + "@typescript-eslint/no-explicit-any": [ + "error" + ], + "no-shadow": "off", + "@typescript-eslint/no-shadow": "error" + } + }, + { + "files": [ + "*.html" + ], + "extends": [ + "plugin:@angular-eslint/template/recommended" + ], + "rules": {} + } + ] +} diff --git a/bookie/angular.json b/bookie/angular.json index 4d181a2..c1b9f34 100644 --- a/bookie/angular.json +++ b/bookie/angular.json @@ -102,14 +102,9 @@ "lint": { "builder": "@angular-eslint/builder:lint", "options": { - "eslintConfig": ".eslintrc.js", - "tsConfig": [ - "tsconfig.app.json", - "tsconfig.spec.json", - "e2e/tsconfig.json" - ], - "exclude": [ - "**/node_modules/**" + "lintFilePatterns": [ + "src/**/*.ts", + "src/**/*.html" ] } }, diff --git a/bookie/package.json b/bookie/package.json index 21c835e..515d3a1 100644 --- a/bookie/package.json +++ b/bookie/package.json @@ -14,57 +14,57 @@ }, "private": true, "dependencies": { - "@angular/animations": "^11.0.0", - "@angular/cdk": "^11.0.0", - "@angular/common": "^11.0.0", - "@angular/compiler": "^11.0.0", - "@angular/core": "^11.0.0", + "@angular/animations": "^11.0.3", + "@angular/cdk": "^11.0.1", + "@angular/common": "^11.0.3", + "@angular/compiler": "^11.0.3", + "@angular/core": "^11.0.3", "@angular/flex-layout": "^11.0.0-beta.33", - "@angular/forms": "^11.0.0", - "@angular/material": "^11.0.0", - "@angular/material-moment-adapter": "^11.0.0", - "@angular/platform-browser": "^11.0.0", - "@angular/platform-browser-dynamic": "^11.0.0", - "@angular/router": "^11.0.0", - "mathjs": "^8.0.1", + "@angular/forms": "^11.0.3", + "@angular/material": "^11.0.1", + "@angular/material-moment-adapter": "^11.0.1", + "@angular/platform-browser": "^11.0.3", + "@angular/platform-browser-dynamic": "^11.0.3", + "@angular/router": "^11.0.3", + "mathjs": "^8.1.0", "moment": "^2.29.1", "rxjs": "^6.6.3", "tslib": "^2.0.0", "zone.js": "^0.11.3" }, "devDependencies": { - "@angular-devkit/build-angular": "~0.1100.1", - "@angular-eslint/builder": "^0.8.0-beta.0", - "@angular-eslint/eslint-plugin": "^0.8.0-beta.0", - "@angular-eslint/eslint-plugin-template": "^0.8.0-beta.0", - "@angular-eslint/schematics": "^0.8.0-beta.0", - "@angular-eslint/template-parser": "^0.8.0-beta.0", - "@angular/cli": "^11.0.1", - "@angular/compiler-cli": "^11.0.0", - "@angular/language-service": "^11.0.0", - "@types/jasmine": "~3.6.0", - "@types/mathjs": "^6.0.7", - "@types/node": "^14.14.7", - "@typescript-eslint/eslint-plugin": "^4.8.0", - "@typescript-eslint/parser": "^4.8.0", - "eslint": "^7.13.0", - "eslint-config-airbnb-typescript": "^12.0.0", - "eslint-config-prettier": "^6.15.0", + "@angular-devkit/build-angular": "~0.1100.3", + "@angular-eslint/builder": "^0.8.0-beta.3", + "@angular-eslint/eslint-plugin": "^0.8.0-beta.3", + "@angular-eslint/eslint-plugin-template": "^0.8.0-beta.3", + "@angular-eslint/schematics": "^0.8.0-beta.3", + "@angular-eslint/template-parser": "^0.8.0-beta.3", + "@angular/cli": "^11.0.3", + "@angular/compiler-cli": "^11.0.3", + "@angular/language-service": "^11.0.3", + "@types/jasmine": "~3.6.2", + "@types/mathjs": "^6.0.8", + "@types/node": "^14.14.10", + "@typescript-eslint/eslint-plugin": "^4.9.1", + "@typescript-eslint/parser": "^4.9.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^7.0.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsdoc": "^30.7.8", - "husky": "^4.3.0", + "eslint-plugin-prefer-arrow": "1.2.2", + "husky": "^4.3.5", "jasmine-core": "^3.6.0", "jasmine-spec-reporter": "^6.0.0", "karma": "^5.2.3", "karma-chrome-launcher": "~3.1.0", - "karma-coverage": "~2.0.3", + "karma-coverage-istanbul-reporter": "~3.0.2", "karma-jasmine": "^4.0.0", "karma-jasmine-html-reporter": "^1.5.0", - "lint-staged": "^10.5.1", - "prettier": "^2.1.2", + "lint-staged": "^10.5.3", + "prettier": "^2.2.1", "protractor": "~7.0.0", "standard-version": "^9.0.0", - "ts-node": "^9.0.0", + "ts-node": "^9.1.1", "typescript": "~4.0.5" }, "husky": { diff --git a/bookie/src/app/auth/auth.service.ts b/bookie/src/app/auth/auth.service.ts index 8af38bb..c658f60 100644 --- a/bookie/src/app/auth/auth.service.ts +++ b/bookie/src/app/auth/auth.service.ts @@ -14,9 +14,9 @@ const JWT_USER = 'JWT_USER'; @Injectable({ providedIn: 'root' }) export class AuthService { - private currentUserSubject: BehaviorSubject = new BehaviorSubject(null); public currentUser: Observable; public device: Device; + private currentUserSubject: BehaviorSubject = new BehaviorSubject(null); constructor(private http: HttpClient, private cs: CookieService) { this.checkStorage(); diff --git a/bookie/src/app/beer-sale-report/beer-sale-report.service.ts b/bookie/src/app/beer-sale-report/beer-sale-report.service.ts index 2713230..70d66c2 100644 --- a/bookie/src/app/beer-sale-report/beer-sale-report.service.ts +++ b/bookie/src/app/beer-sale-report/beer-sale-report.service.ts @@ -24,10 +24,8 @@ export class BeerSaleReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(url, options) - .pipe(catchError(this.log.handleError(serviceName, 'get'))) - ); + return this.http + .get(url, options) + .pipe(catchError(this.log.handleError(serviceName, 'get'))) as Observable; } } diff --git a/bookie/src/app/bill-settlement-report/bill-settlement-report.service.ts b/bookie/src/app/bill-settlement-report/bill-settlement-report.service.ts index cb2b82c..66c848c 100644 --- a/bookie/src/app/bill-settlement-report/bill-settlement-report.service.ts +++ b/bookie/src/app/bill-settlement-report/bill-settlement-report.service.ts @@ -24,10 +24,10 @@ export class BillSettlementReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(url, options) - .pipe(catchError(this.log.handleError(serviceName, 'get'))) - ); + return this.http + .get(url, options) + .pipe( + catchError(this.log.handleError(serviceName, 'get')), + ) as Observable; } } diff --git a/bookie/src/app/cashier-report/cashier-report.service.ts b/bookie/src/app/cashier-report/cashier-report.service.ts index aadd889..0b050cb 100644 --- a/bookie/src/app/cashier-report/cashier-report.service.ts +++ b/bookie/src/app/cashier-report/cashier-report.service.ts @@ -30,11 +30,9 @@ export class CashierReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(listUrl, options) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(listUrl, options) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } activeCashiers(startDate: string | null, finishDate: string | null): Observable { @@ -45,10 +43,10 @@ export class CashierReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >this.http + return this.http .get(`${url}/active`, options) - .pipe(catchError(this.log.handleError(serviceName, 'activeCashiers'))); + .pipe(catchError(this.log.handleError(serviceName, 'activeCashiers'))) as Observable; } print(id: string, startDate: string | null, finishDate: string | null): Observable { @@ -60,10 +58,8 @@ export class CashierReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(printUrl, options) - .pipe(catchError(this.log.handleError(serviceName, 'print'))) - ); + return this.http + .get(printUrl, options) + .pipe(catchError(this.log.handleError(serviceName, 'print'))) as Observable; } } diff --git a/bookie/src/app/core/error-logger.service.ts b/bookie/src/app/core/error-logger.service.ts index 3d875cf..16a2bdf 100644 --- a/bookie/src/app/core/error-logger.service.ts +++ b/bookie/src/app/core/error-logger.service.ts @@ -14,6 +14,7 @@ export class ErrorLoggerService { /** * Handle Http operation that failed. * Let the app continue. + * * @param operation - name of the operation that failed * @param result - optional value to return as the observable result */ diff --git a/bookie/src/app/core/http-auth-interceptor.ts b/bookie/src/app/core/http-auth-interceptor.ts index 25c2b4b..0a82653 100644 --- a/bookie/src/app/core/http-auth-interceptor.ts +++ b/bookie/src/app/core/http-auth-interceptor.ts @@ -46,7 +46,9 @@ export class ErrorInterceptor implements HttpInterceptor { data: { title: 'Logged out!', content: - 'You have been logged out.\nYou can press Cancel to stay on page and login in another tab to resume here, or you can press Ok to navigate to the login page.', + 'You have been logged out.\n' + + 'You can press Cancel to stay on page and login in another tab to resume here,' + + ' or you can press Ok to navigate to the login page.', }, }); dialogRef.afterClosed().subscribe((result: boolean) => { diff --git a/bookie/src/app/devices/device.service.ts b/bookie/src/app/devices/device.service.ts index 687bd3f..38f049a 100644 --- a/bookie/src/app/devices/device.service.ts +++ b/bookie/src/app/devices/device.service.ts @@ -17,35 +17,27 @@ export class DeviceService { get(id: string | null): Observable { const getUrl: string = id === null ? `${url}` : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } save(device: Device): Observable { - return >( - this.http - .post(`${url}`, device) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(`${url}`, device) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(device: Device): Observable { - return >( - this.http - .put(`${url}/${device.id}`, device) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${device.id}`, device) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } saveOrUpdate(device: Device): Observable { @@ -56,10 +48,8 @@ export class DeviceService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } } diff --git a/bookie/src/app/discount-report/discount-report.service.ts b/bookie/src/app/discount-report/discount-report.service.ts index 20322aa..f3bb73e 100644 --- a/bookie/src/app/discount-report/discount-report.service.ts +++ b/bookie/src/app/discount-report/discount-report.service.ts @@ -24,11 +24,9 @@ export class DiscountReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(url, options) - .pipe(catchError(this.log.handleError(serviceName, 'get'))) - ); + return this.http + .get(url, options) + .pipe(catchError(this.log.handleError(serviceName, 'get'))) as Observable; } print(startDate: string | null, finishDate: string | null): Observable { @@ -40,10 +38,8 @@ export class DiscountReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(printUrl, options) - .pipe(catchError(this.log.handleError(serviceName, 'print'))) - ); + return this.http + .get(printUrl, options) + .pipe(catchError(this.log.handleError(serviceName, 'print'))) as Observable; } } diff --git a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts index 4994091..6a78c55 100644 --- a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts +++ b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts @@ -44,11 +44,11 @@ export class GuestBookListComponent implements OnInit { listenToDateChange(): void { (this.form.get('date') as FormControl).valueChanges .pipe(map((x) => moment(x).format('DD-MMM-YYYY'))) - .subscribe((x) => { - return this.ser.list(x).subscribe((list: GuestBookList) => { + .subscribe((x) => + this.ser.list(x).subscribe((list: GuestBookList) => { this.data.next(list.list); - }); - }); + }), + ); } ngOnInit() { diff --git a/bookie/src/app/guest-book/guest-book.service.ts b/bookie/src/app/guest-book/guest-book.service.ts index 60a5eb2..1cfc795 100644 --- a/bookie/src/app/guest-book/guest-book.service.ts +++ b/bookie/src/app/guest-book/guest-book.service.ts @@ -21,36 +21,28 @@ export class GuestBookService { get(id: string | null): Observable { const getUrl: string = id === null ? url : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable; } list(date: string | null): Observable { const options = { params: new HttpParams().set('q', date === null ? '' : date) }; - return >( - this.http - .get(`${url}/list`, options) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`, options) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } save(guestBook: GuestBook): Observable { - return >( - this.http - .post(url, guestBook, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(url, guestBook, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(guestBook: GuestBook): Observable { - return >( - this.http - .put(`${url}/${guestBook.id}`, guestBook, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${guestBook.id}`, guestBook, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } saveOrUpdate(guestBook: GuestBook): Observable { @@ -61,10 +53,8 @@ export class GuestBookService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } } diff --git a/bookie/src/app/header-footer/header-footer.component.ts b/bookie/src/app/header-footer/header-footer.component.ts index 929f3bb..09bd56c 100644 --- a/bookie/src/app/header-footer/header-footer.component.ts +++ b/bookie/src/app/header-footer/header-footer.component.ts @@ -70,7 +70,9 @@ export class HeaderFooterComponent implements OnInit { getItem(): HeaderFooter { const formModel = this.form.value; const item = this.list.find((v) => v.id === this.id); - if (item === undefined) return new HeaderFooter(); + if (item === undefined) { + return new HeaderFooter(); + } item.text = formModel.text; return item; } diff --git a/bookie/src/app/header-footer/header-footer.service.ts b/bookie/src/app/header-footer/header-footer.service.ts index ba3cf79..ef3e224 100644 --- a/bookie/src/app/header-footer/header-footer.service.ts +++ b/bookie/src/app/header-footer/header-footer.service.ts @@ -20,16 +20,14 @@ export class HeaderFooterService { constructor(private http: HttpClient, private log: ErrorLoggerService) {} list(): Observable { - return >( - this.http.get(url).pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(url) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } save(item: HeaderFooter): Observable { - return >( - this.http - .post(url, item, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(url, item, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } } diff --git a/bookie/src/app/menu-category/menu-category-list-resolver.service.spec.ts b/bookie/src/app/menu-category/menu-category-list-resolver.service.spec.ts index c0b6bb7..6e6550c 100644 --- a/bookie/src/app/menu-category/menu-category-list-resolver.service.spec.ts +++ b/bookie/src/app/menu-category/menu-category-list-resolver.service.spec.ts @@ -1,4 +1,5 @@ import { inject, TestBed } from '@angular/core/testing'; + import { MenuCategoryListResolver } from './menu-category-list-resolver.service'; describe('MenuCategoryListResolver', () => { diff --git a/bookie/src/app/menu-category/menu-category-resolver.service.spec.ts b/bookie/src/app/menu-category/menu-category-resolver.service.spec.ts index 660b368..32c4642 100644 --- a/bookie/src/app/menu-category/menu-category-resolver.service.spec.ts +++ b/bookie/src/app/menu-category/menu-category-resolver.service.spec.ts @@ -1,4 +1,5 @@ import { inject, TestBed } from '@angular/core/testing'; + import { MenuCategoryResolver } from './menu-category-resolver.service'; describe('MenuCategoriesResolver', () => { diff --git a/bookie/src/app/menu-category/menu-category.service.ts b/bookie/src/app/menu-category/menu-category.service.ts index 06477fa..dc59aca 100644 --- a/bookie/src/app/menu-category/menu-category.service.ts +++ b/bookie/src/app/menu-category/menu-category.service.ts @@ -20,43 +20,37 @@ export class MenuCategoryService { get(id: string | null): Observable { const getUrl: string = id === null ? url : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe( + catchError(this.log.handleError(serviceName, `get id=${id}`)), + ) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } save(menuCategory: MenuCategory): Observable { - return >( - this.http - .post(url, menuCategory, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(url, menuCategory, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(menuCategory: MenuCategory): Observable { - return >( - this.http - .put(`${url}/${menuCategory.id}`, menuCategory, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${menuCategory.id}`, menuCategory, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } updateSortOrder(list: MenuCategory[]): Observable { - return >( - this.http - .post(url, list, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'updateSortOrder'))) - ); + return this.http + .post(url, list, httpOptions) + .pipe( + catchError(this.log.handleError(serviceName, 'updateSortOrder')), + ) as Observable; } saveOrUpdate(menuCategory: MenuCategory): Observable { @@ -67,10 +61,8 @@ export class MenuCategoryService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } } diff --git a/bookie/src/app/modifier-categories/modifier-category.service.ts b/bookie/src/app/modifier-categories/modifier-category.service.ts index 2c10fef..45638fd 100644 --- a/bookie/src/app/modifier-categories/modifier-category.service.ts +++ b/bookie/src/app/modifier-categories/modifier-category.service.ts @@ -20,43 +20,41 @@ export class ModifierCategoryService { get(id: string | null): Observable { const getUrl: string = id === null ? url : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe( + catchError(this.log.handleError(serviceName, `get id=${id}`)), + ) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable< + ModifierCategory[] + >; } listForProduct(id: string): Observable { - return >( - this.http - .get(`${url}/for-product/${id}`) - .pipe(catchError(this.log.handleError(serviceName, 'listIsActiveOfProduct'))) - ); + return this.http + .get(`${url}/for-product/${id}`) + .pipe(catchError(this.log.handleError(serviceName, 'listIsActiveOfProduct'))) as Observable< + ModifierCategory[] + >; } save(modifierCategory: ModifierCategory): Observable { - return >( - this.http - .post(url, modifierCategory, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(url, modifierCategory, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(modifierCategory: ModifierCategory): Observable { - return >( - this.http - .put(`${url}/${modifierCategory.id}`, modifierCategory, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${modifierCategory.id}`, modifierCategory, httpOptions) + .pipe( + catchError(this.log.handleError(serviceName, 'update')), + ) as Observable; } saveOrUpdate(modifierCategory: ModifierCategory): Observable { @@ -67,10 +65,10 @@ export class ModifierCategoryService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe( + catchError(this.log.handleError(serviceName, 'delete')), + ) as Observable; } } diff --git a/bookie/src/app/modifiers/modifier-list/modifier-list-datasource.ts b/bookie/src/app/modifiers/modifier-list/modifier-list-datasource.ts index 5342a7a..c325275 100644 --- a/bookie/src/app/modifiers/modifier-list/modifier-list-datasource.ts +++ b/bookie/src/app/modifiers/modifier-list/modifier-list-datasource.ts @@ -45,8 +45,8 @@ export class ModifierListDataSource extends DataSource { private getFilteredData(data: Modifier[]): Modifier[] { const filter = this.filterValue === undefined ? '' : this.filterValue; - return data.filter((x) => { - return (x.modifierCategory as ModifierCategory).id === filter || filter === ''; - }); + return data.filter( + (x) => (x.modifierCategory as ModifierCategory).id === filter || filter === '', + ); } } diff --git a/bookie/src/app/modifiers/modifier.service.ts b/bookie/src/app/modifiers/modifier.service.ts index 63c24f1..dc42ba8 100644 --- a/bookie/src/app/modifiers/modifier.service.ts +++ b/bookie/src/app/modifiers/modifier.service.ts @@ -19,35 +19,27 @@ export class ModifierService { get(id: string | null): Observable { const getUrl: string = id === null ? url : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'getList'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'getList'))) as Observable; } save(modifier: Modifier): Observable { - return >( - this.http - .post(url, modifier, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(url, modifier, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(modifier: Modifier): Observable { - return >( - this.http - .put(`${url}/${modifier.id}`, modifier, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${modifier.id}`, modifier, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } saveOrUpdate(modifier: Modifier): Observable { @@ -58,10 +50,8 @@ export class ModifierService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } } diff --git a/bookie/src/app/nav-bar/nav-bar.component.html b/bookie/src/app/nav-bar/nav-bar.component.html index 3437c8c..e4ee96f 100644 --- a/bookie/src/app/nav-bar/nav-bar.component.html +++ b/bookie/src/app/nav-bar/nav-bar.component.html @@ -4,7 +4,7 @@ Point of Sale - diff --git a/bookie/src/app/printers/printer.service.ts b/bookie/src/app/printers/printer.service.ts index 64e73fd..1b2ef44 100644 --- a/bookie/src/app/printers/printer.service.ts +++ b/bookie/src/app/printers/printer.service.ts @@ -20,35 +20,27 @@ export class PrinterService { get(id: string | null): Observable { const getUrl: string = id === null ? url : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } save(printer: Printer): Observable { - return >( - this.http - .post(url, printer, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(url, printer, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(printer: Printer): Observable { - return >( - this.http - .put(`${url}/${printer.id}`, printer, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${printer.id}`, printer, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } saveOrUpdate(printer: Printer): Observable { @@ -59,10 +51,8 @@ export class PrinterService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } } diff --git a/bookie/src/app/product-sale-report/product-sale-report.service.ts b/bookie/src/app/product-sale-report/product-sale-report.service.ts index 71ad714..9351377 100644 --- a/bookie/src/app/product-sale-report/product-sale-report.service.ts +++ b/bookie/src/app/product-sale-report/product-sale-report.service.ts @@ -24,10 +24,8 @@ export class ProductSaleReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(url, options) - .pipe(catchError(this.log.handleError(serviceName, 'get'))) - ); + return this.http + .get(url, options) + .pipe(catchError(this.log.handleError(serviceName, 'get'))) as Observable; } } diff --git a/bookie/src/app/product-updates-report/product-updates-report.service.ts b/bookie/src/app/product-updates-report/product-updates-report.service.ts index 7548d95..d1e9e13 100644 --- a/bookie/src/app/product-updates-report/product-updates-report.service.ts +++ b/bookie/src/app/product-updates-report/product-updates-report.service.ts @@ -24,10 +24,10 @@ export class ProductUpdatesReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(url, options) - .pipe(catchError(this.log.handleError(serviceName, 'get'))) - ); + return this.http + .get(url, options) + .pipe( + catchError(this.log.handleError(serviceName, 'get')), + ) as Observable; } } diff --git a/bookie/src/app/product/product-list/product-list.component.html b/bookie/src/app/product/product-list/product-list.component.html index da87968..2d3ce4d 100644 --- a/bookie/src/app/product/product-list/product-list.component.html +++ b/bookie/src/app/product/product-list/product-list.component.html @@ -1,7 +1,7 @@ Products - diff --git a/bookie/src/app/product/product.service.ts b/bookie/src/app/product/product.service.ts index c46ad91..dd0acc7 100644 --- a/bookie/src/app/product/product.service.ts +++ b/bookie/src/app/product/product.service.ts @@ -19,52 +19,44 @@ export class ProductService { get(id: string | null): Observable { const getUrl: string = id === null ? `${url}` : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } listIsActiveOfCategory(id: string): Observable { const options = { params: new HttpParams().set('mc', id) }; - return >( - this.http - .get(`${url}/query`, options) - .pipe(catchError(this.log.handleError(serviceName, 'listIsActiveOfCategory'))) - ); + return this.http + .get(`${url}/query`, options) + .pipe(catchError(this.log.handleError(serviceName, 'listIsActiveOfCategory'))) as Observable< + Product[] + >; } save(product: Product): Observable { - return >( - this.http - .post(`${url}`, product, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(`${url}`, product, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(product: Product): Observable { - return >( - this.http - .put(`${url}/${product.id}`, product, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${product.id}`, product, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } updateSortOrder(list: Product[]): Observable { - return >( - this.http - .post(`${url}/list`, list, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'updateSortOrder'))) - ); + return this.http + .post(`${url}/list`, list, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'updateSortOrder'))) as Observable< + Product[] + >; } saveOrUpdate(product: Product): Observable { @@ -75,19 +67,15 @@ export class ProductService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } balance(id: string, date: string): Observable { const options = { params: new HttpParams().set('d', date) }; - return >( - this.http - .get(`${url}/balance`, options) - .pipe(catchError(this.log.handleError(serviceName, 'balance'))) - ); + return this.http + .get(`${url}/balance`, options) + .pipe(catchError(this.log.handleError(serviceName, 'balance'))) as Observable; } } diff --git a/bookie/src/app/roles/role.service.ts b/bookie/src/app/roles/role.service.ts index 3fb95af..6d74418 100644 --- a/bookie/src/app/roles/role.service.ts +++ b/bookie/src/app/roles/role.service.ts @@ -21,35 +21,27 @@ export class RoleService { get(id: string | null): Observable { const getUrl: string = id === null ? `${url}` : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } save(role: Role): Observable { - return >( - this.http - .post(`${url}`, role, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(`${url}`, role, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(role: Role): Observable { - return >( - this.http - .put(`${url}/${role.id}`, role, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${role.id}`, role, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } saveOrUpdate(role: Role): Observable { @@ -60,10 +52,8 @@ export class RoleService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } } diff --git a/bookie/src/app/sale-category/sale-category-list-resolver.service.spec.ts b/bookie/src/app/sale-category/sale-category-list-resolver.service.spec.ts index f5b1603..fb2aba4 100644 --- a/bookie/src/app/sale-category/sale-category-list-resolver.service.spec.ts +++ b/bookie/src/app/sale-category/sale-category-list-resolver.service.spec.ts @@ -1,4 +1,5 @@ import { inject, TestBed } from '@angular/core/testing'; + import { SaleCategoryListResolver } from './sale-category-list-resolver.service'; describe('SaleCategoryListResolver', () => { diff --git a/bookie/src/app/sale-category/sale-category-resolver.service.spec.ts b/bookie/src/app/sale-category/sale-category-resolver.service.spec.ts index ac34b0f..732207a 100644 --- a/bookie/src/app/sale-category/sale-category-resolver.service.spec.ts +++ b/bookie/src/app/sale-category/sale-category-resolver.service.spec.ts @@ -1,4 +1,5 @@ import { inject, TestBed } from '@angular/core/testing'; + import { SaleCategoryResolver } from './sale-category-resolver.service'; describe('SaleCategoryResolver', () => { diff --git a/bookie/src/app/sale-category/sale-category.service.ts b/bookie/src/app/sale-category/sale-category.service.ts index 7962770..2154f6c 100644 --- a/bookie/src/app/sale-category/sale-category.service.ts +++ b/bookie/src/app/sale-category/sale-category.service.ts @@ -20,43 +20,37 @@ export class SaleCategoryService { get(id: string | null): Observable { const getUrl: string = id === null ? url : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe( + catchError(this.log.handleError(serviceName, `get id=${id}`)), + ) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } listForDiscount(): Observable<{ name: string; discount: number }[]> { - return >( - this.http - .get<{ name: string; discount: number }[]>(`${url}/for-discount`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get<{ name: string; discount: number }[]>(`${url}/for-discount`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable< + { name: string; discount: number }[] + >; } save(saleCategory: SaleCategory): Observable { - return >( - this.http - .post(url, saleCategory, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(url, saleCategory, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(saleCategory: SaleCategory): Observable { - return >( - this.http - .put(`${url}/${saleCategory.id}`, saleCategory, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${saleCategory.id}`, saleCategory, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } saveOrUpdate(saleCategory: SaleCategory): Observable { @@ -67,10 +61,8 @@ export class SaleCategoryService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } } diff --git a/bookie/src/app/sale-report/sale-report.service.ts b/bookie/src/app/sale-report/sale-report.service.ts index 9177510..85bd0e8 100644 --- a/bookie/src/app/sale-report/sale-report.service.ts +++ b/bookie/src/app/sale-report/sale-report.service.ts @@ -24,11 +24,9 @@ export class SaleReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(url, options) - .pipe(catchError(this.log.handleError(serviceName, 'get'))) - ); + return this.http + .get(url, options) + .pipe(catchError(this.log.handleError(serviceName, 'get'))) as Observable; } print(startDate: string | null, finishDate: string | null): Observable { @@ -40,10 +38,8 @@ export class SaleReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(printUrl, options) - .pipe(catchError(this.log.handleError(serviceName, 'print'))) - ); + return this.http + .get(printUrl, options) + .pipe(catchError(this.log.handleError(serviceName, 'print'))) as Observable; } } diff --git a/bookie/src/app/sales/bill-type/bill-type.component.ts b/bookie/src/app/sales/bill-type/bill-type.component.ts index f21e96d..8841891 100644 --- a/bookie/src/app/sales/bill-type/bill-type.component.ts +++ b/bookie/src/app/sales/bill-type/bill-type.component.ts @@ -20,9 +20,14 @@ export class BillTypeComponent { } accept(): void { - if (this.selected === 'REGULAR_BILL') this.dialogRef.close(VoucherType.Bill); - else if (this.selected === 'STAFF') this.dialogRef.close(VoucherType.Staff); - else if (this.selected === 'NO_CHARGE') this.dialogRef.close(VoucherType.NoCharge); - else this.dialogRef.close(); + if (this.selected === 'REGULAR_BILL') { + this.dialogRef.close(VoucherType.Bill); + } else if (this.selected === 'STAFF') { + this.dialogRef.close(VoucherType.Staff); + } else if (this.selected === 'NO_CHARGE') { + this.dialogRef.close(VoucherType.NoCharge); + } else { + this.dialogRef.close(); + } } } diff --git a/bookie/src/app/sales/bill.service.ts b/bookie/src/app/sales/bill.service.ts index d34efa9..b60e506 100644 --- a/bookie/src/app/sales/bill.service.ts +++ b/bookie/src/app/sales/bill.service.ts @@ -115,11 +115,7 @@ export class BillService { }); this.data.push(item); this.modifierCategoryService.listForProduct(product.id as string).subscribe((result) => { - if ( - result.reduce((a: number, c: ModifierCategory) => { - return a + c.minimum; - }, 0) - ) { + if (result.reduce((a: number, c: ModifierCategory) => a + c.minimum, 0)) { this.showModifier(item); } }); @@ -198,26 +194,6 @@ export class BillService { this.updateAmounts(); } - private getKot(): Kot { - return new Kot({ - inventories: this.data - .filter((x) => !x.isKot && !x.isPrinted) - .map( - (y) => - new Inventory({ - product: y.product, - quantity: y.quantity, - price: y.price, - isHappyHour: y.isHappyHour, - discount: y.discount, - modifiers: y.modifiers, - taxRate: y.taxRate, - tax: y.tax, - }), - ), - }); - } - printKot(guestBookId: string | null): Observable { const item = JSON.parse(JSON.stringify(this.bill)); const newKot = this.getKot(); @@ -337,4 +313,24 @@ export class BillService { ); return this.ser.splitBill(this.bill.id as string, inventoriesToMove, table); } + + private getKot(): Kot { + return new Kot({ + inventories: this.data + .filter((x) => !x.isKot && !x.isPrinted) + .map( + (y) => + new Inventory({ + product: y.product, + quantity: y.quantity, + price: y.price, + isHappyHour: y.isHappyHour, + discount: y.discount, + modifiers: y.modifiers, + taxRate: y.taxRate, + tax: y.tax, + }), + ), + }); + } } diff --git a/bookie/src/app/sales/bills/voucher.service.ts b/bookie/src/app/sales/bills/voucher.service.ts index 604bc21..242faf6 100644 --- a/bookie/src/app/sales/bills/voucher.service.ts +++ b/bookie/src/app/sales/bills/voucher.service.ts @@ -20,11 +20,9 @@ export class VoucherService { constructor(private http: HttpClient, private log: ErrorLoggerService) {} get(id: string): Observable { - return >( - this.http - .get(`${url}/from-id/${id}`) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(`${url}/from-id/${id}`) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable; } getFromTable( @@ -40,7 +38,7 @@ export class VoucherService { params = params.set('g', guestId); } - return >this.http + return this.http .get(`${url}/from-table/${tableId}`, { params }) .pipe( catchError( @@ -49,7 +47,7 @@ export class VoucherService { `getFromTable tableId=${tableId} voucherId=${voucherId} guestId=${guestId}`, ), ), - ); + ) as Observable; } save( @@ -64,11 +62,9 @@ export class VoucherService { if (guestBookId !== null) { options.params = options.params.set('g', guestBookId); } - return >( - this.http - .post(`${url}/save`, voucher, options) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(`${url}/save`, voucher, options) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update( @@ -83,11 +79,9 @@ export class VoucherService { if (guestBookId !== null) { options.params = options.params.set('g', guestBookId); } - return >( - this.http - .put(`${url}/update/${voucher.id}`, voucher, options) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/update/${voucher.id}`, voucher, options) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } change( @@ -100,11 +94,9 @@ export class VoucherService { if (guestBookId !== null) { options.params = options.params.set('g', guestBookId); } - return >( - this.http - .put(`${url}/change/${voucher.id}`, voucher, options) - .pipe(catchError(this.log.handleError(serviceName, 'change'))) - ); + return this.http + .put(`${url}/change/${voucher.id}`, voucher, options) + .pipe(catchError(this.log.handleError(serviceName, 'change'))) as Observable; } saveOrUpdate( @@ -129,67 +121,67 @@ export class VoucherService { updateTable: boolean, ): Observable { const options = { params: new HttpParams().set('u', updateTable.toString()) }; - return >( - this.http - .post(`${url}/receive-payment/${id}`, { name, amounts }, options) - .pipe(catchError(this.log.handleError(serviceName, 'receivePayment'))) - ); + return this.http + .post(`${url}/receive-payment/${id}`, { name, amounts }, options) + .pipe(catchError(this.log.handleError(serviceName, 'receivePayment'))) as Observable; } voidBill(id: string, reason: string, updateTable: boolean): Observable { const options = { params: new HttpParams().set('reason', reason).set('u', updateTable.toString()), }; - return >( - this.http - .post(`${url}/void-bill/${id}`, {}, options) - .pipe(catchError(this.log.handleError(serviceName, 'voidBill'))) - ); + return this.http + .post(`${url}/void-bill/${id}`, {}, options) + .pipe(catchError(this.log.handleError(serviceName, 'voidBill'))) as Observable; } moveTable(id: string, table: Table): Observable { - return >this.http + return this.http .post(`${urlMoveTable}/move`, { voucherId: id, tableId: table.id, }) - .pipe(catchError(this.log.handleError(serviceName, 'moveTable'))); + .pipe(catchError(this.log.handleError(serviceName, 'moveTable'))) as Observable; } mergeTable(id: string, table: Table): Observable { - return >this.http + return this.http .post(`${urlMoveTable}/merge`, { voucherId: id, tableId: table.id, newVoucherId: table.voucherId, }) - .pipe(catchError(this.log.handleError(serviceName, 'mergeTable'))); + .pipe(catchError(this.log.handleError(serviceName, 'mergeTable'))) as Observable; } moveKotToNewTable(id: string, kotId: string, table: Table): Observable { - return >this.http + return this.http .post(`${urlMoveKot}/move`, { voucherId: id, kotId, tableId: table.id, }) - .pipe(catchError(this.log.handleError(serviceName, 'moveKotToNewTable'))); + .pipe( + catchError(this.log.handleError(serviceName, 'moveKotToNewTable')), + ) as Observable; } mergeKotWithOldBill(id: string, kotId: string, table: Table): Observable { - return >this.http + return this.http .post(`${urlMoveKot}/merge`, { voucherId: id, kotId, tableId: table.id, newVoucherId: table.voucherId, }) - .pipe(catchError(this.log.handleError(serviceName, 'mergeKotWithOldBill'))); + .pipe( + catchError(this.log.handleError(serviceName, 'mergeKotWithOldBill')), + ) as Observable; } splitBill(id: string, inventoriesToMove: string[], table: Table) { const options = { params: new HttpParams().set('u', 'true') }; - return >this.http + return this.http .post( `${urlSplitBill}/${id}`, { @@ -198,6 +190,6 @@ export class VoucherService { }, options, ) - .pipe(catchError(this.log.handleError(serviceName, 'splitBill'))); + .pipe(catchError(this.log.handleError(serviceName, 'splitBill'))) as Observable; } } diff --git a/bookie/src/app/section-printers/section-printer.service.ts b/bookie/src/app/section-printers/section-printer.service.ts index 6f20ef7..476fb50 100644 --- a/bookie/src/app/section-printers/section-printer.service.ts +++ b/bookie/src/app/section-printers/section-printer.service.ts @@ -20,34 +20,32 @@ export class SectionPrinterService { get(id: string | null): Observable { const getUrl: string = id === null ? `${url}` : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable< + SectionPrinter[] + >; } // item(id: string, menuCategoryId: string): Observable { // const options = {params: new HttpParams().set('m', menuCategoryId)}; - // return >this.http.get(`${url}/${id}`, options) + // return this.http.get(`${url}/${id}`, options) // .pipe( // catchError(this.log.handleError(serviceName, 'list')) - // ); + // ) as Observable; // } save(sectionId: string, list: SectionPrinter[]): Observable { - return >( - this.http - .post(`${url}/${sectionId}`, list, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(`${url}/${sectionId}`, list, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable< + SectionPrinter[] + >; } } diff --git a/bookie/src/app/sections/section.service.ts b/bookie/src/app/sections/section.service.ts index f16d786..2b49499 100644 --- a/bookie/src/app/sections/section.service.ts +++ b/bookie/src/app/sections/section.service.ts @@ -20,35 +20,27 @@ export class SectionService { get(id: string | null): Observable
{ const getUrl: string = id === null ? url : `${url}/${id}`; - return >( - this.http - .get
(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get
(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable
; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } save(section: Section): Observable
{ - return >( - this.http - .post
(url, section, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post
(url, section, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable
; } update(section: Section): Observable
{ - return >( - this.http - .put
(`${url}/${section.id}`, section, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put
(`${url}/${section.id}`, section, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable
; } saveOrUpdate(section: Section): Observable
{ @@ -59,10 +51,8 @@ export class SectionService { } delete(id: string): Observable
{ - return >( - this.http - .delete
(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete
(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable
; } } diff --git a/bookie/src/app/shared/clear.pipe.ts b/bookie/src/app/shared/clear.pipe.ts index e7403ce..ce5855a 100644 --- a/bookie/src/app/shared/clear.pipe.ts +++ b/bookie/src/app/shared/clear.pipe.ts @@ -5,7 +5,9 @@ import { Pipe, PipeTransform } from '@angular/core'; }) export class ClearPipe implements PipeTransform { transform(value: string | null): string { - if (value === null) return ''; + if (value === null) { + return ''; + } return value === 'โ‚นย 0.00' || value === '0.00' ? '' : value; } } diff --git a/bookie/src/app/tables/table.service.ts b/bookie/src/app/tables/table.service.ts index c278156..10dbe4c 100644 --- a/bookie/src/app/tables/table.service.ts +++ b/bookie/src/app/tables/table.service.ts @@ -20,51 +20,41 @@ export class TableService { get(id: string | null): Observable { const getUrl: string = id === null ? url : `${url}/${id}`; - return >( - this.http - .get
(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get
(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable
; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } running(): Observable { - return >( - this.http - .get(`${url}/running`) - .pipe(catchError(this.log.handleError(serviceName, 'running'))) - ); + return this.http + .get(`${url}/running`) + .pipe(catchError(this.log.handleError(serviceName, 'running'))) as Observable; } save(tables: Table): Observable
{ - return >( - this.http - .post
(url, tables, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post
(url, tables, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable
; } update(tables: Table): Observable
{ - return >( - this.http - .put
(`${url}/${tables.id}`, tables, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put
(`${url}/${tables.id}`, tables, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable
; } updateSortOrder(list: Table[]): Observable { - return >( - this.http - .post(`${url}/list`, list, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'updateSortOrder'))) - ); + return this.http + .post(`${url}/list`, list, httpOptions) + .pipe( + catchError(this.log.handleError(serviceName, 'updateSortOrder')), + ) as Observable; } saveOrUpdate(tables: Table): Observable
{ @@ -75,10 +65,8 @@ export class TableService { } delete(id: string): Observable
{ - return >( - this.http - .delete
(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete
(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable
; } } diff --git a/bookie/src/app/tax-report/tax-report.service.ts b/bookie/src/app/tax-report/tax-report.service.ts index f379d27..1e78856 100644 --- a/bookie/src/app/tax-report/tax-report.service.ts +++ b/bookie/src/app/tax-report/tax-report.service.ts @@ -24,10 +24,8 @@ export class TaxReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - return >( - this.http - .get(url, options) - .pipe(catchError(this.log.handleError(serviceName, 'get'))) - ); + return this.http + .get(url, options) + .pipe(catchError(this.log.handleError(serviceName, 'get'))) as Observable; } } diff --git a/bookie/src/app/taxes/tax.service.ts b/bookie/src/app/taxes/tax.service.ts index 2260466..027facd 100644 --- a/bookie/src/app/taxes/tax.service.ts +++ b/bookie/src/app/taxes/tax.service.ts @@ -20,33 +20,27 @@ export class TaxService { get(id: string | null): Observable { const getUrl: string = id === null ? url : `${url}/${id}`; - return >( - this.http.get(getUrl).pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } save(tax: Tax): Observable { - return >( - this.http - .post(url, tax, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(url, tax, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(tax: Tax): Observable { - return >( - this.http - .put(`${url}/${tax.id}`, tax, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${tax.id}`, tax, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } saveOrUpdate(tax: Tax): Observable { @@ -57,10 +51,8 @@ export class TaxService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } } diff --git a/bookie/src/app/update-product-prices/update-product-prices.component.ts b/bookie/src/app/update-product-prices/update-product-prices.component.ts index 05c8db4..4571719 100644 --- a/bookie/src/app/update-product-prices/update-product-prices.component.ts +++ b/bookie/src/app/update-product-prices/update-product-prices.component.ts @@ -83,7 +83,9 @@ export class UpdateProductPricesComponent implements OnInit { show() { const info = this.getInfo(); const route = ['update-product-prices']; - if (info.menuCategoryId !== null) route.push(info.menuCategoryId as string); + if (info.menuCategoryId !== null) { + route.push(info.menuCategoryId as string); + } this.router.navigate(route, { queryParams: { date: info.date, diff --git a/bookie/src/app/update-product-prices/update-product-prices.service.ts b/bookie/src/app/update-product-prices/update-product-prices.service.ts index 4056040..e3c0dbc 100644 --- a/bookie/src/app/update-product-prices/update-product-prices.service.ts +++ b/bookie/src/app/update-product-prices/update-product-prices.service.ts @@ -23,19 +23,19 @@ export class UpdateProductPricesService { if (date !== null) { options.params = options.params.set('d', date); } - return >( - this.http - .get(getUrl, options) - .pipe(catchError(this.log.handleError(serviceName, 'get'))) - ); + return this.http + .get(getUrl, options) + .pipe( + catchError(this.log.handleError(serviceName, 'get')), + ) as Observable; } save(item: UpdateProductPrices): Observable { const saveUrl: string = item.menuCategoryId === null ? url : `${url}/${item.menuCategoryId}`; - return >( - this.http - .post(saveUrl, item) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(saveUrl, item) + .pipe( + catchError(this.log.handleError(serviceName, 'save')), + ) as Observable; } } diff --git a/bookie/src/app/users/user.service.ts b/bookie/src/app/users/user.service.ts index 918c2b5..96241ae 100644 --- a/bookie/src/app/users/user.service.ts +++ b/bookie/src/app/users/user.service.ts @@ -20,35 +20,27 @@ export class UserService { get(id: string | null): Observable { const getUrl: string = id === null ? `${url}` : `${url}/${id}`; - return >( - this.http - .get(getUrl) - .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) - ); + return this.http + .get(getUrl) + .pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable; } list(): Observable { - return >( - this.http - .get(`${url}/list`) - .pipe(catchError(this.log.handleError(serviceName, 'list'))) - ); + return this.http + .get(`${url}/list`) + .pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable; } save(user: User): Observable { - return >( - this.http - .post(`${url}`, user, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'save'))) - ); + return this.http + .post(`${url}`, user, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable; } update(user: User): Observable { - return >( - this.http - .put(`${url}/${user.id}`, user, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'update'))) - ); + return this.http + .put(`${url}/${user.id}`, user, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable; } saveOrUpdate(user: User): Observable { @@ -59,10 +51,8 @@ export class UserService { } delete(id: string): Observable { - return >( - this.http - .delete(`${url}/${id}`, httpOptions) - .pipe(catchError(this.log.handleError(serviceName, 'delete'))) - ); + return this.http + .delete(`${url}/${id}`, httpOptions) + .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } } diff --git a/bookie/tsconfig.spec.json b/bookie/tsconfig.spec.json index 9f661ff..092345b 100644 --- a/bookie/tsconfig.spec.json +++ b/bookie/tsconfig.spec.json @@ -2,10 +2,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../out-tsc/spec", + "outDir": "./out-tsc/spec", "types": [ - "jasmine", - "node" + "jasmine" ] }, "files": [