Skip to content

Commit 1967cc0

Browse files
author
Walden Raines
committed
Merge pull request #100 from dtaylor113/cardUpdates
pfCard: added footer action bar and filter, and Fixed #99
2 parents eaba409 + 7fddb54 commit 1967cc0

File tree

13 files changed

+929
-43
lines changed

13 files changed

+929
-43
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ module.exports = function (grunt) {
123123
html5Mode: false,
124124
template: 'grunt-ngdocs-index.tmpl',
125125
styles: ['lib/patternfly/dist/css/patternfly.css', 'lib/patternfly/dist/css/patternfly-additions.css',
126-
'dist/styles/angular-patternfly.css', 'misc/demo.css']
126+
'dist/styles/angular-patternfly.css', 'misc/demo.css', 'misc/pf-docs.css']
127127
},
128128

129129
all: ['src/**/*.js']

dist/angular-patternfly.js

Lines changed: 199 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -227,26 +227,142 @@ angular.module( 'patternfly.card' ).directive('pfAggregateStatusCard', function
227227
* @name patternfly.card.directive:pfCard
228228
* @restrict A
229229
* @element ANY
230-
* @param {headTitle=} Title for the card - required
231-
* @param {subTitle=} Subtitle for the card - optional
232-
* @param {showTopBorder=} Show Top Border, true shows top border, false (default) hides top border - optional
233-
*
230+
* @param {string} headTitle Title for the card
231+
* @param {string=} subTitle Sub-Title for the card
232+
* @param {boolean=} showTopBorder Show/Hide the blue top border. True shows top border, false (default) hides top border
233+
* @param {boolean=} showTitlesSeparator Show/Hide the grey line between the title and sub-title.
234+
* True (default) shows the line, false hides the line
235+
* @param {object=} footer footer configuration properties:<br/>
236+
* <ul style='list-style-type: none'>
237+
* <li>.iconClass - (optional) the icon to show on the bottom left of the footer panel
238+
* <li>.text - (optional) the text to show on the bottom left of the footer panel, to the right of the icon
239+
* <li>.href - (optional) the href link to navigate to when the footer href is clicked
240+
* <li>.callBackFn - (optional) user defined function to call when the footer href is clicked
241+
* </ul>
242+
* *Note: If a href link and a callBackFn are specified, the href link will be called
243+
* @param {object=} filter filter configuration properties:<br/>
244+
* <ul style='list-style-type: none'>
245+
* <li>.filters - drop down items for the filter.
246+
*<pre class=''>
247+
* Ex: 'filters' : [{label:'Last 30 Days', value:'30'},
248+
* {label:'Last 15 Days', value:'15'},
249+
* {label:'Today', value:'today'}]</pre>
250+
* <li>.defaultFilter - integer, 0 based index into the filters array
251+
* <li>.callBackFn - user defined function to call when a filter is selected
252+
* </ul>
234253
* @description
235254
* Directive for easily displaying a card with html content
236255
*
237256
* @example
238-
<example module="patternfly.card">
257+
<example module="demo">
239258
240259
<file name="index.html">
241-
<div pf-card head-title="My Card Title" sub-title="My card subtitle">
242-
<button>Click Me</button>
243-
</div>
260+
<div ng-controller="ChartCtrl">
261+
<div pf-card head-title="Card Title" sub-title="Card Subtitle" filter="filterConfigHeader" style="width: 50%">
262+
[Card Contents] <button>Click Me</button> Timeframe filter in header
263+
</div>
244264
245-
<div pf-card head-title="Card With Top Border" sub-title="My card subtitle" show-top-border="true">
246-
<button>Click Me</button>
247-
</div>
265+
<div pf-card head-title="Card Title" sub-title="Card Subtitle" show-top-border="true"
266+
footer="footerConfig" filter="filterConfig" style="width: 50%">
267+
[Card Contents] <button>Click Me</button> Footer with Link & Timeframe filter
268+
</div>
269+
270+
<div pf-card head-title="Performance" sub-title="Last 30 Days" show-top-border="false"
271+
show-titles-separator="false" style="width: 65%" footer="actionBarConfig">
272+
<div pf-trends-chart config="configVirtual" chart-data="dataVirtual"></div>
273+
<div pf-trends-chart config="configPhysical" chart-data="dataPhysical"></div>
274+
<div pf-trends-chart config="configMemory" chart-data="dataMemory"></div>
275+
</div>
276+
</div>
248277
</file>
278+
<file name="script.js">
279+
angular.module( 'demo', ['patternfly.charts', 'patternfly.card'] ).controller( 'ChartCtrl', function( $scope ) {
280+
281+
$scope.footerConfig = {
282+
'iconClass' : 'fa fa-flag',
283+
'text' : 'View All Events',
284+
'callBackFn': function () {
285+
alert("Footer Callback Fn Called");
286+
}
287+
}
288+
289+
$scope.filterConfigHeader = {
290+
'filters' : [{label:'Last 30 Days', value:'30'},
291+
{label:'Last 15 Days', value:'15'},
292+
{label:'Today', value:'today'}],
293+
'callBackFn': function (f) {
294+
alert("Header Filter Callback Fn Called for '" + f.label + "' value = " + f.value);
295+
},
296+
'position' : 'header'
297+
}
298+
299+
$scope.filterConfig = {
300+
'filters' : [{label:'Last 30 Days', value:'30'},
301+
{label:'Last 15 Days', value:'15'},
302+
{label:'Today', value:'today'}],
303+
'callBackFn': function (f) {
304+
alert("Filter Callback Fn Called for '" + f.label + "' value = " + f.value);
305+
},
306+
'defaultFilter' : '1'
307+
}
308+
309+
var today = new Date();
310+
var dates = ['dates'];
311+
for (var d = 20 - 1; d >= 0; d--) {
312+
dates.push(new Date(today.getTime() - (d * 24 * 60 * 60 * 1000)));
313+
}
314+
315+
$scope.configVirtual = {
316+
'chartId' : 'virtualTrendsChart',
317+
'layout' : 'inline',
318+
'trendLabel' : 'Virtual Disk I/O',
319+
'units' : 'GB',
320+
'tooltipType' : 'percentage'
321+
};
322+
323+
$scope.dataVirtual = {
324+
'total': '250',
325+
'xData': dates,
326+
'yData': ['used', '90', '20', '30', '20', '20', '10', '14', '20', '25', '68', '44', '56', '78', '56', '67', '88', '76', '65', '87', '76']
327+
};
328+
329+
$scope.configPhysical = {
330+
'chartId' : 'physicalTrendsChart',
331+
'layout' : 'inline',
332+
'trendLabel' : 'Physical Disk I/O',
333+
'units' : 'MHz',
334+
'tooltipType' : 'percentage'
335+
};
336+
337+
$scope.dataPhysical = {
338+
'total': '250',
339+
'xData': dates,
340+
'yData': ['used', '20', '20', '35', '20', '20', '87', '14', '20', '25', '28', '44', '56', '78', '56', '67', '88', '76', '65', '87', '16']
341+
};
342+
343+
$scope.configMemory = {
344+
'chartId' : 'memoryTrendsChart',
345+
'layout' : 'inline',
346+
'trendLabel' : 'Memory Utilization',
347+
'units' : 'GB',
348+
'tooltipType' : 'percentage'
349+
};
249350
351+
$scope.dataMemory = {
352+
'total': '250',
353+
'xData': dates,
354+
'yData': ['used', '20', '20', '35', '70', '20', '87', '14', '95', '25', '28', '44', '56', '66', '16', '67', '88', '76', '65', '87', '56']
355+
};
356+
357+
$scope.actionBarConfig = {
358+
'iconClass' : 'fa fa-plus-circle',
359+
'text' : 'Add New Cluster',
360+
'callBackFn': function () {
361+
alert("Footer Callback Fn Called");
362+
}
363+
}
364+
});
365+
</file>
250366
</example>
251367
*/
252368
angular.module('patternfly.card').directive('pfCard', function () {
@@ -259,8 +375,35 @@ angular.module('patternfly.card').directive('pfCard', function () {
259375
scope: {
260376
headTitle: '@',
261377
subTitle: '@?',
262-
showTopBorder: '@?'
263-
}
378+
showTopBorder: '@?',
379+
showTitlesSeparator: '@?',
380+
footer: '=?',
381+
filter: '=?'
382+
},
383+
controller: ["$scope", function ($scope) {
384+
if ($scope.filter && !$scope.currentFilter) {
385+
if ($scope.filter.defaultFilter) {
386+
$scope.currentFilter = $scope.filter.filters[$scope.filter.defaultFilter];
387+
} else {
388+
$scope.currentFilter = $scope.filter.filters[0];
389+
}
390+
}
391+
392+
$scope.footerCallBackFn = function () {
393+
$scope.footerCallBackResult = $scope.footer.callBackFn();
394+
};
395+
396+
$scope.filterCallBackFn = function (f) {
397+
$scope.currentFilter = f;
398+
if ($scope.filter.callBackFn) {
399+
$scope.filterCallBackResult = $scope.filter.callBackFn(f);
400+
}
401+
};
402+
403+
$scope.showFilterInHeader = function () {
404+
return ($scope.filter && $scope.filter.filters && $scope.filter.position && $scope.filter.position === 'header');
405+
};
406+
}]
264407
};
265408
});
266409

@@ -1201,9 +1344,9 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12011344
* @param {boolean=} showXAxis override sparkline config settings for showing the X Axis
12021345
* @param {boolean=} showYAxis override sparkline config settings for showing the Y Axis
12031346
* @example
1204-
<example module="patternfly.charts">
1347+
<example module="demo">
12051348
<file name="index.html">
1206-
<div ng-controller="ChartCtrl" class="row" style="display:inline-block; width: 100%;">
1349+
<div ng-controller="ChartCtrl" class="row" style="display:inline-block; width: 55%;">
12071350
<div class="col-md-12">
12081351
<div pf-trends-chart config="config" chart-data="data"
12091352
show-x-axis="custShowXAxis" show-y-axis="custShowYAxis"></div>
@@ -1252,10 +1395,17 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12521395
<button ng-click="addDataPoint()">Add Data Point</button>
12531396
</div>
12541397
</div>
1255-
</div>
1398+
<hr class="col-md-12">
1399+
<div class="col-md-12">
1400+
<div pf-card head-title="Cluster Utilization" show-top-border="true"
1401+
footer="footerConfig" filter="filterConfig">
1402+
<div pf-trends-chart config="config2" chart-data="data"></div>
1403+
</div>
1404+
</div>
1405+
</div>
12561406
</file>
12571407
<file name="script.js">
1258-
angular.module( 'patternfly.charts' ).controller( 'ChartCtrl', function( $scope ) {
1408+
angular.module( 'demo', ['patternfly.charts', 'patternfly.card'] ).controller( 'ChartCtrl', function( $scope ) {
12591409
12601410
$scope.config = {
12611411
'chartId' : 'exampleTrendsChart',
@@ -1268,6 +1418,32 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12681418
'tooltipType' : 'percentage'
12691419
};
12701420
1421+
$scope.config2 = {
1422+
'chartId' : 'example2TrendsChart',
1423+
'title' : 'Storage Capacity',
1424+
'layout' : 'compact',
1425+
'valueType' : 'actual',
1426+
'units' : 'TB',
1427+
'tooltipType' : 'percentage'
1428+
};
1429+
1430+
$scope.footerConfig = {
1431+
'iconClass' : 'fa fa-plus-circle',
1432+
'text' : 'Add New Cluster',
1433+
'callBackFn': function () {
1434+
alert("Footer Callback Fn Called");
1435+
}
1436+
}
1437+
1438+
$scope.filterConfig = {
1439+
'filters' : [{label:'Last 30 Days', value:'30'},
1440+
{label:'Last 15 Days', value:'15'},
1441+
{label:'Today', value:'today'}],
1442+
'callBackFn': function (f) {
1443+
alert("Filter Callback Fn Called for '" + f.label + "' value = " + f.value);
1444+
}
1445+
}
1446+
12711447
var today = new Date();
12721448
var dates = ['dates'];
12731449
for (var d = 20 - 1; d >= 0; d--) {
@@ -4493,8 +4669,13 @@ angular.module('patternfly.views').directive('pfDataToolbar',
44934669
);
44944670

44954671

4672+
$templateCache.put('card/basic/card-filter.html',
4673+
"<button type=button class=\"btn btn-default dropdown-toggle\" data-toggle=dropdown aria-haspopup=true aria-expanded=false>{{currentFilter.label}} <span class=caret></span></button><ul class=dropdown-menu><li ng-repeat=\"item in filter.filters\" ng-class=\"{'selected': item === currentFilter}\"><a role=menuitem tabindex=-1 ng-click=filterCallBackFn(item)>{{item.label}}</a></li></ul>"
4674+
);
4675+
4676+
44964677
$templateCache.put('card/basic/card.html',
4497-
"<div ng-class=\"showTopBorder === 'true' ? 'card-pf card-pf-accented' : 'card-pf'\"><div class=card-pf-heading><h2 class=card-pf-title>{{headTitle}}</h2></div><span ng-if=subTitle class=card-pf-subtitle>{{subTitle}}</span><div class=card-pf-body><div ng-transclude></div></div></div>"
4678+
"<div ng-class=\"showTopBorder === 'true' ? 'card-pf card-pf-accented' : 'card-pf'\"><div ng-class=\"!showTitlesSeparator || showTitlesSeparator === 'true' ? 'card-pf-heading' : 'card-pf-heading-no-bottom'\"><div class=card-pf-table><div class=card-pf-cell><h2 class=card-pf-title ng-class=\"{'card-pf-filter-header': showFilterInHeader()}\">{{headTitle}}</h2></div><div class=\"card-pf-cell text-right\" ng-if=showFilterInHeader()><div class=\"dropdown btn-group\"><div ng-include=\"'card/basic/card-filter.html'\"></div></div></div></div></div><span ng-if=subTitle class=card-pf-subtitle>{{subTitle}}</span><div class=card-pf-body><div ng-transclude></div></div><div class=card-pf-footer ng-if=footer><div class=card-pf-table><div class=card-pf-cell><a href={{footer.href}} ng-if=footer.href><span class=\"{{footer.iconClass}} card-pf-footer-text\" ng-if=footer.iconClass></span> <span class=card-pf-footer-text ng-if=footer.text>{{footer.text}}</span></a> <a ng-if=\"footer.callBackFn && !footer.href\" ng-click=footerCallBackFn()><span class=\"{{footer.iconClass}} card-pf-footer-text\" ng-if=footer.iconClass></span> <span class=card-pf-footer-text ng-if=footer.text>{{footer.text}}</span></a> <span ng-if=\"!footer.href && !footer.callBackFn\"><span class=\"{{footer.iconClass}} card-pf-footer-text\" ng-if=footer.iconClass></span> <span class=card-pf-footer-text ng-if=footer.text>{{footer.text}}</span></span></div><div class=\"card-pf-cell text-right\" ng-if=\"filter && filter.filters && (!filter.position || filter.position === 'footer')\"><div class=\"dropdown btn-group\"><div ng-include=\"'card/basic/card-filter.html'\"></div></div></div></div></div></div>"
44984679
);
44994680

45004681
}]);

dist/angular-patternfly.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/styles/angular-patternfly.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@
2626
top: -1px;
2727
}
2828

29+
.card-pf-heading-no-bottom {
30+
margin: 0 -20px 0px;
31+
padding: 0 20px 0;
32+
}
33+
34+
.card-pf-table {
35+
display: table;
36+
width: 100%;
37+
}
38+
39+
.card-pf-cell {
40+
display: table-cell;
41+
}
42+
2943
.donut-chart-pf {
3044
width: 100%;
3145
float: left;
@@ -332,6 +346,7 @@
332346
.trend-flat-details-cell {
333347
display: table-cell;
334348
vertical-align: bottom;
349+
min-width: 70px;
335350
}
336351

337352
.trend-header-compact-pf {

0 commit comments

Comments
 (0)