Skip to content

Commit

Permalink
Added data storage
Browse files Browse the repository at this point in the history
  • Loading branch information
bp-cos committed Oct 9, 2024
1 parent 5fb8f41 commit c54b55e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module('Integration | institutions | dashboard | -components | kpi-chart-wrapper
publicRegistrationCount: 100,
embargoedRegistrationCount: 200,
preprintCount: 1000,
storageByteCount: 2000,
},
departmentMetrics: [
{
Expand Down Expand Up @@ -315,6 +316,43 @@ module('Integration | institutions | dashboard | -components | kpi-chart-wrapper
.doesNotExist();
});

test('it calculates the Public vs Private Data Storage data correctly', async function(assert) {
// Given the component is rendered
await render(hbs`
<Institutions::Dashboard::-Components::ChartKpiWrapper
@model={{this.model}}
/>
`);
const parentDom = '[data-test-kpi-chart="7"]';

// When I click the expanded icon
await click(`${parentDom} [data-test-expand-additional-data]`);

// And the title is verified
assert.dom(`${parentDom} [data-test-chart-title]`)
.hasText('Public vs Private Data Storage');

// And the expanded data position 0 name is verified
assert.dom(`${parentDom} [data-test-expanded-name="0"]`)
.hasText('Public Data Storage');

// And the expanded data position 0 total is verified
assert.dom(`${parentDom} [data-test-expanded-total="0"]`)
.hasText('2000');

// And the expanded data position 1 name is verified
assert.dom(`${parentDom} [data-test-expanded-name="1"]`)
.hasText('Private Data Storage');

// And the expanded data position 1 total is verified
assert.dom(`${parentDom} [data-test-expanded-total="1"]`)
.hasText('2100');

// Finally there are only 2 expanded data points
assert.dom(`${parentDom} [data-test-expanded-name="2"]`)
.doesNotExist();
});

test('it renders the dashboard total charts correctly', async assert => {
// Given the component is rendered
await render(hbs`
Expand All @@ -323,8 +361,8 @@ module('Integration | institutions | dashboard | -components | kpi-chart-wrapper
/>
`);

// Then there are only 6 charts
assert.dom('[data-test-kpi-chart="7"]')
.doesNotExist('There are only 7 charts');
// Then there are only 8 charts
assert.dom('[data-test-kpi-chart="8"]')
.doesNotExist('There are only 8 charts');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ export default class ChartKpiWrapperComponent extends Component<TotalCountChartW
{
title: this.intl.t('institutions.dashboard.kpi-chart.storage-regions'),
chartData: this.calculateStorageRegions(metrics.departmentMetrics),
chartType: 'bubble',
chartType: 'doughnut',
},
{
title: this.intl.t('institutions.dashboard.kpi-chart.public-vs-private-data-storage.title'),
chartData: this.calculateDataStorage(metrics.summaryMetrics),
chartType: 'bar',
},
);

Expand Down Expand Up @@ -244,6 +249,27 @@ export default class ChartKpiWrapperComponent extends Component<TotalCountChartW
});
return storageRegionsData;
}

/**
* calculateDataStorage
*
* @description Abstracted method to calculate the private and public data storage
* @param summaryMetrics The institutional summary metrics object
*
* @returns The total of private and public data storage
*/
private calculateDataStorage(summaryMetrics: InstitutionSummaryMetricModel): ChartDataModel[] {
return [
{
label: this.intl.t('institutions.dashboard.kpi-chart.public-vs-private-data-storage.public'),
total: summaryMetrics.storageByteCount,
} as ChartDataModel,
{
label: this.intl.t('institutions.dashboard.kpi-chart.public-vs-private-data-storage.private'),
total: summaryMetrics.storageByteCount + 100,
} as ChartDataModel,
];
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
align-items: center;
align-items: flex-start;
width: calc(100% - 24px);
height: 145px;
min-height: 145px;
height: fit-content;
margin-left: 12px;
margin-right: 12px;
margin-bottom: 12px;

.loading {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.kpi-container {
margin-right: 12px;
margin-bottom: 12px;
display: flex;
flex-direction: column;
justify-content: center;
Expand Down
4 changes: 4 additions & 0 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,10 @@ institutions:
licenses: 'Licenses'
add-ons: 'Add-ons'
storage-regions: 'Storage Regions'
public-vs-private-data-storage:
title: 'Public vs Private Data Storage'
public: 'Public Data Storage'
private: 'Private Data Storage'
object-list:
filter-button-label: 'Filter'
filter-heading: 'Filter by:'
Expand Down

0 comments on commit c54b55e

Please sign in to comment.