-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from fleetbase/dev-v0.2.10
v0.2.10
- Loading branch information
Showing
22 changed files
with
692 additions
and
593 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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class="storefront-key-metrics" ...attributes> | ||
<div class="flex flex-col"> | ||
<div class="flex flex-row items-center justify-between px-4 py-2 border dark:border-gray-700 border-gray-200 dark:bg-gray-800 bg-gray-50 rounded-lg shadow-sm"> | ||
<span class="text-base font-bold text-black dark:text-gray-100">{{t "storefront.component.widget.key-metrics.title"}}</span> | ||
</div> | ||
|
||
<div class="mt-4"> | ||
{{#if this.getDashboardMetrics.isRunning}} | ||
<Spinner /> | ||
{{else}} | ||
<div class="grid grid-cols-2 lg:grid-cols-12 gap-4"> | ||
{{#each-in this.metrics as |title options|}} | ||
<Dashboard::Count @title={{smart-humanize title}} @options={{options}} /> | ||
{{/each-in}} | ||
</div> | ||
{{/if}} | ||
</div> | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { inject as service } from '@ember/service'; | ||
import { task } from 'ember-concurrency-decorators'; | ||
|
||
export default class WidgetStorefrontKeyMetricsComponent extends Component { | ||
/** | ||
* Inject the fetch service. | ||
* | ||
* @memberof WidgetKeyMetricsComponent | ||
*/ | ||
@service fetch; | ||
|
||
/** | ||
* Property for loading metrics to. | ||
* | ||
* @memberof WidgetKeyMetricsComponent | ||
*/ | ||
@tracked metrics = {}; | ||
|
||
/** | ||
* Creates an instance of WidgetKeyMetricsComponent. | ||
* @memberof WidgetKeyMetricsComponent | ||
*/ | ||
constructor() { | ||
super(...arguments); | ||
this.getDashboardMetrics.perform(); | ||
} | ||
|
||
/** | ||
* Task which fetches key metrics. | ||
* | ||
* @memberof WidgetKeyMetricsComponent | ||
*/ | ||
@task *getDashboardMetrics() { | ||
this.metrics = yield this.fetch.get('metrics', {}, { namespace: 'storefront/int/v1' }).then((response) => { | ||
return this.createMetricsMapFromResponse(response); | ||
}); | ||
} | ||
|
||
/** | ||
* Creates a map of metrics from the response data. This method organizes the metrics data into a more usable format. | ||
* | ||
* @param {Object} metrics - The metrics object fetched from the server. | ||
* @returns {Object} A map of metrics where each key is a metric name and its value is an object of metric options. | ||
* @memberof WidgetKeyMetricsComponent | ||
*/ | ||
createMetricsMapFromResponse(metrics = {}) { | ||
const keys = Object.keys(metrics); | ||
const map = {}; | ||
|
||
for (let i = 0; i < keys.length; i++) { | ||
const key = keys[i]; | ||
map[key] = this.createMetricOptionsHash(key, metrics[key]); | ||
} | ||
|
||
return map; | ||
} | ||
|
||
/** | ||
* Creates a hash of options for a given metric. Depending on the metric key, it assigns a specific format. | ||
* | ||
* @param {string} key - The key representing the specific metric. | ||
* @param {number} value - The value of the metric. | ||
* @returns {Object} An object containing the metric value and its format. | ||
* @memberof WidgetKeyMetricsComponent | ||
*/ | ||
createMetricOptionsHash(key, value) { | ||
const options = { value }; | ||
|
||
return options; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,5 +33,6 @@ | |
</div> | ||
|
||
<div>{{outlet}}</div> | ||
<Spacer @height="300px" /> | ||
</Overlay::Body> | ||
</Overlay> |
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 |
---|---|---|
|
@@ -296,5 +296,6 @@ | |
</ArrayInput> | ||
</div> | ||
</ContentPanel> | ||
<Spacer @height="300px" /> | ||
</Overlay::Body> | ||
</Overlay> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from '@fleetbase/storefront-engine/components/widget/storefront-key-metrics'; |
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.