Skip to content

Commit

Permalink
fix getAppDashboard job in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh committed Jul 27, 2020
1 parent c7e73d3 commit 6583ebe
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions kotsadm/web/src/components/apps/Dashboard.jsx
Expand Up @@ -56,6 +56,7 @@ class Dashboard extends Component {
showUpdateCheckerModal: false,
appStatus: null,
metrics: [],
getAppDashboardJob: new Repeater(),
}

toggleConfigureGraphs = () => {
Expand Down Expand Up @@ -123,41 +124,44 @@ class Dashboard extends Component {
const { getAppLicense } = this.props.getAppLicense;

this.state.updateChecker.start(this.updateStatus, 1000);
this.state.getAppDashboardJob.start(this.getAppDashboard, 2000);

if (app) {
this.setWatchState(app);
}
if (getAppLicense) {
this.setState({ appLicense: getAppLicense });
}

this.getAppDashboardJob = new Repeater()
this.getAppDashboardJob.start(this.getAppDashboard, 2000);
}

componentWillUnmount() {
this.state.updateChecker.stop();
this.state.getAppDashboardJob.stop();
}

getAppDashboard = async () => {
fetch(`${window.env.API_ENDPOINT}/app/${this.props.app?.slug}/cluster/${this.props.cluster?.id}/dashboard`, {
headers: {
"Authorization": Utilities.getToken(),
"Content-Type": "application/json",
},
method: "GET",
})
.then(async (res) => {
const response = await res.json();
this.setState({
appStatus: response.appStatus,
promValue: response.prometheusAddress,
metrics: response.metrics,
})
getAppDashboard = () => {
return new Promise((resolve, reject) => {
fetch(`${window.env.API_ENDPOINT}/app/${this.props.app?.slug}/cluster/${this.props.cluster?.id}/dashboard`, {
headers: {
"Authorization": Utilities.getToken(),
"Content-Type": "application/json",
},
method: "GET",
})
.catch((err) => {
console.log(err);
});
.then(async (res) => {
const response = await res.json();
this.setState({
appStatus: response.appStatus,
promValue: response.prometheusAddress,
metrics: response.metrics,
});
resolve();
})
.catch((err) => {
console.log(err);
reject(err);
});
});
}

onCheckForUpdates = async () => {
Expand Down

0 comments on commit 6583ebe

Please sign in to comment.