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

ui: client count card refactor #22349

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions ui/app/components/dashboard/client-count-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import { inject as service } from '@ember/service';
*/

export default class DashboardClientCountCard extends Component {
@tracked currentDate = timestamp.now().toISOString();

@service store;

@tracked activityData = null;
@tracked clientConfig = null;
@tracked updatedAt = timestamp.now().toISOString();

constructor() {
super(...arguments);
Expand All @@ -44,25 +43,17 @@ export default class DashboardClientCountCard extends Component {
return this.args.license.startTime || getStorage().getItem('vault:ui-inputted-start-date') || null;
}

@task
@waitFor
*getActivity(start_time) {
this.currentDate = timestamp.now().toISOString();
// on init ONLY make network request if we have a start_time
return start_time
? yield this.store.queryRecord('clients/activity', {
start_time: { timestamp: start_time },
end_time: { timestamp: this.currentDate },
})
: {};
}

@task
@waitFor
*fetchClientActivity() {
this.updatedAt = timestamp.now().toISOString();
// only make the network request if we have a start_time
if (!this.licenseStartTime) return {};
try {
this.activityData = yield this.getActivity.perform(this.licenseStartTime);
this.updatedAt = timestamp.now().toISOString();
this.activityData = yield this.store.queryRecord('clients/activity', {
start_time: { timestamp: this.licenseStartTime },
end_time: { timestamp: this.updatedAt },
});
this.noActivityData = this.activityData.activity.id === 'no-data' ? true : false;
} catch (error) {
this.error = error;
Expand Down