mirror of https://github.com/grafana/grafana.git
				
				
				
			fix(dashboard): minor function name fixes, removed insert row above/below because it did not work, #2909
This commit is contained in:
		
							parent
							
								
									8305fd0451
								
							
						
					
					
						commit
						2e155bdeda
					
				| 
						 | 
				
			
			@ -29,7 +29,7 @@ function (angular, $, config) {
 | 
			
		|||
    var resizeEventTimeout;
 | 
			
		||||
 | 
			
		||||
    this.init = function(dashboard) {
 | 
			
		||||
      $scope.reset_row();
 | 
			
		||||
      $scope.resetRow();
 | 
			
		||||
      $scope.registerWindowResizeEvent();
 | 
			
		||||
      $scope.onAppEvent('show-json-editor', $scope.showJsonEditor);
 | 
			
		||||
      $scope.setupDashboard(dashboard);
 | 
			
		||||
| 
						 | 
				
			
			@ -88,17 +88,17 @@ function (angular, $, config) {
 | 
			
		|||
      $rootScope.$broadcast('refresh');
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.add_row = function(dash, row) {
 | 
			
		||||
    $scope.addRow = function(dash, row) {
 | 
			
		||||
      dash.rows.push(row);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.add_row_default = function() {
 | 
			
		||||
      $scope.reset_row();
 | 
			
		||||
    $scope.addRowDefault = function() {
 | 
			
		||||
      $scope.resetRow();
 | 
			
		||||
      $scope.row.title = 'New row';
 | 
			
		||||
      $scope.add_row($scope.dashboard, $scope.row);
 | 
			
		||||
      $scope.addRow($scope.dashboard, $scope.row);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.reset_row = function() {
 | 
			
		||||
    $scope.resetRow = function() {
 | 
			
		||||
      $scope.row = {
 | 
			
		||||
        title: '',
 | 
			
		||||
        height: '250px',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -118,7 +118,7 @@ function (angular, $, kbn, _, moment) {
 | 
			
		|||
      },0);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    p.add_panel = function(panel, row) {
 | 
			
		||||
    p.addPanel = function(panel, row) {
 | 
			
		||||
      var rowSpan = this.rowSpan(row);
 | 
			
		||||
      var panelCount = row.panels.length;
 | 
			
		||||
      var space = (12 - rowSpan) - panel.span;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ function (angular, _, config) {
 | 
			
		|||
      $scope.panelMenuPos = posX;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.toggle_row = function(row) {
 | 
			
		||||
    $scope.toggleRow = function(row) {
 | 
			
		||||
      row.collapse = row.collapse ? false : true;
 | 
			
		||||
      if (!row.collapse) {
 | 
			
		||||
        $timeout(function() {
 | 
			
		||||
| 
						 | 
				
			
			@ -37,11 +37,11 @@ function (angular, _, config) {
 | 
			
		|||
      }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.add_panel = function(panel) {
 | 
			
		||||
      $scope.dashboard.add_panel(panel, $scope.row);
 | 
			
		||||
    $scope.addPanel = function(panel) {
 | 
			
		||||
      $scope.dashboard.addPanel(panel, $scope.row);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.delete_row = function() {
 | 
			
		||||
    $scope.deleteRow = function() {
 | 
			
		||||
      $scope.appEvent('confirm-modal', {
 | 
			
		||||
        title: 'Are you sure you want to delete this row?',
 | 
			
		||||
        icon: 'fa-trash',
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +52,7 @@ function (angular, _, config) {
 | 
			
		|||
      });
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.move_row = function(direction) {
 | 
			
		||||
    $scope.moveRow = function(direction) {
 | 
			
		||||
      var rowsList = $scope.dashboard.rows;
 | 
			
		||||
      var rowIndex = _.indexOf(rowsList, $scope.row);
 | 
			
		||||
      var newIndex = rowIndex;
 | 
			
		||||
| 
						 | 
				
			
			@ -82,17 +82,7 @@ function (angular, _, config) {
 | 
			
		|||
      }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.insert_row = function(direction) {
 | 
			
		||||
      var rowsList = $scope.dashboard.rows;
 | 
			
		||||
      var currentRowIndex = _.indexOf(rowsList, $scope.row);
 | 
			
		||||
      $scope.add_row_default();
 | 
			
		||||
      var newIndex = currentRowIndex + direction;
 | 
			
		||||
      if (newIndex >= 0 && newIndex <= (rowsList.length - 1)) {
 | 
			
		||||
        _.move(rowsList, rowsList.length - 1, newIndex);
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.add_panel_default = function(type) {
 | 
			
		||||
    $scope.addPanelDefault = function(type) {
 | 
			
		||||
      var defaultSpan = 12;
 | 
			
		||||
      var _as = 12 - $scope.dashboard.rowSpan($scope.row);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -104,14 +94,14 @@ function (angular, _, config) {
 | 
			
		|||
        type: type
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      $scope.add_panel(panel);
 | 
			
		||||
      $scope.addPanel(panel);
 | 
			
		||||
 | 
			
		||||
      $timeout(function() {
 | 
			
		||||
        $scope.$broadcast('render');
 | 
			
		||||
      });
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $scope.set_height = function(height) {
 | 
			
		||||
    $scope.setHeight = function(height) {
 | 
			
		||||
      $scope.row.height = height;
 | 
			
		||||
      $scope.$broadcast('render');
 | 
			
		||||
    };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,11 +18,11 @@
 | 
			
		|||
				<div class="row-control-inner">
 | 
			
		||||
					<div class="row-close" ng-show="row.collapse" data-placement="bottom" >
 | 
			
		||||
						<div class="row-close-buttons">
 | 
			
		||||
							<span class="row-button bgPrimary" ng-click="toggle_row(row)">
 | 
			
		||||
							<span class="row-button bgPrimary" ng-click="toggleRow(row)">
 | 
			
		||||
								<i bs-tooltip="'Expand row'" data-placement="right" class="fa fa-caret-left pointer" ></i>
 | 
			
		||||
							</span>
 | 
			
		||||
						</div>
 | 
			
		||||
						<div class="row-text pointer" ng-click="toggle_row(row)" ng-bind="row.title | interpolateTemplateVars:this"></div>
 | 
			
		||||
						<div class="row-text pointer" ng-click="toggleRow(row)" ng-bind="row.title | interpolateTemplateVars:this"></div>
 | 
			
		||||
					</div>
 | 
			
		||||
					<div class="row-open" ng-show="!row.collapse">
 | 
			
		||||
						<div class='row-tab bgSuccess dropdown' ng-show="dashboardMeta.canEdit" ng-hide="dashboardViewState.fullscreen">
 | 
			
		||||
| 
						 | 
				
			
			@ -31,53 +31,46 @@
 | 
			
		|||
							</span>
 | 
			
		||||
							<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="drop1">
 | 
			
		||||
								<li>
 | 
			
		||||
									<a ng-click="toggle_row(row)">Collapse row</a>
 | 
			
		||||
									<a ng-click="toggleRow(row)">Collapse row</a>
 | 
			
		||||
								</li>
 | 
			
		||||
								<li class="dropdown-submenu">
 | 
			
		||||
									<a href="javascript:void(0);">Add Panel</a>
 | 
			
		||||
									<ul class="dropdown-menu">
 | 
			
		||||
										<li bindonce ng-repeat="(key, value) in panels">
 | 
			
		||||
											<a ng-click="add_panel_default(key)" bo-text="value.name"></a>
 | 
			
		||||
											<a ng-click="addPanelDefault(key)" bo-text="value.name"></a>
 | 
			
		||||
										</li>
 | 
			
		||||
									</ul>
 | 
			
		||||
								</li>
 | 
			
		||||
								<li class="dropdown-submenu">
 | 
			
		||||
									<a href="javascript:void(0);">Set height</a>
 | 
			
		||||
									<ul class="dropdown-menu">
 | 
			
		||||
										<li><a ng-click="set_height('25px')">25 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('100px')">100 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('150px')">150 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('200px')">200 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('250px')">250 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('300px')">300 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('350px')">350 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('450px')">450 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('500px')">500 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('600px')">600 px</a></li>
 | 
			
		||||
										<li><a ng-click="set_height('700px')">700 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('25px')">25 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('100px')">100 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('150px')">150 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('200px')">200 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('250px')">250 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('300px')">300 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('350px')">350 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('450px')">450 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('500px')">500 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('600px')">600 px</a></li>
 | 
			
		||||
										<li><a ng-click="setHeight('700px')">700 px</a></li>
 | 
			
		||||
									</ul>
 | 
			
		||||
								</li>
 | 
			
		||||
								<li class="dropdown-submenu">
 | 
			
		||||
									<a href="javascript:void(0);">Move</a>
 | 
			
		||||
									<ul class="dropdown-menu">
 | 
			
		||||
										<li><a ng-click="move_row('up')">Up</a></li>
 | 
			
		||||
										<li><a ng-click="move_row('down')">Down</a></li>
 | 
			
		||||
                    <li><a ng-click="move_row('top')">To top</a></li>
 | 
			
		||||
                    <li><a ng-click="move_row('bottom')">To Bottom</a></li>
 | 
			
		||||
										<li><a ng-click="moveRow('up')">Up</a></li>
 | 
			
		||||
										<li><a ng-click="moveRow('down')">Down</a></li>
 | 
			
		||||
                    <li><a ng-click="moveRow('top')">To top</a></li>
 | 
			
		||||
                    <li><a ng-click="moveRow('bottom')">To Bottom</a></li>
 | 
			
		||||
									</ul>
 | 
			
		||||
								</li>
 | 
			
		||||
								<li>
 | 
			
		||||
									<a dash-editor-link="app/partials/roweditor.html">Row editor</a>
 | 
			
		||||
								</li>
 | 
			
		||||
                <li class="dropdown-submenu">
 | 
			
		||||
                  <a href="javascript:void(0);">Insert Row</a>
 | 
			
		||||
                  <ul class="dropdown-menu">
 | 
			
		||||
                    <li><a ng-click="insert_row(0)">Above</a></li>
 | 
			
		||||
                    <li><a ng-click="insert_row(1)">Below</a></li>
 | 
			
		||||
                  </ul>
 | 
			
		||||
                </li>
 | 
			
		||||
								<li>
 | 
			
		||||
									<a ng-click="delete_row()">Delete row</a>
 | 
			
		||||
									<a ng-click="deleteRow()">Delete row</a>
 | 
			
		||||
								</li>
 | 
			
		||||
							</ul>
 | 
			
		||||
						</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -108,7 +101,7 @@
 | 
			
		|||
 | 
			
		||||
		<div ng-show='dashboardMeta.canEdit' class="row-fluid add-row-panel-hint" ng-hide="dashboardViewState.fullscreen">
 | 
			
		||||
			<div class="span12" style="text-align:right;">
 | 
			
		||||
				<span style="margin-right: 10px;" ng-click="add_row_default()" class="pointer btn btn-info btn-small">
 | 
			
		||||
				<span style="margin-right: 10px;" ng-click="addRowDefault()" class="pointer btn btn-info btn-small">
 | 
			
		||||
					<span><i class="fa fa-plus"></i> ADD ROW</span>
 | 
			
		||||
				</span>
 | 
			
		||||
			</div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -94,7 +94,7 @@ define([
 | 
			
		|||
 | 
			
		||||
      it('adding default should split span in half', function() {
 | 
			
		||||
        dashboard.rows = [{ panels: [{ span: 12, id: 7 }] }];
 | 
			
		||||
        dashboard.add_panel({span: 4}, dashboard.rows[0]);
 | 
			
		||||
        dashboard.addPanel({span: 4}, dashboard.rows[0]);
 | 
			
		||||
 | 
			
		||||
        expect(dashboard.rows[0].panels[0].span).to.be(6);
 | 
			
		||||
        expect(dashboard.rows[0].panels[1].span).to.be(6);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue