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
2027d77b
Commit
2027d77b
authored
Apr 04, 2022
by
El Mghazli Yacine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APIv2.1
parent
6e3f09a3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
145 additions
and
112 deletions
+145
-112
common/utils/websrv/frontend/src/app/api/commands.api.ts
common/utils/websrv/frontend/src/app/api/commands.api.ts
+19
-16
common/utils/websrv/frontend/src/app/components/commands/commands.component.html
...ntend/src/app/components/commands/commands.component.html
+37
-17
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
...rontend/src/app/components/commands/commands.component.ts
+42
-25
common/utils/websrv/frontend/src/app/controls/cmd.control.ts
common/utils/websrv/frontend/src/app/controls/cmd.control.ts
+32
-0
common/utils/websrv/frontend/src/app/controls/cmds.control.ts
...on/utils/websrv/frontend/src/app/controls/cmds.control.ts
+0
-34
common/utils/websrv/frontend/src/app/controls/options.control.ts
...utils/websrv/frontend/src/app/controls/options.control.ts
+0
-13
common/utils/websrv/frontend/src/app/controls/var.control.ts
common/utils/websrv/frontend/src/app/controls/var.control.ts
+15
-7
No files found.
common/utils/websrv/frontend/src/app/api/commands.api.ts
View file @
2027d77b
...
@@ -3,21 +3,22 @@ import { Injectable } from '@angular/core';
...
@@ -3,21 +3,22 @@ import { Injectable } from '@angular/core';
import
{
environment
}
from
'
src/environments/environment
'
;
import
{
environment
}
from
'
src/environments/environment
'
;
export
enum
IOptionType
{
export
interface
IVariable
{
subcommand
=
"
subcommand
"
,
name
:
string
;
variable
=
"
variable
"
value
:
string
;
type
:
IArgType
;
modifiable
:
boolean
;
//set command ?
}
}
export
interface
IOption
{
type
:
IOptionType
;
export
enum
IArgType
{
boolean
=
"
boolean
"
,
list
=
"
list
"
,
range
=
"
range
"
,
string
=
"
string
"
}
}
export
interface
I
Variable
extends
IOption
{
export
interface
I
Command
{
name
:
string
;
name
:
string
;
value
:
string
;
modifiable
:
boolean
;
}
export
interface
ISubCommands
extends
IOption
{
name
:
string
[];
}
}
const
route
=
'
/oaisoftmodem
'
;
const
route
=
'
/oaisoftmodem
'
;
...
@@ -28,14 +29,16 @@ const route = '/oaisoftmodem';
...
@@ -28,14 +29,16 @@ const route = '/oaisoftmodem';
export
class
CommandsApi
{
export
class
CommandsApi
{
constructor
(
private
httpClient
:
HttpClient
)
{
}
constructor
(
private
httpClient
:
HttpClient
)
{
}
public
readStatus$
=
()
=>
this
.
httpClient
.
get
<
IVariable
[]
>
(
environment
.
backend
+
route
+
'
/status/
'
);
public
readVariables$
=
()
=>
this
.
httpClient
.
get
<
IVariable
[]
>
(
environment
.
backend
+
route
+
'
/variables/
'
);
public
readCommands$
=
()
=>
this
.
httpClient
.
get
<
ICommand
[]
>
(
environment
.
backend
+
route
+
'
/commands/
'
);
public
readModule
s$
=
()
=>
this
.
httpClient
.
get
<
string
[]
>
(
environment
.
backend
+
route
+
'
/modules/
'
);
public
readModule
Variables$
=
(
moduleName
:
string
)
=>
this
.
httpClient
.
get
<
IVariable
[]
>
(
environment
.
backend
+
route
+
'
/variables/
'
+
moduleName
);
public
getOptions$
=
(
cmdName
:
string
)
=>
this
.
httpClient
.
get
<
IOption
[]
>
(
environment
.
backend
+
route
+
'
/module/
'
+
cmd
Name
);
public
readModuleCommands$
=
(
moduleName
:
string
)
=>
this
.
httpClient
.
get
<
ICommand
[]
>
(
environment
.
backend
+
route
+
'
/commands/
'
+
module
Name
);
public
runCommand$
=
(
c
mdName
:
string
)
=>
this
.
httpClient
.
post
<
string
>
(
environment
.
backend
+
route
+
'
/command/
'
+
cmdName
,
{}
);
public
runCommand$
=
(
c
ommand
:
ICommand
)
=>
this
.
httpClient
.
post
<
string
>
(
environment
.
backend
+
route
+
'
/run/
'
,
command
);
public
setVariable$
=
(
variable
:
IVariable
)
=>
this
.
httpClient
.
post
<
string
>
(
environment
.
backend
+
route
+
'
/
variable/
'
+
variable
.
name
,
variable
.
valu
e
);
public
setVariable$
=
(
variable
:
IVariable
)
=>
this
.
httpClient
.
post
<
string
>
(
environment
.
backend
+
route
+
'
/
set/
'
,
variabl
e
);
}
}
common/utils/websrv/frontend/src/app/components/commands/commands.component.html
View file @
2027d77b
<div
*ngIf=
"
status$ | async as statusVariable
s"
>
<div
*ngIf=
"
vars$ | async as var
s"
>
<h1
mat-dialog-title
>
Statu
s
</h1>
<h1
mat-dialog-title
>
Variable
s
</h1>
<div
*ngFor=
"let
status of statusVariable
s"
>
<div
*ngFor=
"let
variable of var
s"
>
<mat-form-field>
<mat-form-field>
<mat-label>
{{
status
.nameFC.value }}
</mat-label>
<mat-label>
{{
variable
.nameFC.value }}
</mat-label>
<input
input
matInput
[formControl]=
"
status
.valueFC"
/>
<input
input
matInput
[formControl]=
"
variable
.valueFC"
/>
</mat-form-field>
</mat-form-field>
<button
mat-raised-button
color=
"primary"
[disabled]=
"!
status.modifiableFC.value"
(click)=
"onVarSubmit(status
)"
>
<button
mat-raised-button
color=
"primary"
[disabled]=
"!
variable.modifiableFC.value"
(click)=
"onVarSubmit(variable
)"
>
set
set
</button>
</button>
</div>
</div>
</div>
</div>
<div
*ngIf=
"cmds$ | async as cmds"
fxLaypout=
"row"
>
<div
*ngIf=
"cmds$ | async as cmds"
fxLaypout=
"row"
>
<h1
mat-dialog-title
>
Command
s
</h1>
<h1
mat-dialog-title
>
Menu
s
</h1>
<mat-form-field>
<mat-form-field>
<mat-label>
Command
</mat-label>
<mat-label>
Command
</mat-label>
<mat-select
[formControl]=
"selectedCmd"
[value]=
"selectedCmd?.value"
(selectionChange)=
"onSelect(selectedCmd)"
>
<mat-select
[formControl]=
"selectedCmd!.nameFC"
[value]=
"selectedCmd!.nameFC.value"
<mat-option
*ngFor=
"let cmd of cmds"
[value]=
"cmd"
>
{{ cmd }}
(selectionChange)=
"onCmdSelect(selectedCmd!)"
>
<mat-option
*ngFor=
"let cmd of cmds"
[value]=
"cmd"
>
{{ cmd.nameFC.value }}
</mat-option>
</mat-option>
</mat-select>
</mat-select>
</mat-form-field>
</mat-form-field>
<div
*ngIf=
"
variables$ | async as variable
s"
fxLaypout=
"column"
>
<div
*ngIf=
"
subvars$ | async as subvar
s"
fxLaypout=
"column"
>
<h1
mat-dialog-title
>
Variables
</h1>
<h1
mat-dialog-title
>
Sub-
Variables
</h1>
<div
*ngFor=
"let variable of
variable
s"
>
<div
*ngFor=
"let variable of
subvar
s"
>
<mat-form-field>
<mat-form-field>
<mat-label>
{{ variable.nameFC.value }}
</mat-label>
<mat-label>
{{ variable.nameFC.value }}
</mat-label>
<input
input
matInput
[formControl]=
"variable.valueFC"
/>
<input
input
matInput
[formControl]=
"variable.valueFC"
/>
</mat-form-field>
</mat-form-field>
<button
mat-raised-button
color=
"primary"
[disabled]=
"!variable.modifiableFC.value"
<button
mat-raised-button
color=
"primary"
[disabled]=
"!variable.modifiableFC.value"
(click)=
"onVarSubmit(variable)"
>
(click)=
"onVarSubmit(variable)"
>
s
e
t
s
ubmi
t
</button>
</button>
</div>
</div>
</div>
</div>
<div
*ngIf=
"subcmds$ | async as subcmds"
fxLaypout=
"column"
fxLayoutGap=
"10px"
>
<div
*ngIf=
"subcmds$ | async as subcmds"
fxLaypout=
"column"
fxLayoutGap=
"10px"
>
<h1
mat-dialog-title
>
Sub-commands
</h1>
<h1
mat-dialog-title
>
Sub-commands
</h1>
<button
*ngFor=
"let control of subcmds.namesFA.controls"
mat-raised-button
color=
"primary"
<mat-form-field>
(click)=
"onCmdSubmit(control.value)"
>
<mat-label>
Command
</mat-label>
{{ control.value }}
<mat-select
[formControl]=
"selectedSubCmd!.nameFC"
[value]=
"selectedSubCmd!.nameFC.value"
</button>
(selectionChange)=
"onSubCmdSelect(selectedSubCmd!)"
>
<mat-option
*ngFor=
"let cmd of subcmds"
[value]=
"cmd"
>
{{ cmd.nameFC.value }}
</mat-option>
</mat-select>
</mat-form-field>
<div
*ngIf=
"args$ | async as args"
fxLaypout=
"column"
>
<h1
mat-dialog-title
>
Sub-Variables
</h1>
<div
*ngFor=
"let variable of args"
>
<mat-form-field>
<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)"
>
submit
</button>
</div>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
View file @
2027d77b
import
{
Component
}
from
'
@angular/core
'
;
import
{
Component
}
from
'
@angular/core
'
;
import
{
FormControl
}
from
'
@angular/forms
'
;
import
{
FormControl
}
from
'
@angular/forms
'
;
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
{
CommandsApi
,
I
OptionType
,
ISubCommands
,
IVariabl
e
}
from
'
src/app/api/commands.api
'
;
import
{
CommandsApi
,
I
ArgTyp
e
}
from
'
src/app/api/commands.api
'
;
import
{
SubCmdCtrl
}
from
'
src/app/controls/cmds
.control
'
;
import
{
CmdCtrl
}
from
'
src/app/controls/cmd
.control
'
;
import
{
VariableCtrl
}
from
'
src/app/controls/variable
.control
'
;
import
{
VariableCtrl
as
VarCtrl
}
from
'
src/app/controls/var
.control
'
;
import
{
LoadingService
}
from
'
src/app/services/loading.service
'
;
import
{
LoadingService
}
from
'
src/app/services/loading.service
'
;
...
@@ -16,41 +15,59 @@ import { LoadingService } from 'src/app/services/loading.service';
...
@@ -16,41 +15,59 @@ import { LoadingService } from 'src/app/services/loading.service';
})
})
export
class
CommandsComponent
{
export
class
CommandsComponent
{
IOptionType
=
I
Option
Type
;
IOptionType
=
I
Arg
Type
;
status$
:
Observable
<
Variable
Ctrl
[]
>
vars$
:
Observable
<
Var
Ctrl
[]
>
cmds$
:
Observable
<
string
[]
>
cmds$
:
Observable
<
CmdCtrl
[]
>
variables$
=
new
BehaviorSubject
<
VariableCtrl
[]
>
([])
selectedCmd
?:
CmdCtrl
s
ubcmds$
:
BehaviorSubject
<
SubCmdCtrl
>
|
undefined
s
electedVar
?:
VarCtrl
selectedCmd
=
new
FormControl
()
subvars$
?:
Observable
<
VarCtrl
[]
>
selectedSubCmd
=
new
FormControl
()
subcmds$
?:
Observable
<
CmdCtrl
[]
>
selectedVariable
?:
VariableCtrl
selectedSubCmd
?:
CmdCtrl
selectedSubVar
?:
VarCtrl
args$
?:
Observable
<
VarCtrl
[]
>
selectedArg
?:
VarCtrl
constructor
(
constructor
(
public
commandsApi
:
CommandsApi
,
public
commandsApi
:
CommandsApi
,
public
loadingService
:
LoadingService
,
public
loadingService
:
LoadingService
,
)
{
)
{
this
.
status$
=
this
.
commandsApi
.
readStatu
s$
().
pipe
(
this
.
vars$
=
this
.
commandsApi
.
readVariable
s$
().
pipe
(
map
((
ivars
)
=>
ivars
.
map
(
ivar
=>
new
Var
iable
Ctrl
(
ivar
)))
map
((
ivars
)
=>
ivars
.
map
(
ivar
=>
new
VarCtrl
(
ivar
)))
);
);
this
.
cmds$
=
this
.
commandsApi
.
readModules$
();
this
.
cmds$
=
this
.
commandsApi
.
readCommands$
().
pipe
(
map
((
ivars
)
=>
ivars
.
map
(
ivar
=>
new
CmdCtrl
(
ivar
)))
);
}
}
onCmdSubmit
(
subCmdName
:
string
)
{
onCmdSubmit
(
control
:
CmdCtrl
)
{
this
.
commandsApi
.
runCommand$
(
subCmdName
).
subscribe
();
this
.
commandsApi
.
runCommand$
(
control
.
api
()).
subscribe
();
}
onCmdSelect
(
control
:
CmdCtrl
)
{
this
.
subcmds$
=
this
.
commandsApi
.
readModuleCommands$
(
control
.
nameFC
.
value
).
pipe
(
map
(
cmds
=>
cmds
.
map
(
cmd
=>
new
CmdCtrl
(
cmd
))),
// tap(cmds => [this.selectedSubCmd] = cmds)
)
this
.
subvars$
=
this
.
commandsApi
.
readModuleVariables$
(
control
.
nameFC
.
value
).
pipe
(
map
(
vars
=>
vars
.
map
(
v
=>
new
VarCtrl
(
v
))),
// tap(vars => [this.selectedSubVar] = vars)
)
}
}
onVarSubmit
(
varCtrl
:
VariableCtrl
)
{
onSubCmdSelect
(
control
:
CmdCtrl
)
{
this
.
commandsApi
.
setVariable$
(
varCtrl
.
api
()).
subscribe
();
this
.
args$
=
this
.
commandsApi
.
readModuleVariables$
(
control
.
nameFC
.
value
).
pipe
(
map
(
vars
=>
vars
.
map
(
v
=>
new
VarCtrl
(
v
))),
// tap(vars => [this.selectedSubVar] = vars)
)
}
}
onSelect
(
cmdNameFC
:
FormControl
)
{
onVarSubmit
(
control
:
VarCtrl
)
{
this
.
commandsApi
.
getOptions$
(
cmdNameFC
.
value
).
subscribe
(
opts
=>
{
control
.
nameFC
=
new
FormControl
(
`
${
this
.
selectedCmd
?.
nameFC
.
value
}
${
this
.
selectedSubCmd
?.
nameFC
.
value
}
${
control
.
nameFC
.
value
}
`
.
trim
())
this
.
variables$
.
next
(
opts
.
filter
(
iopt
=>
iopt
.
type
===
IOptionType
.
variable
).
map
(
iopt
=>
new
VariableCtrl
(
iopt
as
IVariable
)))
this
.
commandsApi
.
setVariable$
(
control
.
api
()).
subscribe
();
const
[
subCmds
]
=
opts
.
filter
(
iopt
=>
iopt
.
type
===
IOptionType
.
subcommand
)
this
.
subcmds$
=
new
BehaviorSubject
<
SubCmdCtrl
>
(
new
SubCmdCtrl
(
subCmds
as
ISubCommands
))
})
}
}
}
}
common/utils/websrv/frontend/src/app/controls/cmd.control.ts
0 → 100644
View file @
2027d77b
import
{
FormControl
,
FormGroup
}
from
'
@angular/forms
'
;
import
{
ICommand
}
from
'
../api/commands.api
'
;
const
enum
CmdFCN
{
name
=
'
name
'
,
}
export
class
CmdCtrl
extends
FormGroup
{
constructor
(
cmd
:
ICommand
)
{
super
({});
this
.
addControl
(
CmdFCN
.
name
,
new
FormControl
(
cmd
.
name
));
}
api
()
{
const
doc
:
ICommand
=
{
name
:
this
.
nameFC
.
value
};
return
doc
;
}
get
nameFC
()
{
return
this
.
get
(
CmdFCN
.
name
)
as
FormControl
;
}
set
nameFC
(
fc
:
FormControl
)
{
this
.
setControl
(
CmdFCN
.
name
,
fc
);
}
}
common/utils/websrv/frontend/src/app/controls/cmds.control.ts
deleted
100644 → 0
View file @
6e3f09a3
import
{
FormArray
,
FormControl
}
from
'
@angular/forms
'
;
import
{
ISubCommands
}
from
'
../api/commands.api
'
;
import
{
OptionsCtrl
}
from
'
./options.control
'
;
const
enum
SubCmdsFCN
{
names
=
'
names
'
,
}
export
class
SubCmdCtrl
extends
OptionsCtrl
{
constructor
(
isubs
:
ISubCommands
)
{
super
(
isubs
);
this
.
addControl
(
SubCmdsFCN
.
names
,
new
FormArray
(
isubs
.
name
.
map
((
name
)
=>
new
FormControl
(
name
))));
}
api
()
{
const
doc
:
ISubCommands
=
{
type
:
this
.
type
,
name
:
this
.
namesFA
.
value
};
return
doc
;
}
get
namesFA
()
{
return
this
.
get
(
SubCmdsFCN
.
names
)
as
FormArray
;
}
set
namesFA
(
fa
:
FormArray
)
{
this
.
setControl
(
SubCmdsFCN
.
names
,
fa
);
}
}
common/utils/websrv/frontend/src/app/controls/options.control.ts
deleted
100644 → 0
View file @
6e3f09a3
import
{
FormGroup
}
from
"
@angular/forms
"
;
import
{
IOption
,
IOptionType
}
from
"
../api/commands.api
"
;
export
class
OptionsCtrl
extends
FormGroup
{
type
:
IOptionType
constructor
(
ioption
:
IOption
)
{
super
({});
this
.
type
=
ioption
.
type
}
}
\ No newline at end of file
common/utils/websrv/frontend/src/app/controls/var
iable
.control.ts
→
common/utils/websrv/frontend/src/app/controls/var.control.ts
View file @
2027d77b
import
{
FormControl
}
from
'
@angular/forms
'
;
import
{
FormControl
,
FormGroup
}
from
'
@angular/forms
'
;
import
{
IOptionType
,
IVariable
}
from
'
../api/commands.api
'
;
import
{
IVariable
}
from
'
../api/commands.api
'
;
import
{
OptionsCtrl
}
from
'
./options.control
'
;
const
enum
VariablesFCN
{
const
enum
VariablesFCN
{
name
=
'
name
'
,
name
=
'
name
'
,
value
=
"
value
"
,
value
=
"
value
"
,
type
=
"
type
"
,
modifiable
=
"
modifiable
"
modifiable
=
"
modifiable
"
}
}
export
class
VariableCtrl
extends
OptionsCtrl
{
export
class
VariableCtrl
extends
FormGroup
{
constructor
(
ivar
:
IVariable
)
{
constructor
(
ivar
:
IVariable
)
{
super
(
ivar
);
super
(
{}
);
this
.
addControl
(
VariablesFCN
.
name
,
new
FormControl
(
ivar
.
name
));
this
.
addControl
(
VariablesFCN
.
name
,
new
FormControl
(
ivar
.
name
));
this
.
addControl
(
VariablesFCN
.
value
,
new
FormControl
(
ivar
.
value
));
this
.
addControl
(
VariablesFCN
.
value
,
new
FormControl
(
ivar
.
value
));
this
.
addControl
(
VariablesFCN
.
type
,
new
FormControl
(
ivar
.
type
));
this
.
addControl
(
VariablesFCN
.
modifiable
,
new
FormControl
(
ivar
.
modifiable
));
this
.
addControl
(
VariablesFCN
.
modifiable
,
new
FormControl
(
ivar
.
modifiable
));
}
}
api
()
{
api
()
{
const
doc
:
IVariable
=
{
const
doc
:
IVariable
=
{
type
:
this
.
type
,
name
:
this
.
nameFC
.
value
,
name
:
this
.
nameFC
.
value
,
value
:
this
.
valueFC
.
value
,
value
:
this
.
valueFC
.
value
,
type
:
this
.
typeFC
.
value
,
modifiable
:
this
.
modifiableFC
.
value
modifiable
:
this
.
modifiableFC
.
value
};
};
...
@@ -48,6 +48,14 @@ export class VariableCtrl extends OptionsCtrl {
...
@@ -48,6 +48,14 @@ export class VariableCtrl extends OptionsCtrl {
this
.
setControl
(
VariablesFCN
.
value
,
control
);
this
.
setControl
(
VariablesFCN
.
value
,
control
);
}
}
get
typeFC
()
{
return
this
.
get
(
VariablesFCN
.
value
)
as
FormControl
;
}
set
typeFC
(
control
:
FormControl
)
{
this
.
setControl
(
VariablesFCN
.
value
,
control
);
}
get
modifiableFC
()
{
get
modifiableFC
()
{
return
this
.
get
(
VariablesFCN
.
modifiable
)
as
FormControl
;
return
this
.
get
(
VariablesFCN
.
modifiable
)
as
FormControl
;
}
}
...
...
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