← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~j-corwin/openlp/remote into lp:openlp

 

Jonathan Corwin has proposed merging lp:~j-corwin/openlp/remote into lp:openlp.

Requested reviews:
  Raoul Snyman (raoul-snyman)
Related bugs:
  Bug #596995 in OpenLP: "Remotes Plugin does not work with PPA version"
  https://bugs.launchpad.net/openlp/+bug/596995

For more details, see:
https://code.launchpad.net/~j-corwin/openlp/remote/+merge/61854

Final remote change for now: Add to service via search

** Made changes to the jquery 
-- 
https://code.launchpad.net/~j-corwin/openlp/remote/+merge/61854
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2011-05-18 14:27:29 +0000
+++ openlp/core/lib/mediamanageritem.py	2011-05-21 09:16:36 +0000
@@ -508,18 +508,18 @@
             # 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()
-                for item in items:
-                    serviceItem = self.buildServiceItem(item, True)
-                    if serviceItem:
-                        serviceItem.from_plugin = False
-                        self.parent.serviceManager.addServiceItem(serviceItem)
+                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,
+                    replace=replace)
 
     def onAddEditClick(self):
         """

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2011-05-13 13:58:17 +0000
+++ openlp/core/ui/servicemanager.py	2011-05-21 09:16:36 +0000
@@ -757,7 +757,7 @@
         """
         Called by a signal to select a specific item.
         """
-        self.setItem(int(message[0]))
+        self.setItem(int(message))
 
     def setItem(self, index):
         """

=== modified file 'openlp/plugins/remotes/html/openlp.js'
--- openlp/plugins/remotes/html/openlp.js	2011-05-17 22:00:50 +0000
+++ openlp/plugins/remotes/html/openlp.js	2011-05-21 09:16:36 +0000
@@ -219,10 +219,11 @@
         } 
         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,25 @@
     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})
+    history.back();
+    return false;
   }
-
 }
 // Service Manager
 $("#service-manager").live("pagebeforeshow", OpenLP.loadService);

=== modified file 'openlp/plugins/remotes/lib/httpserver.py'
--- openlp/plugins/remotes/lib/httpserver.py	2011-05-17 22:00:50 +0000
+++ openlp/plugins/remotes/lib/httpserver.py	2011-05-21 09:16:36 +0000
@@ -253,7 +253,8 @@
             (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 @@
         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():


Follow ups