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
zzha zzha
OpenXG-RAN
Commits
b4e02802
Commit
b4e02802
authored
Apr 26, 2022
by
El Mghazli Yacine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display fix
parent
6dc9440b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
38 deletions
+67
-38
common/utils/websrv/frontend/src/app/api/commands.api.ts
common/utils/websrv/frontend/src/app/api/commands.api.ts
+19
-14
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
...rontend/src/app/components/commands/commands.component.ts
+15
-14
common/utils/websrv/frontend/src/app/controls/var.control.ts
common/utils/websrv/frontend/src/app/controls/var.control.ts
+1
-1
common/utils/websrv/frontend/src/app/interceptors/error.interceptor.ts
...websrv/frontend/src/app/interceptors/error.interceptor.ts
+1
-4
common/utils/websrv/frontend/src/app/services/dialog.service.ts
.../utils/websrv/frontend/src/app/services/dialog.service.ts
+31
-5
No files found.
common/utils/websrv/frontend/src/app/api/commands.api.ts
View file @
b4e02802
...
@@ -26,18 +26,6 @@ export enum ILogOutput {
...
@@ -26,18 +26,6 @@ export enum ILogOutput {
file
=
"
/tmp/<component>.log
"
,
file
=
"
/tmp/<component>.log
"
,
}
}
export
interface
IColumn
{
//should use IVariable ?
name
:
string
;
type
:
IArgType
;
modifiable
:
boolean
;
//set command ?
}
export
type
IRow
=
string
[]
export
interface
ITable
{
columns
:
IColumn
[];
rows
:
IRow
[];
}
export
enum
IArgType
{
export
enum
IArgType
{
boolean
=
"
boolean
"
,
boolean
=
"
boolean
"
,
list
=
"
list
"
,
list
=
"
list
"
,
...
@@ -51,6 +39,23 @@ export interface ICommand {
...
@@ -51,6 +39,23 @@ export interface ICommand {
confirm
?:
string
;
confirm
?:
string
;
}
}
export
interface
IColumn
{
//should use IVariable ?
name
:
string
;
type
:
IArgType
;
modifiable
:
boolean
;
//set command ?
}
export
type
IRow
=
string
[]
export
interface
ITable
{
columns
:
IColumn
[];
rows
:
IRow
[];
}
export
interface
IResp
{
display
:
string
[],
table
?:
ITable
}
const
route
=
'
/oaisoftmodem
'
;
const
route
=
'
/oaisoftmodem
'
;
@
Injectable
({
@
Injectable
({
...
@@ -63,8 +68,8 @@ export class CommandsApi {
...
@@ -63,8 +68,8 @@ export class CommandsApi {
public
readCommands$
=
(
moduleName
?:
string
)
=>
this
.
httpClient
.
get
<
ICommand
[]
>
(
environment
.
backend
+
route
+
'
/
'
+
(
moduleName
?
(
'
/
'
+
moduleName
)
:
""
)
+
'
/commands/
'
);
public
readCommands$
=
(
moduleName
?:
string
)
=>
this
.
httpClient
.
get
<
ICommand
[]
>
(
environment
.
backend
+
route
+
'
/
'
+
(
moduleName
?
(
'
/
'
+
moduleName
)
:
""
)
+
'
/commands/
'
);
public
runCommand$
=
(
command
:
ICommand
,
moduleName
:
string
)
=>
this
.
httpClient
.
post
<
I
Table
>
(
environment
.
backend
+
route
+
'
/
'
+
moduleName
+
'
/commands/
'
,
command
);
public
runCommand$
=
(
command
:
ICommand
,
moduleName
:
string
)
=>
this
.
httpClient
.
post
<
I
Resp
>
(
environment
.
backend
+
route
+
'
/
'
+
moduleName
+
'
/commands/
'
,
command
);
public
setVariable$
=
(
variable
:
IVariable
,
moduleName
?:
string
)
=>
this
.
httpClient
.
post
<
string
[]
>
(
environment
.
backend
+
route
+
(
moduleName
?
(
'
/
'
+
moduleName
)
:
""
)
+
'
/variables/
'
,
variable
);
public
setVariable$
=
(
variable
:
IVariable
,
moduleName
?:
string
)
=>
this
.
httpClient
.
post
<
IResp
>
(
environment
.
backend
+
route
+
(
moduleName
?
(
'
/
'
+
moduleName
)
:
""
)
+
'
/variables/
'
,
variable
);
}
}
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
View file @
b4e02802
import
{
Component
}
from
'
@angular/core
'
;
import
{
Component
}
from
'
@angular/core
'
;
import
{
Observable
}
from
'
rxjs/internal/Observable
'
;
import
{
Observable
}
from
'
rxjs/internal/Observable
'
;
import
{
of
}
from
'
rxjs/internal/observable/of
'
;
import
{
map
}
from
'
rxjs/internal/operators/map
'
;
import
{
map
}
from
'
rxjs/internal/operators/map
'
;
import
{
mergeMap
}
from
'
rxjs/internal/operators/mergeMap
'
;
import
{
mergeMap
}
from
'
rxjs/internal/operators/mergeMap
'
;
import
{
CommandsApi
,
IArgType
,
IColumn
}
from
'
src/app/api/commands.api
'
;
import
{
CommandsApi
,
IArgType
,
IColumn
,
ITable
}
from
'
src/app/api/commands.api
'
;
import
{
CmdCtrl
}
from
'
src/app/controls/cmd.control
'
;
import
{
CmdCtrl
}
from
'
src/app/controls/cmd.control
'
;
import
{
RowCtrl
}
from
'
src/app/controls/row.control
'
;
import
{
RowCtrl
}
from
'
src/app/controls/row.control
'
;
import
{
VarCtrl
}
from
'
src/app/controls/var.control
'
;
import
{
VarCtrl
}
from
'
src/app/controls/var.control
'
;
...
@@ -83,31 +84,31 @@ export class CommandsComponent {
...
@@ -83,31 +84,31 @@ export class CommandsComponent {
onSubVarSubmit
(
control
:
VarCtrl
)
{
onSubVarSubmit
(
control
:
VarCtrl
)
{
this
.
commandsApi
.
setVariable$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
)
this
.
commandsApi
.
setVariable$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
)
.
pipe
(
.
pipe
(
map
(
resp
=>
this
.
success
(
'
setVariable
'
+
control
.
nameFC
.
value
+
'
OK
'
,
resp
[
0
]
))
map
(
resp
=>
this
.
dialogService
.
openRespDialog
(
resp
))
).
subscribe
();
).
subscribe
();
}
}
onCmdSubmit
(
control
:
CmdCtrl
)
{
onCmdSubmit
(
control
:
CmdCtrl
)
{
// const obs = control.confirm ? this.dialogService.openConfirmDialog(control.confirm) : of(null)
this
.
rows$
=
this
.
dialogService
.
openConfirmDialog
().
pipe
(
// this.rows$ = obs.pipe(
mergeMap
(()
=>
this
.
commandsApi
.
runCommand$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
)),
// mergeMap(() => this.commandsApi.runCommand$(control.api(), `${this.selectedModule!.nameFC.value}`)),
map
(
iresp
=>
{
this
.
columns
=
iresp
.
columns
this
.
rows$
=
this
.
commandsApi
.
runCommand$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
).
pipe
(
mergeMap
(
resp
=>
{
if
(
resp
.
display
[
0
])
return
this
.
dialogService
.
openRespDialog
(
resp
,
'
cmd
'
+
control
.
nameFC
.
value
+
'
response:
'
)
else
return
of
(
resp
)
}),
map
(
resp
=>
{
this
.
columns
=
resp
.
table
!
.
columns
this
.
displayedColumns
=
this
.
columns
.
map
(
col
=>
col
.
name
)
this
.
displayedColumns
=
this
.
columns
.
map
(
col
=>
col
.
name
)
let
rows
:
RowCtrl
[]
=
[]
let
rows
:
RowCtrl
[]
=
[]
iresp
.
rows
.
map
(
row
=>
this
.
columns
.
map
(
col
=>
rows
.
push
(
new
RowCtrl
(
row
,
col
.
type
))))
resp
.
table
?
.
rows
.
map
(
row
=>
this
.
columns
.
map
(
col
=>
rows
.
push
(
new
RowCtrl
(
row
,
col
.
type
))))
return
rows
return
rows
})
})
);
);
}
}
private
success
=
(
mess
:
string
,
str
:
string
)
=>
{
return
this
.
dialogService
.
openDialog
({
title
:
mess
,
body
:
str
,
})
};
}
}
\ No newline at end of file
common/utils/websrv/frontend/src/app/controls/var.control.ts
View file @
b4e02802
...
@@ -24,7 +24,7 @@ export class VarCtrl extends FormGroup {
...
@@ -24,7 +24,7 @@ export class VarCtrl extends FormGroup {
api
()
{
api
()
{
const
doc
:
IVariable
=
{
const
doc
:
IVariable
=
{
name
:
this
.
nameFC
.
value
,
name
:
this
.
nameFC
.
value
,
value
:
this
.
valueFC
.
value
,
value
:
String
(
this
.
valueFC
.
value
),
//FIXME
type
:
this
.
typeFC
.
value
,
type
:
this
.
typeFC
.
value
,
modifiable
:
this
.
modifiableFC
.
value
modifiable
:
this
.
modifiableFC
.
value
};
};
...
...
common/utils/websrv/frontend/src/app/interceptors/error.interceptor.ts
View file @
b4e02802
...
@@ -33,10 +33,7 @@ export class ErrorInterceptor implements HttpInterceptor {
...
@@ -33,10 +33,7 @@ export class ErrorInterceptor implements HttpInterceptor {
case
501
:
case
501
:
case
500
:
case
500
:
this
.
log
(
YELLOW
,
request
.
method
+
'
'
+
error
.
status
+
'
Error:
'
+
error
.
error
);
this
.
log
(
YELLOW
,
request
.
method
+
'
'
+
error
.
status
+
'
Error:
'
+
error
.
error
);
this
.
dialogService
.
openDialog
({
this
.
dialogService
.
openErrorDialog
(
error
);
title
:
error
.
status
+
'
Error
'
,
body
:
error
.
error
,
});
break
;
break
;
default
:
default
:
...
...
common/utils/websrv/frontend/src/app/services/dialog.service.ts
View file @
b4e02802
import
{
HttpErrorResponse
}
from
'
@angular/common/http
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
MatDialog
}
from
'
@angular/material/dialog
'
;
import
{
MatDialog
}
from
'
@angular/material/dialog
'
;
import
{
MatSnackBar
}
from
'
@angular/material/snack-bar
'
;
import
{
MatSnackBar
}
from
'
@angular/material/snack-bar
'
;
import
{
Observable
}
from
'
rxjs/internal/Observable
'
;
import
{
of
}
from
'
rxjs/internal/observable/of
'
;
import
{
of
}
from
'
rxjs/internal/observable/of
'
;
import
{
tap
}
from
'
rxjs/internal/operators/tap
'
;
import
{
tap
}
from
'
rxjs/internal/operators/tap
'
;
import
{
IResp
}
from
'
../api/commands.api
'
;
import
{
ConfirmDialogComponent
}
from
'
../components/confirm/confirm.component
'
;
import
{
ConfirmDialogComponent
}
from
'
../components/confirm/confirm.component
'
;
import
{
ErrorDialogComponent
}
from
'
../components/error-dialog/error-dialog.component
'
;
import
{
ErrorDialogComponent
}
from
'
../components/error-dialog/error-dialog.component
'
;
...
@@ -17,22 +20,44 @@ export class DialogService {
...
@@ -17,22 +20,44 @@ export class DialogService {
private
_snackBar
:
MatSnackBar
,
private
_snackBar
:
MatSnackBar
,
)
{
}
)
{
}
open
Dialog
(
data
:
any
):
any
{
open
ErrorDialog
(
error
:
HttpErrorResponse
):
Observable
<
any
>
{
if
(
this
.
isDialogOpen
)
{
if
(
this
.
isDialogOpen
)
{
return
false
;
return
of
(
undefined
);
}
this
.
isDialogOpen
=
true
;
return
this
.
_dialog
.
open
(
ErrorDialogComponent
,
{
width
:
'
900px
'
,
data
:
{
title
:
error
.
status
+
'
Error
'
,
body
:
error
.
error
,
},
}).
afterClosed
()
.
pipe
(
tap
(()
=>
this
.
isDialogOpen
=
false
));
}
openRespDialog
(
resp
:
IResp
,
title
?:
string
):
Observable
<
IResp
>
{
if
(
this
.
isDialogOpen
||
!
resp
.
display
.
length
)
{
return
of
(
resp
);
}
}
this
.
isDialogOpen
=
true
;
this
.
isDialogOpen
=
true
;
const
dialogRef
=
this
.
_dialog
.
open
(
ErrorDialogComponent
,
{
const
dialogRef
=
this
.
_dialog
.
open
(
ErrorDialogComponent
,
{
width
:
'
900px
'
,
width
:
'
900px
'
,
data
,
data
:
{
title
:
title
,
body
:
resp
.
display
!
.
join
(
"
</p><p>
"
)
},
});
});
dialogRef
.
afterClosed
().
subscribe
((
_
)
=>
{
dialogRef
.
afterClosed
().
subscribe
((
_
)
=>
{
console
.
log
(
'
The dialog was closed
'
);
console
.
log
(
'
The dialog was closed
'
);
this
.
isDialogOpen
=
false
;
this
.
isDialogOpen
=
false
;
});
});
return
of
(
resp
)
}
}
openSnackBar
(
title
:
string
):
void
{
openSnackBar
(
title
:
string
):
void
{
...
@@ -43,7 +68,7 @@ export class DialogService {
...
@@ -43,7 +68,7 @@ export class DialogService {
});
});
}
}
openConfirmDialog
()
{
openConfirmDialog
(
question
:
string
)
{
if
(
this
.
isDialogOpen
)
{
if
(
this
.
isDialogOpen
)
{
return
of
(
undefined
);
return
of
(
undefined
);
}
}
...
@@ -51,7 +76,8 @@ export class DialogService {
...
@@ -51,7 +76,8 @@ export class DialogService {
this
.
isDialogOpen
=
true
;
this
.
isDialogOpen
=
true
;
return
this
.
_dialog
.
open
(
ConfirmDialogComponent
,
{
return
this
.
_dialog
.
open
(
ConfirmDialogComponent
,
{
width
:
'
300px
'
width
:
'
300px
'
,
data
:
{
title
:
question
}
})
})
.
afterClosed
()
.
afterClosed
()
.
pipe
(
tap
(()
=>
this
.
isDialogOpen
=
false
));
.
pipe
(
tap
(()
=>
this
.
isDialogOpen
=
false
));
...
...
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