2019-01-22 13:48:00 +03:00
/*global Blob,Proxmox*/
Ext . define ( 'PBS.SubscriptionKeyEdit' , {
extend : 'Proxmox.window.Edit' ,
2019-12-18 21:21:59 +03:00
2019-01-22 13:48:00 +03:00
title : gettext ( 'Upload Subscription Key' ) ,
width : 300 ,
autoLoad : true ,
onlineHelp : 'getting_help' ,
items : {
xtype : 'textfield' ,
name : 'key' ,
value : '' ,
fieldLabel : gettext ( 'Subscription Key' )
}
} ) ;
Ext . define ( 'PBS.Subscription' , {
extend : 'Proxmox.grid.ObjectGrid' ,
xtype : 'pbsSubscription' ,
title : gettext ( 'Subscription' ) ,
2019-04-11 13:18:04 +03:00
border : true ,
2019-01-22 13:48:00 +03:00
onlineHelp : 'getting_help' ,
viewConfig : {
enableTextSelection : true
} ,
initComponent : function ( ) {
var me = this ;
var reload = function ( ) {
me . rstore . load ( ) ;
} ;
2020-07-21 14:41:06 +03:00
var baseurl = '/nodes/localhost/subscription' ;
2019-01-22 13:48:00 +03:00
var render _status = function ( value ) {
var message = me . getObjectValue ( 'message' ) ;
if ( message ) {
return value + ": " + message ;
}
return value ;
} ;
var rows = {
productname : {
header : gettext ( 'Type' )
} ,
key : {
header : gettext ( 'Subscription Key' )
} ,
status : {
header : gettext ( 'Status' ) ,
renderer : render _status
} ,
message : {
visible : false
} ,
serverid : {
header : gettext ( 'Server ID' )
} ,
sockets : {
header : gettext ( 'Sockets' )
} ,
checktime : {
header : gettext ( 'Last checked' ) ,
renderer : Proxmox . Utils . render _timestamp
} ,
nextduedate : {
header : gettext ( 'Next due date' )
}
} ;
Ext . apply ( me , {
url : '/api2/json' + baseurl ,
cwidth1 : 170 ,
2019-12-18 21:21:59 +03:00
tbar : [
2019-01-22 13:48:00 +03:00
{
text : gettext ( 'Upload Subscription Key' ) ,
handler : function ( ) {
var win = Ext . create ( 'PBS.SubscriptionKeyEdit' , {
2019-12-18 21:21:59 +03:00
url : '/api2/extjs/' + baseurl
2019-01-22 13:48:00 +03:00
} ) ;
win . show ( ) ;
win . on ( 'destroy' , reload ) ;
}
} ,
{
text : gettext ( 'Check' ) ,
handler : function ( ) {
Proxmox . Utils . API2Request ( {
params : { force : 1 } ,
url : baseurl ,
method : 'POST' ,
waitMsgTarget : me ,
failure : function ( response , opts ) {
Ext . Msg . alert ( gettext ( 'Error' ) , response . htmlStatus ) ;
} ,
callback : reload
} ) ;
}
}
] ,
rows : rows
} ) ;
me . callParent ( ) ;
reload ( ) ;
}
} ) ;