Просмотр исходного кода

projectsection provisioning select handled

jusrhee 5 лет назад
Родитель
Сommit
44f34914d6

BIN
dashboard/src/assets/135838220_453682579008540_3631330216063463363_n.jpg


BIN
dashboard/src/assets/135843858_160478529194149_2718194807911771299_n.jpg


BIN
dashboard/src/assets/My Health Connection - Appointment Details.pdf


+ 0 - 1
dashboard/src/components/repo-selector/RepoSelector.tsx

@@ -45,7 +45,6 @@ export default class RepoSelector extends Component<PropsType, StateType> {
       if (err) {
         this.setState({ loading: false, error: true });
       } else {
-        console.log(res.data);
         this.setState({ repos: res.data, loading: false, error: false });
       }
     });

+ 9 - 1
dashboard/src/main/home/Home.tsx

@@ -155,6 +155,14 @@ export default class Home extends Component<PropsType, StateType> {
     );
   }
 
+  setCurrentView = (x: string, viewData?: any) => {
+    if (!viewData) {
+      this.setState({ currentView: x });
+    } else {
+      this.setState({ currentView: x, viewData });
+    }
+  }
+
   renderSidebar = () => {
     if (this.context.projects.length > 0) {
 
@@ -167,7 +175,7 @@ export default class Home extends Component<PropsType, StateType> {
         <Sidebar
           forceSidebar={this.state.forceSidebar}
           setWelcome={(x: boolean) => this.setState({ showWelcome: x })}
-          setCurrentView={(x: string) => this.setState({ currentView: x })}
+          setCurrentView={this.setCurrentView}
           currentView={this.state.currentView}
         />
       );

+ 0 - 2
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -438,8 +438,6 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
       this.props.currentChart 
     );
 
-    console.log(this.props.currentChart.name)
-
     api.getIngress('<token>', { 
       cluster_id: currentCluster.id,
     }, {

+ 2 - 3
dashboard/src/main/home/cluster-dashboard/expanded-chart/status/ControllerTab.tsx

@@ -117,13 +117,12 @@ export default class ControllerTab extends Component<PropsType, StateType> {
       >
         {
           this.state.raw.map((pod, i) => {
-            console.log('pod', pod)
-            let status = this.getPodStatus(pod.status)
+            let status = this.getPodStatus(pod.status);
             return (
               <Tab 
                 key={pod.metadata?.name}
                 selected={selectedPod?.metadata?.name === pod?.metadata?.name}
-                onClick={() => {selectPod(pod)}}
+                onClick={() => { selectPod(pod)} }
               > 
                 <Gutter>
                   <Rail />

+ 3 - 16
dashboard/src/main/home/navbar/Feedback.tsx

@@ -1,8 +1,8 @@
 import React, { Component } from 'react';
 import styled from 'styled-components';
 
-import axios from 'axios';
 import { Context } from '../../../shared/Context';
+import { handleSubmitFeedback } from '../../../shared/feedback';
 
 type PropsType = {
   currentView: string,
@@ -37,22 +37,9 @@ export default class Feedback extends Component<PropsType, StateType> {
   handleSubmitFeedback = () => {
     let { user } = this.context;
     let msg = '👤 ' + user.email + ' 📍 ' + this.props.currentView + ': ' + this.state.feedbackText;
-    axios.post('http://35.190.59.124/feedback', {
-      key: 'uzNP7MVYqDC7hs9Q8YP7ehvsBO4yRO02ZGYQ5rKJ2YngEqgYVBITRsvDww8CfV3q',
-      cid: '794372152769642507',
-      message: msg,
-    }, {
-      headers: {
-        Authorization: `Bearer <>`
-      }
-    })
-    .then(res => {
-      console.log('feedback sent');
+    handleSubmitFeedback(msg, () => {
+      this.setState({ feedbackSent: true, feedbackText: '' });
     })
-    .catch(err => {
-      console.log(err);
-    });
-    this.setState({ feedbackSent: true, feedbackText: '' });
   }
 
   renderFeedbackDropdown = () => {

+ 27 - 6
dashboard/src/main/home/sidebar/ProjectSection.tsx

@@ -4,11 +4,11 @@ import gradient from '../../../assets/gradient.jpg';
 
 import api from '../../../shared/api';
 import { Context } from '../../../shared/Context';
-import { ProjectType } from '../../../shared/types';
+import { ProjectType, InfraType } from '../../../shared/types';
 
 type PropsType = {
   currentProject: ProjectType,
-  setCurrentView: (x: string) => void,
+  setCurrentView: (x: string, viewData?: any) => void,
   projects: ProjectType[],
 };
 
@@ -21,16 +21,37 @@ export default class ProjectSection extends Component<PropsType, StateType> {
     expanded: false,
   };
 
+  handleSelectProject = (project: ProjectType) => {
+    this.context.setCurrentProject(project);
+    
+    api.getInfra('<token>', {}, { project_id: project.id }, (err: any, res: any) => {
+      if (err) {
+        console.log(err);
+      } else if (res.data) {
+        let anyProvisioning = false;
+        res.data.forEach((el: InfraType) => {
+          if (el.status === 'creating') {
+            anyProvisioning = true;
+            this.props.setCurrentView('provisioner', {
+              infra_id: el.id,
+              kind: el.kind,
+            });
+          }
+        });
+        if (!anyProvisioning) {
+          this.props.setCurrentView('dashboard');
+        }
+      }
+    });
+  }
+
   renderOptionList = () => {
     return this.props.projects.map((project: ProjectType, i: number) => {
       return (
         <Option
           key={i}
           selected={project.name === this.props.currentProject.name}
-          onClick={() => {
-            this.context.setCurrentProject(project);
-            this.props.setCurrentView('dashboard');
-          }}
+          onClick={() => this.handleSelectProject(project)}
         >
           <ProjectIcon>
             <ProjectImage src={gradient} />

+ 1 - 1
dashboard/src/main/home/sidebar/ProjectSectionContainer.tsx

@@ -5,7 +5,7 @@ import { Context } from '../../../shared/Context';
 import ProjectSection from './ProjectSection';
 
 type PropsType = {
-  setCurrentView: (x: string) => void,
+  setCurrentView: (x: string, viewData?: any) => void,
 };
 
 type StateType = {

+ 1 - 1
dashboard/src/main/home/sidebar/Sidebar.tsx

@@ -13,7 +13,7 @@ import loading from '../../../assets/loading.gif';
 type PropsType = {
   forceSidebar: boolean,
   setWelcome: (x: boolean) => void,
-  setCurrentView: (x: string) => void,
+  setCurrentView: (x: string, viewData?: any) => void,
   currentView: string,
 };
 

+ 19 - 0
dashboard/src/shared/feedback.tsx

@@ -0,0 +1,19 @@
+import axios from 'axios';
+
+export const handleSubmitFeedback = (msg: string, callback?: (err: any, res: any) => void) => {
+  axios.post(process.env.FEEDBACK_ENDPOINT, {
+    key: process.env.DISCORD_KEY,
+    cid: process.env.DISCORD_CID,
+    message: msg,
+  }, {
+    headers: {
+      Authorization: `Bearer <>`
+    }
+  })
+  .then(res => {
+    callback && callback(null, res);
+  })
+  .catch(err => {
+    callback && callback(err, null);
+  });
+}