]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - src/node/APT.js
739aaf3429aca38621ef250347f506b573aa118a
1 Ext
.define('apt-pkglist', {
2 extend
: 'Ext.data.Model',
4 'Package', 'Title', 'Description', 'Section', 'Arch', 'Priority', 'Version', 'OldVersion',
5 'ChangeLogUrl', 'Origin',
10 Ext
.define('Proxmox.node.APT', {
11 extend
: 'Ext.grid.GridPanel',
13 xtype
: 'proxmoxNodeAPT',
15 upgradeBtn
: undefined,
19 header
: gettext('Package'),
25 text
: gettext('Version'),
28 header
: gettext('current'),
31 dataIndex
: 'OldVersion',
34 header
: gettext('new'),
42 header
: gettext('Description'),
49 initComponent: function() {
53 throw "no node name specified";
56 let store
= Ext
.create('Ext.data.Store', {
61 url
: `/api2/json/nodes/${me.nodename}/apt/update`,
70 Proxmox
.Utils
.monStoreErrors(me
, store
, true);
72 let groupingFeature
= Ext
.create('Ext.grid.feature.Grouping', {
73 groupHeaderTpl
: '{[ "Origin: " + values.name ]} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})',
74 enableGroupingMenu
: false,
77 let rowBodyFeature
= Ext
.create('Ext.grid.feature.RowBody', {
78 getAdditionalData: function(data
, rowIndex
, record
, orig
) {
79 let headerCt
= this.view
.headerCt
;
80 let colspan
= headerCt
.getColumnCount();
82 rowBody
: `<div style="padding: 1em">${Ext.htmlEncode(data.Description)}</div>`,
83 rowBodyCls
: me
.full_description
? '' : Ext
.baseCSSPrefix
+ 'grid-row-body-hidden',
84 rowBodyColspan
: colspan
,
89 let apt_command = function(cmd
) {
90 Proxmox
.Utils
.API2Request({
91 url
: `/nodes/${me.nodename}/apt/${cmd}`,
93 success
: ({ result
}) => Ext
.create('Proxmox.window.TaskViewer', {
97 close
: () => store
.load(),
103 let sm
= Ext
.create('Ext.selection.RowModel', {});
105 let update_btn
= new Ext
.Button({
106 text
: gettext('Refresh'),
107 handler
: () => Proxmox
.Utils
.checked_command(function() { apt_command('update'); }),
110 let show_changelog = function(rec
) {
111 if (!rec
?.data
?.ChangeLogUrl
|| !rec
?.data
?.Package
) {
112 console
.debug('cannot show changelog, missing Package and/or ChangeLogUrl', rec
);
116 let view
= Ext
.createWidget('component', {
119 'white-space': 'pre',
120 'font-family': 'monospace',
125 let win
= Ext
.create('Ext.window.Window', {
126 title
: gettext('Changelog') + ": " + rec
.data
.Package
,
134 Proxmox
.Utils
.API2Request({
136 url
: "/nodes/" + me
.nodename
+ "/apt/changelog",
138 name
: rec
.data
.Package
,
139 version
: rec
.data
.Version
,
142 failure: function(response
, opts
) {
144 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
146 success: function(response
, opts
) {
148 view
.update(Ext
.htmlEncode(response
.result
.data
));
153 let changelog_btn
= new Proxmox
.button
.Button({
154 text
: gettext('Changelog'),
157 enableFn
: rec
=> !!rec
?.data
?.ChangeLogUrl
&& !!rec
?.data
?.Package
,
158 handler
: (b
, e
, rec
) => show_changelog(rec
),
161 let verbose_desc_checkbox
= new Ext
.form
.field
.Checkbox({
162 boxLabel
: gettext('Show details'),
165 change
: (f
, val
) => {
166 me
.full_description
= val
;
167 me
.getView().refresh();
173 me
.tbar
= [update_btn
, me
.upgradeBtn
, changelog_btn
, '->', verbose_desc_checkbox
];
175 me
.tbar
= [update_btn
, changelog_btn
, '->', verbose_desc_checkbox
];
181 stateId
: 'grid-update',
185 emptyText
: `<div style="display:flex;justify-content:center;"><p>${gettext('No updates available.')}</p></div>`,
187 features
: [groupingFeature
, rowBodyFeature
],
189 activate
: () => store
.load(),
190 itemdblclick
: (v
, rec
) => show_changelog(rec
),