2015-07-03 11:29:11 +02:00
Ext . define ( 'PVE.form.FileSelector' , {
2018-01-15 15:17:50 +01:00
extend : 'Proxmox.form.ComboGrid' ,
2016-09-12 12:02:34 +02:00
alias : 'widget.pveFileSelector' ,
2015-07-03 11:29:11 +02:00
2017-07-25 16:26:58 +02:00
editable : true ,
anyMatch : true ,
forceSelection : true ,
2015-07-03 11:29:11 +02:00
setStorage : function ( storage , nodename ) {
var me = this ;
var change = false ;
if ( storage && ( me . storage !== storage ) ) {
me . storage = storage ;
change = true ;
}
if ( nodename && ( me . nodename !== nodename ) ) {
me . nodename = nodename ;
change = true ;
}
if ( ! ( me . storage && me . nodename && change ) ) {
return ;
}
var url = '/api2/json/nodes/' + me . nodename + '/storage/' + me . storage + '/content' ;
if ( me . storageContent ) {
url += '?content=' + me . storageContent ;
}
me . store . setProxy ( {
type : 'pve' ,
url : url
} ) ;
2017-11-10 14:49:27 +01:00
me . store . removeAll ( ) ;
2015-07-03 11:29:11 +02:00
me . store . load ( ) ;
} ,
initComponent : function ( ) {
var me = this ;
var store = Ext . create ( 'Ext.data.Store' , {
model : 'pve-storage-content'
} ) ;
Ext . apply ( me , {
store : store ,
allowBlank : false ,
autoSelect : false ,
valueField : 'volid' ,
displayField : 'text' ,
listConfig : {
2017-07-25 16:26:56 +02:00
width : 600 ,
2015-07-03 11:29:11 +02:00
columns : [
{
header : gettext ( 'Name' ) ,
dataIndex : 'text' ,
hideable : false ,
flex : 1
} ,
{
header : gettext ( 'Format' ) ,
2017-07-25 16:26:56 +02:00
width : 60 ,
2015-07-03 11:29:11 +02:00
dataIndex : 'format'
} ,
{
header : gettext ( 'Size' ) ,
2017-07-25 16:26:56 +02:00
width : 100 ,
dataIndex : 'size' ,
2018-01-15 15:18:09 +01:00
renderer : Proxmox . Utils . format _size
2015-07-03 11:29:11 +02:00
}
]
}
} ) ;
me . callParent ( ) ;
2017-11-10 14:49:20 +01:00
if ( ! me . disabled ) {
me . setStorage ( me . storage , me . nodename ) ;
}
2015-07-03 11:29:11 +02:00
}
} ) ;