Browse Source

Use dedicated component to display the version.

tags/v1.3.1-1
Manuel Friedli 1 year ago
parent
commit
2c50fa0713

+ 5
- 1
angular.json View File

@@ -8,7 +8,11 @@
8 8
       "sourceRoot": "src",
9 9
       "projectType": "application",
10 10
       "prefix": "app",
11
-      "schematics": {},
11
+      "schematics": {
12
+        "@schematics/angular:component": {
13
+          "styleext": "scss"
14
+        }
15
+      },
12 16
       "architect": {
13 17
         "build": {
14 18
           "builder": "@angular-devkit/build-angular:browser",

+ 1
- 1
src/app/app.component.html View File

@@ -14,5 +14,5 @@
14 14
   </div>
15 15
   <div class="errormessage" *ngIf="step.error" [innerHTML]="step.message"></div>
16 16
 </div>
17
-<span>Version: {{VERSION}}</span>
17
+<app-version></app-version>
18 18
 <!--<router-outlet></router-outlet>-->

+ 0
- 2
src/app/app.component.ts View File

@@ -3,7 +3,6 @@ import {ConverterRegistryService} from './converterregistry.service';
3 3
 import {InputComponentManagerService} from './inputcomponentmanager.service';
4 4
 import {Step} from './step';
5 5
 import {Converter} from './converter/converter';
6
-import {environment} from '../environments/environment';
7 6
 
8 7
 @Component({
9 8
   selector: 'app-root',
@@ -11,7 +10,6 @@ import {environment} from '../environments/environment';
11 10
   styleUrls: ['./app.component.scss']
12 11
 })
13 12
 export class AppComponent implements OnInit {
14
-  public readonly VERSION: string = environment.appVersion;
15 13
   public steps: Step[] = [];
16 14
   public converters: Converter[] = [];
17 15
 

+ 8
- 2
src/app/app.module.ts View File

@@ -5,16 +5,22 @@ import {ConverterRegistryService} from './converterregistry.service';
5 5
 import {InputComponentManagerService} from './inputcomponentmanager.service';
6 6
 import {NativeLibraryWrapperService} from './nativelibrarywrapper.service';
7 7
 import {FormsModule} from '@angular/forms';
8
+import {VersionComponent} from './version/version.component';
8 9
 
9 10
 @NgModule({
10 11
   declarations: [
11
-    AppComponent
12
+    AppComponent,
13
+    VersionComponent
12 14
   ],
13 15
   imports: [
14 16
     BrowserModule,
15 17
     FormsModule
16 18
   ],
17
-  providers: [ConverterRegistryService, InputComponentManagerService, NativeLibraryWrapperService],
19
+  providers: [
20
+    ConverterRegistryService,
21
+    InputComponentManagerService,
22
+    NativeLibraryWrapperService
23
+  ],
18 24
   bootstrap: [AppComponent]
19 25
 })
20 26
 export class AppModule {

+ 1
- 0
src/app/version/version.component.html View File

@@ -0,0 +1 @@
1
+<div [ngClass]="{dev: !PROD}">Version: {{VERSION}}</div>

+ 10
- 0
src/app/version/version.component.scss View File

@@ -0,0 +1,10 @@
1
+div {
2
+  font-size: smaller;
3
+  color: gray;
4
+  display: block;
5
+  text-align: right;
6
+  margin-right: 2em;
7
+  &.dev {
8
+    color: red;
9
+  }
10
+}

+ 25
- 0
src/app/version/version.component.spec.ts View File

@@ -0,0 +1,25 @@
1
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+import { VersionComponent } from './version.component';
4
+
5
+describe('VersionComponent', () => {
6
+  let component: VersionComponent;
7
+  let fixture: ComponentFixture<VersionComponent>;
8
+
9
+  beforeEach(async(() => {
10
+    TestBed.configureTestingModule({
11
+      declarations: [ VersionComponent ]
12
+    })
13
+    .compileComponents();
14
+  }));
15
+
16
+  beforeEach(() => {
17
+    fixture = TestBed.createComponent(VersionComponent);
18
+    component = fixture.componentInstance;
19
+    fixture.detectChanges();
20
+  });
21
+
22
+  it('should create', () => {
23
+    expect(component).toBeTruthy();
24
+  });
25
+});

+ 15
- 0
src/app/version/version.component.ts View File

@@ -0,0 +1,15 @@
1
+import {Component} from '@angular/core';
2
+import {environment} from '../../environments/environment';
3
+
4
+@Component({
5
+  selector: 'app-version',
6
+  templateUrl: './version.component.html',
7
+  styleUrls: ['./version.component.scss']
8
+})
9
+export class VersionComponent {
10
+  public readonly PROD: boolean = environment.production;
11
+  public readonly VERSION: string = environment.appVersion + (this.PROD ? '' : ' (development build)');
12
+
13
+  constructor() {
14
+  }
15
+}

+ 1
- 1
src/environments/environment.ts View File

@@ -4,7 +4,7 @@
4 4
 
5 5
 export const environment = {
6 6
   production: false,
7
-  appVersion: `${require('../../package.json').version} (development build)`
7
+  appVersion: require('../../package.json').version
8 8
 };
9 9
 
10 10
 /*

Loading…
Cancel
Save