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?
|
||||
if self.singleServiceItem or self.remoteTriggered:
|
||||
log.debug(u'%s Add requested', self.plugin.name)
|
||||
serviceItem = self.buildServiceItem(None, True)
|
||||
if serviceItem:
|
||||
serviceItem.from_plugin = False
|
||||
self.parent.serviceManager.addServiceItem(serviceItem,
|
||||
replace=self.remoteTriggered)
|
||||
self.addToService([None], self.remoteTriggered)
|
||||
else:
|
||||
items = self.listView.selectedIndexes()
|
||||
self.addToService(items)
|
||||
|
||||
def addToService(self, items, replace=None):
|
||||
for item in items:
|
||||
serviceItem = self.buildServiceItem(item, True)
|
||||
if serviceItem:
|
||||
serviceItem.from_plugin = False
|
||||
self.parent.serviceManager.addServiceItem(serviceItem)
|
||||
self.parent.serviceManager.addServiceItem(serviceItem,
|
||||
replace=replace)
|
||||
|
||||
def onAddEditClick(self):
|
||||
"""
|
||||
|
@ -109,7 +109,7 @@
|
||||
<input type="search" name="search-text" id="search-text" value="" />
|
||||
</div>
|
||||
<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>
|
||||
</body>
|
||||
|
@ -219,9 +219,13 @@ window.OpenLP = {
|
||||
}
|
||||
else {
|
||||
$.each(data.results.items, function (idx, value) {
|
||||
var li = $("<li data-icon=\"false\">").append(
|
||||
$("<a href=\"#\">").attr("value", value[0]).text(value[1]));
|
||||
li.children("a").click(OpenLP.goLive);
|
||||
var li = $("<li>");
|
||||
li.append($("<a href=\"#\">").text(value[1]).click(function () {
|
||||
OpenLP.goLive(value[0]);
|
||||
}));
|
||||
li.append($("<a href=\"#\">").click(function () {
|
||||
OpenLP.addToService(value[0]);
|
||||
}));
|
||||
ul.append(li);
|
||||
});
|
||||
}
|
||||
@ -230,17 +234,21 @@ window.OpenLP = {
|
||||
);
|
||||
return false;
|
||||
},
|
||||
goLive: function (event) {
|
||||
var slide = OpenLP.getElement(event);
|
||||
var id = slide.attr("value");
|
||||
goLive: function (id) {
|
||||
var text = JSON.stringify({"request": {"id": id}});
|
||||
$.getJSON(
|
||||
"/api/" + $("#search-plugin").val() + "/live",
|
||||
{"data": text})
|
||||
$.mobile.changePage("slide-controller");
|
||||
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").live("pagebeforeshow", OpenLP.loadService);
|
||||
|
@ -253,7 +253,8 @@ class HttpConnection(object):
|
||||
(r'^/api/alert$', self.alert),
|
||||
(r'^/api/plugin/(search)$', self.pluginInfo),
|
||||
(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()'),
|
||||
self.ready_read)
|
||||
@ -490,6 +491,16 @@ class HttpConnection(object):
|
||||
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
||||
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):
|
||||
http = u'HTTP/1.1 %s\r\n' % response.code
|
||||
for header, value in response.headers.iteritems():
|
||||
|
Loading…
Reference in New Issue
Block a user