Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
98f677e6
Commit
98f677e6
authored
Oct 11, 2021
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_jio: status
parent
aad1fd71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
101 deletions
+93
-101
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_slapos_status_js.js
...mplateItem/web_page_module/rjs_gadget_slapos_status_js.js
+91
-99
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_slapos_status_js.xml
...plateItem/web_page_module/rjs_gadget_slapos_status_js.xml
+2
-2
No files found.
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_slapos_status_js.js
View file @
98f677e6
/*globals window, rJS,
Handlebars
*/
/*globals window, rJS,
domsugar
*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(
function
(
window
,
rJS
,
Handlebars
)
{
(
function
(
window
,
rJS
,
domsugar
)
{
"
use strict
"
;
var
gadget_klass
=
rJS
(
window
)
,
inline_status_source
=
gadget_klass
.
__template_element
.
getElementById
(
"
inline-status-template
"
)
.
innerHTML
,
inline_status_template
=
Handlebars
.
compile
(
inline_status_source
)
;
function
checkComputeNodeStatus
(
options
)
{
if
(
!
options
||
!
options
.
news
||
!
options
.
news
.
text
)
{
return
'
ui-btn-no-data
'
;
var
STATUS_ERROR
=
'
ui-btn-error
'
,
STATUS_WARNING
=
'
ui-btn-warning
'
,
STATUS_NODATA
=
'
ui-btn-no-data
'
,
STATUS_UNHANDLED
=
'
XXX
'
,
STATUS_OK
=
'
ui-btn-ok
'
;
function
checkComputeNodeStatus
(
compute_node_news_dict
)
{
if
(
compute_node_news_dict
.
no_data
)
{
return
STATUS_NODATA
;
}
if
(
options
.
news
.
text
.
startsWith
(
"
#access
"
))
{
if
(
options
.
news
.
no_data_since_15_minutes
)
{
return
'
ui-btn-error
'
;
if
(
compute_node_news_dict
.
text
.
startsWith
(
"
#access
"
))
{
if
(
compute_node_news_dict
.
no_data_since_15_minutes
)
{
return
STATUS_ERROR
;
}
if
(
options
.
news
.
no_data_since_5_minutes
)
{
return
'
ui-btn-warning
'
;
if
(
compute_node_news_dict
.
no_data_since_5_minutes
)
{
return
STATUS_WARNING
;
}
return
'
ui-btn-ok
'
;
}
if
(
options
.
news
.
no_data
)
{
return
'
ui-btn-no-data
'
;
return
STATUS_OK
;
}
return
'
ui-btn-error
'
;
return
STATUS_UNHANDLED
;
}
function
checkComputePartitionStatus
(
options
)
{
var
message
,
compute_partition
,
partition_class
=
'
ui-btn-ok
'
,
function
checkComputePartitionStatus
(
partition_news_dict_dict
)
{
var
key
,
error_amount
=
0
,
total
_amount
=
0
;
partition
_amount
=
0
;
if
(
!
options
||
!
options
.
compute_partition_news
)
{
return
'
ui-btn-no-data
'
;
}
for
(
compute_partition
in
options
.
compute_partition_news
)
{
if
(
options
.
compute_partition_news
.
hasOwnProperty
(
compute_partition
)
&&
options
.
compute_partition_news
[
compute_partition
].
text
)
{
message
=
options
.
compute_partition_news
[
compute_partition
].
text
;
if
(
message
.
startsWith
(
"
#error
"
))
{
partition_class
=
'
ui-btn-warning
'
;
for
(
key
in
partition_news_dict_dict
)
{
if
(
partition_news_dict_dict
.
hasOwnProperty
(
key
))
{
partition_amount
+=
1
;
if
(
partition_news_dict_dict
.
text
&&
partition_news_dict_dict
.
text
.
startWith
(
'
#error
'
))
{
error_amount
+=
1
;
}
total_amount
+=
1
;
if
((
error_amount
>
0
)
&&
(
error_amount
<
total_amount
))
{
// No need to continue the result will be a warnning
return
partition_class
;
}
}
}
if
(
total_amount
===
0
)
{
return
'
ui-btn-no-data
'
;
}
if
(
error_amount
===
total_amount
)
{
// No need to continue the result will be a warnning
return
'
ui-btn-error
'
;
}
return
partition_class
;
}
function
renderStatusxxx
(
result
)
{
var
monitor_url
,
status_class
=
'
ui-btn-no-data
'
,
status_title
=
'
Compute Node
'
,
right_title
=
'
Partitions
'
,
right_class
=
'
ui-btn-no-data
'
,
status_style
=
''
,
right_style
=
''
;
if
(
result
&&
result
.
news
&&
result
.
news
.
compute_node
)
{
status_class
=
checkComputeNodeStatus
({
news
:
result
.
news
.
compute_node
})
;
if
(
partition_amount
===
0
)
{
return
STATUS_NODATA
;
}
if
((
status_class
===
'
ui-btn-error
'
)
||
(
status_class
===
'
ui-btn-no-data
'
))
{
right_class
=
status_class
;
}
else
{
if
(
result
&&
result
.
news
&&
result
.
news
.
partition
)
{
right_class
=
checkComputePartitionStatus
(
{
compute_partition_news
:
result
.
news
.
partition
}
);
if
(
0
<
error_amount
)
{
if
(
error_amount
<
partition_amount
)
{
return
STATUS_WARNING
;
}
return
STATUS_ERROR
;
}
monitor_url
=
'
https://monitor.app.officejs.com/#/
'
+
'
?page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20
'
+
'
AND%20aggregate_reference%3A%22
'
+
result
.
reference
+
'
%22
'
;
return
{
html
:
inline_status_template
({
monitor_url
:
monitor_url
,
status_class
:
status_class
,
status_title
:
status_title
,
status_style
:
status_style
,
right_class
:
right_class
,
right_title
:
right_title
,
right_style
:
right_style
})};
return
STATUS_OK
;
}
function
renderStatus
(
status_dict
)
{
console
.
log
(
status_dict
);
/*
if (status_dict.compute_node) {
status_class = checkComputeNodeStatus({news: status_dict.compute_node});
// Check if we have info related to the partition
var
compute_node_status
,
partition_status
;
if
(
status_dict
.
compute_node_news_dict
)
{
compute_node_status
=
checkComputeNodeStatus
(
status_dict
.
compute_node_news_dict
);
if
((
compute_node_status
===
STATUS_OK
)
||
(
compute_node_status
===
STATUS_WARNING
))
{
partition_status
=
STATUS_NODATA
;
if
(
status_dict
.
partition_news_dict_dict
)
{
// Check if we have info related to the partition
partition_status
=
checkComputePartitionStatus
(
status_dict
.
partition_news_dict_dict
);
}
return
[
domsugar
(
'
div
'
,
{
'
class
'
:
'
ui-block-a ui-bar ui-corner-all first-child
'
+
'
ui-btn ui-btn-icon-left ui-icon-desktop
'
+
compute_node_status
,
style
:
'
width:50%
'
,
text
:
'
Compute Node
'
}),
domsugar
(
'
div
'
,
{
'
class
'
:
'
ui-block-c ui-bar ui-corner-all last-child
'
+
'
ui-btn ui-btn-icon-left ui-icon-desktop
'
+
compute_node_status
,
style
:
'
width:50%
'
,
text
:
'
Partitions
'
})
];
}
if
(
compute_node_status
!==
STATUS_UNHANDLED
)
{
return
[
domsugar
(
'
div
'
,
{
'
class
'
:
'
ui-block-a ui-bar ui-corner-all first-child
'
+
'
ui-btn ui-btn-icon-left ui-icon-desktop
'
+
partition_status
,
text
:
'
Compute Node
'
})
];
}
}
*/
// By default, display the full parameters,
// as it means the gadget does not support the configuration
// but the parameters may contain usefull stuff for the user
...
...
@@ -121,7 +109,7 @@
];
}
gadget_klass
rJS
(
window
)
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareMethod
(
"
getContent
"
,
function
()
{
...
...
@@ -130,13 +118,14 @@
.
onLoop
(
function
()
{
var
gadget
=
this
;
console
.
log
(
'
STATUS.onLoop1
'
,
gadget
.
state
);
if
(
gadget
.
state
.
jio_key
)
{
return
gadget
.
jio_get
(
gadget
.
state
.
jio_key
)
.
push
(
function
(
result
)
{
console
.
log
(
'
STATUS.onLoop
'
,
result
);
console
.
log
(
'
STATUS.onLoop
2
'
,
result
);
return
gadget
.
changeState
({
compute_node
:
JSON
.
stringify
(
result
.
news
.
compute_node
),
partition
:
JSON
.
stringify
(
result
.
news
.
partition
)
compute_node
_news_dict
:
JSON
.
stringify
(
result
.
news
.
compute_node
),
partition
_news_dict_dict
:
JSON
.
stringify
(
result
.
news
.
partition
)
});
});
}
...
...
@@ -145,8 +134,10 @@
.
declareMethod
(
"
render
"
,
function
(
options
)
{
console
.
log
(
'
STATUS.render
'
,
options
);
return
this
.
changeState
({
compute_node
:
JSON
.
stringify
(
options
.
compute_node
),
partition
:
JSON
.
stringify
(
options
.
partition
),
compute_node_news_dict
:
JSON
.
stringify
(
options
.
compute_node
),
partition_news_dict_dict
:
JSON
.
stringify
(
options
.
partition
),
jio_key
:
options
.
value
,
reference
:
options
.
reference
});
...
...
@@ -155,8 +146,9 @@
.
onStateChange
(
function
(
modification_dict
)
{
console
.
log
(
'
STATUS.onStateChange
'
,
modification_dict
);
domsugar
(
this
.
element
,
renderStatus
({
compute_node
:
JSON
.
parse
(
this
.
state
.
compute_node
),
partition
:
JSON
.
parse
(
this
.
state
.
partition
),
compute_node_news_dict
:
JSON
.
parse
(
this
.
state
.
compute_node_news_dict
),
partition_news_dict_dict
:
JSON
.
parse
(
this
.
state
.
partition_news_dict_dict
)
}));
});
}(
window
,
rJS
,
Handlebars
));
\ No newline at end of file
}(
window
,
rJS
,
domsugar
));
\ No newline at end of file
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_slapos_status_js.xml
View file @
98f677e6
...
...
@@ -273,7 +273,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
995.2
1748.56330.51234
</string>
</value>
<value>
<string>
995.2
5882.22519.23739
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -291,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>
1633
708139.98
</float>
<float>
1633
956166.82
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
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