|
1 |
| -/* global jQuery, Vue, _, CV, countlyCommon, countlyGlobal, CountlyHelpers, moment, countlyTaskManager, _merge */ |
| 1 | +/* global jQuery, Vue, _, CV, countlyCommon, countlyGlobal, CountlyHelpers, countlyTaskManager, _merge */ |
2 | 2 |
|
3 | 3 | (function(countlyVue, $) {
|
4 | 4 |
|
|
588 | 588 | type: Boolean,
|
589 | 589 | default: true,
|
590 | 590 | required: false
|
| 591 | + }, |
| 592 | + customExportFileName: { |
| 593 | + type: Boolean, |
| 594 | + default: true, |
| 595 | + required: false |
591 | 596 | }
|
592 | 597 | },
|
593 | 598 | data: function() {
|
|
599 | 604 | {'name': '.JSON', value: 'json'},
|
600 | 605 | {'name': '.XLSX', value: 'xlsx'}
|
601 | 606 | ],
|
602 |
| - searchQuery: '' |
| 607 | + searchQuery: '', |
| 608 | + exportFileName: this.getDefaultFileName(), |
603 | 609 | };
|
604 | 610 | },
|
605 | 611 | methods: {
|
|
608 | 614 | type: this.selectedExportType
|
609 | 615 | });
|
610 | 616 | },
|
611 |
| - getDefaultFileName: function(params) { |
612 |
| - var name = "countly"; |
613 |
| - if (params.title) { |
614 |
| - name = params.title.replace(/[\r\n]+/g, ""); |
615 |
| - } |
616 |
| - if (params.timeDependent) { |
617 |
| - //include export range |
618 |
| - name += "_for_" + countlyCommon.getDateRange(); |
| 617 | + getDefaultFileName: function() { |
| 618 | + var siteName = countlyGlobal.countlyTitle; |
| 619 | + var sectionName = ""; |
| 620 | + var selectedMenuItem = this.$store.getters["countlySidebar/getSelectedMenuItem"]; |
| 621 | + if (selectedMenuItem && selectedMenuItem.item && selectedMenuItem.item.title) { |
| 622 | + sectionName = this.i18n(selectedMenuItem.item.title); |
619 | 623 | }
|
620 |
| - else { |
621 |
| - //include export date |
622 |
| - name += "_on_" + moment().format("DD-MMM-YYYY"); |
| 624 | + var appName = ""; |
| 625 | + if (this.$store.getters["countlyCommon/getActiveApp"]) { |
| 626 | + appName = this.$store.getters["countlyCommon/getActiveApp"].name; |
623 | 627 | }
|
624 |
| - return (name.charAt(0).toUpperCase() + name.slice(1).toLowerCase()); |
| 628 | + var date = countlyCommon.getDateRange(); |
| 629 | + |
| 630 | + return siteName + " " + appName + " " + sectionName + " " + date; |
625 | 631 | },
|
626 | 632 | getLocalExportContent: function() {
|
627 | 633 | if (this.exportFormat) {
|
|
630 | 636 | return this.rows;
|
631 | 637 | },
|
632 | 638 | initiateExport: function(params) {
|
633 |
| - |
634 | 639 | var formData = null,
|
635 | 640 | url = null;
|
636 | 641 |
|
|
666 | 671 | type: params.type,
|
667 | 672 | path: path,
|
668 | 673 | prop: "aaData",
|
669 |
| - filename: this.getDefaultFileName(params), |
| 674 | + filename: this.exportFileName, |
670 | 675 | api_key: countlyGlobal.member.api_key
|
671 | 676 | };
|
672 | 677 | }
|
|
675 | 680 | formData = {
|
676 | 681 | type: params.type,
|
677 | 682 | data: JSON.stringify(this.getLocalExportContent()),
|
678 |
| - filename: this.getDefaultFileName(params), |
| 683 | + filename: this.exportFileName, |
679 | 684 | api_key: countlyGlobal.member.api_key
|
680 | 685 | };
|
681 | 686 | }
|
| 687 | + if (!formData.filename) { |
| 688 | + formData.filename = this.exportFileName; |
| 689 | + } |
682 | 690 |
|
683 | 691 | if (formData.url === "/o/export/requestQuery") {
|
684 | 692 | if (Array.isArray(formData.prop)) {
|
|
714 | 722 | }
|
715 | 723 | else {
|
716 | 724 | var form = $('<form method="POST" action="' + url + '">');
|
717 |
| - |
718 | 725 | $.each(formData, function(k, v) {
|
719 | 726 | if (CountlyHelpers.isJSON(v)) {
|
720 | 727 | form.append($('<textarea style="visibility:hidden;position:absolute;display:none;" name="' + k + '">' + v + '</textarea>'));
|
|
0 commit comments