mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-11 14:54:41 +00:00
ui/api: metrics: move server to subpath, post to path with ID
We actually wanted to use that scheme for more new API paths, lets see if it is really fitting starting with this. Use the new widget-toolkit submitUrl helper to add the ID on create. And unify the edit/create window creation, which may fit better in a separate commit, it's quite small and was to cumbersome to untangle, so just go against my one rules here... :( Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
71f5bf0a45
commit
d57f8d9482
@ -46,7 +46,7 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
__PACKAGE__->register_method ({
|
__PACKAGE__->register_method ({
|
||||||
subclass => "PVE::API2::Cluster::MetricServer",
|
subclass => "PVE::API2::Cluster::MetricServer",
|
||||||
path => 'metricserver',
|
path => 'metrics',
|
||||||
});
|
});
|
||||||
|
|
||||||
__PACKAGE__->register_method ({
|
__PACKAGE__->register_method ({
|
||||||
@ -138,8 +138,8 @@ __PACKAGE__->register_method ({
|
|||||||
{ name => 'config' },
|
{ name => 'config' },
|
||||||
{ name => 'acme' },
|
{ name => 'acme' },
|
||||||
{ name => 'ceph' },
|
{ name => 'ceph' },
|
||||||
{ name => 'metricserver' },
|
{ name => 'metrics' },
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($have_sdn) {
|
if ($have_sdn) {
|
||||||
push(@{$result}, { name => 'sdn' });
|
push(@{$result}, { name => 'sdn' });
|
||||||
|
@ -17,6 +17,35 @@ __PACKAGE__->register_method ({
|
|||||||
name => 'index',
|
name => 'index',
|
||||||
path => '',
|
path => '',
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
|
description => "Metrics index.",
|
||||||
|
permissions => { user => 'all' },
|
||||||
|
parameters => {
|
||||||
|
additionalProperties => 0,
|
||||||
|
properties => {},
|
||||||
|
},
|
||||||
|
returns => {
|
||||||
|
type => 'array',
|
||||||
|
items => {
|
||||||
|
type => "object",
|
||||||
|
properties => {},
|
||||||
|
},
|
||||||
|
links => [ { rel => 'child', href => "{name}" } ],
|
||||||
|
},
|
||||||
|
code => sub {
|
||||||
|
my ($param) = @_;
|
||||||
|
|
||||||
|
my $result = [
|
||||||
|
{ name => 'server' },
|
||||||
|
];
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->register_method ({
|
||||||
|
name => 'server_index',
|
||||||
|
path => 'server',
|
||||||
|
method => 'GET',
|
||||||
description => "List configured metric servers.",
|
description => "List configured metric servers.",
|
||||||
permissions => {
|
permissions => {
|
||||||
check => ['perm', '/', ['Sys.Audit']],
|
check => ['perm', '/', ['Sys.Audit']],
|
||||||
@ -76,7 +105,7 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
__PACKAGE__->register_method ({
|
__PACKAGE__->register_method ({
|
||||||
name => 'read',
|
name => 'read',
|
||||||
path => '{id}',
|
path => 'server/{id}',
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
description => "Read metric server configuration.",
|
description => "Read metric server configuration.",
|
||||||
permissions => {
|
permissions => {
|
||||||
@ -107,7 +136,7 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
__PACKAGE__->register_method ({
|
__PACKAGE__->register_method ({
|
||||||
name => 'create',
|
name => 'create',
|
||||||
path => '',
|
path => 'server/{id}',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
description => "Create a new external metric server config",
|
description => "Create a new external metric server config",
|
||||||
@ -143,7 +172,7 @@ __PACKAGE__->register_method ({
|
|||||||
__PACKAGE__->register_method ({
|
__PACKAGE__->register_method ({
|
||||||
name => 'update',
|
name => 'update',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
path => '{id}',
|
path => 'server/{id}',
|
||||||
method => 'PUT',
|
method => 'PUT',
|
||||||
description => "Update metric server configuration.",
|
description => "Update metric server configuration.",
|
||||||
permissions => {
|
permissions => {
|
||||||
@ -194,7 +223,7 @@ __PACKAGE__->register_method ({
|
|||||||
__PACKAGE__->register_method ({
|
__PACKAGE__->register_method ({
|
||||||
name => 'delete',
|
name => 'delete',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
path => '{id}',
|
path => 'server/{id}',
|
||||||
method => 'DELETE',
|
method => 'DELETE',
|
||||||
description => "Remove Metric server.",
|
description => "Remove Metric server.",
|
||||||
permissions => {
|
permissions => {
|
||||||
|
@ -16,10 +16,10 @@ Ext.define('PVE.dc.MetricServerView', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addInfluxDB: function() {
|
editWindow: function(xtype, id) {
|
||||||
let me = this;
|
let me = this;
|
||||||
Ext.create(`PVE.dc.InfluxDBEdit`, {
|
Ext.create(`PVE.dc.${xtype}Edit`, {
|
||||||
url: `/api2/extjs/cluster/metricserver`,
|
serverid: id,
|
||||||
autoShow: true,
|
autoShow: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
destroy: () => me.reload(),
|
destroy: () => me.reload(),
|
||||||
@ -27,15 +27,8 @@ Ext.define('PVE.dc.MetricServerView', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
addGraphite: function() {
|
addServer: function(button) {
|
||||||
let me = this;
|
this.editWindow(button.text);
|
||||||
Ext.create(`PVE.dc.GraphiteEdit`, {
|
|
||||||
url: `/api2/extjs/cluster/metricserver`,
|
|
||||||
autoShow: true,
|
|
||||||
listeners: {
|
|
||||||
destroy: () => me.reload(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
editServer: function() {
|
editServer: function() {
|
||||||
@ -46,17 +39,10 @@ Ext.define('PVE.dc.MetricServerView', {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let rec = selection[0];
|
let cfg = selection[0].data;
|
||||||
|
|
||||||
let xtype = me.render_type(rec.data.type);
|
let xtype = me.render_type(cfg.type);
|
||||||
Ext.create(`PVE.dc.${xtype}Edit`, {
|
me.editWindow(xtype, cfg.id);
|
||||||
url: `/api2/extjs/cluster/metricserver/${rec.data.id}`,
|
|
||||||
serverid: rec.data.id,
|
|
||||||
autoShow: true,
|
|
||||||
listeners: {
|
|
||||||
destroy: () => me.reload(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
reload: function() {
|
reload: function() {
|
||||||
@ -69,7 +55,7 @@ Ext.define('PVE.dc.MetricServerView', {
|
|||||||
id: 'metricservers',
|
id: 'metricservers',
|
||||||
proxy: {
|
proxy: {
|
||||||
type: 'proxmox',
|
type: 'proxmox',
|
||||||
url: '/api2/json/cluster/metricserver',
|
url: '/api2/json/cluster/metrics/server',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -109,11 +95,11 @@ Ext.define('PVE.dc.MetricServerView', {
|
|||||||
menu: [
|
menu: [
|
||||||
{
|
{
|
||||||
text: 'Graphite',
|
text: 'Graphite',
|
||||||
handler: 'addGraphite',
|
handler: 'addServer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'InfluxDB',
|
text: 'InfluxDB',
|
||||||
handler: 'addInfluxDB',
|
handler: 'addServer',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -125,7 +111,7 @@ Ext.define('PVE.dc.MetricServerView', {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype: 'proxmoxStdRemoveButton',
|
xtype: 'proxmoxStdRemoveButton',
|
||||||
baseurl: `/api2/extjs/cluster/metricserver`,
|
baseurl: `/api2/extjs/cluster/metrics/server`,
|
||||||
callback: 'reload',
|
callback: 'reload',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -151,6 +137,7 @@ Ext.define('PVE.dc.MetricServerBaseEdit', {
|
|||||||
let me = this;
|
let me = this;
|
||||||
me.isCreate = !me.serverid;
|
me.isCreate = !me.serverid;
|
||||||
me.serverid = me.serverid || "";
|
me.serverid = me.serverid || "";
|
||||||
|
me.url = `/api2/extjs/cluster/metrics/server/${me.serverid}`;
|
||||||
me.method = me.isCreate ? 'POST' : 'PUT';
|
me.method = me.isCreate ? 'POST' : 'PUT';
|
||||||
if (!me.isCreate) {
|
if (!me.isCreate) {
|
||||||
me.subject = `${me.subject}: ${me.serverid}`;
|
me.subject = `${me.subject}: ${me.serverid}`;
|
||||||
@ -158,6 +145,10 @@ Ext.define('PVE.dc.MetricServerBaseEdit', {
|
|||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
submitUrl: function(url, values) {
|
||||||
|
return this.isCreate ? `${url}/${values.id}` : url;
|
||||||
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
let me = this;
|
let me = this;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user