<commit_before>'use strict';

import UIROUTER_ANGULARJS from '@uirouter/angularjs';
import * as angular from 'angular';
import _ from 'lodash';

import {
  AccountService,
  ClusterTargetBuilder,
  ConfirmationModalService,
  confirmNotManaged,
  ReactModal,
  SERVER_GROUP_WRITER,
  ServerGroupReader,
  ServerGroupWarningMessageService,
  SETTINGS,
} from '@spinnaker/core';
import { TitusReactInjector } from 'titus/reactShims';

import { TITUS_SERVERGROUP_CONFIGURE_SERVERGROUPCOMMANDBUILDER } from '../configure/ServerGroupCommandBuilder';
import { TitusCloneServerGroupModal } from '../configure/wizard/TitusCloneServerGroupModal';
import { DISRUPTION_BUDGET_DETAILS_SECTION } from './disruptionBudget/DisruptionBudgetSection';
import { TitusResizeServerGroupModal } from './resize/TitusResizeServerGroupModal';
import { TITUS_SERVERGROUP_DETAILS_ROLLBACK_ROLLBACKSERVERGROUP_CONTROLLER } from './rollback/rollbackServerGroup.controller';
import { SCALING_POLICY_MODULE } from './scalingPolicy/scalingPolicy.module';
import { SERVICE_JOB_PROCESSES_DETAILS_SECTION } from './serviceJobProcesses/ServiceJobProcessesSection';
import { TITUS_SECURITY_GROUPS_DETAILS } from './titusSecurityGroups.component';

export const TITUS_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_TITUS_CONTROLLER =
  'spinnaker.serverGroup.details.titus.controller';
