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
013f8cd8
Commit
013f8cd8
authored
Aug 05, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: moving code around a bit, refactoring PR #12796
parent
f00b5eee
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
47 deletions
+29
-47
public/app/features/dashboard/dashboard_ctrl.ts
+2
-26
public/app/features/dashboard/dashboard_model.ts
+23
-5
public/app/features/dashboard/specs/dashboard_model.jest.ts
+0
-13
public/app/routes/dashboard_loaders.ts
+3
-2
public/sass/pages/_dashboard.scss
+1
-1
No files found.
public/app/features/dashboard/dashboard_ctrl.ts
View file @
013f8cd8
...
@@ -4,7 +4,6 @@ import coreModule from 'app/core/core_module';
...
@@ -4,7 +4,6 @@ import coreModule from 'app/core/core_module';
import
{
PanelContainer
}
from
'./dashgrid/PanelContainer'
;
import
{
PanelContainer
}
from
'./dashgrid/PanelContainer'
;
import
{
DashboardModel
}
from
'./dashboard_model'
;
import
{
DashboardModel
}
from
'./dashboard_model'
;
import
{
PanelModel
}
from
'./panel_model'
;
import
{
PanelModel
}
from
'./panel_model'
;
import
{
GRID_CELL_HEIGHT
,
GRID_CELL_VMARGIN
}
from
'app/core/constants'
;
export
class
DashboardCtrl
implements
PanelContainer
{
export
class
DashboardCtrl
implements
PanelContainer
{
dashboard
:
DashboardModel
;
dashboard
:
DashboardModel
;
...
@@ -24,8 +23,7 @@ export class DashboardCtrl implements PanelContainer {
...
@@ -24,8 +23,7 @@ export class DashboardCtrl implements PanelContainer {
private
unsavedChangesSrv
,
private
unsavedChangesSrv
,
private
dashboardViewStateSrv
,
private
dashboardViewStateSrv
,
public
playlistSrv
,
public
playlistSrv
,
private
panelLoader
,
private
panelLoader
private
$location
)
{
)
{
// temp hack due to way dashboards are loaded
// temp hack due to way dashboards are loaded
// can't use controllerAs on route yet
// can't use controllerAs on route yet
...
@@ -64,8 +62,8 @@ export class DashboardCtrl implements PanelContainer {
...
@@ -64,8 +62,8 @@ export class DashboardCtrl implements PanelContainer {
.
finally
(()
=>
{
.
finally
(()
=>
{
this
.
dashboard
=
dashboard
;
this
.
dashboard
=
dashboard
;
this
.
dashboard
.
processRepeats
();
this
.
dashboard
.
processRepeats
();
this
.
dashboard
.
autoFitPanels
(
window
.
innerHeight
);
this
.
autofitPanels
();
this
.
unsavedChangesSrv
.
init
(
dashboard
,
this
.
$scope
);
this
.
unsavedChangesSrv
.
init
(
dashboard
,
this
.
$scope
);
// TODO refactor ViewStateSrv
// TODO refactor ViewStateSrv
...
@@ -82,28 +80,6 @@ export class DashboardCtrl implements PanelContainer {
...
@@ -82,28 +80,6 @@ export class DashboardCtrl implements PanelContainer {
.
catch
(
this
.
onInitFailed
.
bind
(
this
,
'Dashboard init failed'
,
true
));
.
catch
(
this
.
onInitFailed
.
bind
(
this
,
'Dashboard init failed'
,
true
));
}
}
autofitPanels
()
{
if
(
this
.
$location
.
search
().
autofitpanels
)
{
let
maxRows
=
Math
.
max
(
...
this
.
dashboard
.
panels
.
map
(
panel
=>
{
return
panel
.
gridPos
.
h
+
panel
.
gridPos
.
y
;
})
);
//Consider navbar and submenu controls, padding and margin
let
availableHeight
=
window
.
innerHeight
-
40
;
let
availableRows
=
Math
.
floor
(
availableHeight
/
(
GRID_CELL_HEIGHT
+
GRID_CELL_VMARGIN
));
let
scaleFactor
=
maxRows
/
availableRows
;
this
.
dashboard
.
panels
.
forEach
((
panel
,
i
)
=>
{
panel
.
gridPos
.
y
=
Math
.
round
(
panel
.
gridPos
.
y
/
scaleFactor
)
||
1
;
panel
.
gridPos
.
h
=
Math
.
round
(
panel
.
gridPos
.
h
/
scaleFactor
)
||
1
;
});
this
.
dashboard
.
meta
.
autofitpanels
=
true
;
console
.
log
(
this
.
dashboard
);
}
}
onInitFailed
(
msg
,
fatal
,
err
)
{
onInitFailed
(
msg
,
fatal
,
err
)
{
console
.
log
(
msg
,
err
);
console
.
log
(
msg
,
err
);
...
...
public/app/features/dashboard/dashboard_model.ts
View file @
013f8cd8
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
{
GRID_COLUMN_COUNT
,
REPEAT_DIR_VERTICAL
}
from
'app/core/constants'
;
import
{
GRID_COLUMN_COUNT
,
REPEAT_DIR_VERTICAL
,
GRID_CELL_HEIGHT
,
GRID_CELL_VMARGIN
}
from
'app/core/constants'
;
import
{
DEFAULT_ANNOTATION_COLOR
}
from
'app/core/utils/colors'
;
import
{
DEFAULT_ANNOTATION_COLOR
}
from
'app/core/utils/colors'
;
import
{
Emitter
}
from
'app/core/utils/emitter'
;
import
{
Emitter
}
from
'app/core/utils/emitter'
;
import
{
contextSrv
}
from
'app/core/services/context_srv'
;
import
{
contextSrv
}
from
'app/core/services/context_srv'
;
...
@@ -591,10 +591,6 @@ export class DashboardModel {
...
@@ -591,10 +591,6 @@ export class DashboardModel {
updateSubmenuVisibility
()
{
updateSubmenuVisibility
()
{
this
.
meta
.
submenuEnabled
=
(()
=>
{
this
.
meta
.
submenuEnabled
=
(()
=>
{
if
(
this
.
meta
.
autofitpanels
)
{
return
false
;
}
if
(
this
.
links
.
length
>
0
)
{
if
(
this
.
links
.
length
>
0
)
{
return
true
;
return
true
;
}
}
...
@@ -834,4 +830,26 @@ export class DashboardModel {
...
@@ -834,4 +830,26 @@ export class DashboardModel {
return
!
_
.
isEqual
(
updated
,
this
.
originalTemplating
);
return
!
_
.
isEqual
(
updated
,
this
.
originalTemplating
);
}
}
autoFitPanels
(
viewHeight
:
number
)
{
if
(
!
this
.
meta
.
autofitpanels
)
{
return
;
}
let
maxRows
=
Math
.
max
(
...
this
.
panels
.
map
(
panel
=>
{
return
panel
.
gridPos
.
h
+
panel
.
gridPos
.
y
;
})
);
//Consider navbar and submenu controls, padding and margin
let
availableHeight
=
window
.
innerHeight
-
55
-
20
;
let
availableRows
=
Math
.
floor
(
availableHeight
/
(
GRID_CELL_HEIGHT
+
GRID_CELL_VMARGIN
));
let
scaleFactor
=
maxRows
/
availableRows
;
this
.
panels
.
forEach
((
panel
,
i
)
=>
{
panel
.
gridPos
.
y
=
Math
.
round
(
panel
.
gridPos
.
y
/
scaleFactor
)
||
1
;
panel
.
gridPos
.
h
=
Math
.
round
(
panel
.
gridPos
.
h
/
scaleFactor
)
||
1
;
});
}
}
}
public/app/features/dashboard/specs/dashboard_model.jest.ts
View file @
013f8cd8
...
@@ -305,19 +305,6 @@ describe('DashboardModel', function() {
...
@@ -305,19 +305,6 @@ describe('DashboardModel', function() {
});
});
});
});
describe
(
'updateSubmenuVisibility with autofitpanels enabled'
,
function
()
{
var
model
;
beforeEach
(
function
()
{
model
=
new
DashboardModel
({},
{
autofitpanels
:
true
});
model
.
updateSubmenuVisibility
();
});
it
(
'should not enable submmenu'
,
function
()
{
expect
(
model
.
meta
.
submenuEnabled
).
toBe
(
false
);
});
});
describe
(
'updateSubmenuVisibility with hidden annotation toggle'
,
function
()
{
describe
(
'updateSubmenuVisibility with hidden annotation toggle'
,
function
()
{
var
dashboard
;
var
dashboard
;
...
...
public/app/routes/dashboard_loaders.ts
View file @
013f8cd8
...
@@ -38,9 +38,10 @@ export class LoadDashboardCtrl {
...
@@ -38,9 +38,10 @@ export class LoadDashboardCtrl {
}
}
}
}
if
(
$routeParams
.
keepRow
s
)
{
if
(
$routeParams
.
autofitpanel
s
)
{
result
.
meta
.
keepRow
s
=
true
;
result
.
meta
.
autofitpanel
s
=
true
;
}
}
$scope
.
initDashboard
(
result
,
$scope
);
$scope
.
initDashboard
(
result
,
$scope
);
});
});
}
}
...
...
public/sass/pages/_dashboard.scss
View file @
013f8cd8
.dashboard-container
{
.dashboard-container
{
padding
:
$dashboard-padding
;
padding
:
$dashboard-padding
$dashboard-padding
0
$dashboard-padding
;
width
:
100%
;
width
:
100%
;
min-height
:
100%
;
min-height
:
100%
;
}
}
...
...
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