feat: 设备详情页支持点击✎在线改名
This commit is contained in:
parent
9e6842015a
commit
f92491ebf1
@ -49,7 +49,7 @@
|
||||
{{if .Device.Online}}<span class="pill ok">在线</span>{{else}}<span class="pill bad">离线</span>{{end}}
|
||||
</div>
|
||||
<div class="info-list">
|
||||
<div><span>设备名称</span><strong>{{displayDeviceName .Device .ConfigStatus}}</strong></div>
|
||||
<div><span>设备名称</span><strong>{{displayDeviceName .Device .ConfigStatus}}</strong><span class="btn-icon ghost" style="margin-left:4px;font-size:11px;cursor:pointer" onclick="editDeviceName(this,'{{.Device.DeviceID}}')">✎</span></div>
|
||||
<div><span>设备 ID</span><strong class="mono">{{.Device.DeviceID}}</strong></div>
|
||||
<div><span>管理地址</span><strong class="mono">{{.Device.IP}}:{{.Device.AgentPort}}</strong></div>
|
||||
<div><span>视频端口</span><strong class="mono">{{.Device.MediaPort}}</strong></div>
|
||||
@ -246,4 +246,34 @@
|
||||
{{if .RawText}}<pre style="margin-top:10px">{{.RawText}}</pre>{{end}}
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
function editDeviceName(el, deviceID) {
|
||||
var current = el.parentNode.querySelector('strong').textContent;
|
||||
var input = document.createElement('input');
|
||||
input.value = current.indexOf('[') === 0 ? '' : current;
|
||||
input.style.cssText = 'width:200px;padding:2px 6px;font-size:13px;margin-left:4px';
|
||||
el.style.display = 'none';
|
||||
el.parentNode.appendChild(input);
|
||||
input.focus();
|
||||
input.select();
|
||||
function save() {
|
||||
var name = input.value.trim();
|
||||
input.remove();
|
||||
el.style.display = '';
|
||||
if (!name) return;
|
||||
var form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = '/devices/' + deviceID + '/alias';
|
||||
form.style.display = 'none';
|
||||
var inp = document.createElement('input');
|
||||
inp.name = 'alias';
|
||||
inp.value = name;
|
||||
form.appendChild(inp);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
input.addEventListener('blur', save);
|
||||
input.addEventListener('keydown', function(e) { if (e.key === 'Enter') save(); if (e.key === 'Escape') { input.remove(); el.style.display = ''; } });
|
||||
}
|
||||
</script>
|
||||
{{end}}
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user