Browse Source

Use dedicated component to display the version.

tags/v1.3.1-1
Manuel Friedli 1 year ago
parent
commit
2c50fa0713
9 changed files with 66 additions and 7 deletions
  1. +5
    -1
      angular.json
  2. +1
    -1
      src/app/app.component.html
  3. +0
    -2
      src/app/app.component.ts
  4. +8
    -2
      src/app/app.module.ts
  5. +1
    -0
      src/app/version/version.component.html
  6. +10
    -0
      src/app/version/version.component.scss
  7. +25
    -0
      src/app/version/version.component.spec.ts
  8. +15
    -0
      src/app/version/version.component.ts
  9. +1
    -1
      src/environments/environment.ts

+ 5
- 1
angular.json View File

@@ -8,7 +8,11 @@
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",

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

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

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

@@ -3,7 +3,6 @@ import {ConverterRegistryService} from './converterregistry.service';
import {InputComponentManagerService} from './inputcomponentmanager.service';
import {Step} from './step';
import {Converter} from './converter/converter';
import {environment} from '../environments/environment';

@Component({
selector: 'app-root',
@@ -11,7 +10,6 @@ import {environment} from '../environments/environment';
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
public readonly VERSION: string = environment.appVersion;
public steps: Step[] = [];
public converters: Converter[] = [];


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

@@ -5,16 +5,22 @@ import {ConverterRegistryService} from './converterregistry.service';
import {InputComponentManagerService} from './inputcomponentmanager.service';
import {NativeLibraryWrapperService} from './nativelibrarywrapper.service';
import {FormsModule} from '@angular/forms';
import {VersionComponent} from './version/version.component';

@NgModule({
declarations: [
AppComponent
AppComponent,
VersionComponent
],
imports: [
BrowserModule,
FormsModule
],
providers: [ConverterRegistryService, InputComponentManagerService, NativeLibraryWrapperService],
providers: [
ConverterRegistryService,
InputComponentManagerService,
NativeLibraryWrapperService
],
bootstrap: [AppComponent]
})
export class AppModule {

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

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

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

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

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

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { VersionComponent } from './version.component';

describe('VersionComponent', () => {
let component: VersionComponent;
let fixture: ComponentFixture<VersionComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ VersionComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(VersionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

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

@@ -0,0 +1,15 @@
import {Component} from '@angular/core';
import {environment} from '../../environments/environment';

@Component({
selector: 'app-version',
templateUrl: './version.component.html',
styleUrls: ['./version.component.scss']
})
export class VersionComponent {
public readonly PROD: boolean = environment.production;
public readonly VERSION: string = environment.appVersion + (this.PROD ? '' : ' (development build)');

constructor() {
}
}

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

@@ -4,7 +4,7 @@

export const environment = {
production: false,
appVersion: `${require('../../package.json').version} (development build)`
appVersion: require('../../package.json').version
};

/*

Loading…
Cancel
Save