浏览代码

HUE-7501 [dashboard] Convert layout to gridster format

Romain Rigaux 8 年之前
父节点
当前提交
9f6bbe2
共有 1 个文件被更改,包括 15 次插入1 次删除
  1. 15 1
      desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

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

@@ -28,7 +28,7 @@ function loadSearchLayout(viewModel, json_layout) {
       var row = new Row([], viewModel);
       $(json_row.widgets).each(function (wcnt, widget) {
         row.addWidget(new Widget({
-          size:widget.size,
+          size: widget.size,
           id: widget.id,
           name: widget.name,
           widgetType: widget.widgetType,
@@ -49,6 +49,20 @@ function loadSearchLayout(viewModel, json_layout) {
 
 // End dashboard lib
 
+function layoutToGridster(vm) {
+  fullLayout(vm);
+
+  var numCols = 12;
+  var defaultWidgetHeight = 2;
+
+  $.each(vm.columns()[0].rows(), function (indexY, row) {
+	var rowColSize = numCols / row.widgets().length; // Full length of row if 1 widget
+	$.each(row.widgets(), function (indexX, widget) {
+      console.log({col: 1 + indexY * defaultWidgetHeight, row: 1 + indexX * rowColSize, size_x: rowColSize, size_y: defaultWidgetHeight, id: widget.id()});
+	});
+  });
+}
+
 var Query = function (vm, query) {
   var self = this;