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
d15b0bf4
Commit
d15b0bf4
authored
Jan 08, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(playlist): move backend code to ctrl
data loading should be done in the ctrl
parent
01a910fe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
47 deletions
+38
-47
public/app/features/playlist/playlist_edit_ctrl.js
+32
-24
public/app/features/playlist/playlist_routes.js
+2
-22
public/app/features/playlist/playlists_ctrl.js
+4
-1
No files found.
public/app/features/playlist/playlist_edit_ctrl.js
View file @
d15b0bf4
...
...
@@ -8,14 +8,29 @@ function (angular, config, _) {
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'PlaylistEditCtrl'
,
function
(
playlist
,
dashboards
,
$scope
,
playlistSrv
,
backendSrv
,
$location
)
{
module
.
controller
(
'PlaylistEditCtrl'
,
function
(
$scope
,
playlistSrv
,
backendSrv
,
$location
,
$route
)
{
$scope
.
timespan
=
config
.
playlist_timespan
;
$scope
.
filteredDashboards
=
[];
$scope
.
foundDashboards
=
[];
$scope
.
searchQuery
=
''
;
$scope
.
loading
=
false
;
$scope
.
playlist
=
{};
$scope
.
dashboards
=
[];
if
(
$route
.
current
.
params
.
id
)
{
var
playlistId
=
$route
.
current
.
params
.
id
;
backendSrv
.
get
(
'/api/playlists/'
+
playlistId
)
.
then
(
function
(
result
)
{
$scope
.
playlist
=
result
;
});
backendSrv
.
get
(
'/api/playlists/'
+
playlistId
+
'/dashboards'
)
.
then
(
function
(
result
)
{
$scope
.
dashboards
=
result
;
});
}
$scope
.
search
=
function
()
{
var
query
=
{
starred
:
true
,
limit
:
10
};
...
...
@@ -38,19 +53,19 @@ function (angular, config, _) {
$scope
.
filterFoundDashboards
=
function
()
{
$scope
.
filteredDashboards
=
_
.
reject
(
$scope
.
foundDashboards
,
function
(
dashboard
)
{
return
_
.
findWhere
(
dashboards
,
function
(
listDashboard
)
{
return
_
.
findWhere
(
$scope
.
dashboards
,
function
(
listDashboard
)
{
return
listDashboard
.
id
===
dashboard
.
id
;
});
});
};
$scope
.
addDashboard
=
function
(
dashboard
)
{
dashboards
.
push
(
dashboard
);
$scope
.
dashboards
.
push
(
dashboard
);
$scope
.
filterFoundDashboards
();
};
$scope
.
removeDashboard
=
function
(
dashboard
)
{
_
.
remove
(
dashboards
,
function
(
listedDashboard
)
{
_
.
remove
(
$scope
.
dashboards
,
function
(
listedDashboard
)
{
return
dashboard
===
listedDashboard
;
});
$scope
.
filterFoundDashboards
();
...
...
@@ -80,7 +95,7 @@ function (angular, config, _) {
};
$scope
.
isNew
=
function
()
{
return
!
playlist
.
id
;
return
!
$scope
.
playlist
.
id
;
};
$scope
.
startPlaylist
=
function
(
playlist
,
dashboards
)
{
...
...
@@ -88,7 +103,7 @@ function (angular, config, _) {
};
$scope
.
isPlaylistEmpty
=
function
()
{
return
!
dashboards
.
length
;
return
!
$scope
.
dashboards
.
length
;
};
$scope
.
isSearchResultsEmpty
=
function
()
{
...
...
@@ -108,12 +123,12 @@ function (angular, config, _) {
};
$scope
.
moveDashboard
=
function
(
dashboard
,
offset
)
{
var
currentPosition
=
dashboards
.
indexOf
(
dashboard
);
var
currentPosition
=
$scope
.
dashboards
.
indexOf
(
dashboard
);
var
newPosition
=
currentPosition
+
offset
;
if
(
newPosition
>=
0
&&
newPosition
<
dashboards
.
length
)
{
dashboards
.
splice
(
currentPosition
,
1
);
dashboards
.
splice
(
newPosition
,
0
,
dashboard
);
if
(
newPosition
>=
0
&&
newPosition
<
$scope
.
dashboards
.
length
)
{
$scope
.
dashboards
.
splice
(
currentPosition
,
1
);
$scope
.
dashboards
.
splice
(
newPosition
,
0
,
dashboard
);
}
};
...
...
@@ -125,13 +140,6 @@ function (angular, config, _) {
$scope
.
moveDashboard
(
dashboard
,
1
);
};
$scope
.
playlist
=
playlist
;
$scope
.
dashboards
=
dashboards
;
$scope
.
timespan
=
config
.
playlist_timespan
;
$scope
.
filteredDashboards
=
[];
$scope
.
foundDashboards
=
[];
$scope
.
searchQuery
=
''
;
$scope
.
loading
=
false
;
$scope
.
search
();
});
});
public/app/features/playlist/playlist_routes.js
View file @
d15b0bf4
...
...
@@ -16,31 +16,11 @@ function (angular, config, _) {
})
.
when
(
'/playlists/create'
,
{
templateUrl
:
'app/features/playlist/partials/playlist.html'
,
controller
:
'PlaylistEditCtrl'
,
resolve
:
{
playlist
:
function
()
{
return
{};
},
dashboards
:
function
()
{
return
[];
}
}
controller
:
'PlaylistEditCtrl'
})
.
when
(
'/playlists/edit/:id'
,
{
templateUrl
:
'app/features/playlist/partials/playlist.html'
,
controller
:
'PlaylistEditCtrl'
,
resolve
:
{
playlist
:
function
(
backendSrv
,
$route
)
{
var
playlistId
=
$route
.
current
.
params
.
id
;
return
backendSrv
.
get
(
'/api/playlists/'
+
playlistId
);
},
dashboards
:
function
(
backendSrv
,
$route
)
{
var
playlistId
=
$route
.
current
.
params
.
id
;
return
backendSrv
.
get
(
'/api/playlists/'
+
playlistId
+
'/dashboards'
);
}
}
controller
:
'PlaylistEditCtrl'
})
.
when
(
'/playlists/play/:id'
,
{
templateUrl
:
'app/partials/dashboard.html'
,
...
...
public/app/features/playlist/playlists_ctrl.js
View file @
d15b0bf4
...
...
@@ -12,7 +12,10 @@ function (angular, _) {
$location
,
backendSrv
)
{
$scope
.
playlists
=
backendSrv
.
get
(
'/api/playlists'
);
backendSrv
.
get
(
'/api/playlists'
)
.
then
(
function
(
result
)
{
$scope
.
playlists
=
result
;
});
$scope
.
playlistUrl
=
function
(
playlist
)
{
return
'/playlists/play/'
+
playlist
.
id
;
...
...
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