Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ angular.module('EntityService', []).provider('EntityService', function EntitySer
const body = JSON.stringify(entity);
return $http.post(url, body);
}.bind(this);

const exportCsv = function () {
const url = `${this.baseUrl}/export`;
return $http.post(url);
}.bind(this);

const create = function (entity) {
const url = this.baseUrl;
Expand All @@ -86,6 +91,7 @@ angular.module('EntityService', []).provider('EntityService', function EntitySer
create: create,
update: update,
'delete': deleteEntity,
exportCsv: exportCsv,
};
}];
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,24 @@ export class ${name}Repository {

return Query.executeNamed(sql, parameters, this.datasourceName)[0].REPORT_COUNT;
}

public exportCsv() {
const sql = `
#foreach($queryLine in $queryLines)
${queryLine}
#end
`;

const parameters: NamedQueryParameter[] = [];
#foreach($parameter in $parameters)
parameters.push({
name: `${parameter.name}`,
type: `${parameter.type}`,
value: filter['${parameter.name}'] !== undefined ? #if($parameter.typeTypescript == 'string' && $parameter.isLikeCondition) `%${dollar}{filter['${parameter.name}']}%`#else filter['${parameter.name}']#end : `${parameter.initial}`
});
#end

return Query.exportCsv(sql, parameters, this.datasourceName, '${name}');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,24 @@ export class ${name}Repository {

return Query.executeNamed(sql, parameters, this.datasourceName)[0].REPORT_COUNT;
}

public exportCsv() {
const sql = `
#foreach($queryLine in $queryLines)
${queryLine}
#end
`;

const parameters: NamedQueryParameter[] = [];
#foreach($parameter in $parameters)
parameters.push({
name: `${parameter.name}`,
type: `${parameter.type}`,
value: filter['${parameter.name}'] !== undefined ? #if($parameter.typeTypescript == 'string' && $parameter.isLikeCondition) `%${dollar}{filter['${parameter.name}']}%`#else filter['${parameter.name}']#end : `${parameter.initial}`
});
#end

return Query.exportCsv(sql, parameters, this.datasourceName, '${name}');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,23 @@ class ${name}Service {
this.handleError(error);
}
}

@Post("/export")
public exportCsv() {
try {
#if($perspectiveRole || $security.roleRead)
this.checkPermissions("read");

#end
#if($isEntityPropertySecurityEnabled)
return this.repository.exportCsv().map(e => this.transformEntity("read", e));
#else
return this.repository.exportCsv();
#end
} catch (error: any) {
this.handleError(error);
}
}

private handleError(error: any) {
if (error.name === "ForbiddenError") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ class ${name}Service {
this.handleError(error);
}
}

@Post("/export")
public exportCsv() {
try {
#if($perspectiveRole || $security.roleRead)
this.checkPermissions("read");

#end
#if($isEntityPropertySecurityEnabled)
return this.repository.exportCsv().map(e => this.transformEntity("read", e));
#else
return this.repository.exportCsv();
#end
} catch (error: any) {
this.handleError(error);
}
}

private handleError(error: any) {
if (error.name === "ForbiddenError") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer
}])
.controller('PageController', (${dollar}scope, EntityService, LocaleService, Extensions) => {
const Dialogs = new DialogHub();
const exportsHub = new ExportsHub();
$scope.dataPage = 1;
$scope.dataCount = 0;
$scope.dataLimit = 20;

$scope.triggerExportAction = () => {
let request = EntityService.exportCsv();
request.then(() => {
exportsHub.refresh();
});
}

//-----------------Custom Actions-------------------//
Extensions.getWindows(['${projectName}-custom-action']).then((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#if($parameters && $parameters.size() > 0)
<bk-button compact="true" state="transparent" label="{{ '$projectName:${tprefix}.defaults.filter' | t }}" ng-click="openFilter()"></bk-button>
#end
<bk-button compact="true" state="transparent" label="{{'$projectName:${tprefix}.defaults.export' | t}}" ng-click="triggerExportAction()"></bk-button>
<bk-button ng-repeat="action in pageActions track by $index" compact="true" state="transparent" label="{{action.translation.key | t:action.translation.options:action.label}}" ng-click="triggerPageAction(action)"></bk-button>
<bk-toolbar-spacer></bk-toolbar-spacer>
</bk-toolbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"formHeadSelect": "{{name}} Details",
"reportTitle": "{{name}} Report",
"reportFilter": "Report Filter",
"viewDetails": "View Details"
"viewDetails": "View Details",
"export": "Export"
},
"extName": "{{content}}",
"t": {}
Expand Down
Loading