summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/api/ipxeconfigs.js12
-rw-r--r--server/migrations/20190415232633-add-isdefault-config.js13
-rw-r--r--server/models/config.js7
-rw-r--r--webapp/src/components/ConfiguratorModule.vue26
4 files changed, 53 insertions, 5 deletions
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 ###############################
diff --git a/server/migrations/20190415232633-add-isdefault-config.js b/server/migrations/20190415232633-add-isdefault-config.js
new file mode 100644
index 0000000..364352f
--- /dev/null
+++ b/server/migrations/20190415232633-add-isdefault-config.js
@@ -0,0 +1,13 @@
+'use strict'
+module.exports = {
+ up: (queryInterface, Sequelize) => {
+ return queryInterface.addColumn('configs', 'isDefault', {
+ type: Sequelize.BOOLEAN,
+ defaultValue: false,
+ allowNull: false
+ })
+ },
+ down: (queryInterface, Sequelize) => {
+ return queryInterface.removeColumn('configs', 'isDefault')
+ }
+}
diff --git a/server/models/config.js b/server/models/config.js
index b8770e1..d8dd2de 100644
--- a/server/models/config.js
+++ b/server/models/config.js
@@ -11,7 +11,12 @@ module.exports = (sequelize, DataTypes) => {
description: DataTypes.STRING(2048),
defaultEntry: DataTypes.INTEGER,
timeout: DataTypes.INTEGER,
- script: DataTypes.STRING(4096)
+ script: DataTypes.STRING(4096),
+ isDefault: {
+ type: DataTypes.BOOLEAN,
+ defaultValue: false,
+ allowNull: false
+ }
}, {
timestamps: false
})
diff --git a/webapp/src/components/ConfiguratorModule.vue b/webapp/src/components/ConfiguratorModule.vue
index 0641221..a08eb47 100644
--- a/webapp/src/components/ConfiguratorModule.vue
+++ b/webapp/src/components/ConfiguratorModule.vue
@@ -9,7 +9,9 @@
"deleteConfigs": "Delete one config | Delete {0} configs",
"createConfig": "Create config",
"deleteEntries": "Delete one entry | Delete {0} entries",
- "createEntry": "Create entry"
+ "createEntry": "Create entry",
+ "successSetAsDefault": "Successfully set config as default.",
+ "defaultConfig": "Default Config"
},
"de": {
"id": "ID",
@@ -20,7 +22,9 @@
"deleteConfigs": "Eine Konfiguration löschen | {0} Konfigurationen löschen",
"createConfig": "Konfiguration erstellen",
"deleteEntries": "Einen Eintrag löschen | {0} Einträge löschen",
- "createEntry": "Eintrag erstellen"
+ "createEntry": "Eintrag erstellen",
+ "successSetAsDefault": "Konfiguration erfolgreich als Standard gesetzt.",
+ "defaultConfig": "Standard Konfiguration"
}
}
</i18n>
@@ -40,7 +44,16 @@
<v-subheader>{{ $t('configs') }}</v-subheader>
<v-card>
<data-table v-model="selectedConfigs" :headers="configHeaders" :items="configs" min-width="800px" @dblclick="editConfig($event)">
- <div slot="actions" slot-scope="row" style="text-align: right">
+ <div slot="actions" slot-scope="row" style="display: flex; justify-content: flex-end; align-items: center">
+ <v-tooltip top v-if="row.item.isDefault">
+ <template #activator="{ on }">
+ <v-icon v-on="on" color="success" style="margin-right: 14px">flag</v-icon>
+ </template>
+ <span>{{ $t('defaultConfig') }}</span>
+ </v-tooltip>
+ <v-btn v-else icon @click.stop="setAsDefault(row.item.id)">
+ <v-icon style="opacity: 0.2">outlined_flag</v-icon>
+ </v-btn>
<v-btn flat small @click.stop="assignConfig(row.item)">
<span class="mr-1">{{ row.item.groupCount }}</span><v-icon small>category</v-icon>
<span class="mx-1">/</span>
@@ -131,7 +144,7 @@ export default {
{ key: 'id', text: this.$t('id'), width: '50px' },
{ key: 'name', text: this.$t('name'), width: '220px' },
{ key: 'description', text: this.$t('description') },
- { key: 'actions', width: '200px' }
+ { key: 'actions', width: '210px' }
]
},
entryHeaders () {
@@ -168,6 +181,11 @@ export default {
},
editEntry (item) {
this.setDialog({ show: true, type: 'entry', info: item })
+ },
+ async setAsDefault (id) {
+ await this.$http.put('/api/ipxeconfigs/' + id + '/default')
+ this.$snackbar({ text: this.$t('successSetAsDefault'), color: 'success', timeout: 2000 })
+ this.$store.dispatch('configurator/loadData')
}
},
created () {