<commit_before>(function (angular) {
    "use strict";
    angular.module('dashboard.analytics')
        .controller('discoveryResourcesCtrl', ['$scope', '$rootScope', '$state','analyticsServices', 'genericServices','$timeout','toastr','$modal', function ($scope,$rootScope,$state,analyticsServices,genSevs,$timeout,toastr,$modal){
            var disResrc=this;
            $scope.gridApi=null;
            disResrc.filterValue='';
            $scope.colArray=[];
            $scope.instanceType=null;
            $scope.selectInstanceRow=[];
            $scope.TagName={
                environment:[],
                bg:[],
                project:[] ,bgTag:'',
                environmentTag:'',
                projectTag:''
            };
            // get gat name  Start
            disResrc.getAllTagNames=function () {
                $scope.TagName={
                    environment:[],
                    bg:[],
                    project:[],
                    bgTag:'bg',
                    environmentTag:'env',
                    projectTag:'pro'
                };
                // environment
                var param = {
                    url: '/providers/' + fltrObj.provider.id + '/tag-mappings/environment'
                };
                genSevs.promiseGet(param).then(function (instResult) {
                    $scope.TagName.environmentTag=instResult.tagName+'-en';
                    $scope.TagName.envFild='tags.'+instResult.tagName;
                    angular.forEach(instResult.tagValues,function(val){
                        $scope.TagName.environment.push({id:val,name:val})
                    });
                });
                // Bu
                var param = {
                    url: '/providers/' + fltrObj.provider.id + '/tag-mappings/businessGroup'
                };
                genSevs.promiseGet(param).then(function (instResult) {
                    $scope.TagName.bgTag=instResult.tagName+'-bu';
                    $scope.TagName.bgFild='tags.'+instResult.tagName;
                    angular.forEach(instResult.tagValues,function(val){
                        $scope.TagName.bg.push({id:val,name:val})
                    });
                });
                // project
                var param = {
                    url: '/providers/' + fltrObj.provider.id + '/tag-mappings/project'
                };
                genSevs.promiseGet(param).then(function (instResult) {
                    $scope.TagName.projectTag=instResult.tagName+'-pr';
                    $scope.TagName.projFild='tags.'+instResult.tagName;
                    angular.forEach(instResult.tagValues,function(val){
                        $scope.TagName.project.push({id:val,name:val})
                    });

                });

                // get gat name  End##########
            };
            disResrc.init=function () {
                if(fltrObj && fltrObj.provider && fltrObj.provider.id) {
                    disResrc.getAllTagNames();
                    $scope.instLoader=true;
                    $timeout(function () {
                        console.log( $scope.TagName);
                        disResrc.gridOptionInstances = {
                            allowCellFocus : false,
                            paginationPageSizes: [25, 50, 100],
                            paginationPageSize:25,
                            columnDefs: [],
                            onRegisterApi: function (gridApi) {
                                gridApi.grid.registerRowsProcessor( $scope.singleFilter, 200 );
                                $scope.gridApi=gridApi;
                                gridApi.edit.on.afterCellEdit($scope, function (rowEntity, colDefa, newValue, oldValue) {
                                    console.log( colDefa.name,'---',colDefa.name.substring(0, colDefa.name.length-3));
                                    var tagna=colDefa.name.substring(0, colDefa.name.length-3);
                                        var param = {
                                            url: '/providers/' + fltrObj.provider.id + '/unassigned-instances/' + rowEntity._id,
                                            data: {
                                                tags:{}
                                            }
                                        };
                                    param.data.tags[tagna]=newValue;
                                    console.log(param);
                                    if(newValue !== oldValue) {
                                        genSevs.promisePatch(param).then(function () {
                                            toastr.success('Successfully updated.', 'Update');
                                        });
                                    }
                                });
                                gridApi.selection.on.rowSelectionChanged($scope,function(row){
                                    if(row.isSelected){
                                        $scope.selectInstanceRow.push(row.entity._id);
                                    } else {
                                        $scope.selectInstanceRow.splice(row.entity._id,1);
                                    }

                                });<commit_msg>confirm box added for edit tag value<commit_after>(function (angular) {
    "use strict";
    angular.module('dashboard.analytics')
        .controller('discoveryResourcesCtrl', ['$scope', '$rootScope', '$state','analyticsServices', 'genericServices','$timeout','toastr','$modal','confirmbox', function ($scope,$rootScope,$state,analyticsServices,genSevs,$timeout,toastr,$modal,confirmbox){
            var disResrc=this;
            $scope.gridApi=null;
            disResrc.filterValue='';
            $scope.colArray=[];
            $scope.instanceType=null;
            $scope.selectInstanceRow=[];
            $scope.TagName={
                environment:[],
                bg:[],
                project:[] ,bgTag:'',
                environmentTag:'',
                projectTag:''
            };
            // get gat name  Start
            disResrc.getAllTagNames=function () {
                $scope.TagName={
                    environment:[],
                    bg:[],
                    project:[],
                    bgTag:'bg',
                    environmentTag:'env',
                    projectTag:'pro'
                };
                // environment
                var param = {
                    url: '/providers/' + fltrObj.provider.id + '/tag-mappings/environment'
                };
                genSevs.promiseGet(param).then(function (instResult) {
                    $scope.TagName.environmentTag=instResult.tagName+'-en';
                    $scope.TagName.envFild='tags.'+instResult.tagName;
                    angular.forEach(instResult.tagValues,function(val){
                        $scope.TagName.environment.push({id:val,name:val})
                    });
                });
                // Bu
                var param = {
                    url: '/providers/' + fltrObj.provider.id + '/tag-mappings/businessGroup'
                };
                genSevs.promiseGet(param).then(function (instResult) {
                    $scope.TagName.bgTag=instResult.tagName+'-bu';
                    $scope.TagName.bgFild='tags.'+instResult.tagName;
                    angular.forEach(instResult.tagValues,function(val){
                        $scope.TagName.bg.push({id:val,name:val})
                    });
                });
                // project
                var param = {
                    url: '/providers/' + fltrObj.provider.id + '/tag-mappings/project'
                };
                genSevs.promiseGet(param).then(function (instResult) {
                    $scope.TagName.projectTag=instResult.tagName+'-pr';
                    $scope.TagName.projFild='tags.'+instResult.tagName;
                    angular.forEach(instResult.tagValues,function(val){
                        $scope.TagName.project.push({id:val,name:val})
                    });

                });

                // get gat name  End##########
            };
            disResrc.init=function () {
                if(fltrObj && fltrObj.provider && fltrObj.provider.id) {
                    disResrc.getAllTagNames();
                    $scope.instLoader=true;
                    $timeout(function () {
                        console.log( $scope.TagName);
                        disResrc.gridOptionInstances = {
                            allowCellFocus : false,
                            paginationPageSizes: [25, 50, 100],
                            paginationPageSize:25,
                            columnDefs: [],
                            onRegisterApi: function (gridApi) {
                                gridApi.grid.registerRowsProcessor( $scope.singleFilter, 200 );
                                $scope.gridApi=gridApi;
                                gridApi.edit.on.afterCellEdit($scope, function (rowEntity, colDefa, newValue, oldValue) {
                                    console.log(rowEntity);
                                    confirmbox.showModal({}, {
                                        closeButtonText: 'Cancel',
                                        actionButtonText: 'Yes',
                                        actionButtonStyle: 'cat-btn-update',
                                        headerText: 'Update tag value',
                                        bodyText: 'Are you sure you want to Update tag value?'
                                    }).then(function() {
                                        var tagna=colDefa.name.substring(0, colDefa.name.length-3);
                                        var param = {
                                            url: '/providers/' + fltrObj.provider.id + '/unassigned-instances/' + rowEntity._id,
                                            data: {
                                                tags:{}
                                            }
                                        };
                                        param.data.tags[tagna]=newValue;
                                        console.log(param);
                                        if(newValue !== oldValue) {
                                            genSevs.promisePatch(param).then(function () {
                                                toastr.success('Successfully updated.', 'Update');
                                            });
                                        }
                                    },function() {
                                        var param = {
                                            url: '/providers/' + fltrObj.provider.id + '/' + $scope.instanceType
                                            // url:'src/partials/sections/dashboard/analytics/data/ins.json'
                                        };
                                        genSevs.promiseGet(param).then(function (instResult) {
                                            if($rootScope.organNewEnt.instanceType === 'Managed') {
                                                disResrc.gridOptionInstances.data = instResult.managedInstances;
                                            } else if($rootScope.organNewEnt.instanceType === 'Assigned'){
                                                disResrc.gridOptionInstances.data = instResult.unmanagedInstances;
                                            } else if($rootScope.organNewEnt.instanceType === 'Unassigned'){
                                                disResrc.gridOptionInstances.data = instResult.data;
                                            }
                                            disResrc.gridOptionInstances.isRowSelectable = function(row){
                                                if(row.entity.state !== 'running'){
                                                    return false;
                                                } else {
                                                    return true;
                                                }
                                            };
                                        });
                                    });

                                });
                                gridApi.selection.on.rowSelectionChanged($scope,function(row){
                                    if(row.isSelected){
                                        $scope.selectInstanceRow.push(row.entity._id);
                                    } else {
                                        $scope.selectInstanceRow.splice(row.entity._id,1);
                                    }

                                });
{'fraction_non_alphanumeric': 0.10507867269045022, 'fraction_numerical': 0.0024926000934725034, 'mean_word_length': 0.9324202287778447, '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': 101, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7254424', 'n_tokens_mistral': 2817, 'n_tokens_neox': 2659, 'n_words': 339}