This repository has been archived by the owner on Apr 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GH-34) Add report using DevExtreme PivotGrid
- Loading branch information
1 parent
03b52c4
commit 2eec246
Showing
5 changed files
with
158 additions
and
1 deletion.
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
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
146 changes: 146 additions & 0 deletions
146
src/Cake.Issues.Reporting.Generic/Templates/DxPivotGrid.cshtml
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,146 @@ | ||
@model IEnumerable<Cake.Issues.IIssue> | ||
|
||
<!DOCTYPE html> | ||
|
||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Issues Report</title> | ||
|
||
@* DevExtreme dependencies *@ | ||
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.1.0.min.js"></script> | ||
@* DevExtreme themes *@ | ||
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/18.1.3/css/dx.common.css" /> | ||
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/18.1.3/css/dx.light.css" /> | ||
@* DevExtreme library *@ | ||
<script type="text/javascript" src="https://cdn3.devexpress.com/jslib/18.1.3/js/dx.all.js"></script> | ||
</head> | ||
<body class="dx-viewport"> | ||
<h1>Issues Report</h1> | ||
|
||
<div class="container"> | ||
<div id="pivotgrid-chart"></div> | ||
<div id="pivotgrid"></div> | ||
<div id="pivotgrid-popup"></div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
var issues = []; | ||
@foreach (var issue in Model) | ||
{ | ||
@:issues.push({ProviderName: "@issue.ProviderName", ProviderType: "@issue.ProviderType", Priority: "@issue.Priority", PriorityName: "@issue.PriorityName", Project: "@issue.Project", Path: "@if (issue.AffectedFileRelativePath != null) { @issue.AffectedFileRelativePath.GetDirectory() }", File: "@if (issue.AffectedFileRelativePath != null) { @issue.AffectedFileRelativePath.GetFilename() }", Line: "@issue.Line", Rule: "@issue.Rule", RuleUrl: "@issue.RuleUrl", Message: "@issue.Message"}); | ||
} | ||
</script> | ||
<script type="text/javascript"> | ||
$(function(){ | ||
var pivotGridChart = $("#pivotgrid-chart").dxChart({ | ||
commonSeriesSettings: { | ||
type: "bar" | ||
}, | ||
tooltip: { | ||
enabled: true, | ||
customizeTooltip: function(args) { | ||
return { | ||
html: "Total " + args.seriesName + ": " + args.valueText | ||
}; | ||
} | ||
}, | ||
size: { | ||
height: 200 | ||
}, | ||
adaptiveLayout: { | ||
width: 450 | ||
} | ||
}).dxChart("instance"); | ||
var pivotGrid = $("#pivotgrid").dxPivotGrid({ | ||
height: "calc(100% - 200px)", | ||
allowFiltering: true, | ||
fieldPanel: { | ||
showColumnFields: false, | ||
showDataFields: false, | ||
showFilterFields: true, | ||
showRowFields: false, | ||
allowFieldDragging: true, | ||
visible: true | ||
}, | ||
onCellClick: function(e) { | ||
if (e.area == "data") { | ||
var pivotGridDataSource = e.component.getDataSource(), | ||
rowPathLength = e.cell.rowPath.length, | ||
rowPathName = e.cell.rowPath[rowPathLength - 1], | ||
popupTitle = (rowPathName ? rowPathName : "Total") + " issues"; | ||
drillDownDataSource = pivotGridDataSource.createDrillDownDataSource(e.cell); | ||
pivotgridPopup.option("title", popupTitle); | ||
pivotgridPopup.show(); | ||
} | ||
}, | ||
dataSource: { | ||
fields: [ | ||
{ | ||
caption: "Project", | ||
dataField: "Project", | ||
area: "row" | ||
}, | ||
{ | ||
caption: "Path", | ||
dataField: "Path", | ||
area: "row" | ||
}, | ||
{ | ||
caption: "File", | ||
dataField: "File", | ||
area: "row" | ||
}, | ||
{ | ||
caption: "PriorityName", | ||
dataField: "PriorityName", | ||
area: "column" | ||
}, | ||
{ | ||
caption: "Provider", | ||
dataField: "ProviderName", | ||
area: "filter" | ||
}, | ||
{ | ||
caption: "Count", | ||
dataField: "Rule", | ||
area: "data" | ||
} | ||
], | ||
store: issues | ||
} | ||
}).dxPivotGrid("instance"); | ||
pivotGrid.bindChart( | ||
pivotGridChart, { | ||
inverted: true, | ||
dataFieldsDisplayMode: "splitPanes", | ||
alternateDataFields: false | ||
}); | ||
var pivotgridPopup = $("#pivotgrid-popup").dxPopup({ | ||
width: 600, | ||
height: 400, | ||
resizeEnabled: true, | ||
contentTemplate: function(contentElement) { | ||
$("<div />") | ||
.addClass("drill-down") | ||
.dxDataGrid({ | ||
width: "100%", | ||
height: "100%", | ||
columns: ["Project", "Path", "File", "Line", "Rule", "Message"] | ||
}) | ||
.appendTo(contentElement); | ||
}, | ||
onShowing: function() { | ||
$(".drill-down") | ||
.dxDataGrid("instance") | ||
.option("dataSource", drillDownDataSource); | ||
} | ||
}).dxPopup("instance"); | ||
}); | ||
</script> | ||
</body> | ||
</html> |