Browse Source

Fixed some playlist issues, error when adding duplicates

Torkel Ödegaard 11 years ago
parent
commit
6263ec1d38
2 changed files with 10 additions and 6 deletions
  1. 9 0
      src/app/features/dashboard/playlistCtrl.js
  2. 1 6
      src/app/partials/playlist.html

+ 9 - 0
src/app/features/dashboard/playlistCtrl.js

@@ -27,15 +27,24 @@ function (angular, _, config) {
 
       $scope.db.searchDashboards(query).then(function(results) {
         $scope.searchHits = results.dashboards;
+        $scope.filterHits();
+      });
+    };
+
+    $scope.filterHits = function() {
+      $scope.filteredHits = _.reject($scope.searchHits, function(dash) {
+        return _.findWhere($scope.playlist, {slug: dash.slug});
       });
     };
 
     $scope.addDashboard = function(dashboard) {
       $scope.playlist.push(dashboard);
+      $scope.filterHits();
     };
 
     $scope.removeDashboard = function(dashboard) {
       $scope.playlist = _.without($scope.playlist, dashboard);
+      $scope.filterHits();
     };
 
     $scope.start = function() {

+ 1 - 6
src/app/partials/playlist.html

@@ -36,7 +36,7 @@
 		<div class="row">
 			<div class="span6">
 				<table class="grafana-options-table">
-					<tr ng-repeat="dashboard in searchHits">
+					<tr ng-repeat="dashboard in filteredHits">
 						<td style="white-space: nowrap;">
 							{{dashboard.title}}
 						</td>
@@ -65,11 +65,6 @@
 							</button>
 						</td>
 					</tr>
-					<tr ng-hide="searchHits.length">
-						<td colspan="3">
-							<i class="fa fa-warning"></i> No dashboards found
-						</td>
-					</tr>
 				</table>
 			</div>
 		</div>