Commit 8c355a08 authored by El Mghazli Yacine's avatar El Mghazli Yacine

api first test

parent fc3319c9
...@@ -33,20 +33,7 @@ ...@@ -33,20 +33,7 @@
"type": "chrome", "type": "chrome",
"request": "launch", "request": "launch",
"url": "http://localhost:4200", "url": "http://localhost:4200",
"webRoot": "${workspaceFolder}" "webRoot": "${workspaceFolder}/common/utils/websrv/frontend"
},
{
"name": "Launch Firefox (4200 ng serve)",
"type": "firefox",
"request": "launch",
"reAttach": true,
"url": "http://localhost:4200",
"pathMappings": [
{
"url": "webpack:///src",
"path": "${workspaceFolder}/src"
}
]
}, },
{ {
"name": "Launch Chrome (localhost)", "name": "Launch Chrome (localhost)",
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
], ],
"parserOptions": { "parserOptions": {
"project": [ "project": [
"./tsconfig.json" "common/utils/websrv/frontend/tsconfig.json"
], ],
"createDefaultProgram": true "createDefaultProgram": true
}, },
......
stages: stages:
- install - install
- build - build
- publish
- deploy
variables: variables:
TRION_CLI_VERSION: 12.2.4 TRION_CLI_VERSION: 12.2.4
.install:
cache:
key:
files:
- package-lock.json
paths:
- .npm
- node_modules
policy: pull
only:
- master
- dev
# #
#jobs #jobs
# #
install: install:
stage: install stage: install
extends: .install
image: trion/ng-cli:${TRION_CLI_VERSION} image: trion/ng-cli:${TRION_CLI_VERSION}
script: script:
- npm ci - npm ci
cache:
policy: pull-push
only: only:
changes: changes:
- package-lock.json - package-lock.json
...@@ -46,62 +28,4 @@ build: ...@@ -46,62 +28,4 @@ build:
artifacts: artifacts:
expire_in: 1 day expire_in: 1 day
paths: paths:
- dist/lsd-ngx - dist/softmodem-ngx
on-gitlab:
stage: publish
dependencies:
- build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile Dockerfile --destination $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:latest
only:
- dev
- master
on-heroku:
stage: publish
dependencies:
- build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"registry.heroku.com\":{\"username\":\"_\",\"password\":\"$HEROKU_API_KEY\"}}}" > /kaniko/.docker/config.json
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile Dockerfile --destination registry.heroku.com/$HEROKU_APP_NAME/web
only:
- dev
herokuapp:
stage: deploy
image: node:lts-alpine
before_script:
- apk update && apk add curl bash
- rm -rf /var/cache/apk/*
- curl https://cli-assets.heroku.com/install.sh | sh
script:
- heroku container:release web --app $HEROKU_APP_NAME
environment:
name: heroku-dev
url: https://lsdngx.herokuapp.com
only:
- dev
on-gke:
stage: deploy
image: alpine/k8s:1.20.7
script:
- kubectl config use-context lsd5/k8s:gke-agent
- kubectl apply -f k8s/manifest.yaml --namespace=$NAMESPACE
environment:
name: gke-master
url: https://lsd.nutridata.io
only:
- master
FROM nginx:alpine
COPY dist/softmodem-ngx /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/conf.d/default.conf
# sed replace $PORT by $PORT at runtime (on heroku with the correct port)
CMD sed -i -e 's/$PORT/'"$PORT"'/g' /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'
...@@ -21,6 +21,8 @@ export class CommandsApi { ...@@ -21,6 +21,8 @@ export class CommandsApi {
constructor(private httpClient: HttpClient) { } constructor(private httpClient: HttpClient) { }
public readInfos$ = () => this.httpClient.get<IInfos>(environment.backend + route); public readInfos$ = () => this.httpClient.get<IInfos>(environment.backend + route);
public runCommand$ = (cmdName: string) => this.httpClient.post<string>(environment.backend + route, cmdName);
} }
......
<!-- <div *ngIf="infos$ | async as infos"> --> <div *ngIf="infos$ | async as infos">
<h1 mat-dialog-title>Status</h1> <h1 mat-dialog-title>Status</h1>
<p> config_file: {{ infos.display_status.config_file }}</p> <p> config_file: {{ infos.display_status.config_file }}</p>
<p> executable_function: {{ infos.display_status.executable_function }}</p> <p> executable_function: {{ infos.display_status.executable_function }}</p>
<h1 mat-dialog-title>Commands</h1> <h1 mat-dialog-title>Commands</h1>
<mat-form-field> <div fxLaypout="row">
<mat-form-field>
<mat-label>Command</mat-label> <mat-label>Command</mat-label>
<mat-select [formControl]="selectedCmd?.value" [value]="selectedCmd?.value"> <mat-select [formControl]="selected" [value]="selected?.value">
<mat-option *ngFor="let control of infos.cmdsFA.controls" [value]="control.value">{{ control.value }} <mat-option *ngFor="let control of infos.cmdsFA.controls" [value]="control.value">{{ control.value }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
\ No newline at end of file <button mat-raised-button color="primary" [disabled]="!selected" (click)="onSubmit()">
submit
</button>
</div>
</div>
\ No newline at end of file
/* eslint-disable @typescript-eslint/member-ordering */ import { Component } from '@angular/core';
/* eslint-disable no-shadow */
/* eslint-disable eqeqeq */
/* eslint-disable @typescript-eslint/naming-convention */
import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { Observable } from 'rxjs/internal/Observable';
import { map } from 'rxjs/internal/operators/map';
import { CommandsApi } from 'src/app/api/commands.api'; import { CommandsApi } from 'src/app/api/commands.api';
import { InfosCtrl } from 'src/app/controls/infos.control'; import { InfosCtrl } from 'src/app/controls/infos.control';
import { LoadingService } from 'src/app/services/loading.service'; import { LoadingService } from 'src/app/services/loading.service';
...@@ -16,33 +14,50 @@ import { LoadingService } from 'src/app/services/loading.service'; ...@@ -16,33 +14,50 @@ import { LoadingService } from 'src/app/services/loading.service';
}) })
export class CommandsComponent { export class CommandsComponent {
// infos$: Observable<InfosCtrl> infos$: Observable<InfosCtrl>
infos: InfosCtrl // infos: InfosCtrl
selectedCmd?: FormControl selected = new FormControl()
constructor( constructor(
public commandsApi: CommandsApi, public commandsApi: CommandsApi,
public loadingService: LoadingService, public loadingService: LoadingService,
) { ) {
// this.infos$ = this.commandsApi.readInfos$().pipe( this.infos$ = this.commandsApi.readInfos$().pipe(
// map((doc) => new InfosCtrl(doc)), map((doc) => new InfosCtrl(doc)),
// ); );
this.infos = new InfosCtrl({ // this.infos = new InfosCtrl({
display_status: { // display_status: {
config_file: '../../../ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf', // config_file: '../../../ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf',
executable_function: "gnb" // executable_function: "gnb"
}, // },
menu_cmds: [ // menu_cmds: [
"telnet", // "telnet",
"softmodem", // "softmodem",
"loader", // "loader",
"measur", // "measur",
"rfsimu" // "rfsimu"
] // ]
}) // })
// console.log(JSON.stringify(this.infos, null, 2)) // const BODY_JSON = {
// "display_status": {
// "config_file": '../../../ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf',
// "executable_function": "gnb"
// },
// "menu_cmds": [
// "telnet",
// "softmodem",
// "loader",
// "measur",
// "rfsimu"
// ]
// }
}
onSubmit() {
this.commandsApi.runCommand$(this.selected.value).subscribe();
} }
} }
...@@ -24,13 +24,6 @@ ...@@ -24,13 +24,6 @@
<ng-container *ngIf="loadingService.isLoading$ | async; then loading; else not_loading"> <ng-container *ngIf="loadingService.isLoading$ | async; then loading; else not_loading">
</ng-container> </ng-container>
</div> </div>
<div #notAuthenticated>
<button mat-raised-button color="primary">
login
</button>
</div>
</mat-toolbar-row> </mat-toolbar-row>
</mat-toolbar> </mat-toolbar>
......
/* eslint-disable no-shadow */
import { FormArray, FormControl, FormGroup } from '@angular/forms'; import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { IInfos, IStatus } from '../api/commands.api'; import { IInfos, IStatus } from '../api/commands.api';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment