mirror of https://github.com/statping/statping
added Switch and List inputs for notifiers, added more variable examples
parent
5a042e3c66
commit
04a04ad715
|
@ -38,8 +38,16 @@
|
|||
<td>8080</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>{{"\{\{.Service.DowntimeAgo\}\}"}}</kbd></td>
|
||||
<td>35 minutes ago</td>
|
||||
<td><kbd>{{"\{\{.Service.Downtime.Human\}\}"}}</kbd></td>
|
||||
<td>2 minutes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>{{"\{\{.Service.Uptime.Human\}\}"}}</kbd></td>
|
||||
<td>13 hours</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>{{"\{\{.Service.Online\}\}"}}</kbd></td>
|
||||
<td>true/false</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>{{"\{\{.Service.LastStatusCode\}\}"}}</kbd></td>
|
||||
|
@ -49,6 +57,22 @@
|
|||
<td><kbd>{{"\{\{.Service.FailuresLast24Hours\}\}"}}</kbd></td>
|
||||
<td>38</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>{{"\{\{.Service.LastOnline\}\}"}}</kbd></td>
|
||||
<td>2020-11-05T13:15:30Z</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>{{"\{\{.Service.LastOffline\}\}"}}</kbd></td>
|
||||
<td>2020-10-01T13:15:30Z</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>{{"\{\{.Service.Online24Hours\}\}"}}</kbd></td>
|
||||
<td>0.99</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>{{"\{\{.Service.Online7Days\}\}"}}</kbd></td>
|
||||
<td>0.97</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<small>Additional variables within the Service struct</small>
|
||||
</table>
|
||||
|
|
|
@ -14,7 +14,16 @@
|
|||
|
||||
<div v-for="(form, index) in notifier.form" v-bind:key="index" class="form-group">
|
||||
<label class="text-capitalize">{{form.title}}</label>
|
||||
<input v-if="form.type === 'text' || 'number' || 'password'" v-model="notifier[form.field.toLowerCase()]" :type="form.type" class="form-control" :placeholder="form.placeholder" >
|
||||
<input v-if="formVisible(['text', 'number', 'password', 'email'], form)" v-model="notifier[form.field.toLowerCase()]" :type="form.type" class="form-control" :placeholder="form.placeholder" >
|
||||
|
||||
<select v-if="formVisible(['list'], form)" v-model="notifier[form.field.toLowerCase()]" class="form-control">
|
||||
<option v-for="(val, k) in form.list_options" :value="val">{{val}}</option>
|
||||
</select>
|
||||
|
||||
<span v-if="formVisible(['switch'], form)" @click="notifier[form.field.toLowerCase()] = !!notifier[form.field.toLowerCase()]" class="switch switch-rd-gr float-right mt-2">
|
||||
<input v-model="notifier[form.field.toLowerCase()]" type="checkbox" class="switch-sm" :id="`switch_${notifier.name}_${form.field}`" v-bind:checked="notifier[form.field.toLowerCase()]">
|
||||
<label class="mb-0" :for="`switch_${notifier.name}_${form.field}`"></label>
|
||||
</span>
|
||||
|
||||
<small class="form-text text-muted" v-html="form.small_text"></small>
|
||||
</div>
|
||||
|
@ -155,7 +164,7 @@ export default {
|
|||
theme: 'neat',
|
||||
mode: "mymode",
|
||||
lineWrapping: true,
|
||||
json: true,
|
||||
json: this.notifier.data_type === "json",
|
||||
autoRefresh: true,
|
||||
mime: this.notifier.data_type === "json" ? "application/json" : "text/plain"
|
||||
},
|
||||
|
@ -166,6 +175,9 @@ export default {
|
|||
|
||||
},
|
||||
methods: {
|
||||
formVisible(want, form) {
|
||||
return !!want.includes(form.type);
|
||||
},
|
||||
visible(isVisible, entry) {
|
||||
if (isVisible) {
|
||||
this.$refs.cmfailure.codemirror.refresh()
|
||||
|
@ -173,13 +185,19 @@ export default {
|
|||
}
|
||||
},
|
||||
onCmSuccessReady(cm) {
|
||||
this.success_data = beautify(this.notifier.success_data, this.beautifySettings)
|
||||
this.success_data = this.notifier.success_data
|
||||
if (this.notifier.data_type === "json") {
|
||||
this.success_data = beautify(this.notifier.success_data, this.beautifySettings)
|
||||
}
|
||||
setTimeout(function() {
|
||||
cm.refresh();
|
||||
},1);
|
||||
},
|
||||
onCmFailureReady(cm) {
|
||||
this.failure_data = beautify(this.notifier.failure_data, this.beautifySettings)
|
||||
this.failure_data = this.notifier.failure_data
|
||||
if (this.notifier.data_type === "json") {
|
||||
this.failure_data = beautify(this.notifier.failure_data, this.beautifySettings)
|
||||
}
|
||||
setTimeout(function() {
|
||||
cm.refresh();
|
||||
},1);
|
||||
|
|
|
@ -74,12 +74,12 @@
|
|||
|
||||
<div class="form-group">
|
||||
<label class="text-capitalize">{{ $t('setup.project_name') }}</label>
|
||||
<input @keyup="canSubmit" v-model="setup.project" id="project" type="text" class="form-control" placeholder="Great Uptime" required>
|
||||
<input @keyup="canSubmit" v-model="setup.project" id="project" type="text" class="form-control" placeholder="Work Servers" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="text-capitalize">{{ $t('setup.project_description') }}</label>
|
||||
<input @keyup="canSubmit" v-model="setup.description" id="description" type="text" class="form-control" placeholder="Great Uptime">
|
||||
<input @keyup="canSubmit" v-model="setup.description" id="description" type="text" class="form-control" placeholder="Monitors all of my work services">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
@ -100,6 +100,7 @@
|
|||
<div class="form-group">
|
||||
<label class="text-capitalize">{{ $t('setup.password_confirm') }}</label>
|
||||
<input @keyup="canSubmit" v-model="setup.confirm_password" id="password_confirm" type="password" class="form-control" placeholder="password" required>
|
||||
<span v-if="passnomatch" class="small text-danger">Both passwords should match</span>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
@ -108,7 +109,7 @@
|
|||
<label class="text-capitalize">{{ $t('email') }}</label>
|
||||
<input @keyup="canSubmit" v-model="setup.email" id="email" type="text" class="form-control" placeholder="myemail@domain.com">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="col-4 text-right">
|
||||
<label class="d-none d-sm-block text-capitalize text-capitalize">{{ $t('setup.newsletter') }}</label>
|
||||
<span @click="setup.newsletter = !!setup.newsletter" class="switch">
|
||||
<input v-model="setup.newsletter" type="checkbox" name="send_newsletter" class="switch" id="send_newsletter" :checked="setup.newsletter">
|
||||
|
@ -145,6 +146,7 @@
|
|||
error: null,
|
||||
loading: false,
|
||||
disabled: true,
|
||||
passnomatch: false,
|
||||
setup: {
|
||||
language: "en",
|
||||
db_connection: "sqlite",
|
||||
|
@ -186,6 +188,11 @@
|
|||
canSubmit() {
|
||||
this.error = null
|
||||
const s = this.setup
|
||||
if (s.confirm_password.length > 0 && s.confirm_password !== s.password) {
|
||||
this.passnomatch = true
|
||||
} else {
|
||||
this.passnomatch = false
|
||||
}
|
||||
if (s.db_connection !== 'sqlite') {
|
||||
if (!s.db_host || !s.db_port || !s.db_user || !s.db_password || !s.db_database) {
|
||||
this.disabled = true
|
||||
|
|
|
@ -70,7 +70,7 @@ var email = &emailer{¬ifications.Notification{
|
|||
Type: "switch",
|
||||
Title: "Disable TLS/SSL",
|
||||
Placeholder: "",
|
||||
SmallText: "To Disable TLS/SSL insert 'true'",
|
||||
SmallText: "Enabling this will set Insecure Skip Verify to true",
|
||||
DbField: "api_key",
|
||||
}}},
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ var Pushover = &pushover{¬ifications.Notification{
|
|||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "User Token",
|
||||
Placeholder: "Insert your device's Pushover Token",
|
||||
Placeholder: "Insert your Pushover User Token",
|
||||
DbField: "api_key",
|
||||
Required: true,
|
||||
}, {
|
||||
|
@ -50,6 +50,20 @@ var Pushover = &pushover{¬ifications.Notification{
|
|||
Placeholder: "Create an Application and insert the API Key here",
|
||||
DbField: "api_secret",
|
||||
Required: true,
|
||||
}, {
|
||||
Type: "list",
|
||||
Title: "Priority",
|
||||
Placeholder: "Set the notification priority level",
|
||||
DbField: "Var1",
|
||||
Required: true,
|
||||
ListOptions: []string{"Lowest", "Low", "Normal", "High", "Emergency"},
|
||||
}, {
|
||||
Type: "list",
|
||||
Title: "Notification Sound",
|
||||
Placeholder: "Choose a sound for this Pushover notification",
|
||||
DbField: "Var2",
|
||||
Required: true,
|
||||
ListOptions: []string{"none", "pushover", "bike", "bugle", "cashregister", "classical", "cosmic", "falling", "gamelan", "incoming", "intermissioon", "magic", "mechanical", "painobar", "siren", "spacealarm", "tugboat", "alien", "climb", "persistent", "echo", "updown"},
|
||||
},
|
||||
}},
|
||||
}
|
||||
|
|
|
@ -50,13 +50,13 @@ var Twilio = &twilio{¬ifications.Notification{
|
|||
DbField: "api_secret",
|
||||
Required: true,
|
||||
}, {
|
||||
Type: "text",
|
||||
Type: "number",
|
||||
Title: "SMS to Phone Number",
|
||||
Placeholder: "18555555555",
|
||||
DbField: "Var1",
|
||||
Required: true,
|
||||
}, {
|
||||
Type: "text",
|
||||
Type: "number",
|
||||
Title: "From Phone Number",
|
||||
Placeholder: "18555555555",
|
||||
DbField: "Var2",
|
||||
|
|
|
@ -44,12 +44,13 @@ var Webhook = &webhooker{¬ifications.Notification{
|
|||
DbField: "Host",
|
||||
Required: true,
|
||||
}, {
|
||||
Type: "text",
|
||||
Type: "list",
|
||||
Title: "HTTP Method",
|
||||
Placeholder: "POST",
|
||||
SmallText: "Choose a HTTP method for example: GET, POST, DELETE, or PATCH.",
|
||||
DbField: "Var1",
|
||||
Required: true,
|
||||
ListOptions: []string{"GET", "POST", "PATCH", "DELETE"},
|
||||
}, {
|
||||
Type: "text",
|
||||
Title: "Content Type",
|
||||
|
|
Loading…
Reference in New Issue