2020-06-25 14:53:05 +02:00
Ext . define ( 'PBS.admin.ZFSList' , {
extend : 'Ext.grid.Panel' ,
xtype : 'pbsZFSList' ,
stateful : true ,
stateId : 'grid-node-zfs' ,
controller : {
xclass : 'Ext.app.ViewController' ,
openCreateWindow : function ( ) {
let me = this ;
Ext . create ( 'PBS.window.CreateZFS' , {
nodename : me . nodename ,
listeners : {
destroy : function ( ) { me . reload ( ) ; } ,
2020-09-25 18:34:54 +02:00
} ,
2020-06-25 14:53:05 +02:00
} ) . show ( ) ;
} ,
openDetailWindow : function ( ) {
let me = this ;
let view = me . getView ( ) ;
let selection = view . getSelection ( ) ;
if ( ! selection || selection . length < 1 ) return ;
let rec = selection [ 0 ] ;
let zpool = rec . get ( 'name' ) ;
Ext . create ( 'Proxmox.window.ZFSDetail' , {
zpool ,
nodename : view . nodename ,
} ) . show ( ) ;
} ,
reload : function ( ) {
let me = this ;
let view = me . getView ( ) ;
let store = view . getStore ( ) ;
store . load ( ) ;
store . sort ( ) ;
} ,
init : function ( view ) {
let me = this ;
if ( ! view . nodename ) {
throw "no nodename given" ;
}
let url = ` /api2/json/nodes/ ${ view . nodename } /disks/zfs ` ;
2020-09-25 18:34:54 +02:00
view . getStore ( ) . getProxy ( ) . setUrl ( url ) ;
2020-06-25 14:53:05 +02:00
Proxmox . Utils . monStoreErrors ( view , view . getStore ( ) , true ) ;
me . reload ( ) ;
} ,
} ,
columns : [
{
text : gettext ( 'Name' ) ,
dataIndex : 'name' ,
2020-09-25 18:34:54 +02:00
flex : 1 ,
2020-06-25 14:53:05 +02:00
} ,
{
header : gettext ( 'Size' ) ,
renderer : Proxmox . Utils . format _size ,
2020-09-25 18:34:54 +02:00
dataIndex : 'size' ,
2020-06-25 14:53:05 +02:00
} ,
{
header : gettext ( 'Free' ) ,
renderer : Proxmox . Utils . format _size ,
2020-09-25 18:34:54 +02:00
dataIndex : 'free' ,
2020-06-25 14:53:05 +02:00
} ,
{
header : gettext ( 'Allocated' ) ,
renderer : Proxmox . Utils . format _size ,
2020-09-25 18:34:54 +02:00
dataIndex : 'alloc' ,
2020-06-25 14:53:05 +02:00
} ,
{
header : gettext ( 'Fragmentation' ) ,
renderer : function ( value ) {
return value . toString ( ) + '%' ;
} ,
2020-09-25 18:34:54 +02:00
dataIndex : 'frag' ,
2020-06-25 14:53:05 +02:00
} ,
{
header : gettext ( 'Health' ) ,
renderer : Proxmox . Utils . render _zfs _health ,
2020-09-25 18:34:54 +02:00
dataIndex : 'health' ,
2020-06-25 14:53:05 +02:00
} ,
{
header : gettext ( 'Deduplication' ) ,
hidden : true ,
renderer : function ( value ) {
return value . toFixed ( 2 ) . toString ( ) + 'x' ;
} ,
2020-09-25 18:34:54 +02:00
dataIndex : 'dedup' ,
} ,
2020-06-25 14:53:05 +02:00
] ,
rootVisible : false ,
useArrows : true ,
tbar : [
{
text : gettext ( 'Reload' ) ,
iconCls : 'fa fa-refresh' ,
handler : 'reload' ,
} ,
{
text : gettext ( 'Create' ) + ': ZFS' ,
handler : 'openCreateWindow' ,
} ,
{
text : gettext ( 'Detail' ) ,
xtype : 'proxmoxButton' ,
disabled : true ,
2020-07-03 17:20:33 +02:00
handler : 'openDetailWindow' ,
2020-09-25 18:34:54 +02:00
} ,
2020-06-25 14:53:05 +02:00
] ,
listeners : {
itemdblclick : 'openDetailWindow' ,
} ,
store : {
fields : [ 'name' , 'size' , 'free' , 'alloc' , 'dedup' , 'frag' , 'health' ] ,
proxy : {
type : 'proxmox' ,
} ,
2020-09-25 18:34:54 +02:00
sorters : 'name' ,
2020-06-25 14:53:05 +02:00
} ,
} ) ;