<commit_before>'use strict';

angular
    .module('hawk.pipelinesManagement')
    .controller('PipelinesRunManagement', ['$state','$scope','$stateParams','$interval','pipeStats',
                                            'runManagementService','pipeExecService','pipeConfig','authDataService',
                                            'viewModel','moment','ansi_up','$sce','commonUtitlites',
                                            function ($state, $scope, $stateParams, $interval, pipeStats,
                                                    runManagementService, pipeExecService, pipeConfig,
                                                    authDataService, viewModel, moment, ansi_up, $sce,
                                                    commonUtilities) {
        var vm = this;

        $scope.$on("$destroy", function () {
            if (angular.isDefined($scope.Timer)) {
                $interval.cancel($scope.Timer);
            }
        });
        vm.disabledBtn = false;

        vm.glued = true;
        vm.labels = {
            headers: {
                runManagement: 'Run Management'
            },
            breadCrumb: {
                pipelines: 'Pipelines'
            }
        };

        //Selected jobs from re-run modal.
        vm.selectedJobsForReRun = [];

        vm.lastRunSelected = 1;

        vm.groupName = $stateParams.groupName;
        vm.pipelineName = $state.params.pipelineName;
        vm.pipelineExecutionID = $state.params.executionID;

        vm.defaultHeaders = {
            breadCrumbPipelines: "Pipelines",
            breadCrumbHistory: "Pipeline's history",
            materialsTitle: "Materials",
            commitId: "Commit id: "
        };

        vm.stageDefaultText = {
            run: "Run",
            state: "State",
            start: "Started",
            duration: "Duration",
            trigger: "Trigger",
            stageNotStarted: "Not started yet",
            notAvailable: "Not available",
            of: "of",
            expandHide: "Expand/Colapse"
        };

        //Partials' content begin

        //Re-run stage

        vm.reRunStage = {
            selectAll: "Select all",
            reRun: "Rerun",
            cancel: "Cancel"
        };

        //Run-info

        vm.runInfoDefaultText = {
            scheduled: "Scheduled On: ",
            state: "State: ",
            duration: "Duration: ",
            agent: "Agent: ",
            currentTask: "Current Task: ",
            trigger: "Trigger reason: ",
            tabConsole: "Console",
            tabArtifacts: "Artifacts",
            tabTests: "Tests"
        };

        //Stage

        vm.runsInfoMenu = {
            active: " Active",
            skipped: " Skipped",
            scheduled: " Scheduled",
            inProgress: " In progress",
            completed: " Completed",
            passed: " Passed",
            failed: " Failed"
        };

        //Stage panel

        vm.stagePanelDefault = {
            run: "Run"
        };
        //Partials' content end
        vm.resultIsTheSame = true;

        //Used to determine if this is the first call to the controller
        var isInitial = true,
            firstLoadOfController = true,
            lastResult;

        //Initialization of the controller
        var nameOfStage = '',
            resLength = 0;
        vm.selectedStageIndexInMainDB = 0;

        vm.allPipelineRuns = [];

        vm.currentPipelineRun = [];

        vm.currentPipelineRunStages = [];

        vm.temporaryStages = [];

        vm.allPipelines = [];

        vm.getLastRunAction = function(pipelineRun){
          return moment.getLastRunAction(pipelineRun);
        };

        vm.truncateGitFromUrl = function(repoUrl, commitId) {
          return commonUtilities.truncateGitFromUrl(repoUrl,commitId);
        };

        vm.continueStage = function (stage) {
            stage.isTriggeredManually = false;
            stage.status = 'PAUSED';
            vm.allPipelineRuns.forEach(function (currentPipelineRun, runIndex, runArray) {
                currentPipelineRun.stages.forEach(function (currentStage, stageIndex, stageArray) {
                    if(currentStage.id == stage.id) {
                        currentPipelineRun.status = 'PAUSED';
                        pipeExecService.update(currentPipelineRun);
                    }
                });
            });
        };

        // $scope.$watch(function() { return viewModel.allPipelineRuns }, function(newVal, oldVal) {
        //     vm.allPipelineRuns = viewModel.allPipelineRuns;
        // }, true);

        $scope.$watch(function() { return viewModel.allPipelines}, function (newVal, oldVal) {
            vm.allPipelines = angular.copy(viewModel.allPipelines);
        }, true);

        $scope.$watch(function() { return viewModel.allPipelineRuns }, function(newVal, oldVal) {
            vm.allPipelineRuns = angular.copy(viewModel.allPipelineRuns);
            vm.allPipelineRuns.forEach(function (currentPipelineRun, index, array) {
                if(currentPipelineRun.pipelineDefinitionName == vm.pipelineName && currentPipelineRun.executionId == vm.pipelineExecutionID){
                    vm.currentPipelineRun = currentPipelineRun;<commit_msg>Bug fix in the data the UI sends when Continuing Stage #287<commit_after>'use strict';

angular
    .module('hawk.pipelinesManagement')
    .controller('PipelinesRunManagement', ['$state','$scope','$stateParams','$interval','pipeStats',
                                            'runManagementService','pipeExecService','pipeConfig','authDataService',
                                            'viewModel','moment','ansi_up','$sce','commonUtitlites',
                                            function ($state, $scope, $stateParams, $interval, pipeStats,
                                                    runManagementService, pipeExecService, pipeConfig,
                                                    authDataService, viewModel, moment, ansi_up, $sce,
                                                    commonUtilities) {
        var vm = this;

        $scope.$on("$destroy", function () {
            if (angular.isDefined($scope.Timer)) {
                $interval.cancel($scope.Timer);
            }
        });
        vm.disabledBtn = false;

        vm.glued = true;
        vm.labels = {
            headers: {
                runManagement: 'Run Management'
            },
            breadCrumb: {
                pipelines: 'Pipelines'
            }
        };

        //Selected jobs from re-run modal.
        vm.selectedJobsForReRun = [];

        vm.lastRunSelected = 1;

        vm.groupName = $stateParams.groupName;
        vm.pipelineName = $state.params.pipelineName;
        vm.pipelineExecutionID = $state.params.executionID;

        vm.defaultHeaders = {
            breadCrumbPipelines: "Pipelines",
            breadCrumbHistory: "Pipeline's history",
            materialsTitle: "Materials",
            commitId: "Commit id: "
        };

        vm.stageDefaultText = {
            run: "Run",
            state: "State",
            start: "Started",
            duration: "Duration",
            trigger: "Trigger",
            stageNotStarted: "Not started yet",
            notAvailable: "Not available",
            of: "of",
            expandHide: "Expand/Colapse"
        };

        //Partials' content begin

        //Re-run stage

        vm.reRunStage = {
            selectAll: "Select all",
            reRun: "Rerun",
            cancel: "Cancel"
        };

        //Run-info

        vm.runInfoDefaultText = {
            scheduled: "Scheduled On: ",
            state: "State: ",
            duration: "Duration: ",
            agent: "Agent: ",
            currentTask: "Current Task: ",
            trigger: "Trigger reason: ",
            tabConsole: "Console",
            tabArtifacts: "Artifacts",
            tabTests: "Tests"
        };

        //Stage

        vm.runsInfoMenu = {
            active: " Active",
            skipped: " Skipped",
            scheduled: " Scheduled",
            inProgress: " In progress",
            completed: " Completed",
            passed: " Passed",
            failed: " Failed"
        };

        //Stage panel

        vm.stagePanelDefault = {
            run: "Run"
        };
        //Partials' content end
        vm.resultIsTheSame = true;

        //Used to determine if this is the first call to the controller
        var isInitial = true,
            firstLoadOfController = true,
            lastResult;

        //Initialization of the controller
        var nameOfStage = '',
            resLength = 0;
        vm.selectedStageIndexInMainDB = 0;

        vm.allPipelineRuns = [];

        vm.currentPipelineRun = [];

        vm.currentPipelineRunStages = [];

        vm.temporaryStages = [];

        vm.allPipelines = [];

        vm.getLastRunAction = function(pipelineRun){
          return moment.getLastRunAction(pipelineRun);
        };

        vm.truncateGitFromUrl = function(repoUrl, commitId) {
          return commonUtilities.truncateGitFromUrl(repoUrl,commitId);
        };

        vm.continueStage = function (stage) {
            vm.allPipelineRuns.forEach(function (currentPipelineRun, runIndex, runArray) {
                currentPipelineRun.stages.forEach(function (currentStage, stageIndex, stageArray) {
                    if(currentStage.id == stage.id) {
                        currentStage.isTriggeredManually = false;
                        currentStage.status = 'PAUSED';
                        currentPipelineRun.status = 'IN_PROGRESS';
                        pipeExecService.update(currentPipelineRun);
                    }
                });
            });
        };

        // $scope.$watch(function() { return viewModel.allPipelineRuns }, function(newVal, oldVal) {
        //     vm.allPipelineRuns = viewModel.allPipelineRuns;
        // }, true);

        $scope.$watch(function() { return viewModel.allPipelines}, function (newVal, oldVal) {
            vm.allPipelines = angular.copy(viewModel.allPipelines);
        }, true);

        $scope.$watch(function() { return viewModel.allPipelineRuns }, function(newVal, oldVal) {
            vm.allPipelineRuns = angular.copy(viewModel.allPipelineRuns);
            vm.allPipelineRuns.forEach(function (currentPipelineRun, index, array) {
                if(currentPipelineRun.pipelineDefinitionName == vm.pipelineName && currentPipelineRun.executionId == vm.pipelineExecutionID){
                    vm.currentPipelineRun = currentPipelineRun;
{'fraction_non_alphanumeric': 0.10785694170656153, 'fraction_numerical': 0.0008448324415657561, 'mean_word_length': 1.5998047828208883, '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': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '681714', 'n_tokens_mistral': 2724, 'n_tokens_neox': 2637, 'n_words': 508}