/branches/grupo2/impl/src/java/pt/estgp/estgweb/utils/documentBuilder/DocumentSection.java |
---|
53,7 → 53,7 |
public DocComponent findDocComponent(Class compClass, String internalCode) |
{ |
if(getComponents() != null) |
if(getComponents() != null && internalCode != null) |
for(DocComponent comp: getComponents()) |
{ |
if(comp.getClass().equals(compClass) && comp.getInternalCode().equals(internalCode)) |
/branches/grupo2/impl/src/java/pt/estgp/estgweb/services/courses/CourseReportServices.java |
---|
543,7 → 543,7 |
if (courseReportJson == null) { |
try { |
CourseReportDocument courseReport = new CourseReportServices().createNewCourseReportDocument(courseCode, year); |
CourseReportDocument courseReport = createNewCourseReportDocument(courseCode, year); |
courseReportJson = courseReport.toJson(); |
saveCourseReportDocument(courseReportJson, session); |
} catch (Throwable e) { |
/branches/grupo2/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/learningresults/components/LearningResultsChartSem.java |
---|
102,7 → 102,7 |
renderer.setSeriesPaint(0, new Color(237,127,32)); |
renderer.setSeriesPaint(1, new Color(255,198,0)); |
renderer.setSeriesPaint(2, new Color(122,173,38)); |
renderer.setMaximumBarWidth(0.2); |
renderer.setMaximumBarWidth(0.1); |
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("#.##'%'"))); |
renderer.setBaseItemLabelsVisible(true); |
113,7 → 113,7 |
legend.setFrame(BlockBorder.NONE); |
BufferedImage image = chart.createBufferedImage( 300*4, 200*4); |
BufferedImage image = chart.createBufferedImage( 300*4, 400*4); |
String pathGraficoTiposAlunos = Globals.TMP_DIR + java.io.File.separator + tempName; |
java.io.File output = new java.io.File(pathGraficoTiposAlunos); |
ImageIO.write(image, "png", new FileOutputStream(output)); |
/branches/grupo2/impl/src/java/pt/estgp/estgweb/filters/filters/IsFromCourseCommission.java |
---|
2,14 → 2,11 |
import org.apache.log4j.Logger; |
import pt.estgp.estgweb.domain.CourseImpl; |
import pt.estgp.estgweb.domain.CourseUnit; |
import pt.estgp.estgweb.domain.UserImpl; |
import pt.estgp.estgweb.domain.UserSession; |
import pt.estgp.estgweb.domain.dao.DaoFactory; |
import pt.estgp.estgweb.filters.chains.LoadControlFilter; |
import pt.estgp.estgweb.filters.exceptions.AccessDeniedOperationException; |
import pt.estgp.estgweb.filters.exceptions.NeedAuthenticationException; |
import pt.estgp.estgweb.filters.filters.utils.LoadObjectFromParameters; |
import pt.estgp.estgweb.utils.Globals; |
import pt.utl.ist.berserk.ServiceRequest; |
import pt.utl.ist.berserk.ServiceResponse; |
33,7 → 30,6 |
if(userSession.getUser().isSuperuser()) |
return; |
//CourseImpl course = (CourseImpl) LoadObjectFromParameters.loadObjectFromClassName((String) filterParameters.getParameter(1),filterParameters,request.getServiceParameters()); |
String courseCode = (String) request.getServiceParameters().getParameter((String) filterParameters.getParameter(0)); |
CourseImpl course = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
/branches/grupo2/impl/src/web/user/courses/coursereport/templates.jsp |
---|
647,12 → 647,12 |
}, |
templateUrl: function(elem,attrs) { |
return "globallearningresultschartimg"; |
return "chartcomponenttemplate"; |
} |
} |
}); |
</script> |
<script type="text/ng-template" id="globallearningresultschartimg"> |
<script type="text/ng-template" id="chartcomponenttemplate"> |
<div class="imageComponent component"> |
<div class="componentBody"> |
719,43 → 719,13 |
}, |
templateUrl: function(elem,attrs) { |
return "globallearningresultschartimg"; |
return "chartcomponenttemplate"; |
} |
} |
}); |
</script> |
<script type="text/ng-template" id="globallearninglesultschartyearimg"> |
<div class="imageComponent component"> |
<div class="componentBody"> |
<div class="form-group clearfix"> |
<label class="col-md-2 control-label">Legenda</label> |
<div class="col-md-10"> |
<input type="text" class="form-control" rows="10" ng-model="comp.title"> |
</div> |
</div> |
<div class="form-group clearfix"> |
<div class="col-md-2 control-label"> |
<button class="btn btn-default" ng-click="generateChart(comp)">Refrescar/Gerar Gráfico</button> |
</div> |
<div class="col-md-10"> |
<label ng-if="comp.image.identifier"> Limites do PDF </label> |
<div ng-if="comp.image.identifier" style="text-align: center; width: 595px; border: 1px solid black; padding: 45px"> |
<center> |
<div style="width: 200px;height: 200px; max-width: 500px; max-height: 750px" resizable on-resize="resize($evt, $ui, comp)"> |
<img ng-if="comp.imageUrl" style="width: 100%;height: 100%" ng-src="{{comp.imageUrl}}"> |
<img ng-if="!comp.imageUrl" style="width: 100%;height: 100%" ng-src="{{'<%=request.getContextPath()%>/repositoryStream/' + comp.image.identifier}}"> |
</div> |
(Se desejar altere o tamanho da imagem arrastando no canto inferior direito) |
</center> |
</div> |
</div> |
</div> |
</div> |
</div> |
</script> |
<script type="text/ng-template" id="pt_estgp_estgweb_services_courses_coursereport_documentmodel_learningresults_components_LearningResultsChartSem"> |
<learningresultschartsem> |
</learningresultschartsem> |
792,38 → 762,8 |
}, |
templateUrl: function(elem,attrs) { |
return "learningresultschartsem"; |
return "chartcomponenttemplate"; |
} |
} |
}); |
</script> |
<script type="text/ng-template" id="learningresultschartsem"> |
<div class="imageComponent component"> |
<div class="componentBody"> |
<div class="form-group clearfix"> |
<label class="col-md-2 control-label">Legenda</label> |
<div class="col-md-10"> |
<input type="text" class="form-control" rows="10" ng-model="comp.title"> |
</div> |
</div> |
<div class="form-group clearfix"> |
<div class="col-md-2 control-label"> |
<button class="btn btn-default" ng-click="generateChart(comp)">Refrescar/Gerar Gráfico</button> |
</div> |
<div class="col-md-10"> |
<label ng-if="comp.image.identifier"> Limites do PDF </label> |
<div ng-if="comp.image.identifier" style="text-align: center; width: 595px; border: 1px solid black; padding: 45px"> |
<center> |
<div style="width: 200px;height: 200px; max-width: 500px; max-height: 750px" resizable on-resize="resize($evt, $ui, comp)"> |
<img ng-if="comp.imageUrl" style="width: 100%;height: 100%" ng-src="{{comp.imageUrl}}"> |
<img ng-if="!comp.imageUrl" style="width: 100%;height: 100%" ng-src="{{'<%=request.getContextPath()%>/repositoryStream/' + comp.image.identifier}}"> |
</div> |
(Se desejar altere o tamanho da imagem arrastando no canto inferior direito) |
</center> |
</div> |
</div> |
</div> |
</div> |
</div> |
</script> |
/branches/grupo2/impl/src/web/user/courses/courseReportEdit.jsp |
---|
1,10 → 1,4 |
<%@ page contentType="text/html;charset=UTF-8" language="java" %> |
<%@ page import="jomm.dao.impl.AbstractDao" %> |
<%@ page import="pt.estgp.estgweb.domain.CourseImpl" %> |
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.IServiceManager" %> |
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.ServiceManager" %> |
<%@ page import="pt.estgp.estgweb.web.utils.RequestUtils" %> |
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
13,344 → 7,5 |
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %> |
<%-- http://localhost:8080/baco/user/editCourseReport.do?courseCode=44&year=201617 --%> |
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.css"> |
<script src="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.min.js"></script> |
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/flora-commons/flora.resizable.css"> |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script> |
<script> |
function demoFromHTML() { |
var pdf = new jsPDF('p', 'pt', 'letter'); |
// source can be HTML-formatted string, or a reference |
// to an actual DOM element from which the text will be scraped. |
source = $('#courseReportApp')[0]; |
// we support special element handlers. Register them with jQuery-style |
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.) |
// There is no support for any other type of selectors |
// (class, of compound) at this time. |
specialElementHandlers = { |
// element with id of "bypass" - jQuery style selector |
'#bypassme': function (element, renderer) { |
// true = "handled elsewhere, bypass text extraction" |
return true |
} |
}; |
margins = { |
top: 80, |
bottom: 60, |
left: 40, |
width: 522 |
}; |
// all coords and widths are in jsPDF instance's declared units |
// 'inches' in this case |
pdf.fromHTML( |
source, // HTML string or DOM elem ref. |
margins.left, // x coord |
margins.top, { // y coord |
'width': margins.width, // max width of content on PDF |
'elementHandlers': specialElementHandlers |
}, |
function (dispose) { |
// dispose: object with X, Y of the last line add to the PDF |
// this allow the insertion of new lines after html |
//var pdfDocument = pdf.save('Test.pdf'); |
var pdfDocument = pdf.output(); |
var boundary = '---------------------------'; |
boundary += Math.floor(Math.random()*32768); |
boundary += Math.floor(Math.random()*32768); |
boundary += Math.floor(Math.random()*32768); |
var body = ''; |
body += '--' + boundary + '\r\n' + |
'Content-Disposition: form-data; name="filesInputId-UPLOAD[]"; filename="20170530_210340.pdf"' + '\r\n'; |
body += 'Content-Type: application/pdf'; |
body += '\r\n\r\n'; |
body += pdfDocument; |
body += '\r\n' |
body += '--' + boundary + '--'; |
$.ajax({ |
type: "POST", |
cache: false, |
url: "<%=request.getContextPath()%>/filesUpload", |
data: body , |
processData: false, |
contentType : 'multipart/form-data; boundary=' + boundary, |
success: function (data) { |
alert('success'); |
return false; |
} |
}); |
}, margins |
); |
} |
</script> |
<script>ping()</script> |
<jsp:useBean id="courseReportJson" type="java.lang.String" scope="request"/> |
<jsp:useBean id="course" type="pt.estgp.estgweb.domain.CourseImpl" scope="request"/> |
<% |
//AbstractDao.getCurrentSession().beginTransaction(); |
%> |
<%--<a href="javascript:demoFromHTML()" class="button">Run Code</a>--%> |
<div class="container-fluid"> |
<style> |
.separatorSection |
{ |
border: 1px solid #ddd; |
} |
</style> |
<!-- Apresentacao da Unidade --> |
<div class="panel panel-default"> |
<div class="panel-heading"> |
Relatório Anual do curso: ${course.name} |
</div> |
<div class="panel-body"> |
<p><b class="label-info">Tipo de Curso:</b> <bean:message key="course.${course.degree}"/></p> |
<p><b class="label-info">Ano Lectivo:</b> ${course.importYear}</p> |
<p><b class="label-info">Departamento:</b> ${course.department.name}</p> |
<p><b class="label-info">Escola:</b> ${course.department.courseSchool.name}</p> |
<script> |
//Especifico da aplicacao |
var courseReportApp = angular.module('courseReportApp', ['ui.tree']); |
GLOBAL_BacoAngularAppDependencies.push('courseReportApp'); |
courseReportApp.directive('resizable', function () { |
return { |
restrict: 'A', |
scope: { |
callback: '&onResize' |
}, |
link: function postLink(scope, elem, attrs) { |
elem.resizable(); |
elem.on('resize', function (evt, ui, comp) { |
scope.$apply(function() { |
if (scope.callback) { |
scope.callback({$evt: evt, $ui: ui, $comp: comp }); |
} |
}) |
}); |
} |
}; |
}); |
courseReportApp.controller('courseReportAppController', function($scope) |
{ |
$scope.docAppSelector = "#courseReportApp"; |
$scope.report = ${courseReportJson} |
$scope.resize = function(evt,ui,comp) { |
//console.log (evt,ui); |
comp.width = ui.size.width; |
comp.height = ui.size.height; |
} |
/** |
* @classe class to match |
* @superClasses array of strings |
* */ |
$scope.contains = function(obj,classe) |
{ |
if(obj['@class'] && obj['@class'] == classe) |
return true; |
if(obj.allSuperClasses) |
{ |
for(var i in obj.allSuperClasses) |
{ |
if(classe == obj.allSuperClasses[i]) |
return true; |
} |
} |
return false; |
} |
$scope.showSep = function(section,subSection) |
{ |
var s; |
for(s in section.sections) |
{ |
section.sections[s].active = false; |
} |
/*$(".separatorSectionNav").each(function() |
{ |
angular.element($(this)).scope().section.active = false; |
});*/ |
subSection.active = true; |
} |
/** |
* Este metodo devolve o template mais profundo na hierarquia de classes |
* permitindo emular o override, quanto mais especifica for a classe |
* e caso exista template é esse o template devolvido |
* procura um script com o id da classe e se nao existir |
* vai subindo nas super classes |
* @param obj |
* @returns {*} |
*/ |
$scope.class2id = function(obj) |
{ |
var objClassId = obj["@class"].replaceAll(".","_"); |
if($("script#" + objClassId).length > 0) |
{ |
return objClassId; |
} |
if(obj.allSuperClasses) |
{ |
var s; |
for(s in obj.allSuperClasses) |
{ |
var superClass = obj.allSuperClasses[s]; |
var superClassId = superClass.replaceAll(".","_"); |
if($("script#" + superClassId).length > 0) |
{ |
return superClassId; |
} |
} |
} |
return obj["@class"].replaceAll(".","_"); |
} |
$scope.addText = function(parentCustomPane) |
{ |
$scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.TextComponent") |
} |
$scope.addImage = function(parentCustomPane) |
{ |
$scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.ImageComponent") |
} |
$scope.addSimpleDocComponent = function(parentCustomPane,classComponent) |
{ |
if(!parentCustomPane.components) |
{ |
parentCustomPane.components = []; |
} |
parentCustomPane.components.push( |
{ |
"@class" : classComponent |
} |
); |
} |
$scope.removeComponent = function(index,array) |
{ |
array.splice(index,1); |
} |
$scope.callbackUploadedFiles = function(filesUploadResult,token,targetElement) |
{ |
var modelObject = BacoAngularUtils.getAngularElementModel(targetElement); |
if(modelObject.image && modelObject.image.identifier) |
{ |
widgetCallWithActionParameters( |
"<%=request.getContextPath()%>/user/json/repository.do", |
"replaceRepositoryFileFromTempPrivateDomain", |
{ |
"identifier" : modelObject.image.identifier, |
"fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
}, |
"#courseReportApp", |
function(repositoryFile4JsonView) |
{ |
modelObject.image = repositoryFile4JsonView; |
//image URL is generated on reimport just to avoid caching |
modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
angular.element($("#courseReportApp")).scope().$apply(); |
}, |
function(){} |
); |
} |
else |
{ |
widgetCallWithActionParameters( |
"<%=request.getContextPath()%>/user/json/repository.do", |
"saveRepositoryFileFromTempPrivateDomain", |
{ |
"fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
}, |
"#courseReportApp", |
function(repositoryFile4JsonView) |
{ |
modelObject.image = repositoryFile4JsonView; |
modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
angular.element($("#courseReportApp")).scope().$apply(); |
}, |
function(){} |
); |
} |
} |
$scope.saveCourseReportDocument = function () { |
widgetCallWithActionParameters( |
"<%=request.getContextPath()%>/user/courseReport.do", |
"saveCourseReportDocument", |
{ |
"courseReportDocument" : BacoJS.stringifyOrdered($scope.report) |
}, |
"#courseReportApp", |
function(data) |
{ |
alert(BacoJS.stringifyOrdered(data)); |
}, |
function(){} |
); |
} |
}); |
</script> |
<!--TEMPLATES FOR DOCUMENT BUILDER--> |
<jsp:include page="../utils/documentsBuilder.jsp"/> |
<jsp:include page="../utils/reportEdit.jsp"/> |
<jsp:include page="coursereport/templates.jsp"/> |
<div class="form-vertical"> |
<div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController"> |
<div class="web-messages"></div> |
<button class="btn btn-success" ng-click="saveCourseReportDocument()">Gravar</button> |
<div ng-init="section=report;" ng-include="'pt_estgp_estgweb_utils_documentBuilder_DocumentSection'"> |
</div> |
<!--<pre class="code">{{ report | json }}</pre>--> |
</div><!--App--> |
</div> <!--form--> |
</div><!--Panel Body--> |
</div><!--Panel--> |
</div><!--container-fluid--> |
<% |
//AbstractDao.getCurrentSession().getTransaction().commit(); |
%> |
/branches/grupo2/impl/src/web/user/utils/reportEdit.jsp |
---|
New file |
0,0 → 1,357 |
<%@ page contentType="text/html;charset=UTF-8" language="java" %> |
<%@ page import="jomm.dao.impl.AbstractDao" %> |
<%@ page import="pt.estgp.estgweb.domain.CourseImpl" %> |
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.IServiceManager" %> |
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.ServiceManager" %> |
<%@ page import="pt.estgp.estgweb.web.utils.RequestUtils" %> |
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %> |
<%-- http://localhost:8080/baco/user/editCourseReport.do?courseCode=44&year=201617 --%> |
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.css"> |
<script src="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.min.js"></script> |
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/flora-commons/flora.resizable.css"> |
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>--> |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.debug.js"></script> |
<script> |
function demoFromHTML() { |
var pdf = new jsPDF('p', 'pt', 'letter'); |
// source can be HTML-formatted string, or a reference |
// to an actual DOM element from which the text will be scraped. |
source = $('#courseReportApp')[0]; |
// we support special element handlers. Register them with jQuery-style |
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.) |
// There is no support for any other type of selectors |
// (class, of compound) at this time. |
specialElementHandlers = { |
// element with id of "bypass" - jQuery style selector |
'#bypassme': function (element, renderer) { |
// true = "handled elsewhere, bypass text extraction" |
return true |
} |
}; |
margins = { |
top: 80, |
bottom: 60, |
left: 40, |
width: 522 |
}; |
// all coords and widths are in jsPDF instance's declared units |
// 'inches' in this case |
pdf.fromHTML( |
source, // HTML string or DOM elem ref. |
margins.left, // x coord |
margins.top, { // y coord |
'width': margins.width, // max width of content on PDF |
'elementHandlers': specialElementHandlers |
}, |
function (dispose) { |
// dispose: object with X, Y of the last line add to the PDF |
// this allow the insertion of new lines after html |
var pdfDocument = pdf.save('Test.pdf'); |
/*var pdfDocument = pdf.output(); |
var boundary = '---------------------------'; |
boundary += Math.floor(Math.random()*32768); |
boundary += Math.floor(Math.random()*32768); |
boundary += Math.floor(Math.random()*32768); |
var body = ''; |
body += '--' + boundary + '\r\n' + |
'Content-Disposition: form-data; name="filesInputId-UPLOAD[]"; filename="20170530_210340.pdf"' + '\r\n'; |
body += 'Content-Type: application/pdf'; |
body += '\r\n\r\n'; |
body += pdfDocument; |
body += '\r\n' |
body += '--' + boundary + '--'; |
$.ajax({ |
type: "POST", |
cache: false, |
url: "<%=request.getContextPath()%>/filesUpload", |
data: body , |
processData: false, |
contentType : 'multipart/form-data; boundary=' + boundary, |
success: function (data) { |
alert('success'); |
return false; |
} |
});*/ |
}, margins |
); |
} |
</script> |
<script>ping()</script> |
<jsp:useBean id="courseReportJson" type="java.lang.String" scope="request"/> |
<jsp:useBean id="course" type="pt.estgp.estgweb.domain.CourseImpl" scope="request"/> |
<% |
//AbstractDao.getCurrentSession().beginTransaction(); |
%> |
<%--<a href="javascript:demoFromHTML()" class="button">Run Code</a>--%> |
<div class="container-fluid"> |
<style> |
.separatorSection |
{ |
border: 1px solid #ddd; |
} |
</style> |
<!-- Apresentacao da Unidade --> |
<div class="panel panel-default"> |
<div class="panel-heading"> |
Relatório Anual do curso: ${course.name} |
</div> |
<div class="panel-body"> |
<p><b class="label-info">Tipo de Curso:</b> <bean:message key="course.${course.degree}"/></p> |
<p><b class="label-info">Ano Lectivo:</b> ${course.importYear}</p> |
<p><b class="label-info">Departamento:</b> ${course.department.name}</p> |
<p><b class="label-info">Escola:</b> ${course.department.courseSchool.name}</p> |
<script> |
//Especifico da aplicacao |
var courseReportApp = angular.module('courseReportApp', ['ui.tree']); |
GLOBAL_BacoAngularAppDependencies.push('courseReportApp'); |
courseReportApp.directive('resizable', function () { |
return { |
restrict: 'A', |
scope: { |
callback: '&onResize' |
}, |
link: function postLink(scope, elem, attrs) { |
elem.resizable(); |
elem.on('resize', function (evt, ui, comp) { |
scope.$apply(function() { |
if (scope.callback) { |
scope.callback({$evt: evt, $ui: ui, $comp: comp }); |
} |
}) |
}); |
} |
}; |
}); |
courseReportApp.controller('courseReportAppController', function($scope) |
{ |
$scope.docAppSelector = "#courseReportApp"; |
$scope.report = ${courseReportJson} |
$scope.resize = function(evt,ui,comp) { |
//console.log (evt,ui); |
comp.width = ui.size.width; |
comp.height = ui.size.height; |
} |
/** |
* @classe class to match |
* @superClasses array of strings |
* */ |
$scope.contains = function(obj,classe) |
{ |
if(obj['@class'] && obj['@class'] == classe) |
return true; |
if(obj.allSuperClasses) |
{ |
for(var i in obj.allSuperClasses) |
{ |
if(classe == obj.allSuperClasses[i]) |
return true; |
} |
} |
return false; |
} |
$scope.showSep = function(section,subSection) |
{ |
var s; |
for(s in section.sections) |
{ |
section.sections[s].active = false; |
} |
/*$(".separatorSectionNav").each(function() |
{ |
angular.element($(this)).scope().section.active = false; |
});*/ |
subSection.active = true; |
} |
/** |
* Este metodo devolve o template mais profundo na hierarquia de classes |
* permitindo emular o override, quanto mais especifica for a classe |
* e caso exista template é esse o template devolvido |
* procura um script com o id da classe e se nao existir |
* vai subindo nas super classes |
* @param obj |
* @returns {*} |
*/ |
$scope.class2id = function(obj) |
{ |
var objClassId = obj["@class"].replaceAll(".","_"); |
if($("script#" + objClassId).length > 0) |
{ |
return objClassId; |
} |
if(obj.allSuperClasses) |
{ |
var s; |
for(s in obj.allSuperClasses) |
{ |
var superClass = obj.allSuperClasses[s]; |
var superClassId = superClass.replaceAll(".","_"); |
if($("script#" + superClassId).length > 0) |
{ |
return superClassId; |
} |
} |
} |
return obj["@class"].replaceAll(".","_"); |
} |
$scope.addText = function(parentCustomPane) |
{ |
$scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.TextComponent") |
} |
$scope.addImage = function(parentCustomPane) |
{ |
$scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.ImageComponent") |
} |
$scope.addSimpleDocComponent = function(parentCustomPane,classComponent) |
{ |
if(!parentCustomPane.components) |
{ |
parentCustomPane.components = []; |
} |
parentCustomPane.components.push( |
{ |
"@class" : classComponent |
} |
); |
} |
$scope.removeComponent = function(index,array) |
{ |
array.splice(index,1); |
} |
$scope.callbackUploadedFiles = function(filesUploadResult,token,targetElement) |
{ |
var modelObject = BacoAngularUtils.getAngularElementModel(targetElement); |
if(modelObject.image && modelObject.image.identifier) |
{ |
widgetCallWithActionParameters( |
"<%=request.getContextPath()%>/user/json/repository.do", |
"replaceRepositoryFileFromTempPrivateDomain", |
{ |
"identifier" : modelObject.image.identifier, |
"fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
}, |
"#courseReportApp", |
function(repositoryFile4JsonView) |
{ |
modelObject.image = repositoryFile4JsonView; |
//image URL is generated on reimport just to avoid caching |
modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
angular.element($("#courseReportApp")).scope().$apply(); |
}, |
function(){} |
); |
} |
else |
{ |
widgetCallWithActionParameters( |
"<%=request.getContextPath()%>/user/json/repository.do", |
"saveRepositoryFileFromTempPrivateDomain", |
{ |
"fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0]) |
}, |
"#courseReportApp", |
function(repositoryFile4JsonView) |
{ |
modelObject.image = repositoryFile4JsonView; |
modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime(); |
angular.element($("#courseReportApp")).scope().$apply(); |
}, |
function(){} |
); |
} |
} |
$scope.saveCourseReportDocument = function () { |
widgetCallWithActionParameters( |
"<%=request.getContextPath()%>/user/courseReport.do", |
"saveCourseReportDocument", |
{ |
"courseReportDocument" : BacoJS.stringifyOrdered($scope.report) |
}, |
"#courseReportApp", |
function(data) |
{ |
alert(BacoJS.stringifyOrdered(data)); |
}, |
function(){} |
); |
} |
}); |
</script> |
<!--TEMPLATES FOR DOCUMENT BUILDER--> |
<jsp:include page="documentsBuilder.jsp"/> |
<div class="form-vertical"> |
<div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController"> |
<div class="web-messages"></div> |
<button class="btn btn-success" ng-click="saveCourseReportDocument()">Gravar</button> |
<button class="btn btn-success" onclick="demoFromHTML()">PDF</button> |
<div ng-init="section=report;" ng-include="'pt_estgp_estgweb_utils_documentBuilder_DocumentSection'"> |
</div> |
<!--<pre class="code">{{ report | json }}</pre>--> |
</div><!--App--> |
</div> <!--form--> |
</div><!--Panel Body--> |
</div><!--Panel--> |
</div><!--container-fluid--> |
<% |
//AbstractDao.getCurrentSession().getTransaction().commit(); |
%> |