From cf8fdacfa3f8e514c2efb4ba188cbc997a29a041 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 8 Sep 2021 14:25:14 -0400 Subject: [PATCH] Refactor connection toggle to use API URLs --- netbox/project-static/dist/netbox.js | Bin 322959 -> 322940 bytes netbox/project-static/dist/netbox.js.map | Bin 311231 -> 311224 bytes .../src/buttons/connectionToggle.ts | 6 +++--- .../dcim/inc/cable_toggle_buttons.html | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 0a34d582cac190eec35bd0123082d1929a1f2ac8..33d004108f7a2d8bbc864171bef2575120e8ae90 100644 GIT binary patch delta 45 zcmeCbE&S(}a6=1Y3sVd87M9n`Idw~ma+EZ6@@%Iwda#I2XI;T!$e6m_Zv~5^D*%qF B4}Aat delta 53 zcmex!OSu2Ga6=1Y3sVd87M9n`r@vp$;w_P&pIDHopOT!JtDl^hl#^PluTq^_tDmsl JdIgK4D*#`l6zBi| diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index 75a47192a84e89a6eee86e17cf2b34c827440e17..8bee87505e47b575c85fb70dc5dd0dcb88efb21b 100644 GIT binary patch delta 58 zcmdo0UuegFp@tU57N!>FEi8<^0=_z~j*fvkiH?qmI+2df#?u9RSzK9wV&2meds!ry N44t=E_p-Pc0RTyq5+eWr delta 83 zcmdn-Uuge-p@tU57N!>FEi8<^0^T~Vj*fvkiH?qmI)RSPhSLRmSzJ}~og5wWopih% g9sPBj9UWbD!W|t$L0oSgcZgV8hU@l{UKST409=$A4*&oF diff --git a/netbox/project-static/src/buttons/connectionToggle.ts b/netbox/project-static/src/buttons/connectionToggle.ts index 6485bbb50..74b32dc3a 100644 --- a/netbox/project-static/src/buttons/connectionToggle.ts +++ b/netbox/project-static/src/buttons/connectionToggle.ts @@ -8,12 +8,12 @@ import { isTruthy, apiPatch, hasError, getElements } from '../util'; * @param element Connection Toggle Button Element */ function toggleConnection(element: HTMLButtonElement): void { - const id = element.getAttribute('data'); + const url = element.getAttribute('data-url'); const connected = element.classList.contains('connected'); const status = connected ? 'planned' : 'connected'; - if (isTruthy(id)) { - apiPatch(`/api/dcim/cables/${id}/`, { status }).then(res => { + if (isTruthy(url)) { + apiPatch(url, { status }).then(res => { if (hasError(res)) { // If the API responds with an error, show it to the user. createToast('danger', 'Error', res.error).show(); diff --git a/netbox/templates/dcim/inc/cable_toggle_buttons.html b/netbox/templates/dcim/inc/cable_toggle_buttons.html index 3fe34acd7..77db3093f 100644 --- a/netbox/templates/dcim/inc/cable_toggle_buttons.html +++ b/netbox/templates/dcim/inc/cable_toggle_buttons.html @@ -1,10 +1,10 @@ {% if perms.dcim.change_cable %} {% if cable.status == 'connected' %} - {% else %} - {% endif %}