Skip to content

Commit

Permalink
Merge pull request #490 from NUM-Forschungsdatenplattform/release/v1.…
Browse files Browse the repository at this point in the history
…15.0

Release/v1.15.0
  • Loading branch information
richardbartha committed Sep 14, 2023
2 parents aaa4a06 + 73cd0aa commit 2090fde
Show file tree
Hide file tree
Showing 43 changed files with 556 additions and 78 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "num-portal-webapp",
"version": "1.14.0",
"version": "1.15.0",
"scripts": {
"postinstall": "ngcc",
"ng": "ng",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Routes, RouterModule } from '@angular/router'
import { AuthGuard } from './core/auth/guards/auth.guard'
import { RoleGuard } from './core/auth/guards/role.guard'
import { CanDeactivateSearchGuard } from './modules/search/can-deactivate-search.guard'
import { AvailableRoles } from './shared/models/available-roles.enum'
import { AvailableRoles, allRoles } from './shared/models/available-roles.enum'
import { UserManualUrlResolver } from './shared/resolvers/usermanualurl.resolver'

export const routes: Routes = [
Expand Down
1 change: 0 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core'
import { OAuthInterceptor } from './core/interceptors/oauth.interceptor'
import { AuthService } from './core/auth/auth.service'
import { DateAdapter } from '@angular/material/core'
import { CustomDatePickerAdapter } from './core/adapter/date-picker-adapter'
import { MomentDateAdapter } from '@angular/material-moment-adapter'
import { OAuthStorage } from 'angular-oauth2-oidc'
import { WebpackTranslateLoader } from './webpack-translate-loader'
Expand Down
3 changes: 3 additions & 0 deletions src/app/core/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
*/

export const PARAMETER_REGEX = /\$\w+/g

export const HEALTHCHECK = 'HEALTHCHECK'
export const USERMANUAL = 'USERMANUAL'
16 changes: 14 additions & 2 deletions src/app/core/constants/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* limitations under the License.
*/

import { AvailableRoles } from 'src/app/shared/models/available-roles.enum'
import { AvailableRoles, allRoles } from 'src/app/shared/models/available-roles.enum'
import INavItem from '../../layout/models/nav-item.interface'
import { HEALTHCHECK, USERMANUAL } from './constants'

export const mainNavItems: INavItem[] = [
{
Expand Down Expand Up @@ -165,10 +166,21 @@ export const mainNavItems: INavItem[] = [
translationKey: 'NAVIGATION.MANAGER_TOOLS',
roles: [AvailableRoles.Manager],
},
]
export const mainNavItemsExternal: INavItem[] = [
{
routeTo: 'user-manual',
icon: 'book-open',
translationKey: 'NAVIGATION.USER_MANUAL',
id: USERMANUAL,
isExternal: true,
},
{
icon: 'file-waveform',
translationKey: 'NAVIGATION.HEALTH_CHECK',
roles: allRoles,
id: HEALTHCHECK,
isExternal: true,
highlighted: true,
},
]

Expand Down
5 changes: 3 additions & 2 deletions src/app/core/helper/date-helper.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('DateHelperService', () => {
let service: DateHelperService
const dateString = '2021-01-02T11:12:13+0000'
const date = new Date(2021, 0, 2, 11, 12, 13)
const momentDate = moment(date)

beforeEach(() => {
TestBed.configureTestingModule({})
Expand All @@ -35,7 +36,7 @@ describe('DateHelperService', () => {
})

it('Should convert date times as expected', () => {
const result = DateHelperService.getIsoString(date)
const result = DateHelperService.getIsoString(momentDate)
expect(result).toEqual(dateString)
})

Expand All @@ -45,7 +46,7 @@ describe('DateHelperService', () => {
})

it('Should convert times as expected', () => {
const result = DateHelperService.getTimeString(date)
const result = DateHelperService.getTimeString(momentDate)
expect(result).toEqual('11:12:13')
})
})
25 changes: 15 additions & 10 deletions src/app/core/helper/date-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import moment from 'moment'
export class DateHelperService {
constructor() {}
static getDateString(date: moment.Moment): string {
if (!date.isValid) {
date = moment(date)
}
const d = date.toDate()
const year = d.getFullYear()
const month = (d.getMonth() + 1).toString().padStart(2, '0')
Expand All @@ -31,16 +34,17 @@ export class DateHelperService {
return `${year}-${month}-${day}`
}
//we switched from javascript Date to Momentjs (https://momentjs.com/). If we need to support timebased funtions the cide below needs to be changed, too
static getTimeString(date: Date): string {
const hours = date.getHours().toString().padStart(2, '0')
const minutes = date.getMinutes().toString().padStart(2, '0')
const seconds = date.getSeconds().toString().padStart(2, '0')
static getTimeString(date: moment.Moment): string {
console.log('date: ', date)
const hours = date.hours().toString().padStart(2, '0')
const minutes = date.minutes().toString().padStart(2, '0')
const seconds = date.seconds().toString().padStart(2, '0')

return `${hours}:${minutes}:${seconds}`
}

static getOffsetString(date: Date): string {
const offset = date.getTimezoneOffset()
static getOffsetString(date: moment.Moment): string {
const offset = date.toDate().getTimezoneOffset()
const sign = offset > 0 ? '-' : '+'
const hours = Math.abs(Math.trunc(offset / 60))
.toString()
Expand All @@ -50,10 +54,11 @@ export class DateHelperService {
return `${sign}${hours}${minutes}`
}

static getIsoString(date: Date): string {
const dateString = this.getDateString(moment(date))
const timeString = this.getTimeString(date)
const offset = this.getOffsetString(date)
static getIsoString(date: moment.Moment): string {
const momentDate = moment(date)
const dateString = this.getDateString(momentDate)
const timeString = this.getTimeString(momentDate)
const offset = this.getOffsetString(momentDate)

return `${dateString}T${timeString}${offset}`
}
Expand Down
1 change: 0 additions & 1 deletion src/app/core/services/aql/aql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export class AqlService {
.subscribe((filterResult) => this.filteredAqlsSubject$.next(filterResult))

this.translateService.onLangChange.subscribe((event) => {
console.log('lang change', event.lang)
this.currentLang = event.lang || 'en'
this.setFilter(this.filterSet)
})
Expand Down
1 change: 0 additions & 1 deletion src/app/core/services/aql/test/aql.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ describe('AqlService', () => {
userProfileObservable$: userProfileSubject$.asObservable(),
} as unknown as ProfileService

let onLanguageChangeSubject$: EventEmitter<any>
const mockTranslateService = {
onLangChange: jest.fn(),
currentLang: 'de',
Expand Down
6 changes: 6 additions & 0 deletions src/app/core/services/system-status/envs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum Environment {
DEV = 'DEV',
TEST = 'TEST',
PREPROD = 'PREPROD',
STAGING = 'STAGING',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface SystemStatus {
EHRBASE: string
FE: string
FHIR_BRIDGE: string
KEYCLOAK: string
NUM: string
CHECK_FOR_ANNOUNCEMENTS: string
}
58 changes: 58 additions & 0 deletions src/app/core/services/system-status/system-status.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { TestBed } from '@angular/core/testing'

import { SystemStatusService } from './system-status.service'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { AppConfigService } from 'src/app/config/app-config.service'
import { HttpClient } from '@angular/common/http'

describe('SystemStatusService', () => {
let service: SystemStatusService

const appConfig = {
config: { api: { baseUrl: 'foo.bar' } },
} as unknown as AppConfigService

const httpService = {
get: {
EHRBASE: 'string',
FE: 'string',
FHIR_BRIDGE: 'string',
KEYCLOAK: 'string',
NUM: 'string',
},
} as unknown as HttpClient

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [
{
provide: AppConfigService,
useValue: appConfig,
},
{
provide: HttpClient,
useValue: httpService,
},
],
})
service = TestBed.inject(SystemStatusService)
})

it('should be created', () => {
expect(service).toBeTruthy()
})
it('should check system status', () => {
service.getSystemStatusOberservable()
})
it('should check for errors', () => {
service.hasError({
EHRBASE: '',
KEYCLOAK: '',
NUM: '',
CHECK_FOR_ANNOUNCEMENTS: '',
FE: '',
FHIR_BRIDGE: '',
})
})
})
55 changes: 55 additions & 0 deletions src/app/core/services/system-status/system-status.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Injectable } from '@angular/core'
import { Environment } from './envs'
import { HttpClient } from '@angular/common/http'
import { AppConfigService } from 'src/app/config/app-config.service'
import { SystemStatus } from './system-status.interface'
import { Observable } from 'rxjs'

@Injectable({
providedIn: 'root',
})
export class SystemStatusService {
baseUrl: string
constructor(private httpClient: HttpClient, public appConfig: AppConfigService) {
this.baseUrl = `${appConfig.config.api.baseUrl}/admin/services-status`
}

private getEnv(): Environment {
const hostedEnv = window.location.host.split('.')[0]
let env: Environment
if (hostedEnv.includes('dev') || hostedEnv.includes('localhost')) {
env = Environment.DEV
} else if (hostedEnv.includes('test')) {
env = Environment.TEST
} else if (hostedEnv.includes('preprod')) {
env = Environment.PREPROD
} else {
env = Environment.STAGING
}
return env
}
/* getSystemStatus(): Promise<SystemStatus> {
return new Promise((resolve, reject) => {
this.httpClient.get(`${this.baseUrl}?setup=${this.getEnv()}`).subscribe((systemStatus) => {
resolve(systemStatus as SystemStatus)
})
})
} */
getSystemStatusOberservable(): Observable<SystemStatus> {
return new Observable((subscriber) => {
this.httpClient.get(`${this.baseUrl}?setup=${this.getEnv()}`).subscribe((systemStatus) => {
subscriber.next(systemStatus as SystemStatus)
})
})
}
hasError(status: SystemStatus): boolean {
return (
status.EHRBASE !== '' ||
status.FE !== '' ||
status.FHIR_BRIDGE !== '' ||
status.KEYCLOAK !== '' ||
status.NUM !== '' ||
status.CHECK_FOR_ANNOUNCEMENTS !== ''
)
}
}
4 changes: 2 additions & 2 deletions src/app/core/utils/value-converter.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export const convertParameterInputToType = (
outputValue = DateHelperService.getDateString(inputValue as Moment)
break
case AqlParameterValueType.Time:
outputValue = DateHelperService.getTimeString(inputValue as Date)
outputValue = DateHelperService.getTimeString(inputValue as Moment)
break
case AqlParameterValueType.DateTime:
outputValue = DateHelperService.getIsoString(inputValue as Date)
outputValue = DateHelperService.getIsoString(inputValue as Moment)
break
case AqlParameterValueType.Number:
outputValue = parseInt(inputValue as string, 10)
Expand Down
12 changes: 12 additions & 0 deletions src/app/layout/components/side-menu/side-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
<div>{{ item.translationKey | translate }}</div>
</a>
</ng-template>
<ng-template ngFor let-item [ngForOf]="mainNavItemsExternal">
<a
*numUserHasRole="item.roles"
mat-list-item
[ngClass]="{ 'num-mat-list-item': true, highlighted: item.highlighted }"
(click)="menuItemClicked($event, item)"
[attr.data-test]="'side-menu__main-nav__' + item.translationKey"
>
<fa-icon size="lg" [fixedWidth]="true" [icon]="item.icon"></fa-icon>
<div>{{ item.translationKey | translate }}</div>
</a>
</ng-template>

<ng-template [ngIf]="isLoggedIn">
<mat-divider class="num-d-c--g num-d-w--1"></mat-divider>
Expand Down
3 changes: 3 additions & 0 deletions src/app/layout/components/side-menu/side-menu.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ fa-icon {
justify-content: center;
align-items: center;
}
.num-mat-list-item.highlighted {
color: #eb586a;
}
Loading

0 comments on commit 2090fde

Please sign in to comment.