update preset
This commit is contained in:
parent
f1c953c615
commit
b408a89c1d
|
@ -101,6 +101,11 @@ class API(object):
|
|||
result['presets'] = ctl.camera.get_presets(True)
|
||||
return result
|
||||
|
||||
def setPreset(self, **data):
|
||||
result = {}
|
||||
ctl.camera.set_preset(data['id'], data['name'])
|
||||
return result
|
||||
|
||||
def setPresets(self, **data):
|
||||
result = {}
|
||||
ctl.camera.set_presets(data['presets'])
|
||||
|
|
|
@ -52,12 +52,29 @@ if (value == null || value == undefined || !value.length || !isInt(value)) {
|
|||
}
|
||||
|
||||
var presets = [];
|
||||
var system_presets = [
|
||||
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
||||
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105
|
||||
];
|
||||
|
||||
function presetSelect() {
|
||||
function presetSelect(all) {
|
||||
var options = ''
|
||||
presets.forEach(function(preset) {
|
||||
options += '<option value="'+preset.id+'">' + preset.id + ': ' + preset.name + '</option>';
|
||||
})
|
||||
if (all) {
|
||||
for (var id=1;id<=300;id++) {
|
||||
if (system_presets.indexOf(id) == -1) {
|
||||
var preset = getPreset(id)
|
||||
if (preset) {
|
||||
options += '<option value="'+preset.id+'">' + preset.id + ': ' + preset.name + '</option>';
|
||||
} else {
|
||||
options += '<option value="'+id+'">' + id + ': Preset ' + id + '</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
presets.forEach(function(preset) {
|
||||
options += '<option value="'+preset.id+'">' + preset.id + ': ' + preset.name + '</option>';
|
||||
})
|
||||
}
|
||||
return $('<select name="preset-editor">' + options + '</select>')
|
||||
}
|
||||
|
||||
|
@ -679,5 +696,28 @@ function init_ptz() {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
api('getPresets', {}, function(response) {
|
||||
presets = response.result.presets
|
||||
var id = 1
|
||||
presetSelect(true).on({
|
||||
change: event => {
|
||||
id = parseInt(event.target.value)
|
||||
var preset = getPreset(id)
|
||||
name.val(preset ? preset.name : '')
|
||||
}
|
||||
}).appendTo($('body'))
|
||||
var name = $('<input>').appendTo($('body'))
|
||||
name.val(getPreset(id).name)
|
||||
$('<button>').html('Set')
|
||||
.appendTo($('body')).on({
|
||||
click: function() {
|
||||
var data = {}
|
||||
if (name.val().length) {
|
||||
data['name'] = name.val()
|
||||
}
|
||||
data['id'] = id
|
||||
api('setPreset', data)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user