Skip to content

Commit

Permalink
Make it possible to show the export url
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Jun 10, 2018
1 parent e5ed60f commit 233dea2
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 8 deletions.
2 changes: 2 additions & 0 deletions plugins/CoreHome/CoreHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ public function getClientSideTranslationKeys(&$translationKeys)
$translationKeys[] = 'CoreHome_Default';
$translationKeys[] = 'CoreHome_PageOf';
$translationKeys[] = 'CoreHome_FormatMetrics';
$translationKeys[] = 'CoreHome_ShowExportUrl';
$translationKeys[] = 'CoreHome_HideExportUrl';
$translationKeys[] = 'CoreHome_FlattenDataTable';
$translationKeys[] = 'CoreHome_UnFlattenDataTable';
$translationKeys[] = 'CoreHome_ExternalHelp';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

var popoverParamBackup;

scope.processExport = function() {
scope.showUrl = false;

scope.getExportLink = function() {

var dataTable = scope.dataTable;
var format = scope.reportFormat;
Expand Down Expand Up @@ -159,7 +161,12 @@
exportUrlParams.token_auth = piwik.token_auth;
exportUrlParams.filter_limit = limit;

window.open('index.php?' + $httpParamSerializerJQLike(exportUrlParams));
var currentUrl = $location.absUrl();
var urlParts = currentUrl.split('/');
urlParts.pop();
var url = urlParts.join('/');

return url + '/index.php?' + $httpParamSerializerJQLike(exportUrlParams);
};

element.on('click', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@
</div>
</div>

<div class="col l12" ng-show="showUrl">
<textarea readonly>{{ getExportLink() }}</textarea>
</div>

<div class="col l12">
<div piwik-save-button value="{{ 'General_Export'|translate }}" ng-click="processExport()"></div>
<a class="btn" ng-attr-href="{{ getExportLink() }}" target="_new">{{ 'General_Export'|translate }}</a>
<a href="javascript:;" ng-click="showUrl=!showUrl" class="toggle-export-url">
<span ng-show="!showUrl">{{ 'CoreHome_ShowExportUrl'|translate }}</span>
<span ng-show="showUrl">{{ 'CoreHome_HideExportUrl'|translate }}</span>
</a>
</div>

</div>
11 changes: 11 additions & 0 deletions plugins/CoreHome/angularjs/report-export/reportexport.popover.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
}
}

textarea {
word-break: break-all;
padding: 5px;
height: 80px;
}

.toggle-export-url {
font-size: 14px;
margin-left: 20px;
}

.filter_limit {
clear: both;
float: none;
Expand Down
2 changes: 2 additions & 0 deletions plugins/CoreHome/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"ExternalHelp": "Help (opens in new tab)",
"FlattenDataTable": "The report is hierarchical %s Make it flat",
"FormatMetrics": "Format metrics",
"ShowExportUrl": "Show Export URL",
"HideExportUrl": "Hide Export URL",
"HomeShortcut": "Home",
"HowMuchIsPiwikWorth": "How much is Matomo worth to you?",
"IncludeRowsWithLowPopulation": "Rows with low population are hidden %s Show all rows",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions tests/UI/specs/ReportExporting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("ReportExporting", function () {
page.evaluate(function(){
$('[name=filter_limit] input').val(100).trigger('change');
});
page.click('[ng-click="processExport()"]', 100);
page.click('#reportExport a.btn', 100);

unsetWindowOpen(page);

Expand Down Expand Up @@ -84,7 +84,7 @@ describe("ReportExporting", function () {
page.evaluate(function(){
$('[name=filter_limit] input').val(100).trigger('change');
});
page.click('[ng-click="processExport()"]', 100);
page.click('#reportExport a.btn', 100);

unsetWindowOpen(page);

Expand Down Expand Up @@ -120,7 +120,7 @@ describe("ReportExporting", function () {
page.evaluate(function(){
$('[name=filter_limit] input').val(100).trigger('change');
});
page.click('[ng-click="processExport()"]', 100);
page.click('#reportExport a.btn', 100);

unsetWindowOpen(page);

Expand Down

0 comments on commit 233dea2

Please sign in to comment.