Rev 1930 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1930 | grupo1 | 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
2 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
||
3 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
||
4 | <%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
||
5 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
||
6 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
||
7 | <%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
||
8 | <%@ taglib prefix="t" tagdir="/WEB-INF/tags" %> |
||
9 | |||
10 | <%-- http://localhost:8080/baco/user/editCourseReport.do?courseCode=44&year=201617 --%> |
||
11 | |||
12 | <link rel="stylesheet" href="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.css"> |
||
13 | <script src="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.min.js"></script> |
||
14 | <link rel="stylesheet" href="<%=request.getContextPath()%>/css/flora-commons/flora.resizable.css"> |
||
15 | <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>--> |
||
16 | <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.debug.js"></script> |
||
17 | <script> |
||
18 | function demoFromHTML() { |
||
19 | var pdf = new jsPDF('p', 'pt', 'letter'); |
||
20 | // source can be HTML-formatted string, or a reference |
||
21 | // to an actual DOM element from which the text will be scraped. |
||
22 | source = $('#courseReportApp')[0]; |
||
23 | |||
24 | // we support special element handlers. Register them with jQuery-style |
||
25 | // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.) |
||
26 | // There is no support for any other type of selectors |
||
27 | // (class, of compound) at this time. |
||
28 | specialElementHandlers = { |
||
29 | // element with id of "bypass" - jQuery style selector |
||
30 | '#bypassme': function (element, renderer) { |
||
31 | // true = "handled elsewhere, bypass text extraction" |
||
32 | return true |
||
33 | } |
||
34 | }; |
||
35 | margins = { |
||
36 | top: 80, |
||
37 | bottom: 60, |
||
38 | left: 40, |
||
39 | width: 522 |
||
40 | }; |
||
41 | // all coords and widths are in jsPDF instance's declared units |
||
42 | // 'inches' in this case |
||
43 | pdf.fromHTML( |
||
44 | source, // HTML string or DOM elem ref. |
||
45 | margins.left, // x coord |
||
46 | margins.top, { // y coord |
||
47 | 'width': margins.width, // max width of content on PDF |
||
48 | 'elementHandlers': specialElementHandlers |
||
49 | }, |
||
50 | |||
51 | function (dispose) { |
||
52 | // dispose: object with X, Y of the last line add to the PDF |
||
53 | // this allow the insertion of new lines after html |
||
54 | var pdfDocument = pdf.save('Test.pdf'); |
||
55 | /*var pdfDocument = pdf.output(); |
||
56 | |||
57 | var boundary = '---------------------------'; |
||
58 | boundary += Math.floor(Math.random()*32768); |
||
59 | boundary += Math.floor(Math.random()*32768); |
||
60 | boundary += Math.floor(Math.random()*32768); |
||
61 | |||
62 | var body = ''; |
||
63 | body += '--' + boundary + '\r\n' + |
||
64 | 'Content-Disposition: form-data; name="filesInputId-UPLOAD[]"; filename="20170530_210340.pdf"' + '\r\n'; |
||
65 | body += 'Content-Type: application/pdf'; |
||
66 | body += '\r\n\r\n'; |
||
67 | body += pdfDocument; |
||
68 | body += '\r\n' |
||
69 | body += '--' + boundary + '--'; |
||
70 | |||
71 | |||
72 | |||
73 | $.ajax({ |
||
74 | type: "POST", |
||
75 | cache: false, |
||
76 | url: "<%=request.getContextPath()%>/filesUpload", |
||
77 | data: body , |
||
78 | processData: false, |
||
79 | contentType : 'multipart/form-data; boundary=' + boundary, |
||
80 | success: function (data) { |
||
81 | alert('success'); |
||
82 | return false; |
||
83 | } |
||
84 | });*/ |
||
85 | }, margins |
||
86 | ); |
||
87 | } |
||
88 | </script> |
||
89 | |||
90 | <script>ping()</script> |
||
91 | |||
92 | <jsp:useBean id="courseReportJson" type="java.lang.String" scope="request"/> |
||
93 | |||
94 | <% |
||
95 | //AbstractDao.getCurrentSession().beginTransaction(); |
||
96 | %> |
||
97 | <%--<a href="javascript:demoFromHTML()" class="button">Run Code</a>--%> |
||
98 | |||
1989 | grupo1 | 99 | <div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController" class="container-fluid"> |
1930 | grupo1 | 100 | |
101 | <style> |
||
102 | .separatorSection |
||
103 | { |
||
104 | border: 1px solid #ddd; |
||
105 | } |
||
106 | </style> |
||
107 | |||
108 | |||
109 | <!-- Apresentacao da Unidade --> |
||
110 | |||
111 | <div class="panel panel-default"> |
||
112 | <div class="panel-heading"> |
||
1989 | grupo1 | 113 | Relatório Anual do curso: {{report.name}} |
1930 | grupo1 | 114 | </div> |
115 | <div class="panel-body"> |
||
116 | |||
1989 | grupo1 | 117 | <p><b class="label-info">Tipo de Curso:</b> {{report.degree}}</p> |
118 | <p><b class="label-info">Ano Lectivo:</b> {{report.years}}</p> |
||
119 | <p><b class="label-info">Escola:</b> {{report.nomeEscola}}</p> |
||
1930 | grupo1 | 120 | |
121 | |||
1989 | grupo1 | 122 | <div ng-include="class2id(report)"> |
1930 | grupo1 | 123 | |
124 | <script> |
||
125 | |||
126 | //Especifico da aplicacao |
||
127 | var courseReportApp = angular.module('courseReportApp', ['ui.tree']); |
||
128 | GLOBAL_BacoAngularAppDependencies.push('courseReportApp'); |
||
129 | |||
130 | |||
131 | courseReportApp.directive('resizable', function () { |
||
132 | return { |
||
133 | restrict: 'A', |
||
134 | scope: { |
||
135 | callback: '&onResize' |
||
136 | }, |
||
137 | link: function postLink(scope, elem, attrs) { |
||
138 | elem.resizable(); |
||
139 | elem.on('resize', function (evt, ui, comp) { |
||
140 | scope.$apply(function() { |
||
141 | if (scope.callback) { |
||
142 | scope.callback({$evt: evt, $ui: ui, $comp: comp }); |
||
143 | } |
||
144 | }) |
||
145 | }); |
||
146 | } |
||
147 | }; |
||
148 | }); |
||
149 | |||
150 | |||
151 | courseReportApp.controller('courseReportAppController', function($scope) |
||
152 | { |
||
153 | |||
154 | $scope.docAppSelector = "#courseReportApp"; |
||
155 | $scope.report = ${courseReportJson} |
||
156 | |||
157 | $scope.resize = function(evt,ui,comp) { |
||
158 | //console.log (evt,ui); |
||
159 | comp.width = ui.size.width; |
||
160 | comp.height = ui.size.height; |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * @classe class to match |
||
165 | * @superClasses array of strings |
||
166 | * */ |
||
167 | $scope.contains = function(obj,classe) |
||
168 | { |
||
169 | if(obj['@class'] && obj['@class'] == classe) |
||
170 | return true; |
||
171 | if(obj.allSuperClasses) |
||
172 | { |
||
173 | for(var i in obj.allSuperClasses) |
||
174 | { |
||
175 | if(classe == obj.allSuperClasses[i]) |
||
176 | return true; |
||
177 | } |
||
178 | } |
||
179 | return false; |
||
180 | } |
||
181 | |||
182 | $scope.showSep = function(section,subSection) |
||
183 | { |
||
184 | var s; |
||
185 | for(s in section.sections) |
||
186 | { |
||
187 | section.sections[s].active = false; |
||
188 | } |
||
189 | /*$(".separatorSectionNav").each(function() |
||
190 | { |
||
191 | angular.element($(this)).scope().section.active = false; |
||
192 | });*/ |
||
193 | subSection.active = true; |
||
194 | } |
||
195 | |||
196 | /** |
||
197 | * Este metodo devolve o template mais profundo na hierarquia de classes |
||
198 | * permitindo emular o override, quanto mais especifica for a classe |
||
199 | * e caso exista template é esse o template devolvido |
||
200 | * procura um script com o id da classe e se nao existir |
||
201 | * vai subindo nas super classes |
||
202 | * @param obj |
||
203 | * @returns {*} |
||
204 | */ |
||
205 | $scope.class2id = function(obj) |
||
206 | { |
||
207 | var objClassId = obj["@class"].replaceAll(".","_"); |
||
208 | if($("script#" + objClassId).length > 0) |
||
209 | { |
||
210 | return objClassId; |
||
211 | } |
||
212 | if(obj.allSuperClasses) |
||
213 | { |
||
214 | var s; |
||
215 | for(s in obj.allSuperClasses) |
||
216 | { |
||
217 | var superClass = obj.allSuperClasses[s]; |
||
218 | var superClassId = superClass.replaceAll(".","_"); |
||
219 | if($("script#" + superClassId).length > 0) |
||
220 | { |
||
221 | return superClassId; |
||
222 | } |
||
223 | } |
||
224 | } |
||
225 | return obj["@class"].replaceAll(".","_"); |
||
226 | } |
||
227 | |||
228 | $scope.addText = function(parentCustomPane) |
||
229 | { |
||
230 | $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.TextComponent") |
||
231 | } |
||
232 | |||
233 | $scope.addImage = function(parentCustomPane) |
||
234 | { |
||
235 | $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.ImageComponent") |
||
236 | } |
||
237 | |||
238 | $scope.addSimpleDocComponent = function(parentCustomPane,classComponent) |
||
239 | { |
||
240 | if(!parentCustomPane.components) |
||
241 | { |
||
242 | parentCustomPane.components = []; |
||
243 | } |
||
244 | parentCustomPane.components.push( |
||
245 | { |
||
246 | "@class" : classComponent |
||
247 | } |
||
248 | ); |
||
249 | } |
||
250 | $scope.removeComponent = function(index,array) |
||
251 | { |
||
252 | array.splice(index,1); |
||
253 | } |
||
254 | |||
255 | $scope.callbackUploadedFiles = function(filesUploadResult,token,targetElement) |
||
256 | { |
||
257 | var modelObject = BacoAngularUtils.getAngularElementModel(targetElement); |
||
258 | |||
259 | if(modelObject.image && modelObject.image.identifier) |
||
260 | { |
||
261 | widgetCallWithActionParameters( |
||
262 | "<%=request.getContextPath()%>/user/json/repository.do", |
||
263 | "replaceRepositoryFileFromTempPrivateDomain", |
||
264 | { |
||
265 | "identifier" : modelObject.image.identifier, |
||
266 | "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
||
267 | }, |
||
268 | "#courseReportApp", |
||
269 | function(repositoryFile4JsonView) |
||
270 | { |
||
271 | modelObject.image = repositoryFile4JsonView; |
||
272 | //image URL is generated on reimport just to avoid caching |
||
273 | modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
||
274 | angular.element($("#courseReportApp")).scope().$apply(); |
||
275 | }, |
||
276 | function(){} |
||
277 | ); |
||
278 | } |
||
279 | else |
||
280 | { |
||
281 | widgetCallWithActionParameters( |
||
282 | "<%=request.getContextPath()%>/user/json/repository.do", |
||
283 | "saveRepositoryFileFromTempPrivateDomain", |
||
284 | { |
||
285 | "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
||
286 | }, |
||
287 | "#courseReportApp", |
||
288 | function(repositoryFile4JsonView) |
||
289 | { |
||
290 | modelObject.image = repositoryFile4JsonView; |
||
291 | modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
||
292 | angular.element($("#courseReportApp")).scope().$apply(); |
||
293 | }, |
||
294 | function(){} |
||
295 | ); |
||
296 | } |
||
297 | } |
||
298 | |||
299 | $scope.saveCourseReportDocument = function () { |
||
300 | widgetCallWithActionParameters( |
||
301 | "<%=request.getContextPath()%>/user/courseReport.do", |
||
302 | "saveCourseReportDocument", |
||
303 | { |
||
304 | "courseReportDocument" : BacoJS.stringifyOrdered($scope.report) |
||
305 | }, |
||
306 | "#courseReportApp", |
||
307 | function(data) |
||
308 | { |
||
309 | alert(BacoJS.stringifyOrdered(data)); |
||
310 | }, |
||
311 | function(){} |
||
312 | ); |
||
313 | } |
||
314 | |||
315 | |||
316 | |||
317 | }); |
||
318 | </script> |
||
319 | |||
320 | <!--TEMPLATES FOR DOCUMENT BUILDER--> |
||
321 | <jsp:include page="documentsBuilder.jsp"/> |
||
322 | |||
323 | <div class="form-vertical"> |
||
1989 | grupo1 | 324 | <div> |
1930 | grupo1 | 325 | <div class="web-messages"></div> |
326 | |||
327 | <button class="btn btn-success" ng-click="saveCourseReportDocument()">Gravar</button> |
||
328 | <button class="btn btn-success" onclick="demoFromHTML()">PDF</button> |
||
329 | |||
330 | <div ng-init="section=report;" ng-include="'pt_estgp_estgweb_utils_documentBuilder_DocumentSection'"> |
||
331 | |||
332 | </div> |
||
333 | |||
334 | <!--<pre class="code">{{ report | json }}</pre>--> |
||
335 | |||
336 | |||
337 | |||
338 | </div><!--App--> |
||
339 | </div> <!--form--> |
||
340 | |||
341 | </div><!--Panel Body--> |
||
342 | |||
343 | </div><!--Panel--> |
||
344 | |||
345 | </div><!--container-fluid--> |
||
346 | |||
347 | <% |
||
348 | //AbstractDao.getCurrentSession().getTransaction().commit(); |
||
349 | %> |