<commit_before>'use strict';

angular.module('cloudoptingApp')
    .controller('InstancesController', function (SERVICE, localStorageService,
                                                 $scope, $state, $log, $location, $window, $filter,
                                                 Principal, InstanceService, ProcessService, Blob, FileSaver) {

        $scope.currentPage = 0;
        $scope.pageSize = 8;
        $scope.instancesList = [];
        $scope.searchTextInstance = '';
        $scope.numberOfPages = function(){
            return Math.ceil($scope.dataLength()/$scope.pageSize);
        };
        $scope.dataLength = function(){
            return $filter('filter')($scope.instancesList, $scope.searchTextInstance).length;
        };

        //get only the instances of the current application.
        $scope.currentApp = localStorageService.get(SERVICE.STORAGE.INSTANCES.APPLICATION);

        $scope.instancesList = $scope.currentApp.customizationss;

        angular.forEach($scope.instancesList, function(instance, key) {
            instance.applicationName = $scope.currentApp.applicationName;
        });

        $scope.test = function(instance) {
            var callback = function (data, status, headers, config) {
                if(checkStatusCallback(data, status, headers, config, "Test requested.")) {
                    if(data) {
                        var zip = new Blob([data], {type: 'application/zip'});
                        var fileName = 'TOSCA_Archive_Test.zip';
                        FileSaver.saveAs(zip, fileName);
                    }
                }
            };
            ProcessService.test(instance.id, callback);
        };

        $scope.demo = function(instance) {
            var callback = function (data, status, headers, config) {
                if(checkStatusCallback(data, status, headers, config, "Demo requested.")){
                    //Do something here if all went ok.
                }
            };
            ProcessService.demo(instance.id, callback);
        };

        $scope.deploy = function(instance) {
            var callback = function (data, status, headers, config) {
                if(checkStatusCallback(data, status, headers, config, "Deploy requested.")){
                    localStorageService.set(SERVICE.STORAGE.ACTIVITI.PROCESS_ID, data);
                    $state.go("activiti");
                }
            };
            ProcessService.deploy(instance.id, callback);
        };

        $scope.stop = function(instance) {
            $window.alert('Not implemented yet');
            var callback = function(data, status, headers, config){
                if(checkStatusCallback(data, status, headers, config, "Stop requested.")){
                    //Do something here if all went ok.
                }
            };
            //InstanceService.stop(instance);
        };
        $scope.delete = function(instance) {
            $window.alert('Not implemented yet');
            var callback = function(data, status, headers, config){
                if(checkStatusCallback(data, status, headers, config, "Delete requested.")){
                    //Do something here if all went ok.
                }
            };
            //InstanceService.delete(instance.id, callback);
        };

        $scope.monitor = function(instance) {
            localStorageService.set(SERVICE.STORAGE.MONITORING.INSTANCE, instance);
            $state.go('monitoring');
        };

        $scope.start = function(instance) {
            $window.alert('Not implemented yet');
            var callback = function(data, status, headers, config){
                if(checkStatusCallback(data, status, headers, config, "Start requested.")){
                    //Do something here if all went ok.
                }
            };
            //InstanceService.start(instance);
        };
        //Checks for showing the buttons.
        $scope.showDeploy = function(str){
            return str === "Requested";
        };
        $scope.showStop = function(str){
            return str === "Running";
        };
        $scope.showDelete = function(str){
            return str === "Running";
        };
        $scope.showStart = function(str){
            return str === "Stopped";
        };
        $scope.showMonitor = function(str){
            return str === "Running";
        };
<commit_msg>Not showing monitoring if the state is different from "Running". Fix #254<commit_after>'use strict';

angular.module('cloudoptingApp')
    .controller('InstancesController', function (SERVICE, localStorageService,
                                                 $scope, $state, $log, $location, $window, $filter,
                                                 Principal, InstanceService, ProcessService, Blob, FileSaver) {

        $scope.currentPage = 0;
        $scope.pageSize = 8;
        $scope.instancesList = [];
        $scope.searchTextInstance = '';
        $scope.numberOfPages = function(){
            return Math.ceil($scope.dataLength()/$scope.pageSize);
        };
        $scope.dataLength = function(){
            return $filter('filter')($scope.instancesList, $scope.searchTextInstance).length;
        };

        //get only the instances of the current application.
        $scope.currentApp = localStorageService.get(SERVICE.STORAGE.INSTANCES.APPLICATION);
        $scope.instancesList = $scope.currentApp.customizationss;
        angular.forEach($scope.instancesList, function(instance, key) {
            instance.applicationName = $scope.currentApp.applicationName;
        });

        $scope.test = function(instance) {
            var callback = function (data, status, headers, config) {
                if(checkStatusCallback(data, status, headers, config, "Test requested.")) {
                    if(data) {
                        var zip = new Blob([data], {type: 'application/zip'});
                        var fileName = 'TOSCA_Archive_Test.zip';
                        FileSaver.saveAs(zip, fileName);
                    }
                }
            };
            ProcessService.test(instance.id, callback);
        };

        $scope.demo = function(instance) {
            var callback = function (data, status, headers, config) {
                if(checkStatusCallback(data, status, headers, config, "Demo requested.")){
                    //Do something here if all went ok.
                }
            };
            ProcessService.demo(instance.id, callback);
        };

        $scope.deploy = function(instance) {
            var callback = function (data, status, headers, config) {
                if(checkStatusCallback(data, status, headers, config, "Deploy requested.")){
                    localStorageService.set(SERVICE.STORAGE.ACTIVITI.PROCESS_ID, data);
                    $state.go("activiti");
                }
            };
            ProcessService.deploy(instance.id, callback);
        };

        $scope.stop = function(instance) {
            $scope.errorMessage = "Stop not implemented yet";
            var callback = function(data, status, headers, config){
                if(checkStatusCallback(data, status, headers, config, "Stop requested.")){
                    //Do something here if all went ok.
                }
            };
            //ProcessService.stop(instance);
        };
        $scope.delete = function(instance) {
            $scope.errorMessage = "Delete not implemented yet";
            var callback = function(data, status, headers, config){
                if(checkStatusCallback(data, status, headers, config, "Delete requested.")){
                    //Do something here if all went ok.
                }
            };
            //ProcessService.delete(instance.id, callback);
        };

        $scope.monitor = function(instance) {
            if(instance.statusId.status!="Running") {
                $scope.errorMessage = "Cannot check monitoring, the instance is not running.";
            } else {
                localStorageService.set(SERVICE.STORAGE.MONITORING.INSTANCE, instance);
                $state.go('monitoring');
            }
        };

        $scope.start = function(instance) {
            $scope.errorMessage = "Start not implemented yet";
            var callback = function(data, status, headers, config){
                if(checkStatusCallback(data, status, headers, config, "Start requested.")){
                    //Do something here if all went ok.
                }
            }
            //ProcessService.start(instance);
        };
        //Checks for showing the buttons.
        $scope.showDeploy = function(str){
            return str === "Requested";
        };
        $scope.showStop = function(str){
            return str === "Running";
        };
        $scope.showDelete = function(str){
            return str === "Running";
        };
        $scope.showStart = function(str){
            return str === "Stopped";
        };
        $scope.showMonitor = function(str){
            return str === "Running";
        };

{'fraction_non_alphanumeric': 0.11749203909080927, 'fraction_numerical': 0.0007686395080707148, 'mean_word_length': 1.7253141831238779, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5939951', 'n_tokens_mistral': 2251, 'n_tokens_neox': 2181, 'n_words': 497}