<commit_before>'use strict';

angular.module('spotmop.settings', [
    'ngRoute'
])

/**
 * Every controller start with defining its own routes.
 */
.config(function($routeProvider) {
    $routeProvider.when("/settings", {
        templateUrl: "app/settings/template.html",
        controller: "SettingsController"
    });
})
	
.controller('SettingsController', function SettingsController( $scope, $rootScope, $timeout, MopidyService, SpotifyService, EchonestService, SettingsService ){
	
	// load our current settings into the template
	$scope.version;
	$scope.settings = SettingsService.getSettings();
	$scope.currentSubpage = 'mopidy';
	$scope.subpageNavigate = function( subpage ){
		$scope.currentSubpage = subpage;
	};
    $scope.refreshSpotifyToken = function(){
        $rootScope.$broadcast('spotmop:notifyUser', {id: 'refreshtoken', message: "Refreshing token", type: 'loading'});
        $.when(SpotifyService.getNewToken()).then( function(){
            $rootScope.$broadcast('spotmop:notifyUserRemoval', {id: 'refreshtoken'});
        });
    };
    $scope.spotifyLogout = function(){
        SpotifyService.logout();
        $rootScope.$broadcast('spotmop:notifyUser', {id: 'spotify-loggingout', message: "Logging you out", type: 'bad loading'});
        $timeout( function(){ window.location = window.location }, 1000 );
    };
    $scope.toggleMopidyConsume = function(){
    	if( $scope.settings.mopidyconsume ){
            MopidyService.setConsume( false ).then( function(){
                SettingsService.setSetting('mopidyconsume',false);
            });
        }else{
            MopidyService.setConsume( true ).then( function(){
                SettingsService.setSetting('mopidyconsume',true);
            });
        }
    };
    $scope.toggleEchonestEnabled = function(){
    	if( $scope.settings.echonestenabled ){
            EchonestService.stop();
        }else{
            EchonestService.start();
        }
    };
	$scope.deleteEchonestTasteProfile = function( confirmed ){
		if( confirmed ){
			$rootScope.$broadcast('spotmop:notifyUser', {
				id: 'delete-echonest-profile',
				message: "Profile deleted and Echonest disabled",<commit_msg>Adding loader for Echonest connect<commit_after>'use strict';

angular.module('spotmop.settings', [
    'ngRoute'
])

/**
 * Every controller start with defining its own routes.
 */
.config(function($routeProvider) {
    $routeProvider.when("/settings", {
        templateUrl: "app/settings/template.html",
        controller: "SettingsController"
    });
})
	
.controller('SettingsController', function SettingsController( $scope, $rootScope, $timeout, MopidyService, SpotifyService, EchonestService, SettingsService ){
	
	// load our current settings into the template
	$scope.version;
	$scope.settings = SettingsService.getSettings();
	$scope.currentSubpage = 'mopidy';
	$scope.subpageNavigate = function( subpage ){
		$scope.currentSubpage = subpage;
	};
    $scope.refreshSpotifyToken = function(){
        $rootScope.$broadcast('spotmop:notifyUser', {id: 'refreshtoken', message: "Refreshing token", type: 'loading'});
        $.when(SpotifyService.getNewToken()).then( function(){
            $rootScope.$broadcast('spotmop:notifyUserRemoval', {id: 'refreshtoken'});
        });
    };
    $scope.spotifyLogout = function(){
        SpotifyService.logout();
        $rootScope.$broadcast('spotmop:notifyUser', {id: 'spotify-loggingout', message: "Logging you out", type: 'bad loading'});
        $timeout( function(){ window.location = window.location }, 1000 );
    };
    $scope.toggleMopidyConsume = function(){
    	if( $scope.settings.mopidyconsume ){
            MopidyService.setConsume( false ).then( function(){
                SettingsService.setSetting('mopidyconsume',false);
            });
        }else{
            MopidyService.setConsume( true ).then( function(){
                SettingsService.setSetting('mopidyconsume',true);
            });
        }
    };
    $scope.toggleEchonestEnabled = function(){
    	if( $scope.settings.echonestenabled ){
            EchonestService.stop();
        }else{
			$rootScope.$broadcast('spotmop:notifyUser', {id: 'start-echonest', message: "Connecting to Echonest", type: 'loading'});	
            EchonestService.start();
        }
        $scope.$watch(
            // the value function
            function(scope){
                return scope.echonestOnline
            },
            // and the processor function
            function(newState, oldState){
                if( newState === true )
                    $rootScope.$broadcast('spotmop:notifyUserRemoval', {id: 'start-echonest'});	
            }
        );
    };
	$scope.deleteEchonestTasteProfile = function( confirmed ){
		if( confirmed ){
			$rootScope.$broadcast('spotmop:notifyUser', {
				id: 'delete-echonest-profile',
				message: "Profile deleted and Echonest disabled",
{'fraction_non_alphanumeric': 0.1421859039836568, 'fraction_numerical': 0.001634320735444331, 'mean_word_length': 3.110831234256927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3189174', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1414, 'n_words': 259}