feat: 批量工具栏添加时间同步按钮
This commit is contained in:
parent
b369cfd81a
commit
47655b75d2
@ -429,6 +429,21 @@ func (s *TaskService) executeOnDevice(task *models.Task, did string) {
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskSuccess, 1.0, "")
|
||||
s.appendAuditLog(task, did, models.TaskSuccess, "")
|
||||
|
||||
case "time_sync":
|
||||
nowMS := time.Now().UnixMilli()
|
||||
body, _ := json.Marshal(map[string]int64{"unix_ms": nowMS})
|
||||
_, code, err := s.agent.Do("POST", dev.IP, dev.AgentPort, "/v1/time/set", body)
|
||||
if err != nil {
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, err.Error())
|
||||
return
|
||||
}
|
||||
if code >= 400 {
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, fmt.Sprintf("agent error: %d", code))
|
||||
return
|
||||
}
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskSuccess, 1.0, "")
|
||||
s.appendAuditLog(task, did, models.TaskSuccess, "")
|
||||
|
||||
case "face_gallery_reload":
|
||||
_, code, err := s.agent.Do("POST", dev.IP, dev.AgentPort, "/v1/face-gallery/reload", nil)
|
||||
if err != nil {
|
||||
|
||||
@ -1753,7 +1753,7 @@ func (u *UI) actionDevicesBatchAction(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
typeStr := ""
|
||||
switch action {
|
||||
case "media_start", "media_restart", "media_stop", "reload", "rollback":
|
||||
case "media_start", "media_restart", "media_stop", "reload", "rollback", "time_sync":
|
||||
typeStr = action
|
||||
default:
|
||||
u.render(w, r, "devices", u.deviceOverviewPageData(r, deviceIDs, "不支持的操作: "+action))
|
||||
|
||||
@ -47,6 +47,10 @@
|
||||
{{if $allOffline}}
|
||||
<button type="submit" id="cleanup-btn" name="action" value="cleanup_offline" class="danger" style="display:none" onclick="var n=document.querySelectorAll('input[name=device_id]:checked').length;return confirm('确认清理选中的 '+n+' 台离线设备及其全部关联数据?此操作不可恢复。')">清理选中离线设备</button>
|
||||
{{end}}
|
||||
{{$drift := false}}{{range .DeviceRows}}{{if and (gt .TimeDriftSec 5) (hasString $.SelectedDeviceIDs .Device.DeviceID)}}{{$drift = true}}{{end}}{{end}}
|
||||
{{if $drift}}
|
||||
<button type="submit" name="action" value="time_sync" class="secondary">⏱ 时间同步</button>
|
||||
{{end}}
|
||||
<a class="btn secondary" href="{{.BatchConfigURL}}">下发设备分配</a>
|
||||
<a class="btn secondary" href="/devices">清空选择</a>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user