forked from openlp/openlp
Remote web add to service
This commit is contained in:
parent
7b534642b9
commit
d4e83ae45a
@ -506,18 +506,18 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
# multiple service items?
|
# multiple service items?
|
||||||
if self.singleServiceItem or self.remoteTriggered:
|
if self.singleServiceItem or self.remoteTriggered:
|
||||||
log.debug(u'%s Add requested', self.plugin.name)
|
log.debug(u'%s Add requested', self.plugin.name)
|
||||||
serviceItem = self.buildServiceItem(None, True)
|
self.addToService([None], self.remoteTriggered)
|
||||||
if serviceItem:
|
|
||||||
serviceItem.from_plugin = False
|
|
||||||
self.parent.serviceManager.addServiceItem(serviceItem,
|
|
||||||
replace=self.remoteTriggered)
|
|
||||||
else:
|
else:
|
||||||
items = self.listView.selectedIndexes()
|
items = self.listView.selectedIndexes()
|
||||||
for item in items:
|
self.addToService(items)
|
||||||
serviceItem = self.buildServiceItem(item, True)
|
|
||||||
if serviceItem:
|
def addToService(self, items, replace=None):
|
||||||
serviceItem.from_plugin = False
|
for item in items:
|
||||||
self.parent.serviceManager.addServiceItem(serviceItem)
|
serviceItem = self.buildServiceItem(item, True)
|
||||||
|
if serviceItem:
|
||||||
|
serviceItem.from_plugin = False
|
||||||
|
self.parent.serviceManager.addServiceItem(serviceItem,
|
||||||
|
replace=replace)
|
||||||
|
|
||||||
def onAddEditClick(self):
|
def onAddEditClick(self):
|
||||||
"""
|
"""
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
<input type="search" name="search-text" id="search-text" value="" />
|
<input type="search" name="search-text" id="search-text" value="" />
|
||||||
</div>
|
</div>
|
||||||
<a href="#" id="search-submit" data-role="button">Search</a>
|
<a href="#" id="search-submit" data-role="button">Search</a>
|
||||||
<ul data-role="listview" data-inset="true">
|
<ul data-role="listview" data-inset="true" data-split-icon="plus">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -219,9 +219,13 @@ window.OpenLP = {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$.each(data.results.items, function (idx, value) {
|
$.each(data.results.items, function (idx, value) {
|
||||||
var li = $("<li data-icon=\"false\">").append(
|
var li = $("<li>");
|
||||||
$("<a href=\"#\">").attr("value", value[0]).text(value[1]));
|
li.append($("<a href=\"#\">").text(value[1]).click(function () {
|
||||||
li.children("a").click(OpenLP.goLive);
|
OpenLP.goLive(value[0]);
|
||||||
|
}));
|
||||||
|
li.append($("<a href=\"#\">").click(function () {
|
||||||
|
OpenLP.addToService(value[0]);
|
||||||
|
}));
|
||||||
ul.append(li);
|
ul.append(li);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -230,17 +234,21 @@ window.OpenLP = {
|
|||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
goLive: function (event) {
|
goLive: function (id) {
|
||||||
var slide = OpenLP.getElement(event);
|
|
||||||
var id = slide.attr("value");
|
|
||||||
var text = JSON.stringify({"request": {"id": id}});
|
var text = JSON.stringify({"request": {"id": id}});
|
||||||
$.getJSON(
|
$.getJSON(
|
||||||
"/api/" + $("#search-plugin").val() + "/live",
|
"/api/" + $("#search-plugin").val() + "/live",
|
||||||
{"data": text})
|
{"data": text})
|
||||||
$.mobile.changePage("slide-controller");
|
$.mobile.changePage("slide-controller");
|
||||||
return false;
|
return false;
|
||||||
|
},
|
||||||
|
addToService: function (id) {
|
||||||
|
var text = JSON.stringify({"request": {"id": id}});
|
||||||
|
$.getJSON(
|
||||||
|
"/api/" + $("#search-plugin").val() + "/add",
|
||||||
|
{"data": text})
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Service Manager
|
// Service Manager
|
||||||
$("#service-manager").live("pagebeforeshow", OpenLP.loadService);
|
$("#service-manager").live("pagebeforeshow", OpenLP.loadService);
|
||||||
|
@ -253,7 +253,8 @@ class HttpConnection(object):
|
|||||||
(r'^/api/alert$', self.alert),
|
(r'^/api/alert$', self.alert),
|
||||||
(r'^/api/plugin/(search)$', self.pluginInfo),
|
(r'^/api/plugin/(search)$', self.pluginInfo),
|
||||||
(r'^/api/(.*)/search$', self.search),
|
(r'^/api/(.*)/search$', self.search),
|
||||||
(r'^/api/(.*)/live$', self.go_live)
|
(r'^/api/(.*)/live$', self.go_live),
|
||||||
|
(r'^/api/(.*)/add$', self.add_to_service)
|
||||||
]
|
]
|
||||||
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'readyRead()'),
|
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'readyRead()'),
|
||||||
self.ready_read)
|
self.ready_read)
|
||||||
@ -490,6 +491,16 @@ class HttpConnection(object):
|
|||||||
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
||||||
plugin.mediaItem.goLive(id)
|
plugin.mediaItem.goLive(id)
|
||||||
|
|
||||||
|
def add_to_service(self, type):
|
||||||
|
"""
|
||||||
|
Add item of type ``type`` to the end of the service
|
||||||
|
"""
|
||||||
|
id = json.loads(self.url_params[u'data'][0])[u'request'][u'id']
|
||||||
|
plugin = self.parent.parent.pluginManager.get_plugin_by_name(type)
|
||||||
|
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
||||||
|
item_id = plugin.mediaItem.createItemFromId(id)
|
||||||
|
plugin.mediaItem.addToService([item_id])
|
||||||
|
|
||||||
def send_response(self, response):
|
def send_response(self, response):
|
||||||
http = u'HTTP/1.1 %s\r\n' % response.code
|
http = u'HTTP/1.1 %s\r\n' % response.code
|
||||||
for header, value in response.headers.iteritems():
|
for header, value in response.headers.iteritems():
|
||||||
|
Loading…
Reference in New Issue
Block a user