Bladeren bron

[api] Switch to public API for get_config()

Romain Rigaux 4 jaren geleden
bovenliggende
commit
472cf7f27e

+ 0 - 1
desktop/core/src/desktop/js/api/urls.js

@@ -21,7 +21,6 @@ export const DOCUMENTS_API = '/desktop/api2/doc/';
 export const DOCUMENTS_SEARCH_API = '/desktop/api2/docs/';
 export const GET_HUE_CONFIG_API = '/desktop/api2/get_hue_config';
 export const FETCH_CONFIG_API = '/api/get_config/';
-export const FETCH_CONFIG_API_PRIVATE = '/desktop/api2/get_config/';
 export const HDFS_API_PREFIX = '/filebrowser/view=' + encodeURIComponent('/');
 export const ADLS_API_PREFIX = '/filebrowser/view=' + encodeURIComponent('adl:/');
 export const ABFS_API_PREFIX = '/filebrowser/view=' + encodeURIComponent('ABFS://');

+ 1 - 1
desktop/core/src/desktop/js/apps/editor/components/sqlScratchpad/SqlScratchpad.vue

@@ -156,7 +156,7 @@
         }
 
         try {
-          await getConfig(true);
+          await getConfig();
         } catch (err) {
           errorMessage.value = 'Failed loading the Hue config!';
           console.error(err);

+ 3 - 5
desktop/core/src/desktop/js/config/hueConfig.ts

@@ -47,11 +47,10 @@ type ConnectorTest<T extends keyof InterpreterMap> = (connector: InterpreterMap[
 let lastConfigPromise: Promise<HueConfig> | undefined;
 let lastKnownConfig: HueConfig | undefined;
 
-export const refreshConfig = async (viaApi?: boolean): Promise<HueConfig> => {
+export const refreshConfig = async (): Promise<HueConfig> => {
   lastConfigPromise = new Promise<HueConfig>(async (resolve, reject) => {
     try {
-      const url = viaApi ? URLS.FETCH_CONFIG_API : URLS.FETCH_CONFIG_API_PRIVATE;
-      const apiResponse = await post<HueConfig>(url, {}, { silenceErrors: true });
+      const apiResponse = await post<HueConfig>(URLS.FETCH_CONFIG_API, {}, { silenceErrors: true });
       if (apiResponse.status == 0) {
         lastKnownConfig = apiResponse;
         resolve(lastKnownConfig);
@@ -77,8 +76,7 @@ export const refreshConfig = async (viaApi?: boolean): Promise<HueConfig> => {
 
 export const getLastKnownConfig = (): HueConfig | undefined => lastKnownConfig;
 
-export const getConfig = async (viaApi?: boolean): Promise<HueConfig> =>
-  getLastKnownConfig() || refreshConfig(viaApi);
+export const getConfig = async (): Promise<HueConfig> => getLastKnownConfig() || refreshConfig();
 
 const getInterpreters = <T extends keyof InterpreterMap>(appType: T): InterpreterMap[T][] => {
   if (!lastKnownConfig || !lastKnownConfig.app_config) {