forked from openlp/openlp
Add items to service via the search on the web remote
bzr-revno: 1562
This commit is contained in:
commit
ac29839151
@ -515,18 +515,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(replace=self.remoteTriggered)
|
||||
else:
|
||||
items = self.listView.selectedIndexes()
|
||||
for item in items:
|
||||
serviceItem = self.buildServiceItem(item, True)
|
||||
if serviceItem:
|
||||
serviceItem.from_plugin = False
|
||||
self.parent.serviceManager.addServiceItem(serviceItem)
|
||||
self.addToService(item)
|
||||
|
||||
def addToService(self, item=None, replace=None):
|
||||
serviceItem = self.buildServiceItem(item, True)
|
||||
if serviceItem:
|
||||
serviceItem.from_plugin = False
|
||||
self.parent.serviceManager.addServiceItem(serviceItem,
|
||||
replace=replace)
|
||||
|
||||
def onAddEditClick(self):
|
||||
"""
|
||||
|
@ -757,7 +757,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
Called by a signal to select a specific item.
|
||||
"""
|
||||
self.setItem(int(message[0]))
|
||||
self.setItem(int(message))
|
||||
|
||||
def setItem(self, index):
|
||||
"""
|
||||
|
@ -219,10 +219,11 @@ 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);
|
||||
ul.append(li);
|
||||
var item = $("<li>").text(value[1]);
|
||||
var golive = $("<a href=\"#\">Go Live</a>").attr("value", value[0]).click(OpenLP.goLive);
|
||||
var additem = $("<a href=\"#\">Add To Service</a>").attr("value", value[0]).click(OpenLP.addToService);
|
||||
item.append($("<ul>").append($("<li>").append(golive)).append($("<li>").append(additem)));
|
||||
ul.append(item);
|
||||
});
|
||||
}
|
||||
ul.listview("refresh");
|
||||
@ -231,16 +232,28 @@ window.OpenLP = {
|
||||
return false;
|
||||
},
|
||||
goLive: function (event) {
|
||||
var slide = OpenLP.getElement(event);
|
||||
var id = slide.attr("value");
|
||||
var item = OpenLP.getElement(event);
|
||||
var id = item.attr("value");
|
||||
var text = JSON.stringify({"request": {"id": id}});
|
||||
$.getJSON(
|
||||
"/api/" + $("#search-plugin").val() + "/live",
|
||||
{"data": text})
|
||||
$.mobile.changePage("slide-controller");
|
||||
return false;
|
||||
},
|
||||
addToService: function (event) {
|
||||
var item = OpenLP.getElement(event);
|
||||
var id = item.attr("value");
|
||||
var text = JSON.stringify({"request": {"id": id}});
|
||||
$.getJSON(
|
||||
"/api/" + $("#search-plugin").val() + "/add",
|
||||
{"data": text},
|
||||
function () {
|
||||
history.back();
|
||||
}
|
||||
);
|
||||
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