Ver Fonte

[indexer] Delete a collection alias from the UI

Romain Rigaux há 10 anos atrás
pai
commit
53f26b4

+ 1 - 1
desktop/libs/indexer/src/indexer/api.py

@@ -307,7 +307,7 @@ def delete_alias(request):
 
   response = {'status': -1}
 
-  alias = json.loads(request.POST.get('alias', ''))
+  alias = request.POST.get('alias', '')
 
   api = SolrApi(SOLR_URL.get(), request.user, SECURITY_ENABLED.get())
 

+ 16 - 1
desktop/libs/indexer/src/indexer/templates/indexes.mako

@@ -68,7 +68,12 @@ ${ commonheader(_("Solr Indexes"), "spark", user, "60px") | n,unicode }
         </td>
         <td data-bind="text: name"></td>
         <td data-bind="text: type"></td>
-        <td data-bind="text: collections"></td>
+        <td>
+          <span data-bind="text: collections"></span>
+          <a data-bind="click: $root.alias.delete, visible: type() == 'alias'">
+            <i class="fa fa-times"></i> ${ _('Delete') }
+          </a>          
+        </td>
       </tr>
     </tbody>
   </table>
@@ -170,6 +175,16 @@ ${ commonheader(_("Solr Indexes"), "spark", user, "60px") | n,unicode }
         $(document).trigger("error", xhr.responseText);
       });
     }
+    
+    self.delete = function(alias) {
+      $.post("${ url('indexer:delete_alias') }", {
+        "alias": alias.name()
+      }, function() {
+        window.location.reload();
+      }).fail(function (xhr, textStatus, errorThrown) {
+        $(document).trigger("error", xhr.responseText);
+      });
+    }
   };
 
   var Editor = function () {