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