Blacked and isorted the python files

Prettied and eslinted the typescript/html files
This commit is contained in:
2020-10-11 10:56:29 +05:30
parent b31db593c2
commit d677cfb1ea
505 changed files with 7560 additions and 5650 deletions

View File

@ -5,29 +5,47 @@
</mat-card-title-group>
<mat-card-content>
<form [formGroup]="form" fxLayout="column">
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
fxLayoutGap.lt-md="0px">
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Name</mat-label>
<input matInput #nameElement placeholder="Name" formControlName="name" (keyup.enter)="save()">
<input
matInput
#nameElement
placeholder="Name"
formControlName="name"
(keyup.enter)="save()"
/>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
fxLayoutGap.lt-md="0px">
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Section</mat-label>
<mat-select placeholder="Section" formControlName="section">
<mat-option *ngFor="let s of sections" [value]="s.id">
{{ s.name }}
</mat-option>
</mat-select>
</mat-form-field>
</mat-option>
</mat-select>
</mat-form-field>
</div>
</form>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button color="primary" (click)="save()">Save</button>
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">Delete</button>
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">
Delete
</button>
</mat-card-actions>
</mat-card>
</div>

View File

@ -1,6 +1,6 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {DeviceDetailComponent} from './device-detail.component';
import { DeviceDetailComponent } from './device-detail.component';
describe('DeviceDetailComponent', () => {
let component: DeviceDetailComponent;
@ -8,9 +8,8 @@ describe('DeviceDetailComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [DeviceDetailComponent]
})
.compileComponents();
declarations: [DeviceDetailComponent],
}).compileComponents();
}));
beforeEach(() => {

View File

@ -1,18 +1,18 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog} from '@angular/material/dialog';
import { DeviceService } from '../device.service';
import { Device } from '../../core/device';
import { Section } from '../../core/section';
import { ToasterService } from '../../core/toaster.service';
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
import { Section } from '../../core/section';
import { DeviceService } from '../device.service';
@Component({
selector: 'app-device-detail',
templateUrl: './device-detail.component.html',
styleUrls: ['./device-detail.component.css']
styleUrls: ['./device-detail.component.css'],
})
export class DeviceDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
@ -26,7 +26,7 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
private dialog: MatDialog,
private fb: FormBuilder,
private toaster: ToasterService,
private ser: DeviceService
private ser: DeviceService,
) {
this.createForm();
}
@ -34,23 +34,22 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
createForm() {
this.form = this.fb.group({
name: '',
section: ''
section: '',
});
}
ngOnInit() {
this.route.data
.subscribe((data: { item: Device, sections: Section[] }) => {
this.showItem(data.item);
this.sections = data.sections;
});
this.route.data.subscribe((data: { item: Device; sections: Section[] }) => {
this.showItem(data.item);
this.sections = data.sections;
});
}
showItem(item: Device) {
this.item = item;
this.form.setValue({
name: this.item.name || '',
section: this.item.section.id ? this.item.section.id : ''
section: this.item.section.id ? this.item.section.id : '',
});
}
@ -61,35 +60,33 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
}
save() {
this.ser.saveOrUpdate(this.getItem())
.subscribe(
(result) => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/devices');
},
(error) => {
this.toaster.show('Danger', error.error);
}
);
this.ser.saveOrUpdate(this.getItem()).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/devices');
},
(error) => {
this.toaster.show('Danger', error.error);
},
);
}
delete() {
this.ser.delete(this.item.id)
.subscribe(
(result) => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/devices');
},
(error) => {
this.toaster.show('Danger', error.error);
}
);
this.ser.delete(this.item.id).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/devices');
},
(error) => {
this.toaster.show('Danger', error.error);
},
);
}
confirmDelete(): void {
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
width: '250px',
data: {title: 'Delete Device?', content: 'Are you sure? This cannot be undone.'}
data: { title: 'Delete Device?', content: 'Are you sure? This cannot be undone.' },
});
dialogRef.afterClosed().subscribe((result: boolean) => {