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
98dccb86
Commit
98dccb86
authored
Jan 11, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(playlist): refactor FE to support playlistitems
parent
8a389912
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
47 deletions
+48
-47
pkg/services/sqlstore/playlist.go
+1
-0
public/app/features/playlist/partials/playlist.html
+10
-10
public/app/features/playlist/playlist_edit_ctrl.js
+37
-37
No files found.
pkg/services/sqlstore/playlist.go
View file @
98dccb86
...
...
@@ -84,6 +84,7 @@ func UpdatePlaylist(query *m.UpdatePlaylistQuery) error {
}
playlistItems
:=
make
([]
m
.
PlaylistItem
,
0
)
for
_
,
item
:=
range
query
.
Items
{
playlistItems
=
append
(
playlistItems
,
m
.
PlaylistItem
{
PlaylistId
:
playlist
.
Id
,
...
...
public/app/features/playlist/partials/playlist.html
View file @
98dccb86
...
...
@@ -59,14 +59,14 @@
<div>
<div
class=
"span5 pull-left"
>
<h5>
Search results ({{filtered
Dashboard
s.length}})
</h5>
<h5>
Search results ({{filtered
PlaylistItem
s.length}})
</h5>
<table
class=
"grafana-options-table"
>
<tr
ng-repeat=
"
dashboard in filteredDashboard
s"
>
<tr
ng-repeat=
"
playlistItem in filteredPlaylistItem
s"
>
<td
style=
"white-space: nowrap;"
>
{{
dashboard
.title}}
{{
playlistItem
.title}}
</td>
<td
style=
"text-align: center"
>
<button
class=
"btn btn-inverse btn-mini pull-right"
ng-click=
"add
Dashboard(dashboard
)"
>
<button
class=
"btn btn-inverse btn-mini pull-right"
ng-click=
"add
PlaylistItem(playlistItem
)"
>
<i
class=
"fa fa-plus"
></i>
Add to playlist
</button>
...
...
@@ -82,18 +82,18 @@
<div
class=
"span5 pull-left"
>
<h5>
Playlist dashboards
</h5>
<table
class=
"grafana-options-table"
>
<tr
ng-repeat=
"
dashboard in dashboard
s"
>
<tr
ng-repeat=
"
playlistItem in playlistItem
s"
>
<td
style=
"white-space: nowrap;"
>
{{
dashboard
.title}}
{{
playlistItem
.title}}
</td>
<td
style=
"text-align: right"
>
<button
class=
"btn btn-inverse btn-mini"
ng-hide=
"$first"
ng-click=
"move
DashboardUp(dashboard
)"
>
<button
class=
"btn btn-inverse btn-mini"
ng-hide=
"$first"
ng-click=
"move
PlaylistItemUp(playlistItem
)"
>
<i
class=
"fa fa-arrow-up"
></i>
</button>
<button
class=
"btn btn-inverse btn-mini"
ng-hide=
"$last"
ng-click=
"move
DashboardDown(dashboard
)"
>
<button
class=
"btn btn-inverse btn-mini"
ng-hide=
"$last"
ng-click=
"move
PlaylistItemDown(playlistItem
)"
>
<i
class=
"fa fa-arrow-down"
></i>
</button>
<button
class=
"btn btn-inverse btn-mini"
ng-click=
"remove
Dashboard(dashboard
)"
>
<button
class=
"btn btn-inverse btn-mini"
ng-click=
"remove
PlaylistItem(playlistItem
)"
>
<i
class=
"fa fa-remove"
></i>
</button>
</td>
...
...
@@ -113,7 +113,7 @@
<button
type=
"button"
class=
"btn btn-success"
ng-disabled=
"playlistEditForm.$invalid || isPlaylistEmpty()"
ng-click=
"savePlaylist(playlist,
dashboard
s)"
>
Save
</button>
ng-click=
"savePlaylist(playlist,
playlistItem
s)"
>
Save
</button>
<button
type=
"button"
class=
"btn btn-default"
ng-click=
"backToList()"
>
Cancel
</button>
...
...
public/app/features/playlist/playlist_edit_ctrl.js
View file @
98dccb86
...
...
@@ -10,12 +10,12 @@ function (angular, config, _) {
module
.
controller
(
'PlaylistEditCtrl'
,
function
(
$scope
,
playlistSrv
,
backendSrv
,
$location
,
$route
)
{
$scope
.
timespan
=
config
.
playlist_timespan
;
$scope
.
filtered
Dashboard
s
=
[];
$scope
.
found
Dashboard
s
=
[];
$scope
.
filtered
PlaylistItem
s
=
[];
$scope
.
found
PlaylistItem
s
=
[];
$scope
.
searchQuery
=
''
;
$scope
.
loading
=
false
;
$scope
.
playlist
=
{};
$scope
.
dashboard
s
=
[];
$scope
.
playlistItem
s
=
[];
if
(
$route
.
current
.
params
.
id
)
{
var
playlistId
=
$route
.
current
.
params
.
id
;
...
...
@@ -25,9 +25,9 @@ function (angular, config, _) {
$scope
.
playlist
=
result
;
});
backendSrv
.
get
(
'/api/playlists/'
+
playlistId
+
'/
dashboard
s'
)
backendSrv
.
get
(
'/api/playlists/'
+
playlistId
+
'/
playlistitem
s'
)
.
then
(
function
(
result
)
{
$scope
.
dashboard
s
=
result
;
$scope
.
playlistItem
s
=
result
;
});
}
...
...
@@ -43,43 +43,43 @@ function (angular, config, _) {
backendSrv
.
search
(
query
)
.
then
(
function
(
results
)
{
$scope
.
found
Dashboard
s
=
results
;
$scope
.
filterFound
Dashboard
s
();
$scope
.
found
PlaylistItem
s
=
results
;
$scope
.
filterFound
PlaylistItem
s
();
})
.
finally
(
function
()
{
$scope
.
loading
=
false
;
});
};
$scope
.
filterFound
Dashboard
s
=
function
()
{
$scope
.
filtered
Dashboards
=
_
.
reject
(
$scope
.
foundDashboards
,
function
(
dashboard
)
{
return
_
.
findWhere
(
$scope
.
dashboards
,
function
(
listDashboard
)
{
return
list
Dashboard
.
id
===
dashboard
.
id
;
$scope
.
filterFound
PlaylistItem
s
=
function
()
{
$scope
.
filtered
PlaylistItems
=
_
.
reject
(
$scope
.
foundPlaylistItems
,
function
(
playlistItem
)
{
return
_
.
findWhere
(
$scope
.
playlistItems
,
function
(
listPlaylistItem
)
{
return
list
PlaylistItem
===
playlistItem
;
});
});
};
$scope
.
addDashboard
=
function
(
dashboard
)
{
$scope
.
dashboards
.
push
(
dashboard
);
$scope
.
filterFoundDashboards
();
$scope
.
addPlaylistItem
=
function
(
playlistItem
)
{
playlistItem
.
value
=
playlistItem
.
id
.
toString
();
playlistItem
.
type
=
'dashboard_by_id'
;
playlistItem
.
order
=
$scope
.
playlistItems
.
length
+
1
;
$scope
.
playlistItems
.
push
(
playlistItem
);
$scope
.
filterFoundPlaylistItems
();
};
$scope
.
remove
Dashboard
=
function
(
dashboard
)
{
_
.
remove
(
$scope
.
dashboards
,
function
(
listedDashboard
)
{
return
dashboard
===
listedDashboard
;
$scope
.
remove
PlaylistItem
=
function
(
playlistItem
)
{
_
.
remove
(
$scope
.
playlistItems
,
function
(
listedPlaylistItem
)
{
return
playlistItem
===
listedPlaylistItem
;
});
$scope
.
filterFound
Dashboard
s
();
$scope
.
filterFound
PlaylistItem
s
();
};
$scope
.
savePlaylist
=
function
(
playlist
,
dashboard
s
)
{
$scope
.
savePlaylist
=
function
(
playlist
,
playlistItem
s
)
{
var
savePromise
;
playlist
.
data
=
dashboards
.
map
(
function
(
dashboard
)
{
return
dashboard
.
id
;
});
// Hardcoding playlist type for this iteration
playlist
.
type
=
"dashboards"
;
playlist
.
items
=
playlistItems
;
savePromise
=
playlist
.
id
?
backendSrv
.
put
(
'/api/playlists/'
+
playlist
.
id
,
playlist
)
...
...
@@ -90,7 +90,7 @@ function (angular, config, _) {
$scope
.
appEvent
(
'alert-success'
,
[
'Playlist saved'
,
''
]);
$location
.
path
(
'/playlists'
);
},
function
()
{
$scope
.
appEvent
(
'alert-
success
'
,
[
'Unable to save playlist'
,
''
]);
$scope
.
appEvent
(
'alert-
error
'
,
[
'Unable to save playlist'
,
''
]);
});
};
...
...
@@ -103,11 +103,11 @@ function (angular, config, _) {
};
$scope
.
isPlaylistEmpty
=
function
()
{
return
!
$scope
.
dashboard
s
.
length
;
return
!
$scope
.
playlistItem
s
.
length
;
};
$scope
.
isSearchResultsEmpty
=
function
()
{
return
!
$scope
.
found
Dashboard
s
.
length
;
return
!
$scope
.
found
PlaylistItem
s
.
length
;
};
$scope
.
isSearchQueryEmpty
=
function
()
{
...
...
@@ -122,22 +122,22 @@ function (angular, config, _) {
return
$scope
.
loading
;
};
$scope
.
move
Dashboard
=
function
(
dashboard
,
offset
)
{
var
currentPosition
=
$scope
.
dashboards
.
indexOf
(
dashboard
);
$scope
.
move
PlaylistItem
=
function
(
playlistItem
,
offset
)
{
var
currentPosition
=
$scope
.
playlistItems
.
indexOf
(
playlistItem
);
var
newPosition
=
currentPosition
+
offset
;
if
(
newPosition
>=
0
&&
newPosition
<
$scope
.
dashboard
s
.
length
)
{
$scope
.
dashboard
s
.
splice
(
currentPosition
,
1
);
$scope
.
dashboards
.
splice
(
newPosition
,
0
,
dashboard
);
if
(
newPosition
>=
0
&&
newPosition
<
$scope
.
playlistItem
s
.
length
)
{
$scope
.
playlistItem
s
.
splice
(
currentPosition
,
1
);
$scope
.
playlistItems
.
splice
(
newPosition
,
0
,
playlistItem
);
}
};
$scope
.
move
DashboardUp
=
function
(
dashboard
)
{
$scope
.
moveDashboard
(
dashboard
,
-
1
);
$scope
.
move
PlaylistItemUp
=
function
(
playlistItem
)
{
$scope
.
moveDashboard
(
playlistItem
,
-
1
);
};
$scope
.
move
DashboardDown
=
function
(
dashboard
)
{
$scope
.
moveDashboard
(
dashboard
,
1
);
$scope
.
move
PlaylistItemDown
=
function
(
playlistItem
)
{
$scope
.
moveDashboard
(
playlistItem
,
1
);
};
$scope
.
search
();
...
...
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