-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client Count Calendar widget updates (#13777)
* setup * handle current billing period * handle billing period selection * clean up * clean up * turn serializer to class * change to classes * placeholding, handles timezone issues for this.startTime * put in depen * fixing timezone issues for endTime * clean up * move formating on Get to the adapter. Still need to return formating from Get on serializer * fix current billing period * move all inside queryRecord to hit serilaizer * move to serializer * clean up * calendar clean up * clean up * fix styling * small fixes * small fixes Co-authored-by: Claire Bontempo <[email protected]>
- Loading branch information
1 parent
5f5012c
commit 057c67f
Showing
15 changed files
with
203 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,53 @@ | ||
import Application from '../application'; | ||
import { formatRFC3339 } from 'date-fns'; | ||
|
||
export default Application.extend({ | ||
queryRecord(store, type, query) { | ||
let url = `${this.buildURL()}/internal/counters/activity`; | ||
// Query has startTime defined. The API will return the endTime if none is provided. | ||
return this.ajax(url, 'GET', { data: query }).then((resp) => { | ||
let response = resp || {}; | ||
// if the response is a 204 it has no request id (ARG TODO test that it returns a 204) | ||
response.id = response.request_id || 'no-data'; | ||
return response; | ||
}); | ||
}, | ||
// called from components | ||
queryClientActivity(start_time, end_time) { | ||
formatTimeParams(query) { | ||
let { start_time, end_time } = query; | ||
// do not query without start_time. Otherwise returns last year data, which is not reflective of billing data. | ||
if (start_time) { | ||
let url = `${this.buildURL()}/internal/counters/activity`; | ||
let queryParams = {}; | ||
if (!end_time) { | ||
queryParams = { data: { start_time } }; | ||
// check if it's an array, if it is, it's coming from an action like selecting a new startTime or new EndTime | ||
if (Array.isArray(start_time)) { | ||
let startYear = Number(start_time[0]); | ||
let startMonth = Number(start_time[1]); | ||
start_time = formatRFC3339(new Date(startYear, startMonth)); | ||
} | ||
if (end_time) { | ||
if (Array.isArray(end_time)) { | ||
let endYear = Number(end_time[0]); | ||
let endMonth = Number(end_time[1]); | ||
end_time = formatRFC3339(new Date(endYear, endMonth)); | ||
} | ||
|
||
return { start_time, end_time }; | ||
} else { | ||
queryParams = { data: { start_time, end_time } }; | ||
return { start_time }; | ||
} | ||
return this.ajax(url, 'GET', queryParams).then((resp) => { | ||
return resp; | ||
} else { | ||
// did not have a start time, return null through to component. | ||
return null; | ||
} | ||
}, | ||
|
||
// ARG TODO current Month tab is hitting this endpoint. Need to amend so only hit on Monthly history (large payload) | ||
// query comes in as either: {start_time: '2021-03-17T00:00:00Z'} or | ||
// {start_time: Array(2), end_time: Array(2)} | ||
// end_time: (2) ['2022', 0] | ||
// start_time: (2) ['2021', 2] | ||
queryRecord(store, type, query) { | ||
let url = `${this.buildURL()}/internal/counters/activity`; | ||
// check if start and/or end times are in RFC3395 format, if not convert with timezone UTC/zulu. | ||
let queryParams = this.formatTimeParams(query); | ||
if (queryParams) { | ||
return this.ajax(url, 'GET', { data: queryParams }).then((resp) => { | ||
let response = resp || {}; | ||
// if the response is a 204 it has no request id (ARG TODO test that it returns a 204) | ||
response.id = response.request_id || 'no-data'; | ||
return response; | ||
}); | ||
} else { | ||
// did not have a start time, return null through to component. | ||
return null; | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.