<commit_before>/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

/**
 * Pipeline Home module for displaying Pipeline home page content.
 */

angular
  .module('dataCollectorApp.home')
  .config(['$routeProvider', function ($routeProvider) {
    $routeProvider
      .when('/collector/pipeline/:pipelineName', {
        templateUrl: 'app/home/pipelineHome/pipelineHome.tpl.html',
        controller: 'PipelineHomeController',
        resolve: {
          myVar: function(authService) {
            return authService.init();
          }
        },
        data: {
          authorizedRoles: ['admin', 'creator', 'manager', 'guest']
        }
      });
  }])
  .controller('PipelineHomeController', function ($scope, $rootScope, $routeParams, $timeout, api, configuration, _, $q,
                                          $modal, $localStorage, pipelineService, pipelineConstant, visibilityBroadcaster,
                                          $translate, contextHelpService, $location, authService, userRoles, Analytics) {
    var routeParamPipelineName = $routeParams.pipelineName,
      configTimeout,
      configDirty = false,
      configSaveInProgress = false,
      rulesTimeout,
      rulesDirty = false,
      rulesSaveInProgress = false,
      ignoreUpdate = false,
      pipelineMetricsTimer,
      edges = [],
      destroyed = false,
      pageHidden = false,
      isWebSocketSupported,
      webSocketMetricsURL = $rootScope.common.webSocketBaseURL + 'rest/v1/webSocket?type=metrics&pipelineName=' + routeParamPipelineName,
      metricsWebSocket,
      undoLimit = 10,
      archive = [],
      currArchivePos = null,
      archiveOp = false,
      reloadingNew = false,
      retryCountDownTimer,
      infoNameWatchListener,
      pipelineStatusWatchListener,
      metricsWatchListener,
      errorsWatchListener;

    angular.extend($scope, {
      _: _,
      showLoading: true,
      monitorMemoryEnabled: false,
      isPipelineReadOnly: !authService.isAuthorized([userRoles.admin, userRoles.creator]),
      isPipelineRulesReadOnly: !authService.isAuthorized([userRoles.admin, userRoles.creator, userRoles.manager]),
      selectedType: pipelineConstant.PIPELINE,
      loaded: false,
      isPipelineRunning: false,
      pipelines: [],
      sourceExists: false,
      stageLibraries: [],
      pipelineGraphData: {},
      previewMode: false,
      snapshotMode: false,
      hideLibraryPanel: true,
      activeConfigInfo: undefined,
      activeConfigStatus:{
        status: 'STOPPED'
      },
      minimizeDetailPane: false,
      maximizeDetailPane: false,

      /**
       * Add New Pipeline Configuration
       */<commit_msg>SDC-1766. UI does not display stage link endings correctly when the url contains errors<commit_after>/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

/**
 * Pipeline Home module for displaying Pipeline home page content.
 */

angular
  .module('dataCollectorApp.home')
  .config(['$routeProvider', function ($routeProvider) {
    $routeProvider
      .when('/collector/pipeline/:pipelineName', {
        templateUrl: 'app/home/pipelineHome/pipelineHome.tpl.html',
        controller: 'PipelineHomeController',
        resolve: {
          myVar: function(authService) {
            return authService.init();
          }
        },
        data: {
          authorizedRoles: ['admin', 'creator', 'manager', 'guest']
        }
      });
  }])
  .controller('PipelineHomeController', function ($scope, $rootScope, $routeParams, $timeout, api, configuration, _, $q,
                                          $modal, $localStorage, pipelineService, pipelineConstant, visibilityBroadcaster,
                                          $translate, contextHelpService, $location, authService, userRoles, Analytics) {
    var routeParamPipelineName = $routeParams.pipelineName,
      configTimeout,
      configDirty = false,
      configSaveInProgress = false,
      rulesTimeout,
      rulesDirty = false,
      rulesSaveInProgress = false,
      ignoreUpdate = false,
      pipelineMetricsTimer,
      edges = [],
      destroyed = false,
      pageHidden = false,
      isWebSocketSupported,
      webSocketMetricsURL = $rootScope.common.webSocketBaseURL + 'rest/v1/webSocket?type=metrics&pipelineName=' + routeParamPipelineName,
      metricsWebSocket,
      undoLimit = 10,
      archive = [],
      currArchivePos = null,
      archiveOp = false,
      reloadingNew = false,
      retryCountDownTimer,
      infoNameWatchListener,
      pipelineStatusWatchListener,
      metricsWatchListener,
      errorsWatchListener;

    //Remove search parameter if any, search parameter causing canvas arrow issue
    $location.search({});

    angular.extend($scope, {
      _: _,
      showLoading: true,
      monitorMemoryEnabled: false,
      isPipelineReadOnly: !authService.isAuthorized([userRoles.admin, userRoles.creator]),
      isPipelineRulesReadOnly: !authService.isAuthorized([userRoles.admin, userRoles.creator, userRoles.manager]),
      selectedType: pipelineConstant.PIPELINE,
      loaded: false,
      isPipelineRunning: false,
      pipelines: [],
      sourceExists: false,
      stageLibraries: [],
      pipelineGraphData: {},
      previewMode: false,
      snapshotMode: false,
      hideLibraryPanel: true,
      activeConfigInfo: undefined,
      activeConfigStatus:{
        status: 'STOPPED'
      },
      minimizeDetailPane: false,
      maximizeDetailPane: false,

      /**
       * Add New Pipeline Configuration
       */
{'fraction_non_alphanumeric': 0.08999003274953724, 'fraction_numerical': 0.0025630072618539087, 'mean_word_length': 2.893569844789357, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7151817', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1789, 'n_words': 519}