]>
git.proxmox.com Git - pve-manager.git/blob - www/manager/node/APT.js
1 Ext
.define('PVE.node.APT', {
2 extend
: 'Ext.grid.GridPanel',
4 alias
: ['widget.pveNodeAPT'],
6 initComponent : function() {
9 var nodename
= me
.pveSelNode
.data
.node
;
11 throw "no node name specified";
14 var store
= Ext
.create('Ext.data.Store', {
19 url
: "/api2/json/nodes/" + nodename
+ "/apt/update"
29 var groupingFeature
= Ext
.create('Ext.grid.feature.Grouping', {
30 groupHeaderTpl
: '{[ "Origin: " + values.name ]} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})',
31 enableGroupingMenu
: false
34 var rowBodyFeature
= Ext
.create('Ext.grid.feature.RowBody', {
35 getAdditionalData: function (data
, rowIndex
, record
, orig
) {
36 var headerCt
= this.view
.headerCt
;
37 var colspan
= headerCt
.getColumnCount();
38 // Usually you would style the my-body-class in CSS file
40 rowBody
: '<div style="padding: 1em">' + data
.Description
+ '</div>',
41 rowBodyColspan
: colspan
46 var reload = function() {
50 me
.loadCount
= 1; // avoid duplicate load mask
51 PVE
.Utils
.monStoreErrors(me
, store
);
53 var apt_command = function(cmd
){
54 PVE
.Utils
.API2Request({
55 url
: "/nodes/" + nodename
+ "/apt/" + cmd
,
57 failure: function(response
, opts
) {
58 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
60 success: function(response
, opts
) {
61 var upid
= response
.result
.data
;
63 var win
= Ext
.create('PVE.window.TaskViewer', {
67 me
.mon(win
, 'close', reload
);
72 var sm
= Ext
.create('Ext.selection.RowModel', {});
74 var update_btn
= new Ext
.Button({
75 text
: gettext('Refresh'),
77 PVE
.Utils
.checked_command(function() { apt_command('update'); });
81 var upgrade_btn
= new PVE
.button
.Button({
82 text
: gettext('Upgrade'),
83 disabled
: !(PVE
.UserName
&& PVE
.UserName
=== 'root@pam'),
85 PVE
.Utils
.checked_command(function() {
86 var url
= Ext
.urlEncode({
90 var nw
= window
.open("?" + url
, '_blank',
91 "innerWidth=745,innerheight=427");
98 var show_changelog = function(rec
) {
99 if (!rec
|| !rec
.data
|| !(rec
.data
.ChangeLogUrl
&& rec
.data
.Package
)) {
103 var view
= Ext
.createWidget('component', {
106 'background-color': 'white',
107 'white-space': 'pre',
108 'font-family': 'monospace',
113 var win
= Ext
.create('Ext.window.Window', {
114 title
: gettext('Changelog') + ": " + rec
.data
.Package
,
122 PVE
.Utils
.API2Request({
124 url
: "/nodes/" + nodename
+ "/apt/changelog",
126 name
: rec
.data
.Package
,
127 version
: rec
.data
.Version
130 failure: function(response
, opts
) {
132 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
134 success: function(response
, opts
) {
136 view
.update(Ext
.htmlEncode(response
.result
.data
));
142 var changelog_btn
= new PVE
.button
.Button({
143 text
: gettext('Changelog'),
146 enableFn: function(rec
) {
147 if (!rec
|| !rec
.data
|| !(rec
.data
.ChangeLogUrl
&& rec
.data
.Package
)) {
152 handler: function(b
, e
, rec
) {
163 emptyText
: '<div style="display:table; width:100%; height:100%;"><div style="display:table-cell; vertical-align: middle; text-align:center;"><b>' + gettext('No updates available.') + '</div></div>'
165 tbar
: [ update_btn
, upgrade_btn
, changelog_btn
],
166 features
: [ groupingFeature
, rowBodyFeature
],
169 header
: gettext('Package'),
175 text
: gettext('Version'),
178 header
: gettext('current'),
181 dataIndex
: 'OldVersion'
184 header
: gettext('new'),
192 header
: gettext('Description'),
200 itemdblclick: function(v
, rec
) {
210 Ext
.define('apt-pkglist', {
211 extend
: 'Ext.data.Model',
212 fields
: [ 'Package', 'Title', 'Description', 'Section', 'Arch',
213 'Priority', 'Version', 'OldVersion', 'ChangeLogUrl', 'Origin' ],
214 idProperty
: 'Package'