merge
This commit is contained in:
commit
d4a82c8a08
3 changed files with 56 additions and 35 deletions
|
@ -7,6 +7,8 @@ from ox.django.decorators import login_required_json
|
||||||
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
||||||
|
|
||||||
import models
|
import models
|
||||||
|
from item.models import Item
|
||||||
|
|
||||||
from api.actions import actions
|
from api.actions import actions
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,8 +40,8 @@ def addAnnotation(request):
|
||||||
param data {
|
param data {
|
||||||
item: itemId,
|
item: itemId,
|
||||||
layer: layerId,
|
layer: layerId,
|
||||||
start: float,
|
in: float,
|
||||||
end: float,
|
out: float,
|
||||||
value: string
|
value: string
|
||||||
}
|
}
|
||||||
return {'status': {'code': int, 'text': string},
|
return {'status': {'code': int, 'text': string},
|
||||||
|
@ -49,19 +51,19 @@ def addAnnotation(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
for key in ('item', 'layer', 'start', 'end', 'value'):
|
for key in ('item', 'layer', 'in', 'out', 'value'):
|
||||||
if key not in data:
|
if key not in data:
|
||||||
return render_to_json_response(json_response(status=400,
|
return render_to_json_response(json_response(status=400,
|
||||||
text='invalid data'))
|
text='invalid data'))
|
||||||
|
|
||||||
item = get_object_or_404_json(models.Item, itemId=data['item'])
|
item = get_object_or_404_json(Item, itemId=data['item'])
|
||||||
layer = get_object_or_404_json(models.Layer, layerId=data['layer'])
|
layer = get_object_or_404_json(models.Layer, name=data['layer'])
|
||||||
|
|
||||||
annotation = models.Annotation(
|
annotation = models.Annotation(
|
||||||
item=item,
|
item=item,
|
||||||
layer=layer,
|
layer=layer,
|
||||||
user=request.user,
|
user=request.user,
|
||||||
start=float(data['start']), end=float(data['end']),
|
start=float(data['in']), end=float(data['out']),
|
||||||
value=data['value'])
|
value=data['value'])
|
||||||
annotation.save()
|
annotation.save()
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
@ -94,8 +96,8 @@ def editAnnotation(request):
|
||||||
'''
|
'''
|
||||||
param data {
|
param data {
|
||||||
id:,
|
id:,
|
||||||
start: float,
|
in: float,
|
||||||
end: float,
|
out: float,
|
||||||
value: string,
|
value: string,
|
||||||
}
|
}
|
||||||
return {'status': {'code': int, 'text': string},
|
return {'status': {'code': int, 'text': string},
|
||||||
|
@ -105,9 +107,12 @@ def editAnnotation(request):
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
layer = get_object_or_404_json(models.Layer, pk=data['id'])
|
a = get_object_or_404_json(models.Annotation, pk=data['id'])
|
||||||
if layer.editable(request.user):
|
if a.editable(request.user):
|
||||||
response = json_response(status=501, text='not implemented')
|
a.value = data['value']
|
||||||
|
a.start = data['in']
|
||||||
|
a.end = data['out']
|
||||||
|
a.save()
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403, text='permission denied')
|
response = json_response(status=403, text='permission denied')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
|
@ -209,9 +209,12 @@ class File(models.Model):
|
||||||
return srt
|
return srt
|
||||||
|
|
||||||
srts = re.compile('(\d\d:\d\d:\d\d[,.]\d\d\d)\s*-->\s*(\d\d:\d\d:\d\d[,.]\d\d\d)\s*(.+?)\n\n', re.DOTALL)
|
srts = re.compile('(\d\d:\d\d:\d\d[,.]\d\d\d)\s*-->\s*(\d\d:\d\d:\d\d[,.]\d\d\d)\s*(.+?)\n\n', re.DOTALL)
|
||||||
|
i = 0
|
||||||
for s in srts.findall(data):
|
for s in srts.findall(data):
|
||||||
_s = {'in': parseTime(s[0]), 'out': parseTime(s[1]), 'value': s[2].strip()}
|
_s = {'id': str(i),
|
||||||
|
'in': parseTime(s[0]), 'out': parseTime(s[1]), 'value': s[2].strip()}
|
||||||
srt.append(_s)
|
srt.append(_s)
|
||||||
|
i += 1
|
||||||
return srt
|
return srt
|
||||||
|
|
||||||
def editable(self, user):
|
def editable(self, user):
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
// fixme: never set ui.videoPosition to 0 ... set to null a.k.a. delete
|
// fixme: never set ui.videoPosition to 0 ... set to null a.k.a. delete
|
||||||
// fixme: sort=-director doesn't work
|
// fixme: sort=-director doesn't work
|
||||||
// fixme: don't reload full right panel on sortSelect
|
// fixme: don't reload full right panel on sortSelect
|
||||||
|
// fixme: clear items cache after login/logout
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
@ -1443,6 +1444,7 @@
|
||||||
title: folder.title
|
title: folder.title
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
|
// fixme: duplicated
|
||||||
click: function(event, data) {
|
click: function(event, data) {
|
||||||
var $list = app.$ui.folderList[i],
|
var $list = app.$ui.folderList[i],
|
||||||
hasFocus, id;
|
hasFocus, id;
|
||||||
|
@ -1761,26 +1763,34 @@
|
||||||
} : data);
|
} : data);
|
||||||
},
|
},
|
||||||
enterfullscreen: enterFullscreen,
|
enterfullscreen: enterFullscreen,
|
||||||
exitfullscreen: exitFullscreen
|
exitfullscreen: exitFullscreen,
|
||||||
}))/*.bindEvent({
|
|
||||||
resize: function(event, data) {
|
resize: function(event, data) {
|
||||||
app.$ui.player.options({
|
app.$ui.player.options({
|
||||||
height: data
|
height: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})*/;
|
}));
|
||||||
} else if (app.user.ui.itemView == 'timeline') {
|
} else if (app.user.ui.itemView == 'timeline') {
|
||||||
var video = result.data.item.stream,
|
var layers = [],
|
||||||
|
video = result.data.item.stream,
|
||||||
cuts = result.data.item.cuts || {},
|
cuts = result.data.item.cuts || {},
|
||||||
subtitles = result.data.item.layers.subtitles || [{
|
format = Ox.supportedVideoFormat(video.formats),
|
||||||
'in': 5,
|
subtitles = result.data.item.layers.subtitles;
|
||||||
'out': 10,
|
|
||||||
'value': 'This subtitle is just a test...'
|
|
||||||
}],
|
|
||||||
format = Ox.supportedVideoFormat(video.formats);
|
|
||||||
video.height = video.profiles[0];
|
video.height = video.profiles[0];
|
||||||
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
||||||
video.url = video.baseUrl + '/' + video.height + 'p.' + format;
|
video.url = video.baseUrl + '/' + video.height + 'p.' + format;
|
||||||
|
$.each(app.config.layers, function(i, layer) {
|
||||||
|
layers[i] = $.extend({}, layer);
|
||||||
|
if (result.data.item.layers[layer.id])
|
||||||
|
layers[i]['items'] = result.data.item.layers[layer.id];
|
||||||
|
else
|
||||||
|
layers[i]['items'] = [{
|
||||||
|
'in': 5,
|
||||||
|
'out': 10,
|
||||||
|
'value': 'This annotation is just a test...'
|
||||||
|
}];
|
||||||
|
|
||||||
|
});
|
||||||
app.$ui.contentPanel.replace(1, app.$ui.editor = new Ox.VideoEditor({
|
app.$ui.contentPanel.replace(1, app.$ui.editor = new Ox.VideoEditor({
|
||||||
annotationsSize: app.user.ui.annotationsSize,
|
annotationsSize: app.user.ui.annotationsSize,
|
||||||
cuts: cuts,
|
cuts: cuts,
|
||||||
|
@ -1792,7 +1802,7 @@
|
||||||
height: app.$ui.contentPanel.size(1),
|
height: app.$ui.contentPanel.size(1),
|
||||||
id: 'editor',
|
id: 'editor',
|
||||||
largeTimeline: true,
|
largeTimeline: true,
|
||||||
layers: app.config.layers,
|
layers: layers,
|
||||||
matches: [],
|
matches: [],
|
||||||
points: [0, 0],
|
points: [0, 0],
|
||||||
position: app.user.ui.videoPosition[app.user.ui.item] || 0,
|
position: app.user.ui.videoPosition[app.user.ui.item] || 0,
|
||||||
|
@ -1806,15 +1816,18 @@
|
||||||
videoURL: video.url,
|
videoURL: video.url,
|
||||||
width: app.$ui.document.width() - app.$ui.mainPanel.size(0) - 1
|
width: app.$ui.document.width() - app.$ui.mainPanel.size(0) - 1
|
||||||
}).bindEvent({
|
}).bindEvent({
|
||||||
/*
|
|
||||||
resize: function(event, data) {
|
resize: function(event, data) {
|
||||||
app.$ui.editor.options({
|
app.$ui.editor.options({
|
||||||
width: data
|
height: data
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
*/
|
|
||||||
togglesize: function(event, data) {
|
togglesize: function(event, data) {
|
||||||
UI.set({videoSize: data.size});
|
UI.set({videoSize: data.size});
|
||||||
|
},
|
||||||
|
updateAnnotation: function(event, data) {
|
||||||
|
//fixme: check that edit was successfull
|
||||||
|
Ox.print('updateAnnotation', data);
|
||||||
|
pandora.api.editAnnotation(data);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
that.bindEvent('resize', function(event, data) {
|
that.bindEvent('resize', function(event, data) {
|
||||||
|
@ -3367,7 +3380,7 @@
|
||||||
|
|
||||||
function resizeWindow() {
|
function resizeWindow() {
|
||||||
resizeFolders();
|
resizeFolders();
|
||||||
if (app.user.ui.item == '') {
|
if (!app.user.ui.item) {
|
||||||
app.$ui.list.size();
|
app.$ui.list.size();
|
||||||
resizeGroups(app.$ui.rightPanel.width());
|
resizeGroups(app.$ui.rightPanel.width());
|
||||||
if (app.user.ui.listView == 'map') {
|
if (app.user.ui.listView == 'map') {
|
||||||
|
|
Loading…
Reference in a new issue