Fixed linter errors, added pre-commit script and instructions
This commit is contained in:
parent
03ae894776
commit
ae8b16c825
18
README.md
18
README.md
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
This development version contains known bugs and security vulnerabilities. Do not use it!
|
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
|
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
|
Also you have to install Angular CLI globally using
|
||||||
|
@ -17,23 +17,29 @@
|
||||||
```bash
|
```bash
|
||||||
npm install
|
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
|
```bash
|
||||||
cd backend-legacy
|
cd backend-legacy
|
||||||
php -S localhost:8000
|
php -S localhost:8000
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwords you can run the development-server in another terminal using
|
Afterwords you can run the development-server in another terminal using
|
||||||
```bash
|
```bash
|
||||||
npm start
|
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
|
If you want to lint the project run
|
||||||
```bash
|
```bash
|
||||||
npm run lint
|
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.
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
export interface EmptyAnswer {
|
|
||||||
|
|
||||||
}
|
|
|
@ -21,10 +21,10 @@ export class DomainsComponent implements OnInit {
|
||||||
@ViewChild('sortRecords') sortRecords: SortComponent;
|
@ViewChild('sortRecords') sortRecords: SortComponent;
|
||||||
|
|
||||||
private sortField: string = null;
|
private sortField: string = null;
|
||||||
private sortOrder: number = 0;
|
private sortOrder = 0;
|
||||||
|
|
||||||
private searchName: string;
|
private searchName: string;
|
||||||
private searchType: string = 'none';
|
private searchType = 'none';
|
||||||
|
|
||||||
constructor(private domainsService: DomainsService,
|
constructor(private domainsService: DomainsService,
|
||||||
private modalService: ModalService) { }
|
private modalService: ModalService) { }
|
||||||
|
@ -38,8 +38,8 @@ export class DomainsComponent implements OnInit {
|
||||||
* the properties of the components.
|
* the properties of the components.
|
||||||
*/
|
*/
|
||||||
loadDomains() {
|
loadDomains() {
|
||||||
let field = this.sortField ? this.sortField : '';
|
const field = this.sortField ? this.sortField : '';
|
||||||
let searchType = this.searchType === 'none' ? '' : this.searchType;
|
const searchType = this.searchType === 'none' ? '' : this.searchType;
|
||||||
|
|
||||||
this.domainsService.getDomains(1, field, this.sortOrder, this.searchName, searchType)
|
this.domainsService.getDomains(1, field, this.sortOrder, this.searchName, searchType)
|
||||||
.then((data: DomainsAnswer) => {
|
.then((data: DomainsAnswer) => {
|
||||||
|
|
|
@ -17,8 +17,8 @@ export class ModalContainerComponent implements OnInit {
|
||||||
acceptClass: 'primary'
|
acceptClass: 'primary'
|
||||||
};
|
};
|
||||||
|
|
||||||
private show: boolean = false;
|
private show = false;
|
||||||
private animate: boolean = false;
|
private animate = false;
|
||||||
|
|
||||||
private currentResolve: Function;
|
private currentResolve: Function;
|
||||||
private currentReject: Function;
|
private currentReject: Function;
|
||||||
|
|
|
@ -12,7 +12,7 @@ export class SortComponent {
|
||||||
@Output() sort = new EventEmitter<SortEvent>();
|
@Output() sort = new EventEmitter<SortEvent>();
|
||||||
|
|
||||||
@Input() field: string;
|
@Input() field: string;
|
||||||
private order: number = 0;
|
private order = 0;
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpService } from 'app/services/http/http.service';
|
import { HttpService } from 'app/services/http/http.service';
|
||||||
import { DomainsAnswer } from 'app/interfaces/domains-answer';
|
import { DomainsAnswer } from 'app/interfaces/domains-answer';
|
||||||
import { EmptyAnswer } from 'app/interfaces/empty-answer';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DomainsService {
|
export class DomainsService {
|
||||||
|
@ -21,10 +20,10 @@ export class DomainsService {
|
||||||
* @returns A Promise for a DomainsAnswer object
|
* @returns A Promise for a DomainsAnswer object
|
||||||
*/
|
*/
|
||||||
getDomains(page: number, field: string, order: number, searchName: string, searchType: string) {
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
let body: any = {
|
const body: any = {
|
||||||
sort: {
|
sort: {
|
||||||
field: field,
|
field: field,
|
||||||
order: _order
|
order: _order
|
||||||
|
@ -63,7 +62,7 @@ export class DomainsService {
|
||||||
id: id
|
id: id
|
||||||
};
|
};
|
||||||
|
|
||||||
this.httpService.post<EmptyAnswer>('api/domains.php', body)
|
this.httpService.post<{}>('api/domains.php', body)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
resolve();
|
resolve();
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
|
|
|
@ -92,7 +92,7 @@ export class SessionService {
|
||||||
* Loads the state from the sessionStorage.
|
* Loads the state from the sessionStorage.
|
||||||
*/
|
*/
|
||||||
loadState() {
|
loadState() {
|
||||||
let state = JSON.parse(sessionStorage.getItem('state'));
|
const state = JSON.parse(sessionStorage.getItem('state'));
|
||||||
if (state) {
|
if (state) {
|
||||||
this.isLoggedIn = state.isLoggedIn;
|
this.isLoggedIn = state.isLoggedIn;
|
||||||
this.userType = state.userType;
|
this.userType = state.userType;
|
||||||
|
|
4
utils/pre-commit.hook
Executable file
4
utils/pre-commit.hook
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd frontend
|
||||||
|
npm run lint
|
Loading…
Reference in a new issue