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
b203d4ae
Commit
b203d4ae
authored
Apr 14, 2022
by
El Mghazli Yacine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openDialog
parent
dfa75798
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
46 deletions
+54
-46
common/utils/websrv/frontend/src/app/api/commands.api.ts
common/utils/websrv/frontend/src/app/api/commands.api.ts
+16
-16
common/utils/websrv/frontend/src/app/components/commands/commands.component.html
...ntend/src/app/components/commands/commands.component.html
+3
-9
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
...rontend/src/app/components/commands/commands.component.ts
+17
-4
common/utils/websrv/frontend/src/app/interceptors/error.interceptor.ts
...websrv/frontend/src/app/interceptors/error.interceptor.ts
+17
-16
common/utils/websrv/frontend/src/app/services/dialog.service.ts
.../utils/websrv/frontend/src/app/services/dialog.service.ts
+1
-1
No files found.
common/utils/websrv/frontend/src/app/api/commands.api.ts
View file @
b203d4ae
...
...
@@ -10,20 +10,20 @@ export interface IVariable {
modifiable
:
boolean
;
//set command ?
}
export
enum
ILogLvl
{
error
=
"
error
"
,
warn
=
"
warn
"
,
analysis
=
"
analysis
"
,
info
=
"
info
"
,
debug
=
"
debug
"
,
trace
=
"
trace
"
}
export
interface
ICmdResp
{
component
:
string
;
level
:
ILogLvl
;
enabled
:
boolean
;
output
:
string
;
}
//
export enum ILogLvl {
//
error="error",
//
warn="warn",
//
analysis="analysis",
//
info="info",
//
debug="debug",
//
trace="trace"
//
}
//
export interface ICmdResp {
//
component: string;
//
level: ILogLvl;
//
enabled: boolean;
//
output: string;
//
}
export
enum
IArgType
{
boolean
=
"
boolean
"
,
...
...
@@ -50,8 +50,8 @@ 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
<
ICmdResp
[]
>
(
environment
.
backend
+
route
+
'
/
'
+
moduleName
+
'
/commands/
'
,
command
);
public
runCommand$
=
(
command
:
ICommand
,
moduleName
:
string
)
=>
this
.
httpClient
.
post
<
string
[]
>
(
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
<
string
[]
>
(
environment
.
backend
+
route
+
(
moduleName
?
(
'
/
'
+
moduleName
)
:
""
)
+
'
/variables/
'
,
variable
);
}
common/utils/websrv/frontend/src/app/components/commands/commands.component.html
View file @
b203d4ae
...
...
@@ -40,17 +40,11 @@
</div>
</div>
<div
*ngIf=
"cmds$ | async as cmds"
fxLaypout=
"column"
fxLayoutGap=
"10px"
>
<div
*ngIf=
"cmds$ | async as cmds"
>
<div
*ngIf=
"cmds.length"
>
<h2
mat-dialog-title
>
Commands
</h2>
<div
*ngFor=
"let cmd of cmds"
>
<!-- <mat-form-field>
<mat-label>{{ cmd.nameFC.value }}</mat-label>
<input input matInput [formControl]="cmd.nameFC" />
</mat-form-field> -->
<button
mat-raised-button
color=
"primary"
(click)=
"onCmdSubmit(cmd)"
>
{{cmd.nameFC.value}}
</button>
<div
*ngFor=
"let cmd of cmds"
fxLayoutGap=
"10px"
>
<button
mat-raised-button
color=
"primary"
(click)=
"onCmdSubmit(cmd)"
>
{{cmd.nameFC.value}}
</button>
</div>
</div>
</div>
...
...
common/utils/websrv/frontend/src/app/components/commands/commands.component.ts
View file @
b203d4ae
import
{
Component
}
from
'
@angular/core
'
;
import
{
Observable
}
from
'
rxjs/internal/Observable
'
;
import
{
map
}
from
'
rxjs/internal/operators/map
'
;
import
{
tap
}
from
'
rxjs/internal/operators/tap
'
;
import
{
CommandsApi
,
IArgType
}
from
'
src/app/api/commands.api
'
;
import
{
CmdCtrl
}
from
'
src/app/controls/cmd.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
'
;
...
...
@@ -33,6 +33,7 @@ export class CommandsComponent {
constructor
(
public
commandsApi
:
CommandsApi
,
public
loadingService
:
LoadingService
,
public
dialogService
:
DialogService
)
{
this
.
vars$
=
this
.
commandsApi
.
readVariables$
().
pipe
(
map
((
vars
)
=>
vars
.
map
(
ivar
=>
new
VarCtrl
(
ivar
)))
...
...
@@ -72,10 +73,22 @@ export class CommandsComponent {
}
onSubVarSubmit
(
control
:
VarCtrl
)
{
this
.
commandsApi
.
setVariable$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
).
subscribe
();
this
.
commandsApi
.
setVariable$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
)
.
pipe
(
map
(
array
=>
this
.
success
(
'
setVariable
'
+
control
.
nameFC
.
value
+
'
OK
'
,
array
[
0
]))
).
subscribe
();
}
onCmdSubmit
(
control
:
CmdCtrl
)
{
this
.
commandsApi
.
runCommand$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
).
subscribe
();
this
.
commandsApi
.
runCommand$
(
control
.
api
(),
`
${
this
.
selectedModule
!
.
nameFC
.
value
}
`
).
pipe
(
map
(
array
=>
this
.
success
(
'
runCommand
'
+
control
.
nameFC
.
value
+
'
OK
'
,
array
[
0
]))
).
subscribe
();
}
}
private
success
=
(
mess
:
string
,
str
:
string
)
=>
this
.
dialogService
.
openDialog
({
title
:
mess
,
body
:
str
,
});
}
\ No newline at end of file
common/utils/websrv/frontend/src/app/interceptors/error.interceptor.ts
View file @
b203d4ae
...
...
@@ -10,21 +10,22 @@ export class ErrorInterceptor implements HttpInterceptor {
intercept
(
request
:
HttpRequest
<
unknown
>
,
next
:
HttpHandler
)
{
return
next
.
handle
(
request
).
pipe
(
tap
((
event
:
HttpEvent
<
any
>
)
=>
{
if
(
event
instanceof
HttpResponse
)
{
switch
(
event
.
status
)
{
case
201
:
this
.
log
(
GREEN
,
request
.
method
+
'
'
+
event
.
status
+
'
Success
'
);
this
.
dialogService
.
openSnackBar
(
request
.
method
+
'
201 Success
'
);
break
;
default
:
break
;
}
// return throwError(event.body);
}
}),
// tap((event: HttpEvent<any>) => {
// if (event instanceof HttpResponse) {
// switch (event.status) {
// case 200:
// case 201:
// this.log(GREEN, request.method + ' ' + event.status + ' Success');
// this.dialogService.openSnackBar(request.method + ' ' + event.status + ' Success');
// break;
// default:
// break;
// }
// // return throwError(event.body);
// }
// }),
catchError
((
error
:
HttpErrorResponse
)
=>
{
switch
(
error
.
status
)
{
case
400
:
...
...
@@ -32,7 +33,7 @@ export class ErrorInterceptor implements HttpInterceptor {
case
501
:
case
500
:
this
.
log
(
YELLOW
,
request
.
method
+
'
'
+
error
.
status
+
'
Error:
'
+
error
.
error
);
this
.
dialogService
.
open
Error
Dialog
({
this
.
dialogService
.
openDialog
({
title
:
error
.
status
+
'
Error
'
,
body
:
error
.
error
,
});
...
...
common/utils/websrv/frontend/src/app/services/dialog.service.ts
View file @
b203d4ae
...
...
@@ -14,7 +14,7 @@ export class DialogService {
private
_snackBar
:
MatSnackBar
,
)
{
}
open
Error
Dialog
(
data
:
any
):
any
{
openDialog
(
data
:
any
):
any
{
if
(
this
.
isDialogOpen
)
{
return
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