Skip to content

Commit

Permalink
subject_args & text_args, Forced double quotes
Browse files Browse the repository at this point in the history
Library Update

 @fortawesome/fontawesome-svg-core     1.2.34  →   1.2.35
 @fortawesome/free-brands-svg-icons    5.15.2  →   5.15.3
 @fortawesome/free-regular-svg-icons   5.15.2  →   5.15.3
 @fortawesome/free-solid-svg-icons     5.15.2  →   5.15.3
 @vue/cli-plugin-e2e-cypress          ^4.5.11  →  ^4.5.12
 @vue/cli-plugin-eslint               ^4.5.11  →  ^4.5.12
 @vue/cli-plugin-unit-mocha           ^4.5.11  →  ^4.5.12
 @vue/cli-service                     ^4.5.11  →  ^4.5.12
 cypress                               ^6.7.1  →   ^6.8.0
  • Loading branch information
nsano-rururu committed Mar 19, 2021
1 parent 551350c commit 5fed70b
Show file tree
Hide file tree
Showing 7 changed files with 438 additions and 155 deletions.
238 changes: 119 additions & 119 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "praeco",
"version": "1.8.1",
"version": "1.8.2",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand All @@ -17,10 +17,10 @@
"dependencies": {
"@babel/core": "7.13.10",
"@browser-bunyan/server-stream": "1.6.1",
"@fortawesome/fontawesome-svg-core": "1.2.34",
"@fortawesome/free-brands-svg-icons": "5.15.2",
"@fortawesome/free-regular-svg-icons": "5.15.2",
"@fortawesome/free-solid-svg-icons": "5.15.2",
"@fortawesome/fontawesome-svg-core": "1.2.35",
"@fortawesome/free-brands-svg-icons": "5.15.3",
"@fortawesome/free-regular-svg-icons": "5.15.3",
"@fortawesome/free-solid-svg-icons": "5.15.3",
"@fortawesome/vue-fontawesome": "2.0.2",
"@riophae/vue-treeselect": "0.4.0",
"axios": "0.21.1",
Expand Down Expand Up @@ -68,18 +68,18 @@
"devDependencies": {
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8",
"@vue/cli-plugin-babel": "^4.5.11",
"@vue/cli-plugin-e2e-cypress": "^4.5.11",
"@vue/cli-plugin-eslint": "^4.5.11",
"@vue/cli-plugin-unit-mocha": "^4.5.11",
"@vue/cli-service": "^4.5.11",
"@vue/cli-plugin-e2e-cypress": "^4.5.12",
"@vue/cli-plugin-eslint": "^4.5.12",
"@vue/cli-plugin-unit-mocha": "^4.5.12",
"@vue/cli-service": "^4.5.12",
"@vue/eslint-config-airbnb": "^5.3.0",
"@vue/test-utils": "1.1.3",
"axios-mock-adapter": "1.19.0",
"babel-eslint": "^10.1.0",
"babel-plugin-istanbul": "6.0.0",
"chai": "4.3.4",
"cross-env": "7.0.3",
"cypress": "^6.7.1",
"cypress": "^6.8.0",
"eslint": "^6.8.0",
"eslint-plugin-cypress": "^2.11.2",
"eslint-plugin-import": "^2.22.1",
Expand Down
220 changes: 220 additions & 0 deletions src/components/config/alert/ConfigAlertSubjectBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,55 @@
</at>
</el-form-item>

<el-popover v-model="popAlertSubjectArgsVisible" :class="{ 'is-invalid': !popAlertSubjectArgsValid }">
<span slot="reference" class="pop-trigger">
<el-tooltip v-if="alertSubjectArgs.length" :content="alertSubjectArgs.join(', ')" placement="top">
<span>AlertSubjectArgs ({{ alertSubjectArgs.length }})</span>
</el-tooltip>
<span v-else>AlertSubjectArgs ({{ alertSubjectArgs.length }})</span>
</span>
<template>
<el-form
ref="alertSubjectArgs"
:model="$store.state.config.alert"
label-position="top"
style="width: 360px"
@submit.native.prevent>
<el-form-item
v-for="(entry, index) in alertSubjectArgs"
:key="index"
:prop="'alertSubjectArgs.' + index"
:disabled="viewOnly"
class="el-form-item-list"
label=""
required>
<el-row :gutter="5" type="flex" justify="space-between">
<el-col :span="20">
<el-input
v-model="alertSubjectArgs[index]"
:disabled="viewOnly"
placeholder=""
@input="(val) => updateAlertSubjectArgs(val, index)" />
</el-col>
<el-col :span="4">
<el-button
:disabled="viewOnly"
type="danger"
icon="el-icon-delete"
circle
plain
@click="removeAlertSubjectArgsEntry(entry)" />
</el-col>
</el-row>
</el-form-item>
</el-form>

<el-button :disabled="viewOnly" class="m-n-sm" @click="addAlertSubjectArgsEntry">
Add alert_subject_args
</el-button>
</template>
</el-popover>

<el-form-item
v-if="bodyType !== 'aggregation_summary_only'"
id="body"
Expand All @@ -44,6 +93,58 @@
</at>
</el-form-item>

<el-popover
v-if="bodyType !== 'aggregation_summary_only'"
v-model="popAlertTextArgsVisible"
:class="{ 'is-invalid': !popAlertTextArgsValid }">
<span slot="reference" class="pop-trigger">
<el-tooltip v-if="alertTextArgs.length" :content="alertTextArgs.join(', ')" placement="top">
<span>alertTextArgs ({{ alertTextArgs.length }})</span>
</el-tooltip>
<span v-else>alertTextArgs ({{ alertTextArgs.length }})</span>
</span>
<template>
<el-form
ref="alertTextArgs"
:model="$store.state.config.alert"
label-position="top"
style="width: 360px"
@submit.native.prevent>
<el-form-item
v-for="(entry, index) in alertTextArgs"
:key="index"
:prop="'alertTextArgs.' + index"
:disabled="viewOnly"
class="el-form-item-list"
label=""
required>
<el-row :gutter="5" type="flex" justify="space-between">
<el-col :span="20">
<el-input
v-model="alertTextArgs[index]"
:disabled="viewOnly"
placeholder=""
@input="(val) => updateAlertTextArgs(val, index)" />
</el-col>
<el-col :span="4">
<el-button
:disabled="viewOnly"
type="danger"
icon="el-icon-delete"
circle
plain
@click="removeAlertTextArgsEntry(entry)" />
</el-col>
</el-row>
</el-form-item>
</el-form>

<el-button :disabled="viewOnly" class="m-n-sm" @click="addAlertTextArgsEntry">
Add alert_text_args
</el-button>
</template>
</el-popover>

<el-form-item required label="Include">
<el-row>
<el-select v-model="bodyType" :disabled="viewOnly">
Expand Down Expand Up @@ -112,6 +213,15 @@ export default {
props: ['viewOnly'],
data() {
return {
popAlertSubjectArgsVisible: false,
popAlertSubjectArgsValid: true,
popAlertTextArgsVisible: false,
popAlertTextArgsValid: true,
};
},
computed: {
queryString() {
return this.$store.getters['config/query/queryString'];
Expand All @@ -130,6 +240,24 @@ export default {
}
},
alertSubjectArgs: {
get() {
return this.$store.state.config.alert.alertSubjectArgs;
},
set(value) {
this.$store.commit('config/alert/UPDATE_ALERT_SUBJECT_ARGS', value);
}
},
alertTextArgs: {
get() {
return this.$store.state.config.alert.alertTextArgs;
},
set(value) {
this.$store.commit('config/alert/UPDATE_ALERT_TEXT_ARGS', value);
}
},
body: {
get() {
return this.$store.state.config.alert.body;
Expand Down Expand Up @@ -174,6 +302,98 @@ export default {
e.preventDefault();
let text = (e.originalEvent || e).clipboardData.getData('text/plain');
document.execCommand('insertHTML', false, text);
},
async validate() {
try {
if (this.$refs.alertSubjectArgs) {
await this.validateAlertSubjectArgs();
}
if (this.$refs.alertTextArgs) {
await this.validateAlertaTags();
}
this.$emit('validate', true);
return true;
} catch (error) {
this.$emit('validate', false);
return false;
}
},
async validateAlertSubjectArgs() {
if (!this.alertSubjectArgs.length) {
this.popAlertSubjectArgsValid = false;
return;
}
try {
this.popAlertSubjectArgsValid = await this.$refs.alertSubjectArgs.validate();
} catch (error) {
this.popAlertSubjectArgsValid = false;
throw error;
}
},
async validateAlertTextArgs() {
if (!this.alertTextArgs.length) {
this.popAlertTextArgsValid = false;
return;
}
try {
this.popAlertTextArgsValid = await this.$refs.alertTextArgs.validate();
} catch (error) {
this.popAlertTextArgsValid = false;
throw error;
}
},
updateAlertSubjectArgs(entry, index) {
if (Number.isNaN(entry)) return;
this.$store.commit('config/alert/UPDATE_ALERT_SUBJECT_ARGS_ENTRY', {
entry,
index
});
this.$nextTick(() => {
this.validate();
});
},
updateAlertTextArgs(entry, index) {
if (Number.isNaN(entry)) return;
this.$store.commit('config/alert/UPDATE_ALERT_TEXT_ARGS_ENTRY', {
entry,
index
});
this.$nextTick(() => {
this.validate();
});
},
removeAlertSubjectArgsEntry(entry) {
this.$store.commit('config/alert/REMOVE_ALERT_SUBJECT_ARGS_ENTRY', entry);
this.$nextTick(() => {
this.validate();
});
},
removeAlertTextArgsEntry(entry) {
this.$store.commit('config/alert/REMOVE_ALERT_TEXT_ARGS_ENTRY', entry);
this.$nextTick(() => {
this.validate();
});
},
addAlertSubjectArgsEntry() {
this.$store.commit('config/alert/ADD_ALERT_SUBJECT_ARGS_ENTRY');
this.$nextTick(() => {
this.validate();
});
},
addAlertTextArgsEntry() {
this.$store.commit('config/alert/ADD_ALERT_TEXT_ARGS_ENTRY');
this.$nextTick(() => {
this.validate();
});
}
}
};
Expand Down
44 changes: 44 additions & 0 deletions src/store/config/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ function initialState() {
subject: '',
body: '',
bodyType: 'alert_text_only',
alertSubjectArgs: [],
alertTextArgs: [],

/* Slack */
slackChannelOverride: '',
Expand Down Expand Up @@ -705,6 +707,48 @@ export default {
state.subject = subject;
},

UPDATE_ALERT_SUBJECT_ARGS(state, alertSubjectArgs) {
state.alertSubjectArgs = alertSubjectArgs;
},

ADD_ALERT_SUBJECT_ARGS_ENTRY(state) {
state.alertSubjectArgs.push('');
},

ADD_ALERT_SUBJECT_ARGS_ENTRY_VALUE(state, value) {
state.alertSubjectArgs.push(value);
},

REMOVE_ALERT_SUBJECT_ARGS_ENTRY(state, entry) {
state.alertSubjectArgs = state.alertSubjectArgs.filter(b => b !== entry);
},

UPDATE_ALERT_SUBJECT_ARGS_ENTRY(state, { entry, index }) {
if (!state.alertSubjectArgs) return;
state.alertSubjectArgs[index] = entry;
},

UPDATE_ALERT_TEXT_ARGS(state, alertTextArgs) {
state.alertTextArgs = alertTextArgs;
},

ADD_ALERT_TEXT_ARGS_ENTRY(state) {
state.alertTextArgs.push('');
},

ADD_ALERT_TEXT_ARGS_ENTRY_VALUE(state, value) {
state.alertTextArgs.push(value);
},

REMOVE_ALERT_TEXT_ARGS_ENTRY(state, entry) {
state.alertTextArgs = state.alertTextArgs.filter(b => b !== entry);
},

UPDATE_ALERT_TEXT_ARGS_ENTRY(state, { entry, index }) {
if (!state.alertTextArgs) return;
state.alertTextArgs[index] = entry;
},

UPDATE_ALERT(state, alert) {
state.alert = alert;
}
Expand Down
Loading

0 comments on commit 5fed70b

Please sign in to comment.