gocron/templates/host/host_form.html

159 lines
6.1 KiB
HTML

{{{ template "common/header" . }}}
<div class="ui grid">
{{{ template "host/menu" . }}}
<div class="twelve wide column">
<div class="pageHeader">
<div class="segment">
<h3 class="ui dividing header">
<div class="content">
添加主机
</div>
</h3>
</div>
</div>
<form class="ui form fluid vertical segment">
<input type="hidden" name="id" value="{{{.Host.Id}}}">
<div class="four fields">
<div class="field">
<label>主机名 (域名或IP)</label>
<div class="ui small input">
<input type="text" name="name" value="{{{.Host.Name}}}">
</div>
</div>
<div class="field">
<label>主机别名 (方便记忆和引用)</label>
<div class="ui small input">
<input type="text" name="alias" value="{{{.Host.Alias}}}">
</div>
</div>
</div>
<div class="four fields">
<div class="field">
<label>SSH用户名</label>
<div class="ui small input">
<input type="text" name="username" value="{{{.Host.Username}}}">
</div>
</div>
<div class="field">
<label>SSH端口</label>
<div class="ui small input">
<input type="text" name="port" value="{{{.Host.Port}}}">
</div>
</div>
</div>
<div class="four fields">
<div class="field">
<label>认证方式</label>
<select name="auth_type" id="authType">
<option value="2" {{{if .Host}}} {{{if eq .Host.AuthType 2}}}selected {{{end}}} {{{end}}} data-validate-type="selectPrivateKey" data-match="private_key">公钥</option>
<option value="1" {{{if .Host}}} {{{if eq .Host.AuthType 1}}}selected {{{end}}} {{{end}}} data-validate-type="selectPassword" data-match="password">密码</option>
</select>
</div>
</div>
<div class="two fields">
<div class="field">
<label>私钥 (~/.ssh/id_rsa)</label>
<div class="ui small input">
<textarea rows="7" name="private_key">{{{.Host.PrivateKey}}}</textarea>
</div>
</div>
</div>
<div class="four fields">
<div class="field">
<label>SSH密码</label>
<div class="ui small input">
<input type="text" placeholder="" name="password" value="{{{.Host.Password}}}">
</div>
</div>
</div>
<div class="two fields">
<div class="field">
<label>备注</label>
<div class="ui small input">
<textarea rows="7" name="remark" >{{{.Host.Remark}}}</textarea>
</div>
</div>
</div>
<div class="ui primary submit button">保存</div>
</form>
</div>
</div>
<script type="text/javascript">
var $uiForm = $('.ui.form');
registerSelectFormValidation("selectPrivateKey", $uiForm, $('#authType'), 'auth_type');
registerSelectFormValidation("selectPassword", $uiForm, $('#authType'), 'auth_type');
$($uiForm).form(
{
onSuccess: function(event, fields) {
util.post('/host/store', fields, function(code, message) {
location.href = "/host"
});
return false;
},
fields: {
name: {
identifier : 'name',
rules: [
{
type : 'empty',
prompt : '请输入主机名'
}
]
},
alias: {
identifier : 'alias',
rules: [
{
type : 'empty',
prompt : '请输入主机别名'
}
]
},
username: {
identifier : 'username',
rules: [
{
type : 'empty',
prompt : '请输入SSH用户名'
}
]
},
port: {
identifier : 'port',
rules: [
{
type : 'integer[1..65535]',
prompt : '请输入有效的端口号'
}
]
},
PrivateKey: {
identifier : 'private_key',
rules: [
{
type : 'selectPrivateKey',
prompt : '请输入私钥'
}
]
},
Password: {
identifier : 'password',
rules: [
{
type : 'selectPassword',
prompt : '请输入密码'
}
]
}
},
inline : true
});
</script>
{{{ template "common/footer" . }}}