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
Michael Black
OpenXG-RAN
Commits
9d2b7475
Commit
9d2b7475
authored
Apr 25, 2022
by
El Mghazli Yacine
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'websrv-table' into websrv
parents
12099a91
2761d013
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
67 deletions
+103
-67
common/utils/websrv/frontend/src/app/api/commands.api.ts
common/utils/websrv/frontend/src/app/api/commands.api.ts
+1
-13
common/utils/websrv/frontend/src/app/components/commands/commands.component.html
...ntend/src/app/components/commands/commands.component.html
+14
-42
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
...rontend/src/app/components/commands/commands.component.ts
+16
-12
common/utils/websrv/frontend/src/app/controls/row.control.ts
common/utils/websrv/frontend/src/app/controls/row.control.ts
+72
-0
No files found.
common/utils/websrv/frontend/src/app/api/commands.api.ts
View file @
9d2b7475
...
...
@@ -26,13 +26,6 @@ export enum ILogOutput {
file
=
"
/tmp/<component>.log
"
,
}
export
interface
ILog
{
component
:
string
;
level
:
ILogLvl
;
output
:
ILogOutput
;
enabled
:
boolean
;
}
export
interface
IColumn
{
//should use IVariable ?
name
:
string
;
type
:
IArgType
;
...
...
@@ -45,11 +38,6 @@ export interface ITable {
rows
:
IRow
[];
}
export
interface
IResp
{
display
:
string
[],
logs
?:
ILog
[]
}
export
enum
IArgType
{
boolean
=
"
boolean
"
,
list
=
"
list
"
,
...
...
@@ -75,7 +63,7 @@ export class CommandsApi {
public
readCommands$
=
(
moduleName
?:
string
)
=>
this
.
httpClient
.
get
<
ICommand
[]
>
(
environment
.
backend
+
route
+
'
/
'
+
(
moduleName
?
(
'
/
'
+
moduleName
)
:
""
)
+
'
/commands/
'
);
public
runCommand$
=
(
command
:
ICommand
,
moduleName
:
string
)
=>
this
.
httpClient
.
post
<
I
Resp
>
(
environment
.
backend
+
route
+
'
/
'
+
moduleName
+
'
/commands/
'
,
command
);
public
runCommand$
=
(
command
:
ICommand
,
moduleName
:
string
)
=>
this
.
httpClient
.
post
<
I
Table
>
(
environment
.
backend
+
route
+
'
/
'
+
moduleName
+
'
/commands/
'
,
command
);
public
setVariable$
=
(
variable
:
IVariable
,
moduleName
?:
string
)
=>
this
.
httpClient
.
post
<
string
[]
>
(
environment
.
backend
+
route
+
(
moduleName
?
(
'
/
'
+
moduleName
)
:
""
)
+
'
/variables/
'
,
variable
);
...
...
common/utils/websrv/frontend/src/app/components/commands/commands.component.html
View file @
9d2b7475
...
...
@@ -50,59 +50,31 @@
</div>
<mat-table
*ngIf=
"logs$ | async as logs"
mat-table
[dataSource]=
"logs
"
multiTemplateDataRows
class=
"mat-elevation-z8"
>
<mat-table
mat-table
[dataSource]=
"rows$
"
multiTemplateDataRows
class=
"mat-elevation-z8"
>
<!-- For anyone who has set the multiTemplateDataRows property of mat-table to true,
you can't use index. Instead you have use either dataIndex or renderIndex.
See https://github.com/angular/material2/issues/12793 -->
<div
matColumnDef=
"component"
>
<mat-header-cell
*matHeaderCellDef
>
Component
</mat-header-cell>
<mat-cell
*matCellDef=
"let log"
>
<div
fxLayout=
"row"
fxLayoutAlign=
"start end"
>
<p>
{{log.component}}
</p>
</div>
</mat-cell>
</div>
<div
matColumnDef=
"level"
>
<mat-header-cell
*matHeaderCellDef
>
Level
</mat-header-cell>
<mat-cell
*matCellDef=
"let log"
>
<div
fxLayout=
"row"
fxLayoutAlign=
"start end"
>
<p>
{{log.level}}
</p>
</div>
</mat-cell>
</div>
<div
matColumnDef=
"output"
>
<mat-header-cell
*matHeaderCellDef
>
Output
</mat-header-cell>
<mat-cell
*matCellDef=
"let log"
>
<div
fxLayout=
"row"
fxLayoutAlign=
"start end"
>
<p>
{{log.output}}
</p>
<div
*ngFor=
"let col of columns; index as colIndex"
matColumnDef=
"{{col.name}}"
>
<mat-header-cell
*matHeaderCellDef
>
<div>
<h4>
{{ col.name }}
</h4>
</div>
</mat-cell>
</div>
<div
matColumnDef=
"enabled"
>
<mat-header-cell
*matHeaderCellDef
>
Enabled
</mat-header-cell>
<mat-cell
*matCellDef=
"let log"
>
<div
fxLayout=
"row"
fxLayoutAlign=
"start end"
>
<p>
{{log.enabled}}
</p>
</div>
<mat-cell
*matCellDef=
"let row; dataIndex as rowIndex"
>
<mat-form-field
[ngSwitch]=
"col.type"
>
<mat-slide-toggle
*ngSwitchCase=
"IOptionType.boolean"
[formControl]=
"row.booleanFC"
[checked]=
"row.isEnabledFC.value"
[disabled]=
"!col.modifiable"
></mat-slide-toggle>
<input
*ngSwitchCase=
"IOptionType.boolean"
matInput
[formControl]=
"row.stringFC"
[disabled]=
"!col.modifiable"
/>
</mat-form-field>
</mat-cell>
</div>
<mat-header-row
*matHeaderRowDef=
"DISPLAYED_COLUMNS"
></mat-header-row>
<mat-row
*matRowDef=
"let stageCtrl; columns: DISPLAYED_COLUMNS"
></mat-row>
<mat-header-row
*matHeaderRowDef=
"displayedColumns"
></mat-header-row>
<mat-row
*matRowDef=
"let row; columns: displayedColumns"
></mat-row>
</mat-table>
...
...
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
View file @
9d2b7475
import
{
Component
}
from
'
@angular/core
'
;
import
{
Observable
}
from
'
rxjs/internal/Observable
'
;
import
{
map
}
from
'
rxjs/internal/operators/map
'
;
<<<<<<<
HEAD
import
{
tap
,
mergeMap
,
filter
}
from
'
rxjs/operators
'
;
import
{
CommandsApi
,
IArgType
,
ILog
}
from
'
src/app/api/commands.api
'
;
=======
import
{
CommandsApi
,
IArgType
,
IColumn
,
IRow
}
from
'
src/app/api/commands.api
'
;
>>>>>>>
websrv
-
table
import
{
CmdCtrl
}
from
'
src/app/controls/cmd.control
'
;
import
{
RowCtrl
}
from
'
src/app/controls/row.control
'
;
import
{
VarCtrl
}
from
'
src/app/controls/var.control
'
;
import
{
DialogService
}
from
'
src/app/services/dialog.service
'
;
import
{
LoadingService
}
from
'
src/app/services/loading.service
'
;
...
...
@@ -32,14 +37,9 @@ export class CommandsComponent {
// selectedArg?: VarCtrl
//table columns
DISPLAYED_COLUMNS
=
[
'
component
'
,
'
level
'
,
'
output
'
,
'
enabled
'
]
logs$
:
Observable
<
ILog
[]
>
=
new
Observable
<
ILog
[]
>
()
displayedColumns
:
string
[]
=
[]
rows$
:
Observable
<
RowCtrl
[]
>
=
new
Observable
<
RowCtrl
[]
>
()
columns
:
IColumn
[]
=
[]
constructor
(
public
commandsApi
:
CommandsApi
,
...
...
@@ -92,10 +92,14 @@ export class CommandsComponent {
}
onCmdSubmit
(
control
:
CmdCtrl
)
{
this
.
logs$
=
this
.
dialogService
.
openConfirmDialog
().
pipe
(
mergeMap
(()
=>
this
.
commandsApi
.
runCommand$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
)),
tap
(
resp
=>
this
.
success
(
'
runCommand
'
+
control
.
nameFC
.
value
+
'
OK
'
,
resp
.
display
!
.
join
(
"
</p><p>
"
))),
map
(
iresp
=>
iresp
.
logs
!
)
this
.
rows$
=
this
.
commandsApi
.
runCommand$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
).
pipe
(
map
(
iresp
=>
{
this
.
columns
=
iresp
.
columns
this
.
displayedColumns
=
this
.
columns
.
map
(
col
=>
col
.
name
)
let
rows
:
RowCtrl
[]
=
[]
iresp
.
rows
.
map
(
row
=>
this
.
columns
.
map
(
col
=>
rows
.
push
(
new
RowCtrl
(
row
,
col
.
type
))))
return
rows
})
);
}
...
...
common/utils/websrv/frontend/src/app/controls/row.control.ts
0 → 100644
View file @
9d2b7475
import
{
FormControl
,
FormGroup
}
from
'
@angular/forms
'
;
import
{
IArgType
,
IRow
}
from
'
../api/commands.api
'
;
export
class
RowCtrl
extends
FormGroup
{
type
:
IArgType
constructor
(
irow
:
IRow
,
type
:
IArgType
)
{
super
({});
this
.
type
=
type
this
.
addControl
(
type
,
new
FormControl
(
irow
));
}
api
()
{
switch
(
this
.
type
)
{
case
IArgType
.
boolean
:
return
this
.
boolFC
.
value
?
"
true
"
:
"
false
"
;
// case IArgType.list:
// return this.listFC.value as string;
case
IArgType
.
number
:
return
this
.
numberFC
.
value
as
string
;
// case IArgType.range:
// return this.rangeFC.value as string;
case
IArgType
.
string
:
return
this
.
stringFC
.
value
}
}
get
boolFC
()
{
return
this
.
get
(
IArgType
.
boolean
)
as
FormControl
;
}
set
boolFC
(
control
:
FormControl
)
{
this
.
setControl
(
IArgType
.
boolean
,
control
);
}
get
listFC
()
{
return
this
.
get
(
IArgType
.
list
)
as
FormControl
;
}
set
listFC
(
control
:
FormControl
)
{
this
.
setControl
(
IArgType
.
list
,
control
);
}
get
numberFC
()
{
return
this
.
get
(
IArgType
.
number
)
as
FormControl
;
}
set
numberFC
(
control
:
FormControl
)
{
this
.
setControl
(
IArgType
.
number
,
control
);
}
get
rangeFC
()
{
return
this
.
get
(
IArgType
.
range
)
as
FormControl
;
}
set
rangeFC
(
control
:
FormControl
)
{
this
.
setControl
(
IArgType
.
range
,
control
);
}
get
stringFC
()
{
return
this
.
get
(
IArgType
.
string
)
as
FormControl
;
}
set
stringFC
(
control
:
FormControl
)
{
this
.
setControl
(
IArgType
.
string
,
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