<commit_before>'use strict';
/*
 * Controller for the job UI dialog. 
 */
angular.module('hopsWorksApp')
        .controller('JobUICtrl', ['$scope', '$timeout', 'growl', 'JobService', '$interval', 'StorageService',
          '$routeParams', '$route', '$location', 'KibanaService', '$sce',
          function ($scope, $timeout, growl, JobService, $interval, StorageService,
                  $routeParams, $route, $location, KibanaService, $sce) {

            var self = this;
            self.job;
            self.jobtype; //Holds the type of job.
            self.execFile; //Holds the name of the main execution file
            self.showExecutions = false;
            self.projectId = $routeParams.projectID;
            self.jobName = $routeParams.name;
            self.appId = $routeParams.appId;
            self.ui = "";
            self.isLivy = $routeParams.isLivy;
            self.current = "";
            self.loading = false;
            self.loadingText = "";


            var startLoading = function (label) {
              self.loading = true;
              self.loadingText = label;
            };

            var stopLoading = function () {
              self.loading = false;
              self.loadingText = "";
            };

            var getAppId = function (callback) {
              if(self.appId==undefined || self.appId==false || self.appId==""){
                  JobService.getAppId(self.projectId, self.job.id).then(
                          function(success) {
                            self.appId=success.data
                            callback();
                          }, function (error){
                            growl.error(error.data.errorMsg, {title: 'Error fetching ui.', ttl: 15000});
                              stopLoading();
                          });
                }else{
                  callback();
                }
            }
            
            var getJobUI = function () {

              startLoading("Loading Job Details...");
              if(self.jobName!= undefined && self.jobName!= false && self.jobName!=""){
                self.job = StorageService.recover(self.projectId + "_jobui_" + self.jobName);
              }
              if (self.job || self.appId) {
                console.log("Job object found was: ");
                console.log(self.job);
                getAppId(getJobUIInt);
              }
            };

            var getJobUIInt = function(){
              JobService.getExecutionUI(self.projectId, self.appId).then(
                        function (success) {

                          self.ui = success.data;
                          self.current = "jobUI";
                          if (self.ui !== "") {
                            var iframe = document.getElementById('ui_iframe');
                            if (iframe) {
                              iframe.src = $sce.trustAsResourceUrl(self.ui);
                            }
                            $timeout(stopLoading(), 10000);

                          }
                        }, function (error) {
                  growl.error(error.data.errorMsg, {title: 'Error fetching ui.', ttl: 15000});
                  stopLoading();

                });
            }
            
            getJobUI();

            self.yarnUI = function () {

              if (self.job == undefined || self.job == false) {
                if (self.jobName != undefined && self.jobName != false && self.jobName != "") {
                  self.job = StorageService.recover(self.projectId + "_jobui_" + self.jobName);
                }
              }

              startLoading("Loading YARN UI...");
              getAppId(yarnUIInt);

            };

            var yarnUIInt = function () {
              JobService.getYarnUI(self.projectId, self.appId).then(
                      function (success) {

                        self.ui = success.data;
                        self.current = "yarnUI";
                        var iframe = document.getElementById('ui_iframe');
                        if (iframe !== null) {
                          iframe.src = $sce.trustAsResourceUrl(self.ui);
//                          iframe.src = self.ui;
                        }
                        // This timeout is ignored when the iframe is loaded, replacing the overlay
                        $timeout(stopLoading(), 5000);
                      }, function (error) {
                growl.error(error.data.errorMsg, {title: 'Error fetching ui.', ttl: 15000});
                stopLoading();
              });
            }
            
            self.kibanaUI = function () {
              getAppId(kibanaUIInt);
            };

            var kibanaUIInt = function () {
              if (self.job == undefined || self.job == false) {
                JobService.getProjectName(self.projectId).then(
                        function (success) {
                          var projectName = success.data;
                          //if not zeppelin we should have a job
                          self.ui = "/hopsworks-api/kibana/app/kibana#!/discover?_g=(refreshInterval:" +
                                  "(display:Off,pause:!f,value:0),time:(from:now-15m,mode:quick,to:now))" +
                                  "&_a=(columns:!(%27timestamp%27,priority,application,logger_name,thread,message,host),index:" +
                                  projectName.toLowerCase() +
                                  ",interval:auto,query:(query_string:(analyze_wildcard:!t,query:jobname%3D"
                                  + projectName.toLowerCase() + "-zeppelin)),sort:!(%27timestamp%27,desc))";
                          self.current = "kibanaUI";
                          var iframe = document.getElementById('ui_iframe');
                          if (iframe !== null) {
                            iframe.src = $sce.trustAsResourceUrl(self.ui);
                          }
                          $timeout(stopLoading(), 1000);
                        }, function (error) {
                  growl.error(error.data.errorMsg, {title: 'Error fetching project name',
                    ttl: 15000});
                  stopLoading();
                });

              } else {
                self.ui = "/hopsworks-api/kibana/app/kibana#!/discover?_g=(refreshInterval:" +
                        "(display:Off,pause:!f,value:0),time:(from:now-15m,mode:quick,to:now))" +
                        "&_a=(columns:!(%27timestamp%27,priority,application,logger_name,thread,message,host),index:" +
                        self.job.project.name.toLowerCase() +
                        ",interval:auto,query:(query_string:(analyze_wildcard:!t,query:jobname%3D"
                        + self.job.name + ")),sort:!(%27timestamp%27,desc))";
                self.current = "kibanaUI";
                var iframe = document.getElementById('ui_iframe');
                if (iframe !== null) {
                  iframe.src = $sce.trustAsResourceUrl(self.ui);
                }
                $timeout(stopLoading(), 1000);
              }

            }


            self.grafanaUI = function () {<commit_msg>Remove exclamation mark from Kibana url. <commit_after>'use strict';
/*
 * Controller for the job UI dialog. 
 */
angular.module('hopsWorksApp')
        .controller('JobUICtrl', ['$scope', '$timeout', 'growl', 'JobService', '$interval', 'StorageService',
          '$routeParams', '$route', '$location', 'KibanaService', '$sce',
          function ($scope, $timeout, growl, JobService, $interval, StorageService,
                  $routeParams, $route, $location, KibanaService, $sce) {

            var self = this;
            self.job;
            self.jobtype; //Holds the type of job.
            self.execFile; //Holds the name of the main execution file
            self.showExecutions = false;
            self.projectId = $routeParams.projectID;
            self.jobName = $routeParams.name;
            self.appId = $routeParams.appId;
            self.ui = "";
            self.isLivy = $routeParams.isLivy;
            self.current = "";
            self.loading = false;
            self.loadingText = "";


            var startLoading = function (label) {
              self.loading = true;
              self.loadingText = label;
            };

            var stopLoading = function () {
              self.loading = false;
              self.loadingText = "";
            };

            var getAppId = function (callback) {
              if(self.appId==undefined || self.appId==false || self.appId==""){
                  JobService.getAppId(self.projectId, self.job.id).then(
                          function(success) {
                            self.appId=success.data
                            callback();
                          }, function (error){
                            growl.error(error.data.errorMsg, {title: 'Error fetching ui.', ttl: 15000});
                              stopLoading();
                          });
                }else{
                  callback();
                }
            }
            
            var getJobUI = function () {

              startLoading("Loading Job Details...");
              if(self.jobName!= undefined && self.jobName!= false && self.jobName!=""){
                self.job = StorageService.recover(self.projectId + "_jobui_" + self.jobName);
              }
              if (self.job || self.appId) {
                console.log("Job object found was: ");
                console.log(self.job);
                getAppId(getJobUIInt);
              }
            };

            var getJobUIInt = function(){
              JobService.getExecutionUI(self.projectId, self.appId).then(
                        function (success) {

                          self.ui = success.data;
                          self.current = "jobUI";
                          if (self.ui !== "") {
                            var iframe = document.getElementById('ui_iframe');
                            if (iframe) {
                              iframe.src = $sce.trustAsResourceUrl(self.ui);
                            }
                            $timeout(stopLoading(), 10000);

                          }
                        }, function (error) {
                  growl.error(error.data.errorMsg, {title: 'Error fetching ui.', ttl: 15000});
                  stopLoading();

                });
            }
            
            getJobUI();

            self.yarnUI = function () {

              if (self.job == undefined || self.job == false) {
                if (self.jobName != undefined && self.jobName != false && self.jobName != "") {
                  self.job = StorageService.recover(self.projectId + "_jobui_" + self.jobName);
                }
              }

              startLoading("Loading YARN UI...");
              getAppId(yarnUIInt);

            };

            var yarnUIInt = function () {
              JobService.getYarnUI(self.projectId, self.appId).then(
                      function (success) {

                        self.ui = success.data;
                        self.current = "yarnUI";
                        var iframe = document.getElementById('ui_iframe');
                        if (iframe !== null) {
                          iframe.src = $sce.trustAsResourceUrl(self.ui);
//                          iframe.src = self.ui;
                        }
                        // This timeout is ignored when the iframe is loaded, replacing the overlay
                        $timeout(stopLoading(), 5000);
                      }, function (error) {
                growl.error(error.data.errorMsg, {title: 'Error fetching ui.', ttl: 15000});
                stopLoading();
              });
            }
            
            self.kibanaUI = function () {
              getAppId(kibanaUIInt);
            };

            var kibanaUIInt = function () {
              if (self.job == undefined || self.job == false) {
                JobService.getProjectName(self.projectId).then(
                        function (success) {
                          var projectName = success.data;
                          //if not zeppelin we should have a job
                          self.ui = "/hopsworks-api/kibana/app/kibana#/discover?_g=(refreshInterval:" +
                                  "(display:Off,pause:!f,value:0),time:(from:now-15m,mode:quick,to:now))" +
                                  "&_a=(columns:!(%27timestamp%27,priority,application,logger_name,thread,message,host),index:" +
                                  projectName.toLowerCase() +
                                  ",interval:auto,query:(query_string:(analyze_wildcard:!t,query:jobname%3D"
                                  + projectName.toLowerCase() + "-zeppelin)),sort:!(%27timestamp%27,desc))";
                          self.current = "kibanaUI";
                          var iframe = document.getElementById('ui_iframe');
                          if (iframe !== null) {
                            iframe.src = $sce.trustAsResourceUrl(self.ui);
                          }
                          $timeout(stopLoading(), 1000);
                        }, function (error) {
                  growl.error(error.data.errorMsg, {title: 'Error fetching project name',
                    ttl: 15000});
                  stopLoading();
                });

              } else {
                self.ui = "/hopsworks-api/kibana/app/kibana#/discover?_g=(refreshInterval:" +
                        "(display:Off,pause:!f,value:0),time:(from:now-15m,mode:quick,to:now))" +
                        "&_a=(columns:!(%27timestamp%27,priority,application,logger_name,thread,message,host),index:" +
                        self.job.project.name.toLowerCase() +
                        ",interval:auto,query:(query_string:(analyze_wildcard:!t,query:jobname%3D"
                        + self.job.name + ")),sort:!(%27timestamp%27,desc))";
                console.log("kibana ui:"+self.ui);
                self.current = "kibanaUI";
                var iframe = document.getElementById('ui_iframe');
                if (iframe !== null) {
                  iframe.src = $sce.trustAsResourceUrl(self.ui);
                }
                $timeout(stopLoading(), 1000);
              }

            }


            self.grafanaUI = function () {
{'fraction_non_alphanumeric': 0.12239529248875043, 'fraction_numerical': 0.00844582900657667, 'mean_word_length': 1.2417752948479206, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4818933', 'n_tokens_mistral': 3878, 'n_tokens_neox': 3549, 'n_words': 622}