2
0
Эх сурвалжийг харах

hopefully cluster sorting

Sean Rhee 5 жил өмнө
parent
commit
cc93ff3e6d

+ 3 - 1
dashboard/src/main/home/cluster-dashboard/ClusterDashboard.tsx

@@ -34,7 +34,9 @@ export default class ClusterDashboard extends Component<PropsType, StateType> {
     localStorage.setItem("SortType", this.state.sortType);
     localStorage.setItem("SortType", this.state.sortType);
     // Reset namespace filter and close expanded chart on cluster change
     // Reset namespace filter and close expanded chart on cluster change
     if (prevProps.currentCluster !== this.props.currentCluster) {
     if (prevProps.currentCluster !== this.props.currentCluster) {
-      this.setState({ namespace: 'default', sortType: (localStorage.getItem("SortType") ? localStorage.getItem('SortType') : 'Newest'), currentChart: null });
+      this.setState({ namespace: 'default', sortType: (
+        localStorage.getItem("SortType") ? localStorage.getItem('SortType') : 'Newest'
+      ), currentChart: null });
     }
     }
   }
   }
 
 

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/chart/ChartList.tsx

@@ -59,7 +59,7 @@ export default class ChartList extends Component<PropsType, StateType> {
         } else if (this.props.sortType == "Oldest") {
         } else if (this.props.sortType == "Oldest") {
           charts.sort((a: any, b: any) => (Date.parse(a.info.last_deployed) > Date.parse(b.info.last_deployed)) ? 1 : -1);
           charts.sort((a: any, b: any) => (Date.parse(a.info.last_deployed) > Date.parse(b.info.last_deployed)) ? 1 : -1);
         } else if (this.props.sortType == "Alphabetical") {
         } else if (this.props.sortType == "Alphabetical") {
-          charts.sort((a: any, b: any) => (a.name > b.name) ? 1: -1);
+          charts.sort((a: any, b: any) => (a.name > b.name) ? 1 : -1);
         }
         }
         this.setState({ charts }, () => {
         this.setState({ charts }, () => {
           this.setState({ loading: false, error: false });
           this.setState({ loading: false, error: false });

+ 5 - 1
dashboard/src/main/home/sidebar/ClusterSection.tsx

@@ -53,9 +53,12 @@ export default class ClusterSection extends Component<PropsType, StateType> {
         // TODO: handle uninitialized kubeconfig
         // TODO: handle uninitialized kubeconfig
         if (res.data) {
         if (res.data) {
           let clusters = res.data;
           let clusters = res.data;
+          clusters.sort((a, b) => a - b);
           if (clusters.length > 0) {
           if (clusters.length > 0) {
             this.setState({ clusters });
             this.setState({ clusters });
-            setCurrentCluster(clusters[0]);
+            setCurrentCluster(clusters[(
+              localStorage.getItem('currentCluster') ? localStorage.getItem('currentCluster') : 0
+            )]);
           } else if (this.props.currentView !== 'provisioner') {
           } else if (this.props.currentView !== 'provisioner') {
             this.setState({ clusters: [] });
             this.setState({ clusters: [] });
             setCurrentCluster(null);
             setCurrentCluster(null);
@@ -76,6 +79,7 @@ export default class ClusterSection extends Component<PropsType, StateType> {
 
 
       // Refresh clusters on project change 
       // Refresh clusters on project change 
       if (this.state.prevProjectId !== this.context.currentProject.id) {
       if (this.state.prevProjectId !== this.context.currentProject.id) {
+        localStorage.setItem('currentCluster', this.context.currentProject.id);
         this.updateClusters();
         this.updateClusters();
         this.setState({ prevProjectId: this.context.currentProject.id });
         this.setState({ prevProjectId: this.context.currentProject.id });
       } else if (this.props.forceRefreshClusters === true) {
       } else if (this.props.forceRefreshClusters === true) {