Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
97b087f5
Unverified
Commit
97b087f5
authored
Aug 21, 2018
by
Pierre GIRAUD
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use factors for max repeated panels per row
parent
a8814979
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
2 deletions
+28
-2
public/app/core/specs/factors.test.ts
+8
-0
public/app/core/utils/factors.ts
+5
-0
public/app/features/dashboard/dashboard_migration.ts
+11
-1
public/app/features/panel/panel_ctrl.ts
+4
-1
No files found.
public/app/core/specs/factors.test.ts
0 → 100644
View file @
97b087f5
import
getFactors
from
'app/core/utils/factors'
;
describe
(
'factors'
,
()
=>
{
it
(
'should return factors for 12'
,
()
=>
{
const
factors
=
getFactors
(
12
);
expect
(
factors
).
toEqual
([
1
,
2
,
3
,
4
,
6
,
12
]);
});
});
public/app/core/utils/factors.ts
0 → 100644
View file @
97b087f5
// Returns the factors of a number
// Example getFactors(12) -> [1, 2, 3, 4, 6, 12]
export
default
function
getFactors
(
num
:
number
):
number
[]
{
return
Array
.
from
(
new
Array
(
num
+
1
),
(
_
,
i
)
=>
i
).
filter
(
i
=>
num
%
i
===
0
);
}
public/app/features/dashboard/dashboard_migration.ts
View file @
97b087f5
...
...
@@ -9,6 +9,7 @@ import {
}
from
'app/core/constants'
;
import
{
PanelModel
}
from
'./panel_model'
;
import
{
DashboardModel
}
from
'./dashboard_model'
;
import
getFactors
from
'app/core/utils/factors'
;
export
class
DashboardMigrator
{
dashboard
:
DashboardModel
;
...
...
@@ -371,7 +372,16 @@ export class DashboardMigrator {
if
(
oldVersion
<
17
)
{
panelUpgrades
.
push
(
panel
=>
{
if
(
panel
.
minSpan
)
{
panel
.
maxPerRow
=
GRID_COLUMN_COUNT
/
panel
.
minSpan
;
const
max
=
GRID_COLUMN_COUNT
/
panel
.
minSpan
;
const
factors
=
getFactors
(
GRID_COLUMN_COUNT
);
// find the best match compared to factors
// (ie. [1,2,3,4,6,12,24] for 24 columns)
panel
.
maxPerRow
=
factors
[
_
.
findIndex
(
factors
,
o
=>
{
return
o
>
max
;
})
-
1
];
}
delete
panel
.
minSpan
;
});
...
...
public/app/features/panel/panel_ctrl.ts
View file @
97b087f5
...
...
@@ -5,6 +5,7 @@ import Remarkable from 'remarkable';
import
config
from
'app/core/config'
;
import
{
profiler
}
from
'app/core/core'
;
import
{
Emitter
}
from
'app/core/core'
;
import
getFactors
from
'app/core/utils/factors'
;
import
{
duplicatePanel
,
copyPanel
as
copyPanelUtil
,
...
...
@@ -12,7 +13,7 @@ import {
sharePanel
as
sharePanelUtil
,
}
from
'app/features/dashboard/utils/panel'
;
import
{
GRID_CELL_HEIGHT
,
GRID_CELL_VMARGIN
,
PANEL_HEADER_HEIGHT
,
PANEL_BORDER
}
from
'app/core/constants'
;
import
{
GRID_CELL_HEIGHT
,
GRID_CELL_VMARGIN
,
GRID_COLUMN_COUNT
,
PANEL_HEADER_HEIGHT
,
PANEL_BORDER
}
from
'app/core/constants'
;
export
class
PanelCtrl
{
panel
:
any
;
...
...
@@ -32,6 +33,7 @@ export class PanelCtrl {
events
:
Emitter
;
timing
:
any
;
loading
:
boolean
;
maxPanelsPerRowOptions
:
number
[];
constructor
(
$scope
,
$injector
)
{
this
.
$injector
=
$injector
;
...
...
@@ -92,6 +94,7 @@ export class PanelCtrl {
if
(
!
this
.
editModeInitiated
)
{
this
.
editModeInitiated
=
true
;
this
.
events
.
emit
(
'init-edit-mode'
,
null
);
this
.
maxPanelsPerRowOptions
=
getFactors
(
GRID_COLUMN_COUNT
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment