Merge pull request #876 from ubavic/fix/machine_unpair_breaks_server_ui

fix: machine unpair breaks the UI
This commit is contained in:
Rafael Taranto 2021-11-11 18:20:49 +00:00 committed by GitHub
commit 23c4f59606

View file

@ -17,11 +17,14 @@ function pullToken (token) {
} }
function unpair (deviceId) { function unpair (deviceId) {
const sql = 'delete from devices where device_id=$1'
const deleteMachinePings = 'delete from machine_pings where device_id=$1'
// TODO new-admin: We should remove all configs related to that device. This can get tricky. // TODO new-admin: We should remove all configs related to that device. This can get tricky.
return Promise.all([db.none(sql, [deviceId]), db.none(deleteMachinePings, [deviceId])]) return db.tx(t => {
const q1 = t.none('DELETE FROM devices WHERE device_id=$1', [deviceId])
const q2 = t.none('DELETE FROM machine_pings WHERE device_id=$1', [deviceId])
const q3 = t.none('DELETE FROM machine_network_heartbeat WHERE device_id=$1', [deviceId])
const q4 = t.none('DELETE FROM machine_network_performance WHERE device_id=$1', [deviceId])
return Promise.all([q1, q2, q3, q4])
})
} }
function pair (token, deviceId, machineModel, numOfCassettes = DEFAULT_NUMBER_OF_CASSETTES) { function pair (token, deviceId, machineModel, numOfCassettes = DEFAULT_NUMBER_OF_CASSETTES) {