9 Commits

6 changed files with 60 additions and 3 deletions

View File

@ -24,8 +24,10 @@ check:
build:
image: node:14-buster
image: registry.hottis.de/hv2/hv2-node-build-env:1.0.0
stage: build
variables:
GIT_SUBMODULE_STRATEGY: recursive
tags:
- hottis
- linux
@ -37,9 +39,12 @@ build:
script:
- cd hv2-ui
- if [ "$CI_COMMIT_TAG" != "" ]; then
sed -i -e 's/GITTAGVERSION/'"$CI_COMMIT_TAG"'/' ./src/app/navigation/navigation.component.html;
sed -i -e 's/GITTAGVERSION/'"$CI_COMMIT_TAG"':'"$CI_COMMIT_SHORT_SHA"'/' ./src/app/navigation/navigation.component.html;
fi
- npm install
- for F in ./src/app/*.tmpl; do
python ../helpers/hv2-api/generate.py -s ../helpers/hv2-api/schema.json -t $F;
done
- ./node_modules/.bin/ng build --prod
- tar -czf ../dist.tgz dist

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "helpers/hv2-api"]
path = helpers/hv2-api
url = ../hv2-api

1
helpers/hv2-api Submodule

Submodule helpers/hv2-api added at 717d2bc7d8

View File

@ -7,7 +7,9 @@
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"generate": "python ../helpers/hv2-api/generate.py -s ../helpers/hv2-api/schema.json -t ./src/app/*.tmpl"
},
"private": true,
"dependencies": {

View File

@ -0,0 +1,35 @@
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { MessageService } from './message.service';
import { serviceBaseUrl } from './config';
#for $table in $tables
import { ${JsNameConverter($table.name)} } from './data-objects';
#end for
@Injectable({
providedIn: 'root'
})
#from generateHelper import JsNameConverter
#for $table in $tables
export class ${JsNameConverter($table.name)}Service {
constructor(private messageService: MessageService, private http: HttpClient) { }
async get${JsNameConverter($table.name)}(): Promise<${JsNameConverter($table.name)}> {
this.messageService.add(`${JsNameConverter($table.name)}Service: fetch data`);
return this.http.get<${JsNameConverter($table.name)}>(`\${serviceBaseUrl}/v1/${table.name}`).toPromise()
}
}
#end for

View File

@ -0,0 +1,11 @@
#from generateHelper import JsNameConverter
#for $table in $tables
export interface $JsNameConverter($table.name) {
#for $column in $table.columns
${column.name}: ${column.jstype}
#end for
}
#end for