2015-05-28 12:56:27 +03:00
/ * T h i s c l a s s d e f i n e s t h e " T a s k s " t a b o f t h e b o t t o m s t a t u s p a n e l
* Tasks are jobs with a start , end and log output
* /
2015-05-27 17:24:25 +03:00
Ext . define ( 'PVE.dc.Tasks' , {
extend : 'Ext.grid.GridPanel' ,
alias : [ 'widget.pveClusterTasks' ] ,
initComponent : function ( ) {
var me = this ;
2018-01-15 17:18:00 +03:00
var taskstore = Ext . create ( 'Proxmox.data.UpdateStore' , {
2015-05-27 17:24:25 +03:00
storeid : 'pve-cluster-tasks' ,
2017-12-11 16:46:51 +03:00
model : 'proxmox-tasks' ,
2015-05-27 17:24:25 +03:00
proxy : {
2018-10-05 11:19:23 +03:00
type : 'proxmox' ,
2015-05-27 17:24:25 +03:00
url : '/api2/json/cluster/tasks'
2015-06-11 07:05:07 +03:00
}
} ) ;
2017-12-11 14:05:39 +03:00
var store = Ext . create ( 'Proxmox.data.DiffStore' , {
2015-06-11 07:05:07 +03:00
rstore : taskstore ,
sortAfterUpdate : true ,
appendAtStart : true ,
2015-05-27 17:24:25 +03:00
sorters : [
2015-06-11 07:05:07 +03:00
{
property : 'pid' ,
direction : 'DESC'
} ,
2015-05-27 17:24:25 +03:00
{
property : 'starttime' ,
direction : 'DESC'
}
]
} ) ;
var run _task _viewer = function ( ) {
var sm = me . getSelectionModel ( ) ;
var rec = sm . getSelection ( ) [ 0 ] ;
if ( ! rec ) {
return ;
}
2017-12-06 20:30:16 +03:00
var win = Ext . create ( 'Proxmox.window.TaskViewer' , {
2015-05-27 17:24:25 +03:00
upid : rec . data . upid
} ) ;
win . show ( ) ;
} ;
Ext . apply ( me , {
store : store ,
stateful : false ,
viewConfig : {
trackOver : false ,
2015-08-18 15:43:32 +03:00
stripeRows : true , // does not work with getRowClass()
2018-10-05 11:19:22 +03:00
2015-05-27 17:24:25 +03:00
getRowClass : function ( record , index ) {
var status = record . get ( 'status' ) ;
if ( status && status != 'OK' ) {
2018-01-15 17:18:01 +03:00
return "proxmox-invalid-row" ;
2015-05-27 17:24:25 +03:00
}
}
} ,
sortableColumns : false ,
columns : [
2018-10-05 11:19:22 +03:00
{
header : gettext ( "Start Time" ) ,
2015-05-27 17:24:25 +03:00
dataIndex : 'starttime' ,
2015-06-15 16:31:12 +03:00
width : 150 ,
2018-10-05 11:19:22 +03:00
renderer : function ( value ) {
return Ext . Date . format ( value , "M d H:i:s" ) ;
2015-05-27 17:24:25 +03:00
}
} ,
2018-10-05 11:19:22 +03:00
{
header : gettext ( "End Time" ) ,
2015-05-27 17:24:25 +03:00
dataIndex : 'endtime' ,
2015-06-15 16:31:12 +03:00
width : 150 ,
2015-05-27 17:24:25 +03:00
renderer : function ( value , metaData , record ) {
if ( record . data . pid ) {
2018-10-05 11:19:22 +03:00
if ( record . data . type == "vncproxy" ||
2015-05-27 17:24:25 +03:00
record . data . type == "vncshell" ||
record . data . type == "spiceproxy" ) {
metaData . tdCls = "x-grid-row-console" ;
} else {
metaData . tdCls = "x-grid-row-loading" ;
}
return "" ;
}
2018-10-05 11:19:22 +03:00
return Ext . Date . format ( value , "M d H:i:s" ) ;
2015-05-27 17:24:25 +03:00
}
} ,
2018-10-05 11:19:22 +03:00
{
header : gettext ( "Node" ) ,
2015-05-27 17:24:25 +03:00
dataIndex : 'node' ,
width : 100
} ,
2018-10-05 11:19:22 +03:00
{
header : gettext ( "User name" ) ,
2015-05-27 17:24:25 +03:00
dataIndex : 'user' ,
2020-04-30 17:04:19 +03:00
renderer : Ext . String . htmlEncode ,
2015-05-27 17:24:25 +03:00
width : 150
} ,
2018-10-05 11:19:22 +03:00
{
header : gettext ( "Description" ) ,
dataIndex : 'upid' ,
flex : 1 ,
2018-01-15 17:18:09 +03:00
renderer : Proxmox . Utils . render _upid
2015-05-27 17:24:25 +03:00
} ,
2018-10-05 11:19:22 +03:00
{
header : gettext ( "Status" ) ,
dataIndex : 'status' ,
2015-05-27 17:24:25 +03:00
width : 200 ,
2018-10-05 11:19:22 +03:00
renderer : function ( value , metaData , record ) {
2015-05-27 17:24:25 +03:00
if ( record . data . pid ) {
if ( record . data . type != "vncproxy" ) {
metaData . tdCls = "x-grid-row-loading" ;
}
return "" ;
}
if ( value == 'OK' ) {
return 'OK' ;
}
2018-10-05 11:19:22 +03:00
// metaData.attr = 'style="color:red;"';
2018-01-15 17:18:09 +03:00
return Proxmox . Utils . errorText + ': ' + value ;
2015-05-27 17:24:25 +03:00
}
}
] ,
listeners : {
itemdblclick : run _task _viewer ,
2020-04-09 17:45:22 +03:00
show : ( ) => taskstore . startUpdate ( ) ,
destroy : ( ) => taskstore . stopUpdate ( ) ,
2015-05-27 17:24:25 +03:00
}
} ) ;
me . callParent ( ) ;
}
2015-06-11 07:05:07 +03:00
} ) ;