mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 19:47:54 +00:00
Ui/pricing metrics api hookup (#10196)
* Update language to reflect that current namespace includes all children as well * Update metrics config value to correct ones * Handle 204 no data from activity endpoint * Wrap metrics date inputs in form so it handles keyboard events like Enter * Pass default span and retention months from config * remove stray space
This commit is contained in:
@@ -8,8 +8,10 @@ export default Application.extend({
|
|||||||
const url = this.urlForQuery(null, type);
|
const url = this.urlForQuery(null, type);
|
||||||
// API accepts start and end as query params
|
// API accepts start and end as query params
|
||||||
return this.ajax(url, 'GET', { data: query }).then(resp => {
|
return this.ajax(url, 'GET', { data: query }).then(resp => {
|
||||||
resp.id = resp.request_id;
|
let response = resp || {};
|
||||||
return resp;
|
// if the response is a 204 it has no request id
|
||||||
|
response.id = response.request_id || 'no-data';
|
||||||
|
return response;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
* @param {number} [retentionMonths=24] - setting for the retention months, which informs valid dates to query by
|
* @param {number} [retentionMonths=24] - setting for the retention months, which informs valid dates to query by
|
||||||
*/
|
*/
|
||||||
import { computed } from '@ember/object';
|
import { computed } from '@ember/object';
|
||||||
|
import { inject as service } from '@ember/service';
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import {
|
import {
|
||||||
differenceInSeconds,
|
differenceInSeconds,
|
||||||
@@ -32,6 +33,8 @@ import { parseDateString } from 'vault/helpers/parse-date-string';
|
|||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
|
router: service(),
|
||||||
|
|
||||||
queryStart: null,
|
queryStart: null,
|
||||||
queryEnd: null,
|
queryEnd: null,
|
||||||
resultStart: null,
|
resultStart: null,
|
||||||
@@ -138,4 +141,17 @@ export default Component.extend({
|
|||||||
this.start = format(initialStart, 'MM/YYYY');
|
this.start = format(initialStart, 'MM/YYYY');
|
||||||
this.end = format(initialEnd, 'MM/YYYY');
|
this.end = format(initialEnd, 'MM/YYYY');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
handleQuery() {
|
||||||
|
const start = format(this.startDate, 'MM-YYYY');
|
||||||
|
const end = format(this.endDate, 'MM-YYYY');
|
||||||
|
this.router.transitionTo('vault.cluster.metrics', {
|
||||||
|
queryParams: {
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default ApplicationSerializer.extend({
|
|||||||
id: payload.id,
|
id: payload.id,
|
||||||
data: {
|
data: {
|
||||||
...payload.data,
|
...payload.data,
|
||||||
enabled: payload.data.enabled.includes('enabled') ? 'On' : 'Off',
|
enabled: payload.data.enabled.includes('enable') ? 'On' : 'Off',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return this._super(store, primaryModelClass, normalizedPayload, id, requestType);
|
return this._super(store, primaryModelClass, normalizedPayload, id, requestType);
|
||||||
@@ -20,7 +20,7 @@ export default ApplicationSerializer.extend({
|
|||||||
let json = this._super(...arguments);
|
let json = this._super(...arguments);
|
||||||
if (json.enabled === 'On' || json.enabled === 'Off') {
|
if (json.enabled === 'On' || json.enabled === 'Off') {
|
||||||
const oldEnabled = json.enabled;
|
const oldEnabled = json.enabled;
|
||||||
json.enabled = oldEnabled === 'On' ? 'enabled' : 'disabled';
|
json.enabled = oldEnabled === 'On' ? 'enable' : 'disable';
|
||||||
}
|
}
|
||||||
json.default_report_months = parseInt(json.default_report_months, 10);
|
json.default_report_months = parseInt(json.default_report_months, 10);
|
||||||
json.retention_months = parseInt(json.retention_months, 10);
|
json.retention_months = parseInt(json.retention_months, 10);
|
||||||
|
|||||||
@@ -1,40 +1,37 @@
|
|||||||
<div class="field-body pricing-metrics-date-form">
|
<form onsubmit={{action "handleQuery"}}>
|
||||||
<div class="field is-narrow">
|
<div class="field-body pricing-metrics-date-form">
|
||||||
<label for="start" class="is-label">From</label>
|
<div class="field is-narrow">
|
||||||
<div class="control">
|
<label for="start" class="is-label">From</label>
|
||||||
{{input
|
<div class="control">
|
||||||
type="string"
|
{{input
|
||||||
value=start
|
type="string"
|
||||||
name="start"
|
value=start
|
||||||
class=(concat 'input' (unless startDate ' has-error'))
|
name="start"
|
||||||
autocomplete="off"
|
class=(concat 'input' (unless startDate ' has-error'))
|
||||||
spellcheck="false"
|
autocomplete="off"
|
||||||
data-test-start-input="true"
|
spellcheck="false"
|
||||||
}}
|
data-test-start-input="true"
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="field is-narrow">
|
||||||
<div class="field is-narrow">
|
<label for="end" class="is-label">Through</label>
|
||||||
<label for="end" class="is-label">Through</label>
|
<div class="control">
|
||||||
<div class="control">
|
{{input
|
||||||
{{input
|
type="string"
|
||||||
type="string"
|
value=end
|
||||||
value=end
|
name="end"
|
||||||
name="end"
|
class=(concat 'input' (unless endDate ' has-error'))
|
||||||
class=(concat 'input' (unless endDate ' has-error'))
|
autocomplete="off"
|
||||||
autocomplete="off"
|
spellcheck="false"
|
||||||
spellcheck="false"
|
data-test-end-input="true"
|
||||||
data-test-end-input="true"
|
}}
|
||||||
}}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<button disabled={{error}} type="submit" class="button">Query</button>
|
||||||
</div>
|
</div>
|
||||||
{{#link-to 'vault.cluster.metrics'
|
</form>
|
||||||
(query-params start=(date-format startDate 'MM-YYYY') end=(date-format endDate 'MM-YYYY'))
|
|
||||||
class="button"
|
|
||||||
disabled=error
|
|
||||||
}}
|
|
||||||
Query
|
|
||||||
{{/link-to}}
|
|
||||||
</div>
|
|
||||||
{{#if error}}
|
{{#if error}}
|
||||||
<FormError>{{error}}</FormError>
|
<FormError>{{error}}</FormError>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@@ -57,15 +57,15 @@
|
|||||||
This feature is currently disabled and data is not being collected. {{#link-to 'vault.cluster.metrics.edit'}}Edit the configuration{{/link-to}} to enable tracking again.
|
This feature is currently disabled and data is not being collected. {{#link-to 'vault.cluster.metrics.edit'}}Edit the configuration{{/link-to}} to enable tracking again.
|
||||||
</AlertBanner>
|
</AlertBanner>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<p class="has-bottom-margin-s">The active clients metric contributes to billing. It is collected at the end of each month alongside unique entities and direct active tokens.</p>
|
<p class="has-bottom-margin-s">The active clients metric contributes to billing. It is collected at the end of each month alongside unique entities and direct active tokens. The data below includes the current namespace and all its children.</p>
|
||||||
|
|
||||||
<PricingMetricsDates
|
<PricingMetricsDates
|
||||||
@queryStart={{model.queryStart}}
|
@queryStart={{model.queryStart}}
|
||||||
@queryEnd={{model.queryEnd}}
|
@queryEnd={{model.queryEnd}}
|
||||||
@resultStart={{model.activity.startTime}}
|
@resultStart={{model.activity.startTime}}
|
||||||
@resultEnd={{model.activity.endTime}}
|
@resultEnd={{model.activity.endTime}}
|
||||||
|
@defaultSpan={{model.config.defaultReportMonths}}
|
||||||
|
@retentionMonths={{model.config.retentionMonths}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{{#unless model.activity.total}}
|
{{#unless model.activity.total}}
|
||||||
<EmptyState @title="No data found" @message="No data exists for that query period. Try searching again." />
|
<EmptyState @title="No data found" @message="No data exists for that query period. Try searching again." />
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|||||||
Reference in New Issue
Block a user