Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix getAppDashboard job in UI #862

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 25 additions & 21 deletions kotsadm/web/src/components/apps/Dashboard.jsx
Original file line number Diff line number Diff line change
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