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 7559 additions and 5649 deletions
@@ -5,19 +5,31 @@
</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">
<input matInput #nameElement placeholder="Name" formControlName="name" />
</mat-form-field>
</div>
<mat-divider></mat-divider>
<div formArrayName="permissions">
<div fxLayout="row" *ngFor="let p of item.permissions; index as i" [formGroupName]="i" fxLayout="row"
fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
fxLayoutGap.lt-md="0px">
<mat-checkbox formControlName="permission" fxFlex>{{p.name}}</mat-checkbox>
<div
fxLayout="row"
*ngFor="let p of item.permissions; index as i"
[formGroupName]="i"
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-checkbox formControlName="permission" fxFlex>{{ p.name }}</mat-checkbox>
</div>
</div>
</form>
@@ -1,6 +1,6 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {RoleDetailComponent} from './role-detail.component';
import { RoleDetailComponent } from './role-detail.component';
describe('RoleDetailComponent', () => {
let component: RoleDetailComponent;
@@ -8,9 +8,8 @@ describe('RoleDetailComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [RoleDetailComponent]
})
.compileComponents();
declarations: [RoleDetailComponent],
}).compileComponents();
}));
beforeEach(() => {
@@ -1,16 +1,17 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { RoleService } from '../role.service';
import { Role } from '../role';
import { ToasterService } from '../../core/toaster.service';
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
import { MatDialog } from '@angular/material/dialog';
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
import { Role } from '../role';
import { RoleService } from '../role.service';
@Component({
selector: 'app-role-detail',
templateUrl: './role-detail.component.html',
styleUrls: ['./role-detail.component.css']
styleUrls: ['./role-detail.component.css'],
})
export class RoleDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
@@ -23,7 +24,7 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
private fb: FormBuilder,
private toaster: ToasterService,
private dialog: MatDialog,
private ser: RoleService
private ser: RoleService,
) {
this.createForm();
}
@@ -31,23 +32,25 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
createForm() {
this.form = this.fb.group({
name: '',
permissions: this.fb.array([])
permissions: this.fb.array([]),
});
}
ngOnInit() {
this.route.data
.subscribe((data: { item: Role }) => {
this.item = data.item;
this.form.get('name').setValue(this.item.name);
this.form.setControl('permissions', this.fb.array(
this.item.permissions.map(
x => this.fb.group({
permission: x.enabled
})
)
));
});
this.route.data.subscribe((data: { item: Role }) => {
this.item = data.item;
this.form.get('name').setValue(this.item.name);
this.form.setControl(
'permissions',
this.fb.array(
this.item.permissions.map((x) =>
this.fb.group({
permission: x.enabled,
}),
),
),
);
});
}
ngAfterViewInit() {
@@ -57,35 +60,33 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
}
save() {
this.ser.saveOrUpdate(this.getItem())
.subscribe(
(result) => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/roles');
},
(error) => {
this.toaster.show('Danger', error.error);
}
);
this.ser.saveOrUpdate(this.getItem()).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/roles');
},
(error) => {
this.toaster.show('Danger', error.error);
},
);
}
delete() {
this.ser.delete(this.item.id)
.subscribe(
(result) => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/roles');
},
(error) => {
this.toaster.show('Danger', error.error);
}
);
this.ser.delete(this.item.id).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/roles');
},
(error) => {
this.toaster.show('Danger', error.error);
},
);
}
confirmDelete(): void {
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
width: '250px',
data: {title: 'Delete Role?', content: 'Are you sure? This cannot be undone.'}
data: { title: 'Delete Role?', content: 'Are you sure? This cannot be undone.' },
});
dialogRef.afterClosed().subscribe((result: boolean) => {