diff --git a/README.md b/README.md index c3dd00f..46b520c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This development version contains known bugs and security vulnerabilities. Do not use it! - ## Development Commands + ## Development Setup Before you can start you have to configure the backend manually with a valid config-user.php Also you have to install Angular CLI globally using @@ -17,23 +17,29 @@ ```bash npm install ``` - - Then change in the backend-legacy folder and start the backend in one terminal. + +Finally you have to setup a pre-commit hook using +```bash +ln utils/pre-commit.hook .git/hooks/pre-commit +``` + + ## Development Commands + To run a development instance change in the backend-legacy folder and start the backend in one terminal. ```bash cd backend-legacy php -S localhost:8000 ``` - + Afterwords you can run the development-server in another terminal using ```bash npm start ``` - Then you now go to a browser and open http://localhost:4200 + Then you can go to a browser and open http://localhost:4200 If you want to lint the project run ```bash npm run lint ``` -this command will be in a commit hook so that it is impossible to commit code which does not pass the linter. +this command will also be in the provided commit hook so that it is impossible to commit code which does not pass the linter. diff --git a/frontend/src/app/interfaces/empty-answer.ts b/frontend/src/app/interfaces/empty-answer.ts deleted file mode 100644 index 3954a04..0000000 --- a/frontend/src/app/interfaces/empty-answer.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface EmptyAnswer { - -} diff --git a/frontend/src/app/pages/domains/domains.component.ts b/frontend/src/app/pages/domains/domains.component.ts index b342bbc..692a34a 100644 --- a/frontend/src/app/pages/domains/domains.component.ts +++ b/frontend/src/app/pages/domains/domains.component.ts @@ -21,10 +21,10 @@ export class DomainsComponent implements OnInit { @ViewChild('sortRecords') sortRecords: SortComponent; private sortField: string = null; - private sortOrder: number = 0; + private sortOrder = 0; private searchName: string; - private searchType: string = 'none'; + private searchType = 'none'; constructor(private domainsService: DomainsService, private modalService: ModalService) { } @@ -38,8 +38,8 @@ export class DomainsComponent implements OnInit { * the properties of the components. */ loadDomains() { - let field = this.sortField ? this.sortField : ''; - let searchType = this.searchType === 'none' ? '' : this.searchType; + const field = this.sortField ? this.sortField : ''; + const searchType = this.searchType === 'none' ? '' : this.searchType; this.domainsService.getDomains(1, field, this.sortOrder, this.searchName, searchType) .then((data: DomainsAnswer) => { diff --git a/frontend/src/app/partials/modal-container/modal-container.component.ts b/frontend/src/app/partials/modal-container/modal-container.component.ts index 5295b95..69186d8 100644 --- a/frontend/src/app/partials/modal-container/modal-container.component.ts +++ b/frontend/src/app/partials/modal-container/modal-container.component.ts @@ -17,8 +17,8 @@ export class ModalContainerComponent implements OnInit { acceptClass: 'primary' }; - private show: boolean = false; - private animate: boolean = false; + private show = false; + private animate = false; private currentResolve: Function; private currentReject: Function; diff --git a/frontend/src/app/partials/sort/sort.component.ts b/frontend/src/app/partials/sort/sort.component.ts index 4304b38..31a8842 100644 --- a/frontend/src/app/partials/sort/sort.component.ts +++ b/frontend/src/app/partials/sort/sort.component.ts @@ -12,7 +12,7 @@ export class SortComponent { @Output() sort = new EventEmitter(); @Input() field: string; - private order: number = 0; + private order = 0; constructor() { } diff --git a/frontend/src/app/services/domains/domains.service.ts b/frontend/src/app/services/domains/domains.service.ts index 0c838ac..75960cf 100644 --- a/frontend/src/app/services/domains/domains.service.ts +++ b/frontend/src/app/services/domains/domains.service.ts @@ -2,7 +2,6 @@ import { Injectable } from '@angular/core'; import { HttpService } from 'app/services/http/http.service'; import { DomainsAnswer } from 'app/interfaces/domains-answer'; -import { EmptyAnswer } from 'app/interfaces/empty-answer'; @Injectable() export class DomainsService { @@ -21,10 +20,10 @@ export class DomainsService { * @returns A Promise for a DomainsAnswer object */ getDomains(page: number, field: string, order: number, searchName: string, searchType: string) { - let _order = order === 1 ? 1 : 0; + const _order = order === 1 ? 1 : 0; return new Promise((resolve, reject) => { - let body: any = { + const body: any = { sort: { field: field, order: _order @@ -63,7 +62,7 @@ export class DomainsService { id: id }; - this.httpService.post('api/domains.php', body) + this.httpService.post<{}>('api/domains.php', body) .then(() => { resolve(); }, (err) => { diff --git a/frontend/src/app/services/session/session.service.ts b/frontend/src/app/services/session/session.service.ts index a2116cb..4290b91 100644 --- a/frontend/src/app/services/session/session.service.ts +++ b/frontend/src/app/services/session/session.service.ts @@ -92,7 +92,7 @@ export class SessionService { * Loads the state from the sessionStorage. */ loadState() { - let state = JSON.parse(sessionStorage.getItem('state')); + const state = JSON.parse(sessionStorage.getItem('state')); if (state) { this.isLoggedIn = state.isLoggedIn; this.userType = state.userType; diff --git a/utils/pre-commit.hook b/utils/pre-commit.hook new file mode 100755 index 0000000..95b9732 --- /dev/null +++ b/utils/pre-commit.hook @@ -0,0 +1,4 @@ +#!/bin/bash + +cd frontend +npm run lint