Added support for icon color

This commit is contained in:
Fabio Manganiello 2020-06-27 12:05:16 +02:00
parent 12aaa2beb8
commit 9b562f3a89
3 changed files with 45 additions and 9 deletions

View file

@ -23,7 +23,7 @@
> >
<div class="action-head" @click="toggleSelectedAction(name)"> <div class="action-head" @click="toggleSelectedAction(name)">
<div class="icon"> <div class="icon">
<i :class="action.iconClass" v-if="action.iconClass" /> <i :class="action.iconClass" :style="{ color: action.color && action.color.length ? action.color : 'initial' }" v-if="action.iconClass" />
<i class="fas fa-cog" v-else /> <i class="fas fa-cog" v-else />
</div> </div>

View file

@ -81,13 +81,17 @@
</form> </form>
</div> </div>
<form class="save-form" ref="scriptForm" @submit.prevent="save" v-if="saveMode"> <form class="save-form" @submit.prevent="save" v-if="saveMode">
<div class="row"> <div class="row">
<input type="text" name="displayName" placeholder="Display name" /> <input type="text" name="displayName" v-model="saveParams.name" placeholder="Display name" />
</div> </div>
<div class="row"> <div class="row">
<input type="text" name="iconClass" placeholder="FontAwesome icon class (e.g. 'fas fa-play')" /> <input type="text" name="iconClass" v-model="saveParams.iconClass" placeholder="FontAwesome icon class (e.g. 'fas fa-play')" />
</div>
<div class="row">
<input type="text" ref="color" name="color" v-model="saveParams.color" placeholder="HTML/CSS color" />
</div> </div>
<div class="row"> <div class="row">
@ -101,6 +105,10 @@
/> />
</div> </div>
<div class="row icon-preview" v-if="saveParams.iconClass && saveParams.iconClass.length">
<i :class="saveParams.iconClass" :style="{ color: saveParams.color && saveParams.color.length ? saveParams.color : 'initial' }" />
</div>
<div class="row multiple-host-selector"> <div class="row multiple-host-selector">
<div class="desc"> <div class="desc">
Install script on these devices Install script on these devices
@ -176,6 +184,12 @@ export default {
args: [], args: [],
defaultArgs: {}, defaultArgs: {},
}, },
saveParams: {
name: null,
iconClass: null,
color: null,
},
}; };
}, },
@ -295,6 +309,14 @@ export default {
toggleSaveMode() { toggleSaveMode() {
this.saveMode = !this.saveMode; this.saveMode = !this.saveMode;
if (!this.saveMode) {
this.saveParams = {
name: null,
iconClass: null,
color: null,
};
}
}, },
async loadPlugins() { async loadPlugins() {
@ -329,6 +351,7 @@ export default {
const saveForm = event.target; const saveForm = event.target;
const displayName = saveForm.displayName.value.trim(); const displayName = saveForm.displayName.value.trim();
const iconClass = saveForm.iconClass.value.trim(); const iconClass = saveForm.iconClass.value.trim();
const color = saveForm.color.value.trim();
const hosts = [...saveForm.querySelectorAll('input[data-type="host"]:checked')].map(el => el.value); const hosts = [...saveForm.querySelectorAll('input[data-type="host"]:checked')].map(el => el.value);
if (!displayName.length) { if (!displayName.length) {
@ -345,6 +368,7 @@ export default {
type: this.actionMode, type: this.actionMode,
displayName: displayName, displayName: displayName,
iconClass: iconClass, iconClass: iconClass,
color: color.length ? color : null,
hosts: hosts, hosts: hosts,
script: this.script, script: this.script,
categories: this.selectedCategories.map(obj => obj.text), categories: this.selectedCategories.map(obj => obj.text),
@ -357,6 +381,7 @@ export default {
const saveForm = event.target; const saveForm = event.target;
const displayName = saveForm.displayName.value.trim(); const displayName = saveForm.displayName.value.trim();
const iconClass = saveForm.iconClass.value.trim(); const iconClass = saveForm.iconClass.value.trim();
const color = saveForm.color.value.trim();
const hosts = [...saveForm.querySelectorAll('input[data-type="host"]:checked')].map(el => el.value); const hosts = [...saveForm.querySelectorAll('input[data-type="host"]:checked')].map(el => el.value);
if (!displayName.length) { if (!displayName.length) {
@ -373,6 +398,7 @@ export default {
type: this.actionMode, type: this.actionMode,
displayName: displayName, displayName: displayName,
iconClass: iconClass, iconClass: iconClass,
color: color.length ? color : null,
hosts: hosts, hosts: hosts,
name: this.action.name, name: this.action.name,
args: this.getActionArgs(), args: this.getActionArgs(),
@ -524,6 +550,11 @@ form {
margin-bottom: 0.75em; margin-bottom: 0.75em;
} }
} }
.icon-preview {
font-size: 2em;
margin-left: 0.2em;
}
</style> </style>
<!-- vim:sw=2:ts=2:et: --> <!-- vim:sw=2:ts=2:et: -->

View file

@ -38,7 +38,7 @@
<div class="actions" v-if="selectedCategory === category || !category.length"> <div class="actions" v-if="selectedCategory === category || !category.length">
<div class="action" v-for="(action, name) in actions" :key="name" @click="run_(name)"> <div class="action" v-for="(action, name) in actions" :key="name" @click="run_(name)">
<div class="icon"> <div class="icon">
<i :class="action.iconClass" v-if="action.iconClass" /> <i :class="action.iconClass" :style="{ color: action.color && action.color.length ? action.color : 'initial' }" v-if="action.iconClass" />
<i class="fas fa-cog" v-else /> <i class="fas fa-cog" v-else />
</div> </div>
@ -160,10 +160,14 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
body {
overflow: hidden;
}
.container { .container {
width: 30em; width: 30em;
max-height: 40em;
display: flex; display: flex;
overflow: hidden;
} }
.category { .category {
@ -178,8 +182,7 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
overflow-y: auto; overflow: hidden;
overflow-x: hidden;
.head { .head {
width: 100%; width: 100%;
@ -208,7 +211,9 @@ export default {
.body { .body {
height: calc(100% - 2.5em); height: calc(100% - 2.5em);
overflow: auto; max-height: 35em;
overflow-y: auto;
overflow-x: hidden;
.action { .action {
display: flex; display: flex;