Skip to content
Snippets Groups Projects
Commit 4442e17a authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into ozg-3879-mongodb-helmchart

parents 77936dc3 edbc5dac
Branches
Tags
No related merge requests found
Showing
with 168 additions and 18 deletions
......@@ -27,6 +27,7 @@ export interface ApiRoot {
version: string;
buildTime: string;
javaVersion: string;
production: boolean;
}
export interface ApiRootResource extends ApiRoot, Resource { }
......
......@@ -32,7 +32,8 @@ export function createApiRoot(): ApiRoot {
return {
version: '1',
buildTime: '1',
javaVersion: '1'
javaVersion: '1',
production: false,
}
}
......@@ -23,4 +23,11 @@
unter der Lizenz sind dem Lizenztext zu entnehmen.
-->
<p data-test-id="version"><span>Version: {{ apiRoot.version }}</span> | <span data-test-id="build-time">BuildTime: {{ apiRoot.buildTime | formatDateWithTimePipe }}</span></p>
\ No newline at end of file
<p class="version">
<span data-test-id="version">v{{ version }}</span>
<ng-container *ngIf="isNotProduction">
<span data-test-id="build-time">{{ buildDate }}</span>
<span data-test-id="build-time">{{ buildTime }}</span>
</ng-container>
</p>
<p *ngIf="isNotProduction" data-test-id="not-production-text" class="test-environment">Achtung Testumgebung</p>
\ No newline at end of file
......@@ -24,11 +24,13 @@
@import 'variables';
:host {
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100vh;
position: absolute;
right: 0;
bottom: 0;
font-size: 12px;
color: #666;
padding: 4px 8px;
transform: rotate(-90deg) translate(100%, 0);
transform-origin: right bottom;
......@@ -42,4 +44,23 @@ p {
margin: 0;
line-height: 1;
white-space: nowrap;
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-size: 11px;
color: #999;
&.version {
span {
display: inline-block;
margin-right: 8px;
}
}
}
.test-environment {
margin-right: $navigation-height + $header-height;
letter-spacing: 0.42em;
text-transform: uppercase;
color: #FF0000;
}
\ No newline at end of file
......@@ -28,6 +28,8 @@ import { FormatDateWithTimePipe } from '@goofy-client/tech-shared';
import { createApiRootResource } from 'libs/api-root-shared/test/api-root';
import { BuildInfoComponent } from './build-info.component';
import * as DateUtil from '@goofy-client/tech-shared';
registerLocaleData(localeDe);
describe('BuildInfoComponent', () => {
......@@ -54,4 +56,61 @@ describe('BuildInfoComponent', () => {
fixture.detectChanges();
expect(component).toBeTruthy();
});
describe('isNotProduction', () => {
it('should return true at non-production environment', () => {
component.apiRoot.production = false;
expect(component.isNotProduction).toBeTruthy();
})
it('should return false at production environment', () => {
component.apiRoot.production = true;
expect(component.isNotProduction).toBeFalsy();
})
})
describe('isProduction', () => {
it('should return false at non-production environment', () => {
component.apiRoot.production = false;
expect(component.isProduction).toBeFalsy();
})
it('should return true at production environment', () => {
component.apiRoot.production = true;
expect(component.isProduction).toBeTruthy();
})
})
describe('version', () => {
it('should return version fragment', () => {
component.apiRoot.version = '1.12.0-SNAPSHOT';
expect(component.version).toBe('1.12.0');
})
})
describe('buildDate', () => {
it('should call formatFullDate', () => {
const formatFullDate = jest.spyOn(DateUtil, 'formatFullDate');
component.buildDate;
expect(formatFullDate).toHaveBeenCalled();
})
})
describe('buildTime', () => {
it('should call formatHourMinute', () => {
const formatHourMinute = jest.spyOn(DateUtil, 'formatHourMinute');
component.buildTime;
expect(formatHourMinute).toHaveBeenCalled();
})
})
});
......@@ -24,6 +24,8 @@
import { Component, Input } from '@angular/core';
import { ApiRootResource } from '@goofy-client/api-root-shared';
import * as DateUtil from '@goofy-client/tech-shared';
@Component({
selector: 'goofy-client-build-info',
templateUrl: './build-info.component.html',
......@@ -33,4 +35,24 @@ export class BuildInfoComponent {
@Input() apiRoot: ApiRootResource;
get isNotProduction() {
return ! this.apiRoot.production;
}
get isProduction() {
return this.apiRoot.production;
}
get version() {
return this.apiRoot.version.replace(/^([^-]+).*/, "$1");
}
get buildDate() {
return DateUtil.formatFullDate(new Date(this.apiRoot.buildTime));
}
get buildTime() {
return DateUtil.formatHourMinute(new Date(this.apiRoot.buildTime));
}
}
......@@ -23,7 +23,7 @@
*/
import { formatDate, registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
import { formatDateWithoutYearWithTime, formatForDatabase, formatFullDate, formatFullDateWithTimeAndDay, formatFullDateWithTimeWithoutSeconds, formatFullDateWithoutSeperator, formatToPrettyDate, formatWithoutYear, isISODateInPast } from './date.util';
import { formatDateWithoutYearWithTime, formatForDatabase, formatFullDate, formatFullDateWithTimeAndDay, formatFullDateWithTimeWithoutSeconds, formatFullDateWithoutSeperator, formatHourMinute, formatToPrettyDate, formatWithoutYear, isISODateInPast } from './date.util';
import faker from '@faker-js/faker';
import * as dateFns from 'date-fns';
......@@ -60,6 +60,12 @@ describe('Date Util', () => {
expect(formattedDate).toEqual('01.01.1010');
})
it('should return hour and minute', () => {
const formattedDate: string = formatHourMinute(dateToFormat);
expect(formattedDate).toEqual('01:01');
})
it('should return day and name of month', () => {
const formattedDate: string = formatWithoutYear(dateToFormat);
......
......@@ -42,6 +42,10 @@ export function formatFullDate(date: Date): string {
return formatDate(date, 'dd.MM.yyyy', 'de');
}
export function formatHourMinute(date: Date): string {
return formatDate(date, 'hh:mm', 'de');
}
export function formatWithoutYear(date: Date): string {
return formatDate(date, 'dd. MMM', 'de');
}
......
......@@ -68,7 +68,7 @@ public class RootController {
@Autowired
private UserManagerUrlProvider userManagerUrlProvider;
@Value("${ozgcloud.stage.production}")
@Value("${ozgcloud.stage.production:#{true}}")
private boolean production = true;
@GetMapping
......
{
"properties": [
{"properties": [
{
"name": "goofy.production",
"type": "java.lang.Boolean",
"description": "Enables/Disables the production mode. (default: true)"
}
]
"description": "Enables/Disables the Angular production mode. (default: true)"
},
{
"name": "ozgcloud.stage.production",
"type": "java.lang.String",
"description": "Enables/Disables production environment hint. (default: true)"
}
]}
\ No newline at end of file
......@@ -9,3 +9,7 @@ keycloak:
server:
error:
include-stacktrace: always
ozgcloud:
stage:
production: false
\ No newline at end of file
......@@ -12,3 +12,25 @@ grpc:
logging:
config: classpath:log4j2.xml
---
spring:
config:
activate:
on-profile:
- test
ozgcloud:
stage:
production: false
---
spring:
config:
activate:
on-profile:
- stage
ozgcloud:
stage:
production: false
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment