2014-08-05 10:31:17 +04:00
Ext . define ( 'PVE.TaskListBase' , {
extend : 'PVE.Page' ,
config : {
baseUrl : undefined ,
items : [
{
2023-05-28 20:03:20 +03:00
xtype : 'pveTitleBar' ,
2014-08-05 10:31:17 +04:00
} ,
{
xtype : 'list' ,
2015-09-23 18:54:46 +03:00
flex : 1 ,
2014-08-05 10:31:17 +04:00
disableSelection : true ,
listeners : {
itemsingletap : function ( list , index , target , record ) {
2023-05-28 20:03:20 +03:00
PVE . Workspace . gotoPage ( 'nodes/' + record . get ( 'node' ) + '/tasks/' +
2014-08-05 10:31:17 +04:00
record . get ( 'upid' ) ) ;
2023-05-28 20:03:20 +03:00
} ,
2014-08-05 10:31:17 +04:00
} ,
itemTpl : [
2015-09-23 18:54:46 +03:00
'<div style="vertical-align: middle;">' +
'<span>{[this.desc(values)]}</span>' ,
'<span style=" font-size:small; float: right;">' +
'{starttime:date("M d H:i:s")} - {endtime:date("H:i:s")}' +
'</span></div>' ,
'<small>node: {node}<br /> Status: {[this.status(values)]}</small>' ,
2014-08-05 10:31:17 +04:00
{
desc : function ( values ) {
2018-01-15 17:18:09 +03:00
return Proxmox . Utils . format _task _description ( values . type , values . id ) ;
2015-09-23 18:54:46 +03:00
} ,
status : function ( values ) {
return Ext . String . ellipsis ( values . status , 160 ) ;
2023-05-28 20:03:20 +03:00
} ,
} ,
] ,
} ,
] ,
2014-08-05 10:31:17 +04:00
} ,
reload : function ( ) {
var me = this ;
me . store . load ( ) ;
} ,
initialize : function ( ) {
var me = this ;
me . store = Ext . create ( 'Ext.data.Store' , {
model : 'pve-tasks' ,
proxy : {
type : 'pve' ,
2023-05-28 20:03:20 +03:00
url : '/api2/json' + me . getBaseUrl ( ) ,
2014-08-05 10:31:17 +04:00
} ,
sorters : [
{
2023-05-28 20:03:20 +03:00
property : 'starttime' ,
direction : 'DESC' ,
} ,
] ,
2014-08-05 10:31:17 +04:00
} ) ;
var list = me . down ( 'list' ) ;
list . setStore ( me . store ) ;
me . reload ( ) ;
2023-05-28 20:03:20 +03:00
2014-08-05 10:31:17 +04:00
this . callParent ( ) ;
2023-05-28 20:03:20 +03:00
} ,
2014-08-05 10:31:17 +04:00
} ) ;
Ext . define ( 'PVE.ClusterTaskList' , {
extend : 'PVE.TaskListBase' ,
statics : {
pathMatch : function ( loc ) {
return loc . match ( /^tasks$/ ) ;
2023-05-28 20:03:20 +03:00
} ,
2014-08-05 10:31:17 +04:00
} ,
config : {
2023-05-28 20:03:20 +03:00
baseUrl : '/cluster/tasks' ,
2014-08-05 10:31:17 +04:00
} ,
initialize : function ( ) {
var me = this ;
me . down ( 'titlebar' ) . setTitle ( gettext ( 'Tasks' ) + ': ' + gettext ( 'Cluster' ) ) ;
var match = me . self . pathMatch ( me . getAppUrl ( ) ) ;
if ( ! match ) {
throw "pathMatch failed" ;
}
this . callParent ( ) ;
2023-05-28 20:03:20 +03:00
} ,
2014-08-05 10:31:17 +04:00
} ) ;
Ext . define ( 'PVE.NodeTaskList' , {
extend : 'PVE.TaskListBase' ,
statics : {
pathMatch : function ( loc ) {
2023-05-28 20:03:20 +03:00
return loc . match ( /^nodes\/([^\s/]+)\/tasks$/ ) ;
} ,
2014-08-05 10:31:17 +04:00
} ,
nodename : undefined ,
initialize : function ( ) {
var me = this ;
var match = me . self . pathMatch ( me . getAppUrl ( ) ) ;
if ( ! match ) {
throw "pathMatch failed" ;
}
me . nodename = match [ 1 ] ;
me . setBaseUrl ( '/nodes/' + me . nodename + '/tasks' ) ;
me . down ( 'titlebar' ) . setTitle ( gettext ( 'Tasks' ) + ': ' + me . nodename ) ;
this . callParent ( ) ;
2023-05-28 20:03:20 +03:00
} ,
2014-08-05 10:31:17 +04:00
} ) ;