forked from 0x2620/pandora
update video editor / annotation panel
This commit is contained in:
parent
9e35c3b229
commit
3c9676a32a
2 changed files with 23 additions and 25 deletions
|
@ -118,7 +118,7 @@ def addAnnotation(request):
|
|||
}
|
||||
return {'status': {'code': int, 'text': string},
|
||||
'data': {
|
||||
id: 123,
|
||||
id: 123, //id of new annotation
|
||||
...
|
||||
}
|
||||
}
|
||||
|
@ -149,10 +149,10 @@ actions.register(addAnnotation, cache=False)
|
|||
|
||||
|
||||
@login_required_json
|
||||
def removeAnnotations(request):
|
||||
def removeAnnotation(request):
|
||||
'''
|
||||
param data {
|
||||
ids: []
|
||||
id: annotationId
|
||||
}
|
||||
return {'status': {'code': int, 'text': string},
|
||||
'data': {
|
||||
|
@ -161,17 +161,13 @@ def removeAnnotations(request):
|
|||
'''
|
||||
response = json_response({})
|
||||
data = json.loads(request.POST['data'])
|
||||
failed = []
|
||||
for a in models.Annotation.objects.filter(public_id__in=data['ids']):
|
||||
a = get_object_or_404_json(models.Annotation, public_id=data['id'])
|
||||
if a.editable(request.user):
|
||||
a.delete()
|
||||
else:
|
||||
failed.append(a.public_id)
|
||||
if failed:
|
||||
response = json_response(status=403, text='permission denied')
|
||||
response['data']['ids'] = failed
|
||||
return render_to_json_response(response)
|
||||
actions.register(removeAnnotations, cache=False)
|
||||
actions.register(removeAnnotation, cache=False)
|
||||
|
||||
|
||||
@login_required_json
|
||||
|
|
|
@ -287,22 +287,13 @@ pandora.ui.item = function() {
|
|||
item: pandora.user.ui.item,
|
||||
layer: data.layer,
|
||||
out: data.out,
|
||||
value: 'Click to edit',
|
||||
value: data.value,
|
||||
}, function(result) {
|
||||
pandora.$ui.editor.addAnnotation(data.layer, result.data);
|
||||
});
|
||||
},
|
||||
removeannotations: function(data) {
|
||||
pandora.api.removeAnnotations(data, function(result) {
|
||||
//fixme: check for errors
|
||||
pandora.$ui.editor.removeAnnotations(data.layer, data.ids);
|
||||
});
|
||||
},
|
||||
toggleannotations: function(data) {
|
||||
pandora.UI.set('showAnnotations', data.showAnnotations);
|
||||
},
|
||||
updateannotation: function(data) {
|
||||
Ox.Log('', 'editAnnotations', data);
|
||||
editannotation: function(data) {
|
||||
Ox.Log('', 'editAnnotation', data);
|
||||
//fixme: check that edit was successfull
|
||||
pandora.api.editAnnotation({
|
||||
id: data.id,
|
||||
|
@ -310,9 +301,20 @@ pandora.ui.item = function() {
|
|||
out: data.out,
|
||||
value: data.value,
|
||||
}, function(result) {
|
||||
Ox.Log('', 'done updateAnnotation', result);
|
||||
Ox.Log('', 'editAnnotation result', result);
|
||||
});
|
||||
},
|
||||
removeannotation: function(data) {
|
||||
pandora.api.removeAnnotation({
|
||||
id: data.id
|
||||
}, function(result) {
|
||||
//fixme: check for errors
|
||||
pandora.$ui.editor.removeAnnotation(data.layer, data.id);
|
||||
});
|
||||
},
|
||||
toggleannotations: function(data) {
|
||||
pandora.UI.set('showAnnotations', data.showAnnotations);
|
||||
},
|
||||
pandora_showannotations: function(data) {
|
||||
pandora.$ui.editor.options({showAnnotations: data.value});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue