sunguroku 4 jaren geleden
bovenliggende
commit
0ac2355c50

+ 6 - 2
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -420,12 +420,14 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
   };
 
   renderTabContents = (currentTab: string, submitValues?: any) => {
-    let saveButton = <SaveButton
+    let saveButton = (
+      <SaveButton
         text="Rerun Job"
         onClick={() => this.handleSaveValues(submitValues, true)}
         status={this.state.saveValuesStatus}
         makeFlush={true}
       />
+    );
 
     switch (currentTab) {
       case "jobs":
@@ -620,7 +622,9 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
               isInModal={true}
               renderTabContents={this.renderTabContents}
               tabOptionsOnly={true}
-              onSubmit={(formValues) => this.handleSaveValues(formValues, false)}
+              onSubmit={(formValues) =>
+                this.handleSaveValues(formValues, false)
+              }
               saveValuesStatus={this.state.saveValuesStatus}
               saveButtonText="Save Config"
             />

+ 1 - 1
dashboard/src/main/home/launch/launch-flow/LaunchFlow.tsx

@@ -260,7 +260,7 @@ class LaunchFlow extends Component<PropsType, StateType> {
 
     // pause jobs automatically
     if (this.props.currentTemplate?.name == "job") {
-      _.set(values, "paused", true)
+      _.set(values, "paused", true);
     }
 
     var url: string;

+ 35 - 33
dashboard/src/shared/hooks/useWebsockets.ts

@@ -1,4 +1,4 @@
-import { useRef } from "react"
+import { useRef } from "react";
 
 interface NewWebsocketOptions {
   onopen?: () => void;
@@ -12,17 +12,17 @@ interface WebsocketConfig extends NewWebsocketOptions {
 }
 
 type WebsocketConfigMap = {
-  [id: string]: WebsocketConfig
-}
+  [id: string]: WebsocketConfig;
+};
 
 type WebsocketMap = {
-  [id: string]: WebSocket
-}
+  [id: string]: WebSocket;
+};
 
 export const useWebsockets = () => {
   const websocketMap = useRef<WebsocketMap>({});
-  const websocketConfigMap = useRef<WebsocketConfigMap>({})
-  
+  const websocketConfigMap = useRef<WebsocketConfigMap>({});
+
   /**
    * Setup for a new websocket, after calling new websocket you can open the connection with openWebsocket
    * @param id Id to access later the websocket config/connection
@@ -30,50 +30,52 @@ export const useWebsockets = () => {
    * @param options Websocket listeners
    * @returns An object with the config setted for that websocket. This config will be used to open the ws on openWebsocket
    */
-  const newWebsocket = (id: string, apiEndpoint: string, options: NewWebsocketOptions): WebsocketConfig => {
-    
+  const newWebsocket = (
+    id: string,
+    apiEndpoint: string,
+    options: NewWebsocketOptions
+  ): WebsocketConfig => {
     if (!id) {
       console.log("Id cannot be empty");
       return;
     }
 
     if (!apiEndpoint) {
-      console.log("Api endpoint string cannot be empty")
+      console.log("Api endpoint string cannot be empty");
       return;
     }
 
-
     let protocol = window.location.protocol == "https:" ? "wss" : "ws";
 
-    const url = `${protocol}://${window.location.host}${apiEndpoint}`
+    const url = `${protocol}://${window.location.host}${apiEndpoint}`;
+
+    const mockFunction = () => {};
 
-    const mockFunction = () => {}
-    
     const wsConfig: WebsocketConfig = {
       url,
       onopen: options?.onopen || mockFunction,
       onmessage: options?.onmessage || mockFunction,
       onerror: options?.onerror || mockFunction,
       onclose: options?.onclose || mockFunction,
-    }
-    
+    };
+
     websocketConfigMap.current = {
       ...websocketConfigMap.current,
       [id]: wsConfig,
-    }
+    };
     return wsConfig;
-  }
+  };
 
   /**
    * Opens the websocket connection based on a config previously setted by
-   * newWebsocket 
+   * newWebsocket
    */
   const openWebsocket = (id: string) => {
     const wsConfig = websocketConfigMap.current[id];
 
     // Prevent calling openWebsocket before newWebsocket
     if (!wsConfig) {
-      console.log("Couldn't find ws config")
+      console.log("Couldn't find ws config");
       return;
     }
     // In case of having a previous websocket opened with the same ID, close the previous one
@@ -85,14 +87,14 @@ export const useWebsockets = () => {
     const { url, ...listeners } = wsConfig;
 
     const ws = new WebSocket(wsConfig.url);
-    
+
     Object.assign(ws, listeners);
 
     websocketMap.current = {
       ...websocketMap.current,
       [id]: ws,
-    }
-  }
+    };
+  };
 
   /**
    * Close specific websocket
@@ -106,29 +108,29 @@ export const useWebsockets = () => {
     }
 
     ws.close(code, reason);
-  }
+  };
 
-  /** 
+  /**
    * Closes all websockets opened by the useWebsocket hook
-   */ 
+   */
   const closeAllWebsockets = () => {
-    Object.keys(websocketMap.current).forEach(key => {
+    Object.keys(websocketMap.current).forEach((key) => {
       closeWebsocket(key);
-    })
-  }
+    });
+  };
 
   /**
    * Get websocket by id
    */
   const getWebsocket = (id: string) => {
     return websocketMap.current[id];
-  }
+  };
 
   return {
     newWebsocket,
     openWebsocket,
     getWebsocket,
     closeWebsocket,
-    closeAllWebsockets
-  }
-}
+    closeAllWebsockets,
+  };
+};