'use strict';

/**
 * @ngdoc function
 * @name dockstore.ui.controller:SearchCtrl
 * @description
 * # SearchCtrl
 * Controller of the dockstore.ui
 */
angular.module('dockstore.ui')
  .controller('SearchCtrl', [
    '$scope',
    '$rootScope',
    '$q',
    '$window',
    '$location',
    '$auth',
    '$routeParams',
    'ContainerService',
    'UserService',
    'TokenService',
    'NotificationService',
    function ($scope, $rootScope, $q, $window, $location, $auth, $routeParams,
        ContainerService, UserService, TokenService, NtfnService) {

      $scope.userObj = UserService.getUserObj();

      $scope.listRegisteredContainers = function() {
        return ContainerService.getRegisteredContainerList()
          .then(
            function(containers) {
              $scope.containers = containers;
            },
            function(response) {
              var message = '[' + response.status + '] ' + response.statusText;
              NtfnService.popError('List Registered Containers', message);
              return $q.reject(response);
            }
          );
      };

      if ($auth.isAuthenticated()) {
        TokenService.getUserTokenStatusSet($scope.userObj.id)
          .then(
            function(tokenStatusSet) {
              $scope.tokenStatusSet = tokenStatusSet;
              if (!(tokenStatusSet.github && tokenStatusSet.quayio)) {
                $window.location.href = '/onboarding';
              }
            }
          );
      }

      // incomplete
      // also need to remove 'label:' prefix!
      $scope.$on('$locationChangeStart', function(event, newState, oldState) {
        if ($rootScope.searchQuery && $rootScope.searchQuery.length > 0) {
          $rootScope.searchQuery = '';
        }
      });

      if ($routeParams.searchQuery) {
        $rootScope.searchQuery = $routeParams.searchQuery;
      }

      $scope.listRegisteredContainers();
      
  }]);

@@ -1514,51 +1514,8 @@
   //
- also need to remove 'label:' prefix!%0A     
  $sc
@@ -1585,24 +1585,27 @@
 ate) %7B%0A     
+ //
    if ($root
@@ -1663,24 +1663,27 @@
 %3E 0) %7B%0A     
+ //
      $rootSc
@@ -1705,24 +1705,27 @@
  = '';%0A     
+ //
    %7D%0A      %7D
@@ -1722,16 +1722,19 @@
  %7D%0A     
+ //
  %7D);%0A%0A  

Disable search term removal temporarily.