浏览代码

[indexer] Delete a collection alias from the UI

Romain Rigaux 10 年之前
父节点
当前提交
53f26b427c
共有 2 个文件被更改,包括 17 次插入2 次删除
  1. 1 1
      desktop/libs/indexer/src/indexer/api.py
  2. 16 1
      desktop/libs/indexer/src/indexer/templates/indexes.mako

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

@@ -307,7 +307,7 @@ def delete_alias(request):
 
 
   response = {'status': -1}
   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())
   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>
         <td data-bind="text: name"></td>
         <td data-bind="text: name"></td>
         <td data-bind="text: type"></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>
       </tr>
     </tbody>
     </tbody>
   </table>
   </table>
@@ -170,6 +175,16 @@ ${ commonheader(_("Solr Indexes"), "spark", user, "60px") | n,unicode }
         $(document).trigger("error", xhr.responseText);
         $(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 () {
   var Editor = function () {