]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - node/APT.js
1 Ext
.define('apt-pkglist', {
2 extend
: 'Ext.data.Model',
3 fields
: [ 'Package', 'Title', 'Description', 'Section', 'Arch',
4 'Priority', 'Version', 'OldVersion', 'ChangeLogUrl', 'Origin' ],
8 Ext
.define('Proxmox.node.APT', {
9 extend
: 'Ext.grid.GridPanel',
11 xtype
: 'proxmoxNodeAPT',
13 upgradeBtn
: undefined,
17 header
: gettext('Package'),
23 text
: gettext('Version'),
26 header
: gettext('current'),
29 dataIndex
: 'OldVersion'
32 header
: gettext('new'),
40 header
: gettext('Description'),
47 initComponent : function() {
51 throw "no node name specified";
54 var store
= Ext
.create('Ext.data.Store', {
59 url
: "/api2/json/nodes/" + me
.nodename
+ "/apt/update"
69 var groupingFeature
= Ext
.create('Ext.grid.feature.Grouping', {
70 groupHeaderTpl
: '{[ "Origin: " + values.name ]} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})',
71 enableGroupingMenu
: false
74 var rowBodyFeature
= Ext
.create('Ext.grid.feature.RowBody', {
75 getAdditionalData: function (data
, rowIndex
, record
, orig
) {
76 var headerCt
= this.view
.headerCt
;
77 var colspan
= headerCt
.getColumnCount();
78 // Usually you would style the my-body-class in CSS file
80 rowBody
: '<div style="padding: 1em">' +
81 Ext
.String
.htmlEncode(data
.Description
) +
83 rowBodyColspan
: colspan
88 var reload = function() {
92 Proxmox
.Utils
.monStoreErrors(me
, store
, true);
94 var apt_command = function(cmd
){
95 Proxmox
.Utils
.API2Request({
96 url
: "/nodes/" + me
.nodename
+ "/apt/" + cmd
,
98 failure: function(response
, opts
) {
99 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
101 success: function(response
, opts
) {
102 var upid
= response
.result
.data
;
104 var win
= Ext
.create('Proxmox.window.TaskViewer', {
108 me
.mon(win
, 'close', reload
);
113 var sm
= Ext
.create('Ext.selection.RowModel', {});
115 var update_btn
= new Ext
.Button({
116 text
: gettext('Refresh'),
118 Proxmox
.Utils
.checked_command(function() { apt_command('update'); });
122 var show_changelog = function(rec
) {
123 if (!rec
|| !rec
.data
|| !(rec
.data
.ChangeLogUrl
&& rec
.data
.Package
)) {
127 var view
= Ext
.createWidget('component', {
130 'background-color': 'white',
131 'white-space': 'pre',
132 'font-family': 'monospace',
137 var win
= Ext
.create('Ext.window.Window', {
138 title
: gettext('Changelog') + ": " + rec
.data
.Package
,
146 Proxmox
.Utils
.API2Request({
148 url
: "/nodes/" + me
.nodename
+ "/apt/changelog",
150 name
: rec
.data
.Package
,
151 version
: rec
.data
.Version
154 failure: function(response
, opts
) {
156 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
158 success: function(response
, opts
) {
160 view
.update(Ext
.htmlEncode(response
.result
.data
));
166 var changelog_btn
= new Proxmox
.button
.Button({
167 text
: gettext('Changelog'),
170 enableFn: function(rec
) {
171 if (!rec
|| !rec
.data
|| !(rec
.data
.ChangeLogUrl
&& rec
.data
.Package
)) {
176 handler: function(b
, e
, rec
) {
182 me
.tbar
= [ update_btn
, me
.upgradeBtn
, changelog_btn
];
184 me
.tbar
= [ update_btn
, changelog_btn
];
190 stateId
: 'grid-update',
194 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>'
196 features
: [ groupingFeature
, rowBodyFeature
],
199 itemdblclick: function(v
, rec
) {