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

api first test

parent fc3319c9
......@@ -33,20 +33,7 @@
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
},
{
"name": "Launch Firefox (4200 ng serve)",
"type": "firefox",
"request": "launch",
"reAttach": true,
"url": "http://localhost:4200",
"pathMappings": [
{
"url": "webpack:///src",
"path": "${workspaceFolder}/src"
}
]
"webRoot": "${workspaceFolder}/common/utils/websrv/frontend"
},
{
"name": "Launch Chrome (localhost)",
......
......@@ -10,7 +10,7 @@
],
"parserOptions": {
"project": [
"./tsconfig.json"
"common/utils/websrv/frontend/tsconfig.json"
],
"createDefaultProgram": true
},
......
stages:
- install
- build
- publish
- deploy
variables:
TRION_CLI_VERSION: 12.2.4
.install:
cache:
key:
files:
- package-lock.json
paths:
- .npm
- node_modules
policy: pull
only:
- master
- dev
#
#jobs
#
install:
stage: install
extends: .install
image: trion/ng-cli:${TRION_CLI_VERSION}
script:
- npm ci
cache:
policy: pull-push
only:
changes:
- package-lock.json
......@@ -46,62 +28,4 @@ build:
artifacts:
expire_in: 1 day
paths:
- dist/lsd-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
- dist/softmodem-ngx
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 {
constructor(private httpClient: HttpClient) { }
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>
<p> config_file: {{ infos.display_status.config_file }}</p>
<p> executable_function: {{ infos.display_status.executable_function }}</p>
<h1 mat-dialog-title>Status</h1>
<p> config_file: {{ infos.display_status.config_file }}</p>
<p> executable_function: {{ infos.display_status.executable_function }}</p>
<h1 mat-dialog-title>Commands</h1>
<mat-form-field>
<h1 mat-dialog-title>Commands</h1>
<div fxLaypout="row">
<mat-form-field>
<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>
</mat-select>
</mat-form-field>
\ No newline at end of file
</mat-form-field>
<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 */
/* eslint-disable no-shadow */
/* eslint-disable eqeqeq */
/* eslint-disable @typescript-eslint/naming-convention */
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
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 { InfosCtrl } from 'src/app/controls/infos.control';
import { LoadingService } from 'src/app/services/loading.service';
......@@ -16,33 +14,50 @@ import { LoadingService } from 'src/app/services/loading.service';
})
export class CommandsComponent {
// infos$: Observable<InfosCtrl>
infos: InfosCtrl
infos$: Observable<InfosCtrl>
// infos: InfosCtrl
selectedCmd?: FormControl
selected = new FormControl()
constructor(
public commandsApi: CommandsApi,
public loadingService: LoadingService,
) {
// this.infos$ = this.commandsApi.readInfos$().pipe(
// map((doc) => new InfosCtrl(doc)),
// );
this.infos = new InfosCtrl({
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"
]
})
// console.log(JSON.stringify(this.infos, null, 2))
this.infos$ = this.commandsApi.readInfos$().pipe(
map((doc) => new InfosCtrl(doc)),
);
// this.infos = new InfosCtrl({
// 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"
// ]
// })
// 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 @@
<ng-container *ngIf="loadingService.isLoading$ | async; then loading; else not_loading">
</ng-container>
</div>
<div #notAuthenticated>
<button mat-raised-button color="primary">
login
</button>
</div>
</mat-toolbar-row>
</mat-toolbar>
......
/* eslint-disable no-shadow */
import { FormArray, FormControl, FormGroup } from '@angular/forms';
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