export const name = TITUS_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_TITUS_CONTROLLER; // for backwards compatibility
angular
  .module(TITUS_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_TITUS_CONTROLLER, [
    UIROUTER_ANGULARJS,
    TITUS_SERVERGROUP_CONFIGURE_SERVERGROUPCOMMANDBUILDER,
    DISRUPTION_BUDGET_DETAILS_SECTION,
    SERVER_GROUP_WRITER,
    TITUS_SERVERGROUP_DETAILS_ROLLBACK_ROLLBACKSERVERGROUP_CONTROLLER,
    SERVICE_JOB_PROCESSES_DETAILS_SECTION,
    SCALING_POLICY_MODULE,
    TITUS_SECURITY_GROUPS_DETAILS,
  ])
  .controller('titusServerGroupDetailsCtrl', [
    '$scope',
    '$state',
    '$templateCache',
    '$interpolate',
    'app',
    'serverGroup',
    'titusServerGroupCommandBuilder',
    '$uibModal',
    'serverGroupWriter',
    'awsServerGroupTransformer',
    function (
      $scope,
      $state,
      $templateCache,
      $interpolate,
      app,
      serverGroup,
      titusServerGroupCommandBuilder,
      $uibModal,
      serverGroupWriter,
      awsServerGroupTransformer,
    ) {
      const application = app;
      this.application = app;

      $scope.gateUrl = SETTINGS.gateUrl;

      $scope.state = {
        loading: true,
      };

      function extractServerGroupSummary() {
        const summary = _.find(application.serverGroups.data, function (toCheck) {
          return (
            toCheck.name === serverGroup.name &&
            toCheck.account === serverGroup.accountId &&
            toCheck.region === serverGroup.region
          );
        });
        return summary;
      }

      function retrieveServerGroup() {
        const summary = extractServerGroupSummary();
        return ServerGroupReader.getServerGroup(
          application.name,
          serverGroup.accountId,
          serverGroup.region,
          serverGroup.name,
        ).then(function (details) {
          cancelLoader();

          // it's possible the summary was not found because the clusters are still loading
          details.account = serverGroup.accountId;

          AccountService.getAccountDetails(details.account).then((accountDetails) => {
            details.apiEndpoint = _.filter(accountDetails.regions, { name: details.region })[0].endpoint;
          });

          angular.extend(details, summary);

          $scope.serverGroup = details;
          const labels = $scope.serverGroup.labels;
          delete labels['name'];
          delete labels['source'];
          delete labels['spinnakerAccount'];<commit_msg>fix(titus/serverGroup): Remove empty key/pairs from job attributes (#9104)<commit_after>'use strict';

import UIROUTER_ANGULARJS from '@uirouter/angularjs';
import * as angular from 'angular';
import _ from 'lodash';

import {
  AccountService,
  ClusterTargetBuilder,
  ConfirmationModalService,
  confirmNotManaged,
  ReactModal,
  SERVER_GROUP_WRITER,
  ServerGroupReader,
  ServerGroupWarningMessageService,
  SETTINGS,
} from '@spinnaker/core';
import { TitusReactInjector } from 'titus/reactShims';

import { TITUS_SERVERGROUP_CONFIGURE_SERVERGROUPCOMMANDBUILDER } from '../configure/ServerGroupCommandBuilder';
import { TitusCloneServerGroupModal } from '../configure/wizard/TitusCloneServerGroupModal';
import { DISRUPTION_BUDGET_DETAILS_SECTION } from './disruptionBudget/DisruptionBudgetSection';
import { TitusResizeServerGroupModal } from './resize/TitusResizeServerGroupModal';
import { TITUS_SERVERGROUP_DETAILS_ROLLBACK_ROLLBACKSERVERGROUP_CONTROLLER } from './rollback/rollbackServerGroup.controller';
import { SCALING_POLICY_MODULE } from './scalingPolicy/scalingPolicy.module';
import { SERVICE_JOB_PROCESSES_DETAILS_SECTION } from './serviceJobProcesses/ServiceJobProcessesSection';
import { TITUS_SECURITY_GROUPS_DETAILS } from './titusSecurityGroups.component';

export const TITUS_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_TITUS_CONTROLLER =
  'spinnaker.serverGroup.details.titus.controller';
export const name = TITUS_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_TITUS_CONTROLLER; // for backwards compatibility
angular
  .module(TITUS_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_TITUS_CONTROLLER, [
    UIROUTER_ANGULARJS,
    TITUS_SERVERGROUP_CONFIGURE_SERVERGROUPCOMMANDBUILDER,
    DISRUPTION_BUDGET_DETAILS_SECTION,
    SERVER_GROUP_WRITER,
    TITUS_SERVERGROUP_DETAILS_ROLLBACK_ROLLBACKSERVERGROUP_CONTROLLER,
    SERVICE_JOB_PROCESSES_DETAILS_SECTION,
    SCALING_POLICY_MODULE,
    TITUS_SECURITY_GROUPS_DETAILS,
  ])
  .controller('titusServerGroupDetailsCtrl', [
    '$scope',
    '$state',
    '$templateCache',
    '$interpolate',
    'app',
    'serverGroup',
    'titusServerGroupCommandBuilder',
    '$uibModal',
    'serverGroupWriter',
    'awsServerGroupTransformer',
    function (
      $scope,
      $state,
      $templateCache,
      $interpolate,
      app,
      serverGroup,
      titusServerGroupCommandBuilder,
      $uibModal,
      serverGroupWriter,
      awsServerGroupTransformer,
    ) {
      const application = app;
      this.application = app;

      $scope.gateUrl = SETTINGS.gateUrl;

      $scope.state = {
        loading: true,
      };

      function extractServerGroupSummary() {
        const summary = _.find(application.serverGroups.data, function (toCheck) {
          return (
            toCheck.name === serverGroup.name &&
            toCheck.account === serverGroup.accountId &&
            toCheck.region === serverGroup.region
          );
        });
        return summary;
      }

      function retrieveServerGroup() {
        const summary = extractServerGroupSummary();
        return ServerGroupReader.getServerGroup(
          application.name,
          serverGroup.accountId,
          serverGroup.region,
          serverGroup.name,
        ).then(function (details) {
          cancelLoader();

          // it's possible the summary was not found because the clusters are still loading
          details.account = serverGroup.accountId;

          AccountService.getAccountDetails(details.account).then((accountDetails) => {
            details.apiEndpoint = _.filter(accountDetails.regions, { name: details.region })[0].endpoint;
          });

          angular.extend(details, summary);

          $scope.serverGroup = details;
          const labels = $scope.serverGroup.labels;
          delete labels['name'];
          delete labels['source'];
          delete labels['spinnakerAccount'];

          delete labels[''];
{'fraction_non_alphanumeric': 0.0902031836417756, 'fraction_numerical': 0.0007764979940468488, 'mean_word_length': 3.6807995154451847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '684036', 'n_tokens_mistral': 2321, 'n_tokens_neox': 2285, 'n_words': 366}