Create a summary health metrics container and render mock data for graphs

This commit is contained in:
cptran777 2018-08-01 15:35:21 -07:00
parent e58c40ec40
commit fded516db7
9 changed files with 67 additions and 17 deletions

View File

@ -1,5 +1,5 @@
import Component from '@ember/component';
import { get } from '@ember/object';
import { get, set } from '@ember/object';
import { task, TaskInstance } from 'ember-concurrency';
/**
@ -14,6 +14,23 @@ export default class DatasetHealthContainer extends Component {
*/
urn: string;
/**
* Sets the classes for the rendered html element for the component
* @type {Array<string>}
*/
classNames = ['dataset-health'];
/**
* The current filter is used to set a filter for the table to show only items within a certain category or
* severity. It is set as a set of strings in order to support the idea of multiple filters in the future,
* even though our initial version will support only one filter at a time.
* @type {Array<string>}
*/
currentFilters: Set<string>;
constructor() {
super(...arguments);
set(this, 'currentFilters', new Set());
}
didInsertElement() {
get(this, 'getContainerDataTask').perform();
}
@ -31,11 +48,20 @@ export default class DatasetHealthContainer extends Component {
});
actions = {
onFilterSelect(): void {
// Change filter so that table can only show a certain category or severity
/*
* Triggered when the user clicks on one of the bars in the summary charts child component, will trigger
* a filter for whatever bar they select, unless it already is one in which case we will remove the filter
* @param this - Explicit this declaration for typescript
* @param filterName - Passed in to the action by the child component, contains the tag to be filtered for
*/
onFilterSelect(this: DatasetHealthContainer, filterName: string): void {
const currentFilters = get(this, 'currentFilters');
currentFilters.has(filterName) ? currentFilters.delete(filterName) : currentFilters.add(filterName);
}
};
// Mock data for testing demo purposes, to be deleted once we have actual data and further development
testSeries = [{ name: 'Test1', value: 10 }, { name: 'Test2', value: 5 }, { name: 'Test3', value: 3 }];
fakeCategories = [{ name: 'Compliance', value: 60 }, { name: 'Ownership', value: 40 }];
fakeSeverity = [{ name: 'Minor', value: 50 }, { name: 'Warning', value: 30 }, { name: 'Critical', value: 25 }];
}

View File

@ -1,7 +1,9 @@
import Component from '@ember/component';
export default class DatasetsHealthMetricsCharts extends Component.extend({
// anything which *must* be merged to prototype here
}) {
// normal class body definition here
export default class DatasetsHealthMetricsCharts extends Component {
/**
* Sets the classes for the rendered html element for the compoennt
* @type {Array<string>}
*/
classNames = ['dataset-health__metrics-charts'];
}

View File

@ -35,7 +35,7 @@ export default class HorizontalBarChart extends Component {
* Sets the classes for the rendered html element for the component
* @type {Array<string>}
*/
classNames = ['vz-chart', 'viz-bar-chart', 'single-series'];
classNames = ['viz-chart', 'viz-bar-chart', 'single-series'];
/**
* Represents the series of data needed to power our chart. Format is

View File

@ -26,6 +26,7 @@
@import 'dataset-fabric/all';
@import 'dataset-relationships/all';
@import 'visualization/all';
@import 'dataset-health/all';
@import 'nacho/nacho-button';
@import 'nacho/nacho-global-search';

View File

@ -0,0 +1 @@
@import 'metrics-charts';

View File

@ -0,0 +1,11 @@
.dataset-health {
&__metrics-charts {
@include nacho-container;
display: flex;
}
&__chart-container {
width: 100%;
box-sizing: border-box;
padding: 0 16px;
}
}

View File

@ -1,9 +1,5 @@
<h3>Metadata Health</h3>
<div style="width: 50%">
{{visualization/charts/horizontal-bar-chart
title="test Chart"
series=testSeries
labelAppendValue="%"
onBarSelect=(action "onFilterSelect")}}
</div>
{{datasets/health/metrics-charts
categoryData=fakeCategories
severityData=fakeSeverity
onFilterSelect=(action "onFilterSelect")}}

View File

@ -1 +1,14 @@
{{yield}}
<div class="dataset-health__chart-container">
{{visualization/charts/horizontal-bar-chart
title="Categories"
series=categoryData
labelAppendValue="%"
onBarSelect=(action onFilterSelect)}}
</div>
<div class="dataset-health__chart-container">
{{visualization/charts/horizontal-bar-chart
title="Severity"
series=severityData
labelAppendValue="%"
onBarSelect=(action onFilterSelect)}}
</div>