From 9050fe25049560964f03cf1264dcab1a83f6b92f Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Mon, 15 Apr 2019 03:36:13 +0000 Subject: [configurator] add ability to mark a config as default --- server/api/ipxeconfigs.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'server/api') diff --git a/server/api/ipxeconfigs.js b/server/api/ipxeconfigs.js index f7020b6..64f2c37 100644 --- a/server/api/ipxeconfigs.js +++ b/server/api/ipxeconfigs.js @@ -116,6 +116,18 @@ router.putAsync('/:id/clients', async (req, res) => { } }) +router.putAsync('/:id/default', async (req, res) => { + if (!(req.params.id > 0)) return HttpResponse.invalidId().send(res) + const config = await db.config.findOne({ where: { id: req.params.id } }) + if (config) { + await db.config.update({ isDefault: false }, { where: { isDefault: true } }) + await config.update({ isDefault: true }) + HttpResponse.success('set as default:', 'config', config.id).send(res) + } else { + HttpResponse.notFound(req.params.id).send(res) + } +}) + // ############################################################################ // ########################## DELETE requests ############################### -- cgit v1.2.3-55-g7522