update video editor / annotation panel

This commit is contained in:
rolux 2012-01-03 15:56:50 +05:30
parent 9e35c3b229
commit 3c9676a32a
2 changed files with 23 additions and 25 deletions

View file

@ -118,7 +118,7 @@ def addAnnotation(request):
} }
return {'status': {'code': int, 'text': string}, return {'status': {'code': int, 'text': string},
'data': { 'data': {
id: 123, id: 123, //id of new annotation
... ...
} }
} }
@ -149,10 +149,10 @@ actions.register(addAnnotation, cache=False)
@login_required_json @login_required_json
def removeAnnotations(request): def removeAnnotation(request):
''' '''
param data { param data {
ids: [] id: annotationId
} }
return {'status': {'code': int, 'text': string}, return {'status': {'code': int, 'text': string},
'data': { 'data': {
@ -161,17 +161,13 @@ def removeAnnotations(request):
''' '''
response = json_response({}) response = json_response({})
data = json.loads(request.POST['data']) data = json.loads(request.POST['data'])
failed = [] a = get_object_or_404_json(models.Annotation, public_id=data['id'])
for a in models.Annotation.objects.filter(public_id__in=data['ids']):
if a.editable(request.user): if a.editable(request.user):
a.delete() a.delete()
else: else:
failed.append(a.public_id)
if failed:
response = json_response(status=403, text='permission denied') response = json_response(status=403, text='permission denied')
response['data']['ids'] = failed
return render_to_json_response(response) return render_to_json_response(response)
actions.register(removeAnnotations, cache=False) actions.register(removeAnnotation, cache=False)
@login_required_json @login_required_json

View file

@ -287,22 +287,13 @@ pandora.ui.item = function() {
item: pandora.user.ui.item, item: pandora.user.ui.item,
layer: data.layer, layer: data.layer,
out: data.out, out: data.out,
value: 'Click to edit', value: data.value,
}, function(result) { }, function(result) {
pandora.$ui.editor.addAnnotation(data.layer, result.data); pandora.$ui.editor.addAnnotation(data.layer, result.data);
}); });
}, },
removeannotations: function(data) { editannotation: function(data) {
pandora.api.removeAnnotations(data, function(result) { Ox.Log('', 'editAnnotation', data);
//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);
//fixme: check that edit was successfull //fixme: check that edit was successfull
pandora.api.editAnnotation({ pandora.api.editAnnotation({
id: data.id, id: data.id,
@ -310,9 +301,20 @@ pandora.ui.item = function() {
out: data.out, out: data.out,
value: data.value, value: data.value,
}, function(result) { }, 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_showannotations: function(data) {
pandora.$ui.editor.options({showAnnotations: data.value}); pandora.$ui.editor.options({showAnnotations: data.value});
} }