Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lizhongxiao
OpenXG-RAN
Commits
6e3f09a3
Commit
6e3f09a3
authored
Apr 01, 2022
by
El Mghazli Yacine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webserv APIv2 (frontend part)
parent
9ca2d78f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
84 deletions
+47
-84
common/utils/websrv/frontend/src/app/api/commands.api.ts
common/utils/websrv/frontend/src/app/api/commands.api.ts
+3
-10
common/utils/websrv/frontend/src/app/components/commands/commands.component.html
...ntend/src/app/components/commands/commands.component.html
+38
-31
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
...rontend/src/app/components/commands/commands.component.ts
+6
-6
common/utils/websrv/frontend/src/app/controls/infos.control.ts
...n/utils/websrv/frontend/src/app/controls/infos.control.ts
+0
-37
No files found.
common/utils/websrv/frontend/src/app/api/commands.api.ts
View file @
6e3f09a3
...
@@ -2,15 +2,6 @@ import { HttpClient } from '@angular/common/http';
...
@@ -2,15 +2,6 @@ import { HttpClient } from '@angular/common/http';
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
environment
}
from
'
src/environments/environment
'
;
import
{
environment
}
from
'
src/environments/environment
'
;
export
interface
IStatus
{
config_file
:
string
;
executable_function
:
string
;
}
export
interface
IInfos
{
display_status
:
IStatus
;
menu_cmds
:
string
[];
}
export
enum
IOptionType
{
export
enum
IOptionType
{
subcommand
=
"
subcommand
"
,
subcommand
=
"
subcommand
"
,
...
@@ -37,7 +28,9 @@ const route = '/oaisoftmodem';
...
@@ -37,7 +28,9 @@ const route = '/oaisoftmodem';
export
class
CommandsApi
{
export
class
CommandsApi
{
constructor
(
private
httpClient
:
HttpClient
)
{
}
constructor
(
private
httpClient
:
HttpClient
)
{
}
public
readInfos$
=
()
=>
this
.
httpClient
.
get
<
IInfos
>
(
environment
.
backend
+
route
);
public
readStatus$
=
()
=>
this
.
httpClient
.
get
<
IVariable
[]
>
(
environment
.
backend
+
route
+
'
/status/
'
);
public
readModules$
=
()
=>
this
.
httpClient
.
get
<
string
[]
>
(
environment
.
backend
+
route
+
'
/modules/
'
);
public
getOptions$
=
(
cmdName
:
string
)
=>
this
.
httpClient
.
get
<
IOption
[]
>
(
environment
.
backend
+
route
+
'
/module/
'
+
cmdName
);
public
getOptions$
=
(
cmdName
:
string
)
=>
this
.
httpClient
.
get
<
IOption
[]
>
(
environment
.
backend
+
route
+
'
/module/
'
+
cmdName
);
...
...
common/utils/websrv/frontend/src/app/components/commands/commands.component.html
View file @
6e3f09a3
<div
*ngIf=
"infos$ | async as infos"
>
<div
*ngIf=
"status$ | async as statusVariables"
>
<h1
mat-dialog-title
>
Status
</h1>
<h1
mat-dialog-title
>
Status
</h1>
<p>
config_file: {{ infos.display_status.config_file }}
</p>
<div
*ngFor=
"let status of statusVariables"
>
<p>
executable_function: {{ infos.display_status.executable_function }}
</p>
<div
*ngIf=
"infos$ | async as infos"
fxLaypout=
"row"
>
<h1
mat-dialog-title
>
Commands
</h1>
<mat-form-field>
<mat-form-field>
<mat-label>
Command
</mat-label>
<mat-label>
{{ status.nameFC.value }}
</mat-label>
<mat-select
[formControl]=
"selectedCmd"
[value]=
"selectedCmd?.value"
(selectionChange)=
"onSelect(selectedCmd)"
>
<input
input
matInput
[formControl]=
"status.valueFC"
/>
<mat-option
*ngFor=
"let control of infos.cmdsFA.controls"
[value]=
"control.value"
>
{{ control.value }}
</mat-option>
</mat-select>
</mat-form-field>
</mat-form-field>
<button
mat-raised-button
color=
"primary"
[disabled]=
"!status.modifiableFC.value"
(click)=
"onVarSubmit(status)"
>
set
</button>
</div>
</div>
<div
*ngIf=
"variables$ | async as variables"
fxLaypout=
"column"
>
<div
*ngIf=
"cmds$ | async as cmds"
fxLaypout=
"row"
>
<h1
mat-dialog-title
>
Variables
</h1>
<h1
mat-dialog-title
>
Commands
</h1>
<div
*ngFor=
"let variable of variables"
>
<mat-form-field>
<mat-form-field>
<mat-label>
Command
</mat-label>
<mat-label>
{{ variable.nameFC.value }}
</mat-label>
<mat-select
[formControl]=
"selectedCmd"
[value]=
"selectedCmd?.value"
(selectionChange)=
"onSelect(selectedCmd)"
>
<input
input
matInput
[formControl]=
"variable.valueFC"
/>
<mat-option
*ngFor=
"let cmd of cmds"
[value]=
"cmd"
>
{{ cmd }}
</mat-form-field>
</mat-option>
<button
mat-raised-button
color=
"primary"
[disabled]=
"!variable.modifiableFC.value"
</mat-select>
(click)=
"onVarSubmit(variable)"
>
</mat-form-field>
set
</button>
</div>
</div>
<div
*ngIf=
"subcmds$ | async as subcmds"
fxLaypout=
"column"
fxLayoutGap=
"10px"
>
<div
*ngIf=
"variables$ | async as variables"
fxLaypout=
"column"
>
<h1
mat-dialog-title
>
Sub-commands
</h1>
<h1
mat-dialog-title
>
Variables
</h1>
<button
*ngFor=
"let control of subcmds.namesFA.controls"
mat-raised-button
color=
"primary"
<div
*ngFor=
"let variable of variables"
>
(click)=
"onCmdSubmit(control.value)"
>
<mat-form-field>
{{ control.value }}
<mat-label>
{{ variable.nameFC.value }}
</mat-label>
<input
input
matInput
[formControl]=
"variable.valueFC"
/>
</mat-form-field>
<button
mat-raised-button
color=
"primary"
[disabled]=
"!variable.modifiableFC.value"
(click)=
"onVarSubmit(variable)"
>
set
</button>
</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
<div
*ngIf=
"subcmds$ | async as subcmds"
fxLaypout=
"column"
fxLayoutGap=
"10px"
>
<h1
mat-dialog-title
>
Sub-commands
</h1>
<button
*ngFor=
"let control of subcmds.namesFA.controls"
mat-raised-button
color=
"primary"
(click)=
"onCmdSubmit(control.value)"
>
{{ control.value }}
</button>
</div>
</div>
\ No newline at end of file
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
View file @
6e3f09a3
...
@@ -3,10 +3,8 @@ import { FormControl } from '@angular/forms';
...
@@ -3,10 +3,8 @@ import { FormControl } from '@angular/forms';
import
{
BehaviorSubject
}
from
'
rxjs
'
;
import
{
BehaviorSubject
}
from
'
rxjs
'
;
import
{
Observable
}
from
'
rxjs/internal/Observable
'
;
import
{
Observable
}
from
'
rxjs/internal/Observable
'
;
import
{
map
}
from
'
rxjs/internal/operators/map
'
;
import
{
map
}
from
'
rxjs/internal/operators/map
'
;
import
{
tap
}
from
'
rxjs/internal/operators/tap
'
;
import
{
CommandsApi
,
IOptionType
,
ISubCommands
,
IVariable
}
from
'
src/app/api/commands.api
'
;
import
{
CommandsApi
,
IOptionType
,
ISubCommands
,
IVariable
}
from
'
src/app/api/commands.api
'
;
import
{
SubCmdCtrl
}
from
'
src/app/controls/cmds.control
'
;
import
{
SubCmdCtrl
}
from
'
src/app/controls/cmds.control
'
;
import
{
InfosCtrl
}
from
'
src/app/controls/infos.control
'
;
import
{
VariableCtrl
}
from
'
src/app/controls/variable.control
'
;
import
{
VariableCtrl
}
from
'
src/app/controls/variable.control
'
;
import
{
LoadingService
}
from
'
src/app/services/loading.service
'
;
import
{
LoadingService
}
from
'
src/app/services/loading.service
'
;
...
@@ -20,7 +18,8 @@ export class CommandsComponent {
...
@@ -20,7 +18,8 @@ export class CommandsComponent {
IOptionType
=
IOptionType
;
IOptionType
=
IOptionType
;
infos$
:
Observable
<
InfosCtrl
>
status$
:
Observable
<
VariableCtrl
[]
>
cmds$
:
Observable
<
string
[]
>
variables$
=
new
BehaviorSubject
<
VariableCtrl
[]
>
([])
variables$
=
new
BehaviorSubject
<
VariableCtrl
[]
>
([])
subcmds$
:
BehaviorSubject
<
SubCmdCtrl
>
|
undefined
subcmds$
:
BehaviorSubject
<
SubCmdCtrl
>
|
undefined
...
@@ -32,16 +31,17 @@ export class CommandsComponent {
...
@@ -32,16 +31,17 @@ export class CommandsComponent {
public
commandsApi
:
CommandsApi
,
public
commandsApi
:
CommandsApi
,
public
loadingService
:
LoadingService
,
public
loadingService
:
LoadingService
,
)
{
)
{
this
.
infos$
=
this
.
commandsApi
.
readInfo
s$
().
pipe
(
this
.
status$
=
this
.
commandsApi
.
readStatu
s$
().
pipe
(
map
((
doc
)
=>
new
InfosCtrl
(
doc
)),
map
((
ivars
)
=>
ivars
.
map
(
ivar
=>
new
VariableCtrl
(
ivar
)))
);
);
this
.
cmds$
=
this
.
commandsApi
.
readModules$
();
}
}
onCmdSubmit
(
subCmdName
:
string
)
{
onCmdSubmit
(
subCmdName
:
string
)
{
this
.
commandsApi
.
runCommand$
(
subCmdName
).
subscribe
();
this
.
commandsApi
.
runCommand$
(
subCmdName
).
subscribe
();
}
}
onVarSubmit
(
varCtrl
:
VariableCtrl
)
{
onVarSubmit
(
varCtrl
:
VariableCtrl
)
{
this
.
commandsApi
.
setVariable$
(
varCtrl
.
api
()).
subscribe
();
this
.
commandsApi
.
setVariable$
(
varCtrl
.
api
()).
subscribe
();
}
}
...
...
common/utils/websrv/frontend/src/app/controls/infos.control.ts
deleted
100644 → 0
View file @
9ca2d78f
import
{
FormArray
,
FormControl
,
FormGroup
}
from
'
@angular/forms
'
;
import
{
IInfos
,
IStatus
}
from
'
../api/commands.api
'
;
const
enum
InfosFCN
{
menu_cmds
=
'
commands
'
,
}
export
class
InfosCtrl
extends
FormGroup
{
display_status
:
IStatus
constructor
(
icommand
:
IInfos
)
{
super
({});
this
.
display_status
=
icommand
.
display_status
this
.
addControl
(
InfosFCN
.
menu_cmds
,
new
FormArray
(
icommand
.
menu_cmds
.
map
((
cmd
)
=>
new
FormControl
(
cmd
))));
}
api
()
{
const
doc
:
IInfos
=
{
display_status
:
this
.
display_status
,
menu_cmds
:
this
.
cmdsFA
.
value
,
};
return
doc
;
}
get
cmdsFA
()
{
return
this
.
get
(
InfosFCN
.
menu_cmds
)
as
FormArray
;
}
set
cmdsFA
(
control
:
FormArray
)
{
this
.
setControl
(
InfosFCN
.
menu_cmds
,
control
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment