feat: git hook config (husky eslint prettier)

This commit is contained in:
Amadou Ada DIENE
2021-07-20 10:51:46 +02:00
parent 1a5a76f912
commit 77b15bdfc4
33 changed files with 52217 additions and 51866 deletions

View File

@@ -10,26 +10,26 @@ import { MutiplesComponent } from './components/mutiples/mutiples.component';
// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
declarations: [AppComponent, MutiplesComponent],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
ReactiveFormsModule,
TranslateModule.forRoot({
defaultLanguage: 'en',
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient],
},
}),
],
providers: [],
bootstrap: [AppComponent],
declarations: [AppComponent, MutiplesComponent],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
ReactiveFormsModule,
TranslateModule.forRoot({
defaultLanguage: 'en',
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient],
},
}),
],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}

View File

@@ -5,47 +5,47 @@ import { WindowApiConst } from 'shared-lib';
import { ElectronIpcService } from '../../services/electron-ipc.service';
@Component({
selector: 'app-mutiples',
templateUrl: './mutiples.component.html',
styleUrls: ['./mutiples.component.scss'],
selector: 'app-mutiples',
templateUrl: './mutiples.component.html',
styleUrls: ['./mutiples.component.scss'],
})
export class MutiplesComponent implements OnInit {
timesTableForm = new FormGroup({
input: new FormControl(Math.round(Math.random() * 100) % 10),
});
timesTableForm = new FormGroup({
input: new FormControl(Math.round(Math.random() * 100) % 10),
});
multiples: number[] = [];
multiples: number[] = [];
constructor(
private electronIpc: ElectronIpcService,
private translate: TranslateService
) {}
constructor(
private electronIpc: ElectronIpcService,
private translate: TranslateService
) {}
ngOnInit(): void {
// Specifying what to do with received data from main process
this.electronIpc.receive<number[]>(
WindowApiConst.MULTIPLES_OUTPUT,
(output: number[]) => {
// Update current data
this.multiples = output;
}
);
ngOnInit(): void {
// Specifying what to do with received data from main process
this.electronIpc.receive<number[]>(
WindowApiConst.MULTIPLES_OUTPUT,
(output: number[]) => {
// Update current data
this.multiples = output;
}
);
// Reset multiples on form changes
this.timesTableForm.valueChanges.subscribe(() => {
this.multiples = [];
});
// Reset multiples on form changes
this.timesTableForm.valueChanges.subscribe(() => {
this.multiples = [];
});
// Init time tables with given random value
this.onSubmit();
}
// Init time tables with given random value
this.onSubmit();
}
translateIn(lang: string): void {
this.translate.use(lang);
}
translateIn(lang: string): void {
this.translate.use(lang);
}
onSubmit(): void {
const input = this.timesTableForm.value.input;
this.electronIpc.send(WindowApiConst.MULTIPLES_INPUT, input);
}
onSubmit(): void {
const input = this.timesTableForm.value.input;
this.electronIpc.send(WindowApiConst.MULTIPLES_INPUT, input);
}
}

View File

@@ -2,39 +2,39 @@ import { Injectable, NgZone } from '@angular/core';
import { WindowApi } from 'shared-lib';
@Injectable({
providedIn: 'root',
providedIn: 'root',
})
export class ElectronIpcService {
private _api!: WindowApi;
private _api!: WindowApi;
constructor(private zone: NgZone) {
if (window && (window as Window).api) {
this._api = (window as Window).api;
console.log('Preloader API has been loaded successfully');
} else {
console.warn('Preloader API is not loaded');
}
}
constructor(private zone: NgZone) {
if (window && (window as Window).api) {
this._api = (window as Window).api;
console.log('Preloader API has been loaded successfully');
} else {
console.warn('Preloader API is not loaded');
}
}
public receive<Out>(channel: string, func: (output: Out) => void): void {
if (this._api) {
this._api.receive<Out>(channel, (output) => {
console.log(`Received from main process channel [${channel}]`, output);
public receive<Out>(channel: string, func: (output: Out) => void): void {
if (this._api) {
this._api.receive<Out>(channel, (output) => {
console.log(`Received from main process channel [${channel}]`, output);
// Next code might run outside of Angular zone and therefore Angular
// doesn't recognize it needs to run change detection
// Further details on SO : https://stackoverflow.com/a/49136353/11480016
this.zone.run(() => {
func(output);
});
});
}
}
// Next code might run outside of Angular zone and therefore Angular
// doesn't recognize it needs to run change detection
// Further details on SO : https://stackoverflow.com/a/49136353/11480016
this.zone.run(() => {
func(output);
});
});
}
}
public send<In>(channel: string, input: In): void {
if (this._api) {
console.log(`Sending to main process channel [${channel}]`, input);
this._api.send<In>(channel, input);
}
}
public send<In>(channel: string, input: In): void {
if (this._api) {
console.log(`Sending to main process channel [${channel}]`, input);
this._api.send<In>(channel, input);
}
}
}