Rev 1863 | Rev 1935 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1863 | Rev 1927 | ||
---|---|---|---|
Line 93... | Line 93... | ||
93 | </script> |
93 | </script> |
94 | 94 | ||
95 | <% |
95 | <% |
96 | 96 | ||
97 | String courseCode = request.getParameter("courseCode"); |
97 | String courseCode = request.getParameter("courseCode"); |
- | 98 | String year = request.getParameter("year"); |
|
98 | AbstractDao.getCurrentSession().beginTransaction(); |
99 | AbstractDao.getCurrentSession().beginTransaction(); |
99 | CourseImpl courseImpl = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
100 | CourseImpl courseImpl = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
100 | request.setAttribute("course",courseImpl); |
101 | request.setAttribute("course",courseImpl); |
101 | CourseReportDocument courseReport = null; |
102 | CourseReportDocument courseReport = null; |
102 | try { |
103 | try { |
103 | courseReport = new CourseReportServices().createNewCourseReportDocument("44", "201617"); |
104 | courseReport = new CourseReportServices().createNewCourseReportDocument(courseCode, year); |
104 | } catch (Throwable e) { |
105 | } catch (Throwable e) { |
105 | System.out.println(e); |
106 | System.out.println(e); |
106 | e.printStackTrace(); |
107 | e.printStackTrace(); |
107 | } |
108 | } |
108 | String courseReportJson = courseReport.toJson(); |
109 | String courseReportJson = courseReport.toJson(); |
Line 112... | Line 113... | ||
112 | %> |
113 | %> |
113 | <%--<a href="javascript:demoFromHTML()" class="button">Run Code</a>--%> |
114 | <%--<a href="javascript:demoFromHTML()" class="button">Run Code</a>--%> |
114 | 115 | ||
115 | <div class="container-fluid"> |
116 | <div class="container-fluid"> |
116 | 117 | ||
117 | <style> |
118 | <style> |
118 | .separatorSection |
119 | .separatorSection |
119 | { |
120 | { |
120 | border: 1px solid #ddd; |
121 | border: 1px solid #ddd; |
121 | } |
122 | } |
122 | </style> |
123 | </style> |
123 | 124 | ||
124 | 125 | ||
125 | <!-- Apresentacao da Unidade --> |
126 | <!-- Apresentacao da Unidade --> |
126 | 127 | ||
127 | <div class="panel panel-default"> |
128 | <div class="panel panel-default"> |
128 | <div class="panel-heading"> |
129 | <div class="panel-heading"> |
129 | Relatório Anual do curso: ${course.name} |
130 | Relatório Anual do curso: ${course.name} |
130 | </div> |
131 | </div> |
131 | <div class="panel-body"> |
132 | <div class="panel-body"> |
132 | 133 | ||
133 | <p><b class="label-info">Tipo de Curso:</b> <bean:message key="course.${course.degree}"/></p> |
134 | <p><b class="label-info">Tipo de Curso:</b> <bean:message key="course.${course.degree}"/></p> |
134 | <p><b class="label-info">Ano Lectivo:</b> ${course.importYear}</p> |
135 | <p><b class="label-info">Ano Lectivo:</b> ${course.importYear}</p> |
135 | <p><b class="label-info">Departamento:</b> ${course.department.name}</p> |
136 | <p><b class="label-info">Departamento:</b> ${course.department.name}</p> |
136 | <p><b class="label-info">Escola:</b> ${course.department.courseSchool.name}</p> |
137 | <p><b class="label-info">Escola:</b> ${course.department.courseSchool.name}</p> |
137 | 138 | ||
138 | 139 | ||
139 | 140 | ||
140 | 141 | ||
141 | <script> |
142 | <script> |
142 | 143 | ||
143 | //Especifico da aplicacao |
144 | //Especifico da aplicacao |
144 | var courseReportApp = angular.module('courseReportApp', []); |
145 | var courseReportApp = angular.module('courseReportApp', ['ui.tree']); |
145 | GLOBAL_BacoAngularAppDependencies.push('courseReportApp'); |
146 | GLOBAL_BacoAngularAppDependencies.push('courseReportApp'); |
146 | 147 | ||
147 | 148 | ||
148 | courseReportApp.directive('resizable', function () { |
149 | courseReportApp.directive('resizable', function () { |
149 | return { |
150 | return { |
150 | restrict: 'A', |
151 | restrict: 'A', |
151 | scope: { |
152 | scope: { |
152 | callback: '&onResize' |
153 | callback: '&onResize' |
153 | }, |
154 | }, |
154 | link: function postLink(scope, elem, attrs) { |
155 | link: function postLink(scope, elem, attrs) { |
155 | elem.resizable(); |
156 | elem.resizable(); |
156 | elem.on('resize', function (evt, ui, comp) { |
157 | elem.on('resize', function (evt, ui, comp) { |
157 | scope.$apply(function() { |
158 | scope.$apply(function() { |
158 | if (scope.callback) { |
159 | if (scope.callback) { |
159 | scope.callback({$evt: evt, $ui: ui, $comp: comp }); |
160 | scope.callback({$evt: evt, $ui: ui, $comp: comp }); |
160 | } |
- | |
161 | }) |
- | |
162 | }); |
- | |
163 | } |
161 | } |
164 | }; |
162 | }) |
165 | }); |
163 | }); |
- | 164 | } |
|
- | 165 | }; |
|
- | 166 | }); |
|
166 | 167 | ||
167 | 168 | ||
168 | courseReportApp.controller('courseReportAppController', function($scope) |
169 | courseReportApp.controller('courseReportAppController', function($scope) |
- | 170 | { |
|
- | 171 | ||
- | 172 | $scope.docAppSelector = "#courseReportApp"; |
|
- | 173 | $scope.report = <%=courseReportJson%> |
|
- | 174 | ||
- | 175 | $scope.resize = function(evt,ui,comp) { |
|
- | 176 | //console.log (evt,ui); |
|
- | 177 | comp.width = ui.size.width; |
|
- | 178 | comp.height = ui.size.height; |
|
- | 179 | } |
|
- | 180 | ||
- | 181 | /** |
|
- | 182 | * @classe class to match |
|
- | 183 | * @superClasses array of strings |
|
- | 184 | * */ |
|
- | 185 | $scope.contains = function(obj,classe) |
|
- | 186 | { |
|
- | 187 | if(obj['@class'] && obj['@class'] == classe) |
|
- | 188 | return true; |
|
- | 189 | if(obj.allSuperClasses) |
|
- | 190 | { |
|
- | 191 | for(var i in obj.allSuperClasses) |
|
169 | { |
192 | { |
- | 193 | if(classe == obj.allSuperClasses[i]) |
|
- | 194 | return true; |
|
- | 195 | } |
|
- | 196 | } |
|
- | 197 | return false; |
|
- | 198 | } |
|
170 | 199 | ||
171 | $scope.docAppSelector = "#courseReportApp"; |
200 | $scope.showSep = function(section,subSection) |
- | 201 | { |
|
172 | $scope.report = <%=courseReportJson%> |
202 | var s; |
173 | - | ||
174 | $scope.resize = function(evt,ui,comp) { |
203 | for(s in section.sections) |
- | 204 | { |
|
175 | //console.log (evt,ui); |
205 | section.sections[s].active = false; |
- | 206 | } |
|
176 | comp.width = ui.size.width; |
207 | /*$(".separatorSectionNav").each(function() |
- | 208 | { |
|
177 | comp.height = ui.size.height; |
209 | angular.element($(this)).scope().section.active = false; |
178 | } |
210 | });*/ |
- | 211 | subSection.active = true; |
|
- | 212 | } |
|
179 | 213 | ||
- | 214 | /** |
|
- | 215 | * Este metodo devolve o template mais profundo na hierarquia de classes |
|
- | 216 | * permitindo emular o override, quanto mais especifica for a classe |
|
- | 217 | * e caso exista template é esse o template devolvido |
|
- | 218 | * procura um script com o id da classe e se nao existir |
|
- | 219 | * vai subindo nas super classes |
|
- | 220 | * @param obj |
|
180 | /** |
221 | * @returns {*} |
- | 222 | */ |
|
- | 223 | $scope.class2id = function(obj) |
|
- | 224 | { |
|
- | 225 | var objClassId = obj["@class"].replaceAll(".","_"); |
|
- | 226 | if($("script#" + objClassId).length > 0) |
|
- | 227 | { |
|
181 | * @classe class to match |
228 | return objClassId; |
- | 229 | } |
|
182 | * @superClasses array of strings |
230 | if(obj.allSuperClasses) |
- | 231 | { |
|
183 | * */ |
232 | var s; |
- | 233 | for(s in obj.allSuperClasses) |
|
- | 234 | { |
|
184 | $scope.contains = function(obj,classe) |
235 | var superClass = obj.allSuperClasses[s]; |
- | 236 | var superClassId = superClass.replaceAll(".","_"); |
|
- | 237 | if($("script#" + superClassId).length > 0) |
|
185 | { |
238 | { |
186 | if(obj['@class'] && obj['@class'] == classe) |
- | |
187 | return true; |
- | |
188 | if(obj.allSuperClasses) |
- | |
189 | { |
- | |
190 | for(var i in obj.allSuperClasses) |
- | |
191 | { |
- | |
192 | if(classe == obj.allSuperClasses[i]) |
- | |
193 | return true; |
- | |
194 | } |
- | |
195 | } |
- | |
196 | return false; |
239 | return superClassId; |
197 | } |
240 | } |
- | 241 | } |
|
- | 242 | } |
|
- | 243 | return obj["@class"].replaceAll(".","_"); |
|
- | 244 | } |
|
198 | 245 | ||
199 | $scope.showSep = function(section) |
246 | $scope.addText = function(parentCustomPane) |
200 | { |
247 | { |
201 | $(".separatorSectionNav").each(function() |
- | |
202 | { |
- | |
203 | angular.element($(this)).scope().section.active = false; |
248 | $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.TextComponent") |
204 | }); |
- | |
205 | section.active = true; |
- | |
206 | - | ||
207 | } |
249 | } |
208 | 250 | ||
209 | $scope.class2id = function(obj) |
251 | $scope.addImage = function(parentCustomPane) |
210 | { |
252 | { |
211 | return obj["@class"].replaceAll(".","_"); |
253 | $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.ImageComponent") |
212 | } |
254 | } |
213 | 255 | ||
214 | $scope.addText = function(parentCustomPane) |
256 | $scope.addSimpleDocComponent = function(parentCustomPane,classComponent) |
- | 257 | { |
|
- | 258 | if(!parentCustomPane.components) |
|
- | 259 | { |
|
- | 260 | parentCustomPane.components = []; |
|
- | 261 | } |
|
- | 262 | parentCustomPane.components.push( |
|
215 | { |
263 | { |
216 | $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.TextComponent") |
264 | "@class" : classComponent |
217 | } |
265 | } |
- | 266 | ); |
|
- | 267 | } |
|
- | 268 | $scope.removeComponent = function(index,array) |
|
- | 269 | { |
|
- | 270 | array.splice(index,1); |
|
- | 271 | } |
|
218 | 272 | ||
219 | $scope.addImage = function(parentCustomPane) |
273 | $scope.callbackUploadedFiles = function(filesUploadResult,token,targetElement) |
220 | { |
274 | { |
221 | $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.ImageComponent") |
275 | var modelObject = BacoAngularUtils.getAngularElementModel(targetElement); |
222 | } |
- | |
223 | 276 | ||
224 | $scope.addSimpleDocComponent = function(parentCustomPane,classComponent) |
277 | if(modelObject.image && modelObject.image.identifier) |
225 | { |
278 | { |
- | 279 | widgetCallWithActionParameters( |
|
- | 280 | "<%=request.getContextPath()%>/user/json/repository.do", |
|
226 | if(!parentCustomPane.components) |
281 | "replaceRepositoryFileFromTempPrivateDomain", |
227 | { |
282 | { |
228 | parentCustomPane.components = []; |
283 | "identifier" : modelObject.image.identifier, |
229 | } |
- | |
230 | parentCustomPane.components.push( |
- | |
231 | { |
- | |
232 | "@class" : classComponent |
284 | "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
233 | } |
- | |
234 | ); |
285 | }, |
235 | } |
- | |
236 | $scope.removeComponent = function(index,array) |
- | |
237 | { |
- | |
238 | array.splice(index,1); |
286 | "#courseReportApp", |
239 | - | ||
240 | - | ||
241 | } |
- | |
242 | $scope.callbackUploadedFiles = function(filesUploadResult,token,targetElement) |
- | |
243 | { |
- | |
244 | var modelObject = BacoAngularUtils.getAngularElementModel(targetElement); |
- | |
245 | modelObject.filesUploadResult = filesUploadResult; |
287 | function(repositoryFile4JsonView) |
246 | if(modelObject.image && modelObject.image.identifier) |
- | |
247 | { |
288 | { |
248 | widgetCallWithActionParameters( |
- | |
249 | "<%=request.getContextPath()%>/user/json/repository.do", |
- | |
250 | "replaceRepositoryFileFromTempPrivateDomain", |
- | |
251 | { |
- | |
252 | "identifier" : modelObject.image.identifier, |
- | |
253 | "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
- | |
254 | }, |
- | |
255 | "#courseReportApp", |
- | |
256 | function(repositoryFile4JsonView) |
289 | modelObject.image = repositoryFile4JsonView; |
257 | { |
- | |
258 | modelObject.image = repositoryFile4JsonView; |
290 | //image URL is generated on reimport just to avoid caching |
259 | modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
291 | modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
260 | delete modelObject.filesUploadResult; |
- | |
261 | angular.element($("#courseReportApp")).scope().$apply(); |
292 | angular.element($("#courseReportApp")).scope().$apply(); |
262 | }, |
293 | }, |
263 | function(){} |
294 | function(){} |
264 | ); |
295 | ); |
265 | } |
296 | } |
266 | else |
297 | else |
- | 298 | { |
|
- | 299 | widgetCallWithActionParameters( |
|
- | 300 | "<%=request.getContextPath()%>/user/json/repository.do", |
|
- | 301 | "saveRepositoryFileFromTempPrivateDomain", |
|
267 | { |
302 | { |
268 | widgetCallWithActionParameters( |
- | |
269 | "<%=request.getContextPath()%>/user/json/repository.do", |
- | |
270 | "saveRepositoryFileFromTempPrivateDomain", |
- | |
271 | { |
- | |
272 | "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
303 | "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
273 | }, |
304 | }, |
274 | "#courseReportApp", |
305 | "#courseReportApp", |
275 | function(repositoryFile4JsonView) |
306 | function(repositoryFile4JsonView) |
276 | { |
307 | { |
277 | modelObject.image = repositoryFile4JsonView; |
308 | modelObject.image = repositoryFile4JsonView; |
278 | modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
309 | modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
279 | delete modelObject.filesUploadResult; |
- | |
280 | angular.element($("#courseReportApp")).scope().$apply(); |
310 | angular.element($("#courseReportApp")).scope().$apply(); |
281 | }, |
- | |
282 | function(){} |
- | |
283 | ); |
311 | }, |
284 | } |
312 | function(){} |
285 | } |
313 | ); |
286 | - | ||
287 | - | ||
288 | }); |
314 | } |
289 | </script> |
315 | } |
290 | - | ||
291 | <!--TEMPLATES FOR DOCUMENT BUILDER--> |
- | |
292 | <jsp:include page="../utils/documentsBuilder.jsp"/> |
- | |
293 | - | ||
294 | <div class="form-vertical"> |
- | |
295 | <div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController"> |
- | |
296 | 316 | ||
297 | 317 | ||
298 | <ul class="nav nav-tabs"> |
- | |
299 | <li ng-model="section" class="separatorSectionNav" ng-class="{ active: section.active}" ng-repeat="section in report.sections"> |
- | |
300 | <a ng-click="showSep(section)">{{section.title}}</a> |
- | |
301 | </li> |
- | |
302 | </ul> |
- | |
303 | 318 | ||
304 | 319 | ||
- | 320 | }); |
|
- | 321 | </script> |
|
305 | 322 | ||
- | 323 | <!--TEMPLATES FOR DOCUMENT BUILDER--> |
|
306 | <!--DocumentSection--> |
324 | <jsp:include page="../utils/documentsBuilder.jsp"/> |
307 | <div ng-model="section" ng-class="{ hidden: !section.active}" ng-repeat="section in report.sections" class="separatorSection clearfix"> |
325 | <jsp:include page="coursereport/templates.jsp"/> |
308 | 326 | ||
- | 327 | <div class="form-vertical"> |
|
309 | <div ng-repeat="comp in section.components" ng-include="class2id(comp)"> |
328 | <div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController"> |
310 | 329 | ||
311 | </div> |
330 | <div ng-init="section=report;" ng-include="'pt_estgp_estgweb_utils_documentBuilder_DocumentSection'"> |
312 | 331 | ||
- | 332 | </div> |
|
313 | 333 | ||
314 | </div> |
- | |
315 | <!--/DocumentSection--> |
334 | <!-- <pre class="code">{{ report | json }}</pre>--> |
316 | 335 | ||
317 | <%-- |
- | |
318 | <pre class="code">{{ report | json }}</pre> |
- | |
319 | --%> |
- | |
320 | 336 | ||
321 | 337 | ||
322 | </div><!--App--> |
338 | </div><!--App--> |
323 | </div> <!--form--> |
339 | </div> <!--form--> |
324 | 340 | ||
325 | </div><!--Panel Body--> |
341 | </div><!--Panel Body--> |
326 | 342 | ||
327 | </div><!--Panel--> |
343 | </div><!--Panel--> |
328 | 344 | ||
329 | </div><!--container-fluid--> |
345 | </div><!--container-fluid--> |
330 | 346 | ||
331 | <% |
347 | <% |
332 | AbstractDao.getCurrentSession().getTransaction().commit(); |
348 | AbstractDao.getCurrentSession().getTransaction().commit(); |