gocron/templates/task/index.html

131 lines
6.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{{{ template "common/header" . }}}
<div class="ui grid">
{{{template "task/menu" .}}}
<div class="twelve wide column">
<div class="pageHeader">
<div class="segment">
<h3 class="ui dividing header">
<a href="/task/create">
<i class="large add icon"></i>
<div class="content">
</div>
</a>
</h3>
</div>
</div>
<form class="ui form">
<div class="six fields search">
<div class="one wide field">
<input type="text" placeholder="任务ID" name="id" value="{{{if gt .Params.Id 0}}}{{{.Params.Id}}}{{{end}}}">
</div>
<div class="field">
<input type="text" placeholder="任务名称" name="name" value="{{{.Params.Name}}}">
</div>
<div class="field">
<select name="host_id" id="hostId">
<option value=""></option>
{{{range $i, $v := .Hosts}}}
<option value="{{{.Id}}}" {{{if eq $.Params.HostId .Id }}} selected {{{end}}} >{{{.Alias}}}-{{{.Name}}}</option>
{{{end}}}
</select>
</div>
<div class="field">
<select name="protocol" id="protocol">
<option value="0"></option>
<option value="3" {{{if eq .Params.Protocol 3}}}selected{{{end}}}></option>
<option value="2" {{{if eq .Params.Protocol 2}}}selected{{{end}}} data-match="host_id" data-validate-type="selectProtocol">SSH</option>
<option value="1" {{{if eq .Params.Protocol 1}}}selected{{{end}}}>HTTP</option>
</select>
</div>
<div class="field">
<select name="status">
<option value="0"></option>
<option value="1" {{{if eq .Params.Status 0}}}selected{{{end}}} ></option>
<option value="2" {{{if eq .Params.Status 1}}}selected{{{end}}}></option>
</select>
</div>
<div class="field">
<button class="ui linkedin submit button"></button>
</div>
</div>
</form>
<div class="task-list">
{{{range $i, $v := .Tasks}}}
<div class="ui device two column middle aligned vertical grid segment">
<div class="column verborder">
<div class="ui info segment">
<h5 class="ui header">{{{.Task.Name}}} {{{if eq .Status 1}}}<i class="large checkmark blue icon"></i> {{{else}}} <i class="large red minus icon"></i> {{{end}}}
</h5>
<p>ID <span class="stress">{{{.Id}}}</span></p>
<p>cron {{{.Spec}}}</p>
<p>: {{{if eq .Protocol 1}}} HTTP {{{else if eq .Protocol 2}}} SSH {{{else if eq .Protocol 3}}}{{{end}}}</p>
<p class="sensorStatus">{{{.Command}}}</p>
<p class="sensorStatus">{{{if gt .Timeout 0}}}{{{.Timeout}}}{{{else}}}{{{end}}}</p>
<p>: {{{.RetryTimes}}}</p>
<p class="sensorStatus">{{{if gt .Multi 0}}}{{{else}}}{{{end}}}</p>
{{{if eq .Protocol 2}}}
<p>: {{{.Alias}}}-{{{.Name}}}</p>
{{{end}}}
<p>: {{{.Remark}}}</p>
</div>
</div>
<div class="center aligned column">
<div class="ui buttons operation">
<a class="ui purple button" href="/task/edit/{{{.Id}}}"></a>
{{{if eq .Status 1}}}
<button class="ui primary button" @click="changeStatus({{{.Id}}},{{{.Status}}})"></button>
{{{else}}}
<button class="ui blue button" @click="changeStatus({{{.Id}}},{{{.Status}}})"> </button>
{{{end}}}
<button class="ui positive button" @click="remove({{{.Id}}})"></button> <br>
<button class="ui twitter button" @click="run({{{.Id}}})"></button>
<a class="ui instagram button" href="/task/log?task_id={{{.Id}}}"></a>
</div>
</div>
</div>
{{{end}}}
</div>
{{{ template "common/pagination" .}}}
</div>
</div>
<script type="text/javascript">
$('.ui.checkbox').checkbox();
var vue = new Vue(
{
el: '.task-list',
methods: {
changeStatus: function (id ,status) {
var url = '';
if (status) {
url = '/task/disable';
} else {
url = '/task/enable';
}
url += '/' + id;
util.post(url,{}, function() {
location.reload();
});
},
remove: function(id) {
util.removeConfirm('/task/remove/' + id);
},
run: function(id) {
util.get("/task/run/" + id, function(code, message) {
swal('', message, 'success');
})
}
}
}
);
</script>
{{{ template "common/footer" . }}}