Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rclnodejs-testing
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleg Dzhimiev
rclnodejs-testing
Commits
71194915
Commit
71194915
authored
Jan 05, 2019
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scan ports
parent
6a97978c
Pipeline
#870
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
64 deletions
+88
-64
index.js
public/javascripts/index.js
+88
-64
No files found.
public/javascripts/index.js
View file @
71194915
...
...
@@ -7,6 +7,7 @@ let MasterNode = "-";
let
appData
=
{
master
:
"-"
,
slaves
:
[],
ips
:
[],
slaves_selected
:
[]
}
...
...
@@ -24,7 +25,7 @@ function init(){
update_master_node
();
// init button
$
(
'#
testbutton
'
).
on
(
'click'
,
function
(
e
){
$
(
'#
listmasters
'
).
on
(
'click'
,
function
(
e
){
$
.
ajax
({
url
:
'/api/nodelist'
,
...
...
@@ -43,9 +44,8 @@ function init(){
$
(
".master_nodes"
).
on
(
'click'
,
function
(
e
){
update_master_node
(
$
(
this
).
html
());
$
(
"#nodelist"
).
empty
();
//send_command(appData.slaves,'list', parse_cmd_list_init);
// go straight with ifconfig
send_command
(
appData
.
slaves
,
'ifconfig'
,
parse_cmd_ifconfig_init
);
send_command
(
'ifconfig'
,
appData
.
slaves
,
parse_cmd_ifconfig_init
);
});
}
...
...
@@ -53,67 +53,76 @@ function init(){
});
$
(
'#testbutton1'
).
on
(
'click'
,
function
(
e
){
send_command
(
appData
.
slaves_selected
,
'list'
,
parse_cmd_list
);
});
$
(
'#testbutton2'
).
on
(
'click'
,
function
(
e
){
send_command
(
appData
.
slaves_selected
,
'state'
,
parse_cmd_state
);
send_command
(
'state'
,
appData
.
slaves_selected
,
parse_cmd_state
);
});
// need a post request
$
(
'#testbutton3'
).
on
(
'click'
,
function
(
e
){
// examples:
//let cmd = "wget -qO- -o /dev/null 'http://localhost/parsedit.php?immediate&TRIG'";
//let cmd = "ifconfig";
//let cmd = "wget -qO- -o /dev/null 'http://localhost/diagnostics.php'";
const
cmd
=
"ifconfig"
;
send_command
(
appData
.
slaves_selected
,
cmd
,
parse_cmd_ifconfig
);
//const cmd = "ifconfig";
let
path
=
"/sys/devices/soc0/elphel393-detect_sensors@0"
;
let
cmd
=
[
'cd '
+
path
,
'cat port_mux0'
,
'cat sensor00'
,
'cat sensor01'
,
'cat sensor02'
,
'cat sensor03'
,
'cat port_mux1'
,
'cat sensor10'
,
'cat sensor11'
,
'cat sensor12'
,
'cat sensor13'
,
'cat port_mux2'
,
'cat sensor20'
,
'cat sensor21'
,
'cat sensor22'
,
'cat sensor23'
,
'cat port_mux3'
,
'cat sensor30'
,
'cat sensor31'
,
'cat sensor32'
,
'cat sensor33'
].
join
(
';'
);
send_command
(
cmd
,
appData
.
slaves_selected
,
parse_cmd_testing
);
});
}
function
parse_cmd_
list_init
(
res
){
function
parse_cmd_
testing
(
res
){
$
(
res
).
find
(
'target'
).
each
(
function
(){
const
name
=
$
(
this
).
text
();
update_slave_list
(
name
);
});
$
(
res
).
find
(
'response'
).
each
(
function
(){
$
(
".slave_checkbox"
).
on
(
"change"
,
function
(
e
){
let
checked
=
$
(
this
).
prop
(
"checked"
);
let
name
=
$
(
this
).
parent
().
find
(
"label"
).
html
();
console
.
log
(
checked
+
" "
+
name
);
if
(
!
checked
)
{
appData
.
slaves_selected
=
appData
.
slaves_selected
.
filter
(
item
=>
item
!==
name
);
const
name
=
$
(
this
).
find
(
'node'
).
text
();
let
state
=
$
(
this
).
find
(
'state'
).
text
();
const
xmlstate
=
$
.
parseXML
(
`<document>
${
state
}
</document>`
);
if
(
$
(
xmlstate
).
find
(
"error"
).
length
!=
0
){
console
.
log
(
name
+
" is not 10393"
);
$
(
"."
+
name
).
append
(
" <b style='color:DarkOrange;'>not 10393</b>"
);
}
else
{
appData
.
slaves_selected
.
push
(
name
);
let
sensors
=
state
.
trim
().
split
(
'
\
n'
);
//console.log(sensors);
for
(
let
i
=
0
;
i
<
4
;
i
++
){
let
mux
=
sensors
[
5
*
i
];
console
.
log
(
"port "
+
i
+
" mux is "
+
mux
);
if
(
mux
===
"none"
){
console
.
log
(
"sensor is "
+
sensors
[
5
*
i
+
1
]);
}
else
{
console
.
log
(
"warning: mux is not 'none'"
);
}
}
}
});
}
function
parse_cmd_list
(
res
){
let
rtab
=
[
'<table class="slave_table">'
,
' <tr>'
,
' <th>Slave</th>'
,
' </tr>'
];
$
(
res
).
find
(
'target'
).
each
(
function
(){
const
name
=
$
(
this
).
text
();
//update_slave_list(name);
rtab
=
rtab
.
concat
([
'<tr>'
,
' <td class="name">'
+
name
+
'</td>'
,
'</tr>'
,
]);
});
rtab
.
push
(
'</table>'
);
$
(
"#nodelist"
).
empty
().
append
(
rtab
.
join
(
'
\
n'
));
}
...
...
@@ -141,29 +150,48 @@ function parse_cmd_state(res){
$
(
"#nodelist"
).
empty
().
append
(
rtab
.
join
(
'
\
n'
));
}
function
parse_cmd_
testing
(
res
){
function
parse_cmd_
ifconfig_init
(
res
){
$
(
res
).
find
(
'response'
).
each
(
function
(){
const
name
=
$
(
this
).
find
(
'node'
).
text
();
const
state
=
$
(
this
).
find
(
'state'
).
text
();
console
.
log
(
state
);
});
const
ip
=
get_ipaddr_from_ifconfig
(
state
);
}
update_slave_list
(
name
);
update_ip_list
(
ip
);
function
parse_cmd_ifconfig
(
res
){
let
html
=
[
'<div class=
\'
'
+
name
+
'
\'
>'
,
'<input class=
\'
slave_checkbox
\'
type=
\'
checkbox
\'
checked />'
,
'<label class=
\'
lbl_name
\'
>'
+
name
+
'</label>'
,
'(<label class=
\'
lbl_ip
\'
>'
+
ip
+
'</label>)'
,
'</div>'
].
join
(
'
\
n'
);
$
(
"#slavenodes"
).
append
(
html
);
$
(
res
).
find
(
'response'
).
each
(
function
(){
const
name
=
$
(
this
).
find
(
'node'
).
text
();
const
state
=
$
(
this
).
find
(
'state'
).
text
();
const
ip
=
get_ipaddr_from_ifconfig
(
state
);
console
.
log
(
ip
);
$
(
"."
+
name
+
" label"
).
html
(
name
+
" ("
+
ip
+
")"
);
});
$
(
".slave_checkbox"
).
on
(
"change"
,
function
(
e
){
let
checked
=
$
(
this
).
prop
(
"checked"
);
let
name
=
$
(
this
).
parent
().
find
(
"label"
).
html
();
if
(
!
checked
)
{
appData
.
slaves_selected
=
appData
.
slaves_selected
.
filter
(
item
=>
item
!==
name
);
}
else
{
appData
.
slaves_selected
.
push
(
name
);
}
});
}
function
send_command
(
targets
,
cmd
,
callback
){
function
send_command
(
cmd
,
targets
,
callback
){
if
(
callback
===
undefined
)
{
callback
=
function
(
res
){
console
.
log
(
res
);
//console.log($(res).find('document').html());
}
}
let
targets_str
=
""
;
if
(
Array
.
isArray
(
targets
)){
...
...
@@ -186,20 +214,16 @@ function send_command(targets, cmd, callback){
success
:
callback
});
return
0
;
}
function
update_slave_list
(
name
){
appData
.
slaves
.
push
(
name
);
appData
.
slaves_selected
.
push
(
name
);
let
html
=
[
'<div class=
\'
'
+
name
+
'
\'
>'
,
'<input class=
\'
slave_checkbox
\'
type=
\'
checkbox
\'
checked />'
,
'<label>'
+
name
+
'</label>'
,
'</div>'
].
join
(
'
\
n'
);
$
(
"#slavenodes"
).
append
(
html
);
}
function
update_ip_list
(
ip
){
appData
.
ips
.
push
(
ip
);
}
function
update_master_node
(
newvalue
){
...
...
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