/*************************************************
 * Copyright (c) 2015 Ansible, Inc.
 *
 * All Rights Reserved
 *************************************************/

   /**
 * @ngdoc function
 * @name helpers.function:Projects
 * @description
 *  Use GetProjectPath({ scope: <scope>, master: <master obj> }) to
 *  load scope.project_local_paths (array of options for drop-down) and
 *  scope.base_dir (readonly field).
 *
 */


export default
    angular.module('ProjectsHelper', ['RestServices', 'Utilities', 'ProjectStatusDefinition', 'ProjectFormDefinition'])

        .factory('GetProjectIcon', [ function() {
            return function(status) {
                var result = '';
                switch (status) {
                    case 'n/a':
                    case 'ok':
                    case 'never updated':
                        result = 'none';
                        break;
                    case 'pending':
                    case 'waiting':
                    case 'new':
                        result = 'none';
                        break;
                    case 'updating':
                    case 'running':
                        result = 'running';
                        break;
                    case 'successful':
                        result = 'success';
                        break;
                    case 'failed':
                    case 'missing':
                    case 'canceled':
                        result = 'error';
                }
                return result;
            };
        }])

        .factory('GetProjectToolTip', [ function() {
            return function(status) {
                var result = '';
                switch (status) {
                    case 'n/a':
                    case 'ok':
                    case 'never updated':
                        result = 'No SCM updates have run for this project';
                        break;
                    case 'pending':
                    case 'waiting':
                    case 'new':
                        result = 'Queued. Click for details';
                        break;
                    case 'updating':
                    case 'running':
                        result = 'Running! Click for details';
                        break;
                    case 'successful':
                        result = 'Success! Click for details';
                        break;
                    case 'failed':
                        result = 'Failed. Click for details';
                        break;
                    case 'missing':
                        result = 'Missing. Click for details';
                        break;
                    case 'canceled':
                        result = 'Canceled. Click for details';
                        break;
                }
                return result;
            };
        }]);
