Przeglądaj źródła

HUE-7566 [dashboard] Allow removing a Gridster widget

Enrico Berti 8 lat temu
rodzic
commit
12813d0

+ 1 - 0
desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

@@ -2326,6 +2326,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
           $.each(row.widgets(), function (z, widget) {
             if (widget && widget.id() == widget_id) {
               row.widgets.remove(widget);
+              huePubSub.publish('gridster.remove.widget', widget_id);
               row.autosizeWidgets();
               return false;
             }

+ 6 - 5
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -3600,9 +3600,6 @@ $(document).ready(function () {
     avoid_overlapped_widgets: true,
     max_cols: 12,
     max_rows: 60,
-##     draggable: {
-##       handle: '.move-gridster-widget'
-##     },
     resize: {
       enabled: true,
       stop: function (event, ui, $widget) {
@@ -3643,14 +3640,18 @@ $(document).ready(function () {
     }
   }, 200);
 
-  huePubSub.subscribe('plotly.afterplot', function (element){
+  huePubSub.subscribe('plotly.afterplot', function (element) {
     resizeGridsterWidget($(element).parents('li.gs-w'));
   }, 'dashboard');
 
-  huePubSub.subscribe('leaflet.afterplot', function (element){
+  huePubSub.subscribe('leaflet.afterplot', function (element) {
     resizeGridsterWidget($(element).parents('li.gs-w'));
   }, 'dashboard');
 
+  huePubSub.subscribe('gridster.remove.widget', function (widgetId) {
+    $(".gridster>ul").data('gridster').remove_widget($("#wdg_" + widgetId).parents('li.gs-w'));
+  }, 'dashboard');
+
 %endif
 
   $(document).on("click", ".widget-settings-pill", function(){