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' ] ,
2021-01-19 19:39:15 +03:00
initComponent : function ( ) {
2015-05-27 17:24:25 +03:00
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' ,
2021-01-19 19:31:03 +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
{
2021-01-19 19:39:15 +03:00
property : 'pid' ,
2021-01-19 19:31:03 +03:00
direction : 'DESC' ,
2015-06-11 07:05:07 +03:00
} ,
2015-05-27 17:24:25 +03:00
{
2021-01-19 19:39:15 +03:00
property : 'starttime' ,
2021-01-19 19:31:03 +03:00
direction : 'DESC' ,
} ,
] ,
2015-05-27 17:24:25 +03:00
} ) ;
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' , {
2020-06-16 18:00:26 +03:00
upid : rec . data . upid ,
endtime : rec . data . endtime ,
2015-05-27 17:24:25 +03:00
} ) ;
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
}
2021-01-19 19:31:03 +03:00
} ,
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" ) ;
2021-01-19 19:31:03 +03:00
} ,
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 ) {
2021-03-12 15:53:26 +03:00
if ( record . data . type === "vncproxy" ||
record . data . type === "vncshell" ||
record . data . type === "spiceproxy" ) {
2021-01-19 19:39:15 +03:00
metaData . tdCls = "x-grid-row-console" ;
2015-05-27 17:24:25 +03:00
} else {
2021-01-19 19:39:15 +03:00
metaData . tdCls = "x-grid-row-loading" ;
2015-05-27 17:24:25 +03:00
}
return "" ;
}
2018-10-05 11:19:22 +03:00
return Ext . Date . format ( value , "M d H:i:s" ) ;
2021-01-19 19:31:03 +03:00
} ,
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' ,
2021-01-19 19:31:03 +03:00
width : 100 ,
2015-05-27 17:24:25 +03:00
} ,
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 ,
2021-01-19 19:31:03 +03:00
width : 150 ,
2015-05-27 17:24:25 +03:00
} ,
2018-10-05 11:19:22 +03:00
{
header : gettext ( "Description" ) ,
dataIndex : 'upid' ,
flex : 1 ,
2021-01-19 19:31:03 +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 ) {
2021-03-12 15:53:26 +03:00
if ( record . data . type !== "vncproxy" ) {
2021-01-19 19:39:15 +03:00
metaData . tdCls = "x-grid-row-loading" ;
2015-05-27 17:24:25 +03:00
}
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 ;
2021-01-19 19:31:03 +03:00
} ,
} ,
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 ( ) ,
2021-01-19 19:31:03 +03:00
} ,
2015-05-27 17:24:25 +03:00
} ) ;
me . callParent ( ) ;
2021-01-19 19:31:03 +03:00
} ,
2015-06-11 07:05:07 +03:00
} ) ;