diffido/dist/schedule.html

224 lines
8.1 KiB
HTML
Raw Normal View History

2018-01-16 22:24:30 +01:00
{% extends "base.html" %}
{% block body %}
2018-01-20 14:56:34 +01:00
<div id="app">
2018-01-25 23:53:09 +01:00
<div class="md-layout md-gutter">
<div class="md-layout-item md-size-100">
<div class="md-title">
<span>
<md-button href="/" class="md-icon-button md-primary home-icon">
<md-icon>home</md-icon>
</md-button>
Diffido: ${(schedule && schedule.title) || 'new'} schedule
</span>
</div>
</div>
<div class="md-layout-item md-size-60">
2018-01-23 18:45:41 +01:00
<md-card id="main-card">
<md-card-header>
<div class="md-title">
2018-01-25 23:53:09 +01:00
Settings
2018-01-23 18:45:41 +01:00
</div>
</md-card-header>
2018-01-20 17:46:56 +01:00
2018-01-23 18:45:41 +01:00
<md-card-content>
<div class="md-layout md-gutter">
2018-01-25 23:53:09 +01:00
<div class="md-layout-item md-size-50">
2018-01-23 18:45:41 +01:00
<md-field>
<label>title</label>
2018-01-23 22:41:32 +01:00
<md-input v-model="schedule.title" required></md-input>
2018-01-23 18:45:41 +01:00
</md-field>
</div>
2018-01-25 23:53:09 +01:00
<div class="md-layout-item md-size-50">
2018-01-23 18:45:41 +01:00
<md-field>
<label>url</label>
2018-01-23 22:41:32 +01:00
<md-input v-model="schedule.url" required></md-input>
2018-01-23 18:45:41 +01:00
</md-field>
</div>
</div>
2018-01-20 17:46:56 +01:00
2018-01-25 23:53:09 +01:00
<div class="md-layout md-gutter">
<div class="md-layout-item md-size-33">
<md-field>
<label>notify email</label>
<md-input v-model="schedule.email" type="email"></md-input>
</md-field>
</div>
<div class="md-layout-item md-size-33">
<md-field>
<label>XPath selector</label>
<md-input v-model="schedule.xpath"></md-input>
</md-field>
</div>
<div class="md-layout-item md-size-33">
<md-field>
<label>minimum change</label>
<md-input v-model="schedule.minimum_change"></md-input>
</md-field>
</div>
</div>
<md-switch v-model="schedule.enabled">enabled</md-switch>
</md-card-content>
</md-card>
</div>
<div class="md-layout-item">
<md-card id="trigger-card">
<md-card-header>
<div class="md-title">
Trigger
</div>
</md-card-header>
<md-card-content>
2018-01-23 18:45:41 +01:00
<div class="md-layout md-gutter">
<div class="md-layout-item md-size-25">
<md-field>
<label>trigger</label>
<md-select v-model="schedule.trigger">
<md-option value="interval">interval</md-option>
<md-option value="cron">cron</md-option>
</md-select>
</md-field>
</div>
2018-01-25 23:53:09 +01:00
</div>
<div v-if="schedule.trigger == 'cron'" class="md-layout md-gutter">
<div class="md-layout-item md-size-50">
<md-field>
<label>crontab</label>
<md-input v-model="schedule.cron_crontab"></md-input>
</md-field>
2018-01-23 18:45:41 +01:00
</div>
</div>
2018-01-20 17:46:56 +01:00
2018-01-23 18:45:41 +01:00
<div v-if="schedule.trigger == 'interval'" class="md-layout md-gutter">
<div class="md-layout-item md-size-20">
<md-field>
<label>weeks</label>
<md-input v-model="schedule.interval_weeks" type="number"></md-input>
</md-field>
</div>
<div class="md-layout-item md-size-20">
<md-field>
<label>days</label>
<md-input v-model="schedule.interval_days" type="number"></md-input>
</md-field>
</div>
2018-01-25 23:53:09 +01:00
</div>
<div v-if="schedule.trigger == 'interval'" class="md-layout md-gutter">
2018-01-23 18:45:41 +01:00
<div class="md-layout-item md-size-20">
<md-field>
<label>hours</label>
<md-input v-model="schedule.interval_hours" type="number"></md-input>
</md-field>
</div>
<div class="md-layout-item md-size-20">
<md-field>
<label>minutes</label>
<md-input v-model="schedule.interval_minutes" type="number"></md-input>
</md-field>
</div>
<div class="md-layout-item md-size-20">
<md-field>
<label>seconds</label>
<md-input v-model="schedule.interval_seconds" type="number"></md-input>
</md-field>
</div>
</div>
</md-card-content>
</md-card>
2018-01-20 14:56:34 +01:00
</div>
2018-01-25 23:53:09 +01:00
<div class="md-layout-item md-size-100">
<div class="md-title">
<br />
<md-button class="md-raised md-primary" @click="saveSchedule()">save</md-button>
<md-button class="md-raised md-accent" :disabled="!hasID()" @click="deleteSchedule()">delete</md-button>
<md-button href="/">back</md-button>
</div>
</div>
2018-01-20 14:56:34 +01:00
</div>
</div>
<script>
Vue.use(VueMaterial.default);
var app = new Vue({
el: '#app',
delimiters: ['${', '}'],
data: {
{% if isinstance(id, str) %}
id: "{{id}}",
{% else %}
id: null,
{% end %}
2018-01-20 17:46:56 +01:00
schedule: {},
empty_schedule: {enabled: true, trigger: 'interval'}
2018-01-20 14:56:34 +01:00
},
mounted: function() {
this.getSchedule(this.id);
},
computed: {
},
methods: {
hasID: function() {
return !(this.id === undefined || this.id === null || this.id === '');
},
getSchedule: function() {
if (!this.hasID()) {
2018-01-20 17:46:56 +01:00
this.schedule = this.empty_schedule;
2018-01-20 14:56:34 +01:00
return;
}
self = this;
var data = axios.get('/api/schedules/' + this.id).then(function(response) {
2018-01-20 17:46:56 +01:00
self.schedule = response.data.schedule || self.empty_schedule;
2018-01-20 14:56:34 +01:00
});
},
saveSchedule: function() {
var data = this.schedule;
if (this.hasID()) {
axios.put('/api/schedules/' + this.id, data).then(function(response) {
2018-01-23 18:45:41 +01:00
window.location = '/';
2018-01-20 14:56:34 +01:00
});
} else {
axios.post('/api/schedules', data).then(function(response) {
2018-01-23 18:45:41 +01:00
window.location = '/';
/* window.location = '/schedule.html?id=' + response.data.id; */
2018-01-20 14:56:34 +01:00
});
}
},
deleteSchedule: function() {
if (!this.hasID()) {
return;
}
axios.delete('/api/schedules/' + this.id).then(function(response) {
window.location = '/';
});
}
}
});
</script>
2018-01-27 11:48:40 +01:00
{% end %}
2018-01-20 14:56:34 +01:00
2018-01-27 11:48:40 +01:00
{% block style %}
2018-01-23 18:45:41 +01:00
2018-01-27 11:48:40 +01:00
body {
padding: 12px 20px 12px 20px !important;
2018-01-20 14:56:34 +01:00
}
2018-01-25 23:53:09 +01:00
.home-icon {
margin-top: -6px;
}
.md-card-content {
padding: 20px;
}
#trigger-card, #main-card {
min-height: 350px;
}
2018-01-23 18:45:41 +01:00
2018-01-16 22:24:30 +01:00
{% end %}