70da9500a1
* adds date picker if no license start date found * handle permissions denied for license endpoint * handle permissions errors if no license start date * change empty state copy for OSS * fix tests and empty state view * update nav links * remove ternary Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> * simplify hbs boolean Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> * organize history file * organize current file * rerun tests * fix conditional to show attribution chart * match main Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
import Application from '../application';
|
|
import { formatRFC3339 } from 'date-fns';
|
|
|
|
export default Application.extend({
|
|
formatTimeParams(query) {
|
|
let { start_time, end_time } = query;
|
|
// 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 {
|
|
return { start_time };
|
|
}
|
|
},
|
|
|
|
// 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 || {};
|
|
response.id = response.request_id || 'no-data';
|
|
return response;
|
|
});
|
|
}
|
|
},
|
|
});
|