浏览代码

HUE-9239 [frontend] Fix simpleGet reference for the threads and metrics pages

Johan Ahlen 5 年之前
父节点
当前提交
9578cc73e0

+ 2 - 0
desktop/core/src/desktop/js/hue.js

@@ -73,10 +73,12 @@ import sqlStatementsParser from 'parse/sqlStatementsParser'; // In search.ko and
 import HueFileEntry from 'doc/hueFileEntry';
 import HueDocument from 'doc/hueDocument';
 import { REFRESH_CONFIG_EVENT } from 'utils/hueConfig';
+import { simpleGet } from 'api/apiUtils'; // In analytics.mako, metrics.mako, threads.mako
 
 // TODO: Migrate away
 window._ = _;
 window.apiHelper = apiHelper;
+window.simpleGet = simpleGet;
 window.CancellablePromise = CancellablePromise;
 window.contextCatalog = contextCatalog;
 window.d3 = d3;

+ 2 - 3
desktop/core/src/desktop/js/ko/components/assist/ko.assistLangRefPanel.js

@@ -17,11 +17,11 @@
 import $ from 'jquery';
 import * as ko from 'knockout';
 
-import apiHelper from 'api/apiHelper';
 import componentUtils from 'ko/components/componentUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
 import { GET_KNOWN_CONFIG_EVENT, CONFIG_REFRESHED_EVENT } from 'utils/hueConfig';
+import { simpleGet } from 'api/apiUtils';
 
 // prettier-ignore
 const TEMPLATE = `
@@ -109,8 +109,7 @@ class LanguageReferenceTopic {
       return this.loadDeferred.promise();
     }
     this.loading(true);
-    apiHelper
-      .simpleGet(this.index[this.ref])
+    simpleGet(this.index[this.ref])
       .done(doc => {
         this.body(doc.body);
       })

+ 6 - 7
desktop/core/src/desktop/templates/analytics.mako

@@ -36,17 +36,16 @@ else:
   (function () {
     var AnalyticsViewModel = function () {
       var self = this;
-
-      self.apiHelper = window.apiHelper;
-
       self.stats = ko.observableArray();
 
       self.fetchAnalytics = function () {
-        self.apiHelper.simpleGet('/desktop/analytics/api/admin_stats', {}, {successCallback: function (data) {
-          self.stats(data.admin_stats);
-        }});
+        window.simpleGet('/desktop/analytics/api/admin_stats', {}, {
+          successCallback: function (data) {
+            self.stats(data.admin_stats);
+          }
+        });
       };
-    }
+    };
 
     $(document).ready(function () {
       var viewModel = new AnalyticsViewModel();

+ 5 - 4
desktop/core/src/desktop/templates/metrics.mako

@@ -39,7 +39,6 @@ ${ commonheader(_('Metrics'), "about", user, request) | n,unicode }
   (function () {
     var MetricsViewModel = function () {
       var self = this;
-      self.apiHelper = window.apiHelper;
       self.metricsFilter = ko.observable();
       self.metrics = ko.observableArray();
       self.selectedMetric = ko.observable('All');
@@ -76,14 +75,16 @@ ${ commonheader(_('Metrics'), "about", user, request) | n,unicode }
       });
       var successCallback = function (data) {
         self.metrics(data.metric);
-      }
+      };
       self.fetchMetrics = function () {
-        self.apiHelper.simpleGet('/desktop/metrics/', {}, {successCallback: successCallback});
+        window.simpleGet('/desktop/metrics/', {}, {
+          successCallback: successCallback
+        });
       };
       self.isUnusedMetric = function (metricKey) {
         return metricKey.startsWith("auth") || metricKey.startsWith("multiprocessing") || metricKey.startsWith("python.gc");
       }
-    }
+    };
 
     $(document).ready(function () {
       var viewModel = new MetricsViewModel();

+ 4 - 3
desktop/core/src/desktop/templates/threads.mako

@@ -30,12 +30,13 @@ ${ commonheader(_('Threads'), "about", user, request) | n,unicode }
   (function () {
     var ThreadsViewModel = function () {
       var self = this;
-      self.apiHelper = window.apiHelper;
       self.threads = ko.observable();
       self.fetchThreads = function () {
-        self.apiHelper.simpleGet('/desktop/debug/threads', {}, {successCallback: self.threads});
+        window.simpleGet('/desktop/debug/threads', {}, {
+          successCallback: self.threads
+        });
       };
-    }
+    };
     $(document).ready(function () {
       var viewModel = new ThreadsViewModel();
       ko.applyBindings(viewModel, $('#threadsComponents')[0]);