Commit 310928995d104237cf9d11371e1d8f569b9a8a83
1 parent
d71291b8
Exists in
master
Implementação dos recursos de relatórios
Showing
6 changed files
with
65 additions
and
28 deletions
Show diff stats
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/ReportVersionServiceImpl.java
... | ... | @@ -246,6 +246,15 @@ public class ReportVersionServiceImpl extends ResourceVersionServiceImpl impleme |
246 | 246 | return reportVersion; |
247 | 247 | } |
248 | 248 | |
249 | + @Override | |
250 | + public ResourceVersion merge(ResourceVersion resourceVersion) { | |
251 | + if (resourceVersion.getFile() == null) { | |
252 | + ResourceVersion oldResource = this.find(resourceVersion.getId()); | |
253 | + resourceVersion.setFile(oldResource.getFile()); | |
254 | + } | |
255 | + return super.merge(resourceVersion); | |
256 | + } | |
257 | + | |
249 | 258 | private void compile(ReportVersion reportVersion) { |
250 | 259 | if (reportVersion != null && reportVersion.getFile() != null) { |
251 | 260 | if (reportVersion.getEngine().equals(ReportEngineEnum.JASPER)) { | ... | ... |
cit-esi-web/src/main/java/br/com/centralit/controller/ReportController.java
... | ... | @@ -68,10 +68,12 @@ public class ReportController extends ResourceController{ |
68 | 68 | |
69 | 69 | @RequestMapping(value = "/view", method = RequestMethod.GET) |
70 | 70 | public @ResponseBody |
71 | - void view(@RequestParam(value = "path") String path, HttpServletResponse response) { | |
71 | + void view(@RequestParam(value = "path") String path, @RequestParam(value = "delete") boolean delete, HttpServletResponse response) { | |
72 | + String fullPath = servletContext.getRealPath(path); | |
72 | 73 | byte[] buffer = null; |
74 | + | |
73 | 75 | try { |
74 | - FileInputStream is = new FileInputStream(servletContext.getRealPath(path)); | |
76 | + FileInputStream is = new FileInputStream(fullPath); | |
75 | 77 | buffer = new byte[is.available()]; |
76 | 78 | is.read(buffer); |
77 | 79 | is.close(); |
... | ... | @@ -80,7 +82,6 @@ public class ReportController extends ResourceController{ |
80 | 82 | } |
81 | 83 | |
82 | 84 | response.setContentType("application/octet-stream"); |
83 | - | |
84 | 85 | response.setHeader("Content-Disposition", "inline;filename=\"" + path + "\""); |
85 | 86 | |
86 | 87 | try { |
... | ... | @@ -90,7 +91,9 @@ public class ReportController extends ResourceController{ |
90 | 91 | e.printStackTrace(); |
91 | 92 | } |
92 | 93 | |
93 | -// return resp; | |
94 | + if (delete) { | |
95 | + //new File(fullPath).delete(); | |
96 | + } | |
94 | 97 | |
95 | 98 | } |
96 | 99 | ... | ... |
cit-esi-web/src/main/resources/templates/resource_report_controller.js
1 | - $scope.validate = function() { | |
1 | + $scope.reportName = '${formName}'; | |
2 | + | |
3 | + $scope.validate = function() { | |
2 | 4 | return true; |
3 | - } | |
5 | + }; | |
4 | 6 | |
5 | 7 | $scope.beforeSubmit = function() { |
6 | 8 | |
7 | - } | |
8 | - | |
9 | - $scope.onSubmit = function() { | |
9 | + }; | |
10 | 10 | |
11 | - } | |
11 | + $scope.buildParameters = function() { | |
12 | + return {}; | |
13 | + }; | |
12 | 14 | |
13 | 15 | $scope.afterSubmit = function() { |
14 | 16 | |
... | ... | @@ -73,23 +75,35 @@ |
73 | 75 | if ($scope.beforeSubmit) { |
74 | 76 | $scope.beforeSubmit(); |
75 | 77 | } |
76 | - if ($scope.onSubmit) { | |
77 | - $scope.onSubmit(); | |
78 | - } | |
79 | 78 | |
80 | - $scope.setLoading(false); | |
79 | + ReportRepository.execute({name: $scope.reportName}, $scope.buildParameters()).then(function(result) { | |
80 | + $scope.setLoading(false); | |
81 | + | |
82 | + if ($scope.afterSubmit) { | |
83 | + $scope.afterSubmit(); | |
84 | + } | |
81 | 85 | |
82 | - if ($scope.afterSubmit) { | |
83 | - $scope.afterSubmit(); | |
84 | - }else{ | |
85 | - $scope.showAlert("success","ESI.MSG.FORM_EXECUTADO",""); | |
86 | - } | |
87 | - | |
88 | - if ($scope.removeWorkspace) { | |
89 | - $scope.close(); | |
90 | - } | |
86 | + $scope.url = '/cit-esi-web/rest/esi/resource/report/view?path=' + result.originalElement.path+'&delete=true'; | |
87 | + $scope.openModal('view', 'lg'); | |
88 | + | |
89 | + }); | |
90 | + | |
91 | 91 | }; |
92 | 92 | |
93 | + $scope.openModal = function (modalId, size) { | |
94 | + if(modalId === undefined) { | |
95 | + return; | |
96 | + } | |
97 | + | |
98 | + $scope.$modalInstance = $modal.open({ | |
99 | + templateUrl: modalId, | |
100 | + size: size, | |
101 | + windowClass: 'modal-buttons-top modal-no-backdrop mod-green', | |
102 | + backdrop: false, | |
103 | + scope: this | |
104 | + }); | |
105 | + }; | |
106 | + | |
93 | 107 | $scope.close = function() { |
94 | 108 | var workspace = angular.element("#${formName}Edit").scope().workspace; |
95 | 109 | if (workspace) { | ... | ... |
cit-esi-web/src/main/resources/templates/resource_report_html.html
... | ... | @@ -27,4 +27,17 @@ |
27 | 27 | |
28 | 28 | </form> |
29 | 29 | |
30 | -</div><!-- .page-content --> | |
31 | 30 | \ No newline at end of file |
31 | +</div><!-- .page-content --> | |
32 | + | |
33 | +<script type="text/ng-template" id="view"> | |
34 | + <div class="modal-header"> | |
35 | + <button ng-click="$dismiss('cancel');" class="btn btn-clear"> | |
36 | + <i class="fa fa-times red"></i> | |
37 | + <translate>LABEL.FECHAR</translate> | |
38 | + </button> | |
39 | + </div><!-- .modal-header --> | |
40 | + | |
41 | + <div class="modal-body"> | |
42 | + <iframe id="frameView" src="{{url}}" allowfullscreen class="iframe-report" /> | |
43 | + </div><!-- .modal-body --> | |
44 | +</script> | |
32 | 45 | \ No newline at end of file | ... | ... |
cit-esi-web/src/main/webapp/assets/js/angular/custom/controller/ReportController.js
... | ... | @@ -212,9 +212,7 @@ citApp.controller('ReportController', ["$scope", "appService", "ReportRepository |
212 | 212 | if (!$scope.report.formVersion.resource.description || $scope.report.formVersion.resource.description == '') { |
213 | 213 | $scope.report.formVersion.resource.description = $scope.report.resource.description; |
214 | 214 | } |
215 | - if (!$scope.report.formVersion.resource.name || $scope.report.formVersion.resource.name == '') { | |
216 | - $scope.report.formVersion.resource.name = $scope.report.resource.name; | |
217 | - } | |
215 | + $scope.report.formVersion.resource.name = $scope.report.resource.name; | |
218 | 216 | }; |
219 | 217 | |
220 | 218 | var className = "ReportVersion"; | ... | ... |
cit-esi-web/src/main/webapp/html/report/reportEdit.html
... | ... | @@ -241,7 +241,7 @@ |
241 | 241 | <div class="row"> |
242 | 242 | <div class="col-md-4"> |
243 | 243 | <label-input ng-type="text" ng-id="report.formVersion.resource.name" ng-label="ESI.NOME_FORM" ng-obrigatorio="false" |
244 | - ng-disabled="!edit" ng-model="report.formVersion.resource.name" ng-custom-maxlength="100" form="reportForm"/> | |
244 | + ng-disabled="true" ng-model="report.formVersion.resource.name" ng-custom-maxlength="100" form="reportForm"/> | |
245 | 245 | </div> |
246 | 246 | |
247 | 247 | <div class='col-sm-2'> | ... | ... |