2014-08-05 10:31:17 +04:00
Ext . define ( 'PVE.ClusterInfo' , {
extend : 'Ext.Component' ,
alias : 'widget.pveClusterInfo' ,
config : {
style : 'background-color: white;' ,
styleHtmlContent : true ,
tpl : [
'<table style="margin-bottom:0px;">' ,
'<tr><td>Node:</td><td><b>{local_node}</large></b></tr>' ,
'<tpl if="cluster_name">' ,
'<tr><td>Cluster:</td><td>{cluster_name}</td></tr>' ,
'<tr><td>Members:</td><td>{nodes}</td></tr>' ,
'<tr><td>Quorate:</td><td>{quorate}</td></tr>' ,
'</tpl>' ,
'<tr><td>Version:</td><td>{version}</td></tr>' ,
'</table>' ,
2023-05-28 20:03:20 +03:00
] ,
2014-08-05 10:31:17 +04:00
} ,
} ) ;
Ext . define ( 'PVE.Datacenter' , {
extend : 'PVE.Page' ,
alias : 'widget.pveDatacenter' ,
statics : {
pathMatch : function ( loc ) {
if ( loc === '' ) {
return [ '' ] ;
}
2023-05-28 20:03:20 +03:00
} ,
2014-08-05 10:31:17 +04:00
} ,
config : {
appUrl : '' ,
items : [
2015-09-23 18:54:42 +03:00
{
xtype : 'pveTitleBar' ,
2014-08-05 10:31:17 +04:00
title : gettext ( 'Datacenter' ) ,
2023-05-28 20:03:20 +03:00
pveBackButton : false ,
2014-08-05 10:31:17 +04:00
} ,
{
2023-05-28 20:03:20 +03:00
xtype : 'pveClusterInfo' ,
2014-08-05 10:31:17 +04:00
} ,
{
xtype : 'component' ,
cls : 'dark' ,
padding : 5 ,
2023-05-28 20:03:20 +03:00
html : gettext ( 'Nodes' ) ,
2014-08-05 10:31:17 +04:00
} ,
{
xtype : 'list' ,
flex : 1 ,
disableSelection : true ,
2015-09-21 11:22:37 +03:00
sorters : 'name' ,
2014-08-05 10:31:17 +04:00
listeners : {
itemsingletap : function ( list , index , target , record ) {
PVE . Workspace . gotoPage ( 'nodes/' + record . get ( 'name' ) ) ;
2023-05-28 20:03:20 +03:00
} ,
2014-08-05 10:31:17 +04:00
} ,
itemTpl : '{name}' +
2018-01-15 17:18:09 +03:00
'<br><small>Online: {[Proxmox.Utils.format_boolean(values.online)]}</small>' +
2023-05-28 20:03:20 +03:00
'<br><small>Support: {[PVE.Utils.render_support_level(values.level)]}</small>' ,
} ,
] ,
2014-08-05 10:31:17 +04:00
} ,
reload : function ( ) {
var me = this ;
var ci = me . down ( 'pveClusterInfo' ) ;
2014-08-05 11:15:14 +04:00
me . setMasked ( false ) ;
2014-08-05 10:31:17 +04:00
me . summary = { } ;
2018-01-26 10:52:55 +03:00
Proxmox . Utils . API2Request ( {
2014-08-05 10:31:17 +04:00
url : '/version' ,
method : 'GET' ,
success : function ( response ) {
var d = response . result . data ;
2019-10-01 15:42:20 +03:00
me . summary . version = d . version ;
2014-08-05 10:31:17 +04:00
ci . setData ( me . summary ) ;
2023-05-28 20:03:20 +03:00
} ,
2014-08-05 10:31:17 +04:00
} ) ;
var list = me . down ( 'list' ) ;
2018-01-26 10:52:55 +03:00
Proxmox . Utils . API2Request ( {
2014-08-05 10:31:17 +04:00
url : '/cluster/status' ,
method : 'GET' ,
success : function ( response ) {
var d = response . result . data ;
2023-05-28 20:03:20 +03:00
list . setData ( d . filter ( function ( el ) { return el . type === "node" ; } ) ) ;
2014-08-05 10:31:17 +04:00
d . forEach ( function ( el ) {
if ( el . type === "node" ) {
if ( el . local ) {
me . summary . local _node = el . name ;
}
} else if ( el . type === "cluster" ) {
2015-09-21 11:22:37 +03:00
me . summary . nodes = el . nodes ;
2018-01-15 17:18:09 +03:00
me . summary . quorate = Proxmox . Utils . format _boolean ( el . quorate ) ;
2014-08-05 10:31:17 +04:00
me . summary . cluster _name = el . name ;
}
} ) ;
ci . setData ( me . summary ) ;
2014-08-05 11:15:14 +04:00
} ,
failure : function ( response ) {
2023-05-28 20:03:20 +03:00
me . setMasked ( { xtype : 'loadmask' , message : response . htmlStatus } ) ;
} ,
2014-08-05 10:31:17 +04:00
} ) ;
} ,
initialize : function ( ) {
var me = this ;
2015-09-23 18:54:42 +03:00
me . down ( 'pveMenuButton' ) . setMenuItems ( [
{
text : gettext ( 'Tasks' ) ,
handler : function ( ) {
PVE . Workspace . gotoPage ( 'tasks' ) ;
2023-05-28 20:03:20 +03:00
} ,
} ,
2015-09-23 18:54:42 +03:00
] ) ;
2014-08-05 10:31:17 +04:00
me . reload ( ) ;
2023-05-28 20:03:20 +03:00
} ,
2014-08-05 10:31:17 +04:00
} ) ;