2019-01-22 13:48:00 +03:00
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' ) ,
2020-11-10 12:42:45 +03:00
width : 320 ,
2019-01-22 13:48:00 +03:00
autoLoad : true ,
2020-11-10 12:35:35 +03:00
onlineHelp : 'get_help' ,
2019-01-22 13:48:00 +03:00
items : {
xtype : 'textfield' ,
2020-11-10 12:42:45 +03:00
labelWidth : 120 ,
2019-01-22 13:48:00 +03:00
name : 'key' ,
value : '' ,
2020-09-25 19:40:03 +03:00
fieldLabel : gettext ( 'Subscription Key' ) ,
} ,
2019-01-22 13:48:00 +03:00
} ) ;
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
2020-11-10 12:35:35 +03:00
onlineHelp : 'get_help' ,
2020-11-10 15:38:50 +03:00
tools : [ PBS . Utils . get _help _tool ( "get_help" ) ] ,
2019-01-22 13:48:00 +03:00
viewConfig : {
2020-09-25 19:40:03 +03:00
enableTextSelection : true ,
2019-01-22 13:48:00 +03:00
} ,
2020-11-03 15:29:07 +03:00
showReport : function ( ) {
var me = this ;
var getReportFileName = function ( ) {
var now = Ext . Date . format ( new Date ( ) , 'D-d-F-Y-G-i' ) ;
return ` ${ me . nodename } -pbs-report- ${ now } .txt ` ;
} ;
var view = Ext . createWidget ( 'component' , {
itemId : 'system-report-view' ,
scrollable : true ,
style : {
'background-color' : 'white' ,
'white-space' : 'pre' ,
'font-family' : 'monospace' ,
padding : '5px' ,
} ,
} ) ;
var reportWindow = Ext . create ( 'Ext.window.Window' , {
title : gettext ( 'System Report' ) ,
width : 1024 ,
height : 600 ,
layout : 'fit' ,
modal : true ,
buttons : [
'->' ,
{
text : gettext ( 'Download' ) ,
handler : function ( ) {
var fileContent = Ext . String . htmlDecode ( reportWindow . getComponent ( 'system-report-view' ) . html ) ;
var fileName = getReportFileName ( ) ;
// Internet Explorer
if ( window . navigator . msSaveOrOpenBlob ) {
navigator . msSaveOrOpenBlob ( new Blob ( [ fileContent ] ) , fileName ) ;
} else {
var element = document . createElement ( 'a' ) ;
element . setAttribute ( 'href' , 'data:text/plain;charset=utf-8,' +
encodeURIComponent ( fileContent ) ) ;
element . setAttribute ( 'download' , fileName ) ;
element . style . display = 'none' ;
document . body . appendChild ( element ) ;
element . click ( ) ;
document . body . removeChild ( element ) ;
}
} ,
} ,
] ,
items : view ,
} ) ;
Proxmox . Utils . API2Request ( {
url : '/api2/extjs/nodes/' + me . nodename + '/report' ,
method : 'GET' ,
waitMsgTarget : me ,
failure : function ( response ) {
Ext . Msg . alert ( gettext ( 'Error' ) , response . htmlStatus ) ;
} ,
success : function ( response ) {
var report = Ext . htmlEncode ( response . result . data ) ;
reportWindow . show ( ) ;
view . update ( report ) ;
} ,
} ) ;
} ,
2020-09-25 19:40:03 +03:00
initComponent : function ( ) {
2020-10-27 14:27:38 +03:00
let me = this ;
2019-01-22 13:48:00 +03:00
2020-10-27 14:27:38 +03:00
let reload = ( ) => me . rstore . load ( ) ;
let baseurl = '/nodes/localhost/subscription' ;
2019-01-22 13:48:00 +03:00
2020-10-27 14:27:38 +03:00
let rows = {
2019-01-22 13:48:00 +03:00
productname : {
2020-09-25 19:40:03 +03:00
header : gettext ( 'Type' ) ,
2019-01-22 13:48:00 +03:00
} ,
key : {
2020-09-25 19:40:03 +03:00
header : gettext ( 'Subscription Key' ) ,
2019-01-22 13:48:00 +03:00
} ,
status : {
header : gettext ( 'Status' ) ,
2020-10-27 14:27:38 +03:00
renderer : ( value ) => {
value = Ext . String . capitalize ( value ) ;
let message = me . getObjectValue ( 'message' ) ;
if ( message ) {
return value + ": " + message ;
}
return value ;
} ,
2019-01-22 13:48:00 +03:00
} ,
message : {
2020-09-25 19:40:03 +03:00
visible : false ,
2019-01-22 13:48:00 +03:00
} ,
serverid : {
2020-09-25 19:40:03 +03:00
header : gettext ( 'Server ID' ) ,
2019-01-22 13:48:00 +03:00
} ,
checktime : {
header : gettext ( 'Last checked' ) ,
2020-09-25 19:40:03 +03:00
renderer : Proxmox . Utils . render _timestamp ,
2019-01-22 13:48:00 +03:00
} ,
nextduedate : {
2020-09-25 19:40:03 +03:00
header : gettext ( 'Next due date' ) ,
} ,
2019-01-22 13:48:00 +03:00
} ;
Ext . apply ( me , {
2020-10-27 14:27:38 +03:00
url : ` /api2/json ${ baseurl } ` ,
2019-01-22 13:48:00 +03:00
cwidth1 : 170 ,
2019-12-18 21:21:59 +03:00
tbar : [
2019-01-22 13:48:00 +03:00
{
text : gettext ( 'Upload Subscription Key' ) ,
2020-11-10 12:42:45 +03:00
iconCls : 'fa fa-ticket' ,
2019-01-22 13:48:00 +03:00
handler : function ( ) {
2020-10-27 14:27:38 +03:00
let win = Ext . create ( 'PBS.SubscriptionKeyEdit' , {
2020-09-25 19:40:03 +03:00
url : '/api2/extjs/' + baseurl ,
2020-11-10 12:42:45 +03:00
autoShow : true ,
2019-01-22 13:48:00 +03:00
} ) ;
win . on ( 'destroy' , reload ) ;
2020-09-25 19:40:03 +03:00
} ,
2019-01-22 13:48:00 +03:00
} ,
{
text : gettext ( 'Check' ) ,
2020-11-10 12:42:45 +03:00
iconCls : 'fa fa-check-square-o' ,
2019-01-22 13:48:00 +03:00
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 ) ;
} ,
2020-09-25 19:40:03 +03:00
callback : reload ,
2019-01-22 13:48:00 +03:00
} ) ;
2020-09-25 19:40:03 +03:00
} ,
} ,
2020-10-27 14:27:52 +03:00
{
text : gettext ( 'Remove Subscription' ) ,
xtype : 'proxmoxStdRemoveButton' ,
confirmMsg : gettext ( 'Are you sure you want to remove the subscription key?' ) ,
baseurl : baseurl ,
dangerous : true ,
selModel : false ,
callback : reload ,
2020-11-10 12:42:45 +03:00
iconCls : 'fa fa-trash-o' ,
2020-10-27 14:27:52 +03:00
} ,
2020-11-03 15:29:07 +03:00
'-' ,
{
text : gettext ( 'System Report' ) ,
2020-11-10 12:42:45 +03:00
iconCls : 'fa fa-stethoscope' ,
2020-11-03 15:29:07 +03:00
handler : function ( ) {
Proxmox . Utils . checked _command ( function ( ) { me . showReport ( ) ; } ) ;
} ,
} ,
2019-01-22 13:48:00 +03:00
] ,
2020-09-25 19:40:03 +03:00
rows : rows ,
2019-01-22 13:48:00 +03:00
} ) ;
me . callParent ( ) ;
reload ( ) ;
2020-09-25 19:40:03 +03:00
} ,
2019-01-22 13:48:00 +03:00
} ) ;