2021-11-19 14:42:27 +00:00
|
|
|
Ext.define('pmx-traffic-control', {
|
|
|
|
extend: 'Ext.data.Model',
|
|
|
|
fields: [
|
|
|
|
'name', 'rate-in', 'rate-out', 'burst-in', 'burst-out', 'network',
|
|
|
|
'timeframe', 'comment', 'cur-rate-in', 'cur-rate-out',
|
|
|
|
{
|
|
|
|
name: 'rateInUsed',
|
2021-11-20 20:52:29 +00:00
|
|
|
calculate: d => Proxmox.Utils.size_unit_ratios(d['cur-rate-in'], d['rate-in']),
|
2021-11-19 14:42:27 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'rateOutUsed',
|
2021-11-20 20:52:29 +00:00
|
|
|
calculate: d => Proxmox.Utils.size_unit_ratios(d['cur-rate-out'], d['rate-out']),
|
2021-11-19 14:42:27 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
idProperty: 'name',
|
|
|
|
proxy: {
|
|
|
|
type: 'proxmox',
|
|
|
|
url: '/api2/json/admin/traffic-control',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.config.TrafficControlView', {
|
|
|
|
extend: 'Ext.grid.GridPanel',
|
|
|
|
alias: 'widget.pbsTrafficControlView',
|
|
|
|
|
|
|
|
stateful: true,
|
|
|
|
stateId: 'grid-traffic-control',
|
|
|
|
|
|
|
|
title: gettext('Traffic Control'),
|
|
|
|
|
2021-11-20 20:54:53 +00:00
|
|
|
// tools: [PBS.Utils.get_help_tool("backup-remote")], // TODO!
|
2021-11-19 14:42:27 +00:00
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
|
|
|
addRemote: function() {
|
|
|
|
let me = this;
|
|
|
|
Ext.create('PBS.window.TrafficControlEdit', {
|
2021-11-20 20:54:53 +00:00
|
|
|
autoShow: true,
|
2021-11-19 14:42:27 +00:00
|
|
|
listeners: {
|
2021-11-20 20:54:53 +00:00
|
|
|
destroy: () => me.reload(),
|
2021-11-19 14:42:27 +00:00
|
|
|
},
|
2021-11-20 20:54:53 +00:00
|
|
|
});
|
2021-11-19 14:42:27 +00:00
|
|
|
},
|
|
|
|
|
2021-11-20 20:54:53 +00:00
|
|
|
editTrafficControl: function() {
|
2021-11-19 14:42:27 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
let selection = view.getSelection();
|
|
|
|
if (selection.length < 1) return;
|
|
|
|
|
2021-11-20 20:54:53 +00:00
|
|
|
Ext.create('PBS.window.TrafficControlEdit', {
|
|
|
|
name: selection[0].data.name,
|
|
|
|
autoShow: true,
|
2021-11-19 14:42:27 +00:00
|
|
|
listeners: {
|
2021-11-20 20:54:53 +00:00
|
|
|
destroy: () => me.reload(),
|
2021-11-19 14:42:27 +00:00
|
|
|
},
|
2021-11-20 20:54:53 +00:00
|
|
|
});
|
2021-11-19 14:42:27 +00:00
|
|
|
},
|
|
|
|
|
2021-11-20 20:52:29 +00:00
|
|
|
render_bandwidth: v => v ? Proxmox.Utils.autoscale_size_unit(v) + '/s' : '',
|
2021-11-19 14:42:27 +00:00
|
|
|
|
|
|
|
reload: function() { this.getView().getStore().rstore.load(); },
|
|
|
|
|
|
|
|
init: function(view) {
|
|
|
|
Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
listeners: {
|
|
|
|
activate: 'reload',
|
2021-11-20 20:54:53 +00:00
|
|
|
itemdblclick: 'editTrafficControl',
|
2021-11-19 14:42:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
store: {
|
|
|
|
type: 'diff',
|
|
|
|
autoDestroy: true,
|
|
|
|
autoDestroyRstore: true,
|
|
|
|
sorters: 'name',
|
|
|
|
rstore: {
|
|
|
|
type: 'update',
|
|
|
|
storeid: 'pmx-traffic-control',
|
|
|
|
model: 'pmx-traffic-control',
|
|
|
|
autoStart: true,
|
|
|
|
interval: 5000,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Add'),
|
|
|
|
handler: 'addRemote',
|
|
|
|
selModel: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Edit'),
|
2021-11-20 20:54:53 +00:00
|
|
|
handler: 'editTrafficControl',
|
2021-11-19 14:42:27 +00:00
|
|
|
disabled: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxStdRemoveButton',
|
|
|
|
baseurl: '/config/traffic-control',
|
|
|
|
callback: 'reload',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
viewConfig: {
|
|
|
|
trackOver: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
header: gettext('Rule'),
|
2021-11-20 21:32:02 +00:00
|
|
|
width: 120,
|
2021-11-19 14:42:27 +00:00
|
|
|
sortable: true,
|
|
|
|
renderer: Ext.String.htmlEncode,
|
|
|
|
dataIndex: 'name',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Rate In'),
|
2021-11-20 21:32:02 +00:00
|
|
|
width: 120,
|
2021-11-19 14:42:27 +00:00
|
|
|
sortable: true,
|
|
|
|
renderer: 'render_bandwidth',
|
|
|
|
dataIndex: 'rate-in',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Rate In Used'),
|
|
|
|
xtype: 'widgetcolumn',
|
|
|
|
dataIndex: 'rateInUsed',
|
2021-11-20 21:32:02 +00:00
|
|
|
//width: 200,
|
|
|
|
flex: 2,
|
2021-11-19 14:42:27 +00:00
|
|
|
widget: {
|
|
|
|
xtype: 'progressbarwidget',
|
|
|
|
textTpl: '{percent:number("0")}%',
|
|
|
|
animate: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Rate Out'),
|
2021-11-20 21:32:02 +00:00
|
|
|
width: 120,
|
2021-11-19 14:42:27 +00:00
|
|
|
sortable: true,
|
|
|
|
renderer: 'render_bandwidth',
|
|
|
|
dataIndex: 'rate-out',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Rate Out Used'),
|
|
|
|
xtype: 'widgetcolumn',
|
|
|
|
dataIndex: 'rateOutUsed',
|
2021-11-20 21:32:02 +00:00
|
|
|
flex: 2,
|
2021-11-19 14:42:27 +00:00
|
|
|
widget: {
|
|
|
|
xtype: 'progressbarwidget',
|
|
|
|
textTpl: '{percent:number("0")}%',
|
|
|
|
animate: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Burst In'),
|
2021-11-20 21:32:02 +00:00
|
|
|
width: 120,
|
2021-11-19 14:42:27 +00:00
|
|
|
sortable: true,
|
|
|
|
renderer: 'render_bandwidth',
|
|
|
|
dataIndex: 'burst-in',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Burst Out'),
|
2021-11-20 21:32:02 +00:00
|
|
|
width: 120,
|
2021-11-19 14:42:27 +00:00
|
|
|
sortable: true,
|
|
|
|
renderer: 'render_bandwidth',
|
|
|
|
dataIndex: 'burst-out',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Networks'),
|
2021-11-20 21:32:02 +00:00
|
|
|
flex: 3,
|
2021-11-19 14:42:27 +00:00
|
|
|
sortable: true,
|
|
|
|
renderer: Ext.String.htmlEncode,
|
|
|
|
dataIndex: 'network',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Timeframes'),
|
|
|
|
sortable: false,
|
2021-11-20 20:54:22 +00:00
|
|
|
renderer: tf => tf ? Ext.String.htmlEncode(tf.join('; ')) : '',
|
2021-11-19 14:42:27 +00:00
|
|
|
dataIndex: 'timeframe',
|
2021-11-20 21:32:02 +00:00
|
|
|
flex: 3,
|
2021-11-19 14:42:27 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Comment'),
|
|
|
|
sortable: false,
|
|
|
|
renderer: Ext.String.htmlEncode,
|
|
|
|
dataIndex: 'comment',
|
2021-11-20 21:32:02 +00:00
|
|
|
flex: 2,
|
2021-11-19 14:42:27 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|