Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-74273

[docker-swarm] Extract inline script block in org/jenkinsci/plugins/docker/swarm/dashboard/UIPage/index.jelly

XMLWordPrintable

      Problem

      == Inline Script Block
      Line: 64
      ----
      <script>
                      google.charts.load('current', {'packages':['corechart']});
                      google.charts.setOnLoadCallback(drawCharts);
                      function drawCharts() {
                          // restore Array.prototype.entries native behaviour (see JENKINS-49319)
                          Array.prototype.entries = function() {
                              return Object.entries(this).map(([key,value]) => [+key, value])[Symbol.iterator]();
                          }
                          drawCpuChart();
                          drawMemoryChart();
                      }
                      function drawCpuChart() {
                          var data = google.visualization.arrayToDataTable(${dbrd.cpuUsage});
                          var options = {
                              title: 'CPU Usage',
                              width: '100%',
                              legend: { position: 'top', alignment: 'start', maxLines: '4' }
                          };
                          var chart = new
                              google.visualization.PieChart(document.getElementById('cpu-usage-chart'));
                          chart.draw(data, options);
                      }
                      function drawMemoryChart() {
                          var data = google.visualization.arrayToDataTable(${dbrd.memoryUsage});
                          var options = {
                              title: 'Memory Usage',
                              width: '100%',
                              legend: { position: 'top', alignment: 'start', maxLines: '4' }
                          };
                          var chart = new
                              google.visualization.PieChart(document.getElementById('mem-usage-chart'));
                          chart.draw(data, options);
                      }
      
                      window.addEventListener("resize", function(){
                          drawCpuChart();
                          drawMemoryChart();
                      });
                  </script>
      ----
      

      Solution

      https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks

            Unassigned Unassigned
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: