<commit_before>/*
 * Copyright © 2016 <NAME>, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

angular.module(PKG.name + '.feature.tracker')
  .config(function($stateProvider, MYAUTH_ROLE) {

    $stateProvider
      .state('tracker-enable', {
        url: '/enable-tracker',
        parent: 'ns',
        templateUrl: '/assets/features/tracker/templates/tracker-enable.html',
        controller: 'TrackerEnableController',
        controllerAs: 'EnableController',
        data: {
          authorizedRoles: MYAUTH_ROLE.all,
        }
      })
      .state('tracker', {
        url: '/tracker',
        abstract: true,
        parent: 'ns',
        template: '<ui-view/>',
        resolve: {
          rTrackerApp: function (myTrackerApi, $q, $stateParams, $state, UI_CONFIG, myAlertOnValium) {
            let defer = $q.defer();

            let params = {
              namespace: $stateParams.namespace
            };

            myTrackerApi.getTrackerApp(params)
              .$promise
              .then( () => {
                let auditServiceParams = {
                  namespace: $stateParams.namespace,
                  programType: 'services',
                  programId: UI_CONFIG.tracker.programId,
                };

                let auditFlowParams = {
                  namespace: $stateParams.namespace,
                  programType: 'flows',
                  programId: UI_CONFIG.tracker.flowProgramId,
                };

                $q.all([
                  myTrackerApi.trackerProgramStatus(auditServiceParams).$promise,
                  myTrackerApi.trackerProgramStatus(auditFlowParams).$promise
                ]).then( (res) => {
                  let isRunning = true;
                  angular.forEach(res, (program) => {
                    if (program.status !== 'RUNNING') {
                      isRunning = false;
                    }
                  });

                  if (!isRunning) {
                    $state.go('tracker-enable');
                  } else {
                    defer.resolve(true);
                  }
                }, (err) => {
                  myAlertOnValium.show({
                    type: 'danger',
                    content: err.data
                  });
                });<commit_msg>change status check to STOPPED instead of RUNNING<commit_after>/*
 * Copyright © 2016 <NAME>, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

angular.module(PKG.name + '.feature.tracker')
  .config(function($stateProvider, MYAUTH_ROLE) {

    $stateProvider
      .state('tracker-enable', {
        url: '/enable-tracker',
        parent: 'ns',
        templateUrl: '/assets/features/tracker/templates/tracker-enable.html',
        controller: 'TrackerEnableController',
        controllerAs: 'EnableController',
        data: {
          authorizedRoles: MYAUTH_ROLE.all,
        }
      })
      .state('tracker', {
        url: '/tracker',
        abstract: true,
        parent: 'ns',
        template: '<ui-view/>',
        resolve: {
          rTrackerApp: function (myTrackerApi, $q, $stateParams, $state, UI_CONFIG, myAlertOnValium) {
            let defer = $q.defer();

            let params = {
              namespace: $stateParams.namespace
            };

            myTrackerApi.getTrackerApp(params)
              .$promise
              .then( () => {
                let auditServiceParams = {
                  namespace: $stateParams.namespace,
                  programType: 'services',
                  programId: UI_CONFIG.tracker.programId,
                };

                let auditFlowParams = {
                  namespace: $stateParams.namespace,
                  programType: 'flows',
                  programId: UI_CONFIG.tracker.flowProgramId,
                };

                $q.all([
                  myTrackerApi.trackerProgramStatus(auditServiceParams).$promise,
                  myTrackerApi.trackerProgramStatus(auditFlowParams).$promise
                ]).then( (res) => {
                  let isRunning = true;
                  angular.forEach(res, (program) => {
                    if (program.status === 'STOPPED') {
                      isRunning = false;
                    }
                  });

                  if (!isRunning) {
                    $state.go('tracker-enable');
                  } else {
                    defer.resolve(true);
                  }
                }, (err) => {
                  myAlertOnValium.show({
                    type: 'danger',
                    content: err.data
                  });
                });
{'fraction_non_alphanumeric': 0.1050763223287185, 'fraction_numerical': 0.0028399006034788782, 'mean_word_length': 1.5613636363636363, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4109009', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1370, 'n_words': 353}