;
10 |
11 | beforeEach(waitForAsync(() => {
12 | void TestBed.configureTestingModule({
13 | declarations: [],
14 | imports: [HomeComponent, TranslateModule.forRoot()],
15 | providers: [provideRouter([])]
16 | }).compileComponents();
17 |
18 | fixture = TestBed.createComponent(HomeComponent);
19 | component = fixture.componentInstance;
20 | fixture.detectChanges();
21 | }));
22 |
23 | it('should create', () => {
24 | expect(component).toBeTruthy();
25 | });
26 |
27 | it('should render title in a h1 tag', waitForAsync(() => {
28 | const compiled = fixture.debugElement.nativeElement;
29 | expect(compiled.querySelector('h1').textContent).toContain(
30 | 'PAGES.HOME.TITLE'
31 | );
32 | }));
33 | });
34 |
--------------------------------------------------------------------------------
/src/app/home/home.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { Router, RouterLink } from '@angular/router';
3 | import { TranslateModule } from '@ngx-translate/core';
4 |
5 | @Component({
6 | selector: 'app-home',
7 | templateUrl: './home.component.html',
8 | styleUrls: ['./home.component.scss'],
9 | standalone: true,
10 | imports: [RouterLink, TranslateModule]
11 | })
12 | export class HomeComponent implements OnInit {
13 |
14 | constructor(private router: Router) { }
15 |
16 | ngOnInit(): void {
17 | console.log('HomeComponent INIT');
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/shared/components/index.ts:
--------------------------------------------------------------------------------
1 | export * from './page-not-found/page-not-found.component';
2 |
--------------------------------------------------------------------------------
/src/app/shared/components/page-not-found/page-not-found.component.html:
--------------------------------------------------------------------------------
1 |
2 | page-not-found works!
3 |
4 |
--------------------------------------------------------------------------------
/src/app/shared/components/page-not-found/page-not-found.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/app/shared/components/page-not-found/page-not-found.component.scss
--------------------------------------------------------------------------------
/src/app/shared/components/page-not-found/page-not-found.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2 |
3 | import { PageNotFoundComponent } from './page-not-found.component';
4 |
5 | describe('PageNotFoundComponent', () => {
6 | let component: PageNotFoundComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(waitForAsync(() => {
10 | void TestBed.configureTestingModule({
11 | declarations: []
12 | })
13 | .compileComponents();
14 |
15 | fixture = TestBed.createComponent(PageNotFoundComponent);
16 | component = fixture.componentInstance;
17 | fixture.detectChanges();
18 | }));
19 |
20 | it('should create', () => {
21 | expect(component).toBeTruthy();
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/src/app/shared/components/page-not-found/page-not-found.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-page-not-found',
5 | templateUrl: './page-not-found.component.html',
6 | styleUrls: ['./page-not-found.component.scss'],
7 | standalone: true
8 | })
9 | export class PageNotFoundComponent implements OnInit {
10 | constructor() {}
11 |
12 | ngOnInit(): void {
13 | console.log('PageNotFoundComponent INIT');
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/shared/directives/index.ts:
--------------------------------------------------------------------------------
1 | export * from './webview/webview.directive';
2 |
--------------------------------------------------------------------------------
/src/app/shared/directives/webview/webview.directive.spec.ts:
--------------------------------------------------------------------------------
1 | import { WebviewDirective } from './webview.directive';
2 |
3 | describe('WebviewDirective', () => {
4 | it('should create an instance', () => {
5 | const directive = new WebviewDirective();
6 | expect(directive).toBeTruthy();
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/src/app/shared/directives/webview/webview.directive.ts:
--------------------------------------------------------------------------------
1 | import { Directive } from '@angular/core';
2 |
3 | @Directive({
4 | selector: 'webview',
5 | standalone: true
6 | })
7 | export class WebviewDirective {
8 | constructor() { }
9 | }
10 |
--------------------------------------------------------------------------------
/src/app/shared/shared.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { TranslateModule } from '@ngx-translate/core';
5 |
6 | import { FormsModule } from '@angular/forms';
7 |
8 | @NgModule({
9 | declarations: [],
10 | imports: [CommonModule, TranslateModule, FormsModule],
11 | exports: [TranslateModule, FormsModule]
12 | })
13 | export class SharedModule {}
14 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/assets/background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/assets/background.jpg
--------------------------------------------------------------------------------
/src/assets/i18n/en.json:
--------------------------------------------------------------------------------
1 | {
2 | "PAGES": {
3 | "HOME": {
4 | "TITLE": "App works !",
5 | "GO_TO_DETAIL": "Go to Detail"
6 | },
7 | "DETAIL": {
8 | "TITLE": "Detail page !",
9 | "BACK_TO_HOME": "Back to Home"
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/assets/icons/electron.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/assets/icons/electron.bmp
--------------------------------------------------------------------------------
/src/assets/icons/favicon.256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/assets/icons/favicon.256x256.png
--------------------------------------------------------------------------------
/src/assets/icons/favicon.512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/assets/icons/favicon.512x512.png
--------------------------------------------------------------------------------
/src/assets/icons/favicon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/assets/icons/favicon.icns
--------------------------------------------------------------------------------
/src/assets/icons/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/assets/icons/favicon.ico
--------------------------------------------------------------------------------
/src/assets/icons/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/assets/icons/favicon.png
--------------------------------------------------------------------------------
/src/environments/environment.dev.ts:
--------------------------------------------------------------------------------
1 | export const APP_CONFIG = {
2 | production: false,
3 | environment: 'DEV'
4 | };
5 |
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const APP_CONFIG = {
2 | production: true,
3 | environment: 'PROD'
4 | };
5 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | export const APP_CONFIG = {
2 | production: false,
3 | environment: 'LOCAL'
4 | };
5 |
--------------------------------------------------------------------------------
/src/environments/environment.web.prod.ts:
--------------------------------------------------------------------------------
1 | export const APP_CONFIG = {
2 | production: true,
3 | environment: 'WEB-PROD'
4 | };
5 |
--------------------------------------------------------------------------------
/src/environments/environment.web.ts:
--------------------------------------------------------------------------------
1 | export const APP_CONFIG = {
2 | production: false,
3 | environment: 'WEB'
4 | };
5 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximegris/angular-electron/bab2bb2925246db472a7f1b03d1ff7481350a447/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Angular Electron
6 |
7 |
8 |
9 |
10 |
11 |
12 | Loading...
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { bootstrapApplication } from '@angular/platform-browser';
3 | import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
4 | import { importProvidersFrom } from '@angular/core';
5 | import { provideRouter } from '@angular/router';
6 |
7 | import { AppComponent } from './app/app.component';
8 | import { APP_CONFIG } from './environments/environment';
9 | import { CoreModule } from './app/core/core.module';
10 | import { SharedModule } from './app/shared/shared.module';
11 | import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
12 | import { TranslateHttpLoader } from '@ngx-translate/http-loader';
13 | import { HttpClient } from '@angular/common/http';
14 | import { PageNotFoundComponent } from './app/shared/components';
15 | import { HomeComponent } from './app/home/home.component';
16 | import { DetailComponent } from './app/detail/detail.component';
17 |
18 | // AoT requires an exported function for factories
19 | const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json');
20 |
21 | if (APP_CONFIG.production) {
22 | enableProdMode();
23 | }
24 |
25 | bootstrapApplication(AppComponent, {
26 | providers: [
27 | provideHttpClient(withInterceptorsFromDi()),
28 | provideRouter([
29 | {
30 | path: '',
31 | redirectTo: 'home',
32 | pathMatch: 'full'
33 | },
34 | {
35 | path: 'home',
36 | component: HomeComponent
37 | },
38 | {
39 | path: 'detail',
40 | component: DetailComponent
41 | },
42 | {
43 | path: '**',
44 | component: PageNotFoundComponent
45 | }
46 | ]),
47 | importProvidersFrom(
48 | CoreModule,
49 | SharedModule,
50 | TranslateModule.forRoot({
51 | loader: {
52 | provide: TranslateLoader,
53 | useFactory: httpLoaderFactory,
54 | deps: [HttpClient]
55 | }
56 | })
57 | )
58 | ]
59 | }).catch(err => console.error(err));
60 |
--------------------------------------------------------------------------------
/src/polyfills-test.ts:
--------------------------------------------------------------------------------
1 | import 'zone.js';
2 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /**
22 | * By default, zone.js will patch all possible macroTask and DomEvents
23 | * user can disable parts of macroTask/DomEvents patch by setting following flags
24 | * because those flags need to be set before `zone.js` being loaded, and webpack
25 | * will put import in the top of bundle, so user need to create a separate file
26 | * in this directory (for example: zone-flags.ts), and put the following flags
27 | * into that file, and then add the following code before importing zone.js.
28 | * import './zone-flags.ts';
29 | *
30 | * The flags allowed in zone-flags.ts are listed here.
31 | *
32 | * The following flags will work for all browsers.
33 | *
34 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
35 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
36 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
37 | *
38 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
39 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
40 | *
41 | * (window as any).__Zone_enable_cross_context_check = true;
42 | *
43 | */
44 |
45 | /***************************************************************************************************
46 | * Zone JS is required by default for Angular itself.
47 | */
48 | import 'zone.js'; // Included with Angular CLI.
49 |
50 |
51 | /***************************************************************************************************
52 | * APPLICATION IMPORTS
53 | */
54 |
--------------------------------------------------------------------------------
/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 | html, body {
3 | margin: 0;
4 | padding: 0;
5 |
6 | height: 100%;
7 | font-family: Arial, Helvetica, sans-serif;
8 | }
9 |
10 | /* CAN (MUST) BE REMOVED ! Sample Global style */
11 | .container {
12 | height: 100%;
13 | display: flex;
14 | flex-direction: column;
15 | align-items: center;
16 | justify-content: center;
17 |
18 | background: url(./assets/background.jpg) no-repeat center fixed;
19 | -webkit-background-size: cover; /* pour anciens Chrome et Safari */
20 | background-size: cover; /* version standardisée */
21 |
22 | .title {
23 | color: white;
24 | margin: 0;
25 | padding: 50px 20px;
26 | }
27 |
28 | a {
29 | color: #fff !important;
30 | text-transform: uppercase;
31 | text-decoration: none;
32 | background: #ed3330;
33 | padding: 20px;
34 | border-radius: 5px;
35 | display: inline-block;
36 | border: none;
37 | transition: all 0.4s ease 0s;
38 |
39 | &:hover {
40 | background: #fff;
41 | color: #ed3330 !important;
42 | letter-spacing: 1px;
43 | -webkit-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
44 | -moz-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
45 | box-shadow: 5px 40px -10px rgba(0,0,0,0.57);
46 | transition: all 0.4s ease 0s;
47 | }
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "baseUrl": "",
6 | "types": [
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "main.ts",
12 | "polyfills.ts"
13 | ],
14 | "include": [
15 | "**/*.ts",
16 | "**/*.d.ts"
17 | ],
18 | "exclude": [
19 | "**/*.spec.ts"
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "esModuleInterop": true,
5 | "outDir": "../out-tsc/spec",
6 | "types": [
7 | "jest",
8 | "node"
9 | ]
10 | },
11 | "files": [
12 | "polyfills-test.ts"
13 | ],
14 | "include": [
15 | "**/*.spec.ts",
16 | "**/*.d.ts"
17 | ],
18 | "exclude": [
19 | "dist",
20 | "release",
21 | "node_modules"
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare const nodeModule: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 | interface Window {
7 | process: any;
8 | require: any;
9 | }
10 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "strict": true,
5 | "outDir": "./dist/out-tsc",
6 | "module": "es2022",
7 | "esModuleInterop": true,
8 | "sourceMap": true,
9 | "declaration": false,
10 | "moduleResolution": "node",
11 | "emitDecoratorMetadata": true,
12 | "experimentalDecorators": true,
13 | "allowJs": true,
14 | "target": "ES2022",
15 | "typeRoots": [
16 | "node_modules/@types"
17 | ],
18 | "lib": [
19 | "es2017",
20 | "es2016",
21 | "es2015",
22 | "es2018",
23 | "dom"
24 | ],
25 | "useDefineForClassFields": false
26 | },
27 | "exclude": [
28 | "node_modules"
29 | ],
30 | "angularCompilerOptions": {
31 | "strictTemplates": true,
32 | "fullTemplateTypeCheck": true,
33 | "annotateForClosureCompiler": true,
34 | "strictInjectionParameters": true,
35 | "skipTemplateCodegen": false,
36 | "preserveWhitespaces": true,
37 | "skipMetadataEmit": false,
38 | "disableTypeScriptVersionCheck": true
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/tsconfig.serve.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "sourceMap": true,
4 | "declaration": false,
5 | "moduleResolution": "node",
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "module": "commonjs",
9 | "target": "es2015",
10 | "types": [
11 | "node"
12 | ],
13 | "lib": [
14 | "es2017",
15 | "es2016",
16 | "es2015",
17 | "dom"
18 | ]
19 | },
20 | "files": [
21 | "app/main.ts"
22 | ],
23 | "exclude": [
24 | "node_modules",
25 | "**/*.spec.ts"
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------