Blame | Last modification | View Log | RSS feed
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ 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" %>
<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>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src='http://cdnjs.cloudflare.com/ajax/libs/textAngular/1.5.0/textAngular-rangy.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/textAngular/1.5.0/textAngular-sanitize.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/textAngular/1.5.0/textAngular.min.js'></script>
<jsp:useBean id="courseReportJson" type="java.lang.String" scope="request"/>
<jsp:useBean id="course" type="pt.estgp.estgweb.domain.CourseImpl" scope="request"/>
<div class="container-fluid">
<style>
.separatorSection
{
border: 1px solid #ddd;
}
</style>
<!-- Apresentacao da Unidade -->
<div class="panel panel-default" id="document">
<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', ['ngSanitize']);
GLOBAL_BacoAngularAppDependencies.push('courseReportApp');
courseReportApp.controller('courseReportAppController', function ($scope) {
$scope.docAppSelector = "#courseReportApp";
$scope.report = ${courseReportJson}
/**
* @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;
}
/**
* 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.generatePdf = function () {
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', html)[0];
source = $('#document')[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');
}, margins
);
}
});
</script>
<!--TEMPLATES FOR DOCUMENT BUILDER-->
<script type="text/ng-template" id="pt_estgp_estgweb_utils_documentBuilder_CustomPane">
<div class="customComponent clearfix component">
<div class="componentBody">
<div class="clearfix" ng-repeat="subComp in comp.components" ng-init="parent=comp;comp=subComp" ng-include="class2id(subComp)">
</div>
</div>
</div>
</script>
<script type="text/ng-template" id="pt_estgp_estgweb_utils_documentBuilder_ImageComponent">
<div class="imageComponent component">
<div class="componentBody">
<h2>{{ comp.title }}</h2>
<div style="width: {{comp.width}}px;height: {{comp.height}}px; max-width: 500px; max-height: 750px">
<img style="width: 100%;height: 100%" ng-src="{{'<%=request.getContextPath()%>/repositoryStream/' + comp.image.identifier}}">
</div>
</div>
</div>
</script>
<script type="text/ng-template" id="pt_estgp_estgweb_utils_documentBuilder_TextComponent">
<div class="textComponent component">
<div class="componentBody">
<div ng-if="parent['@class']=='pt.estgp.estgweb.utils.documentBuilder.CustomPane'" class="form-group clearfix">
<h2>{{ comp.title }}</h2>
</div>
<p ng-bind-html="comp.text"></p>
</div>
</div>
</script>
<script type="text/ng-template" id="pt_estgp_estgweb_utils_documentBuilder_DocumentSection">
<div class="sections">
<div ng-model="subSection"
ng-repeat="subSection in section.sections">
<h1>{{$chapter}}{{$index+1}} - {{subSection.title}}</h1>
<div ng-repeat="comp in subSection.components"
ng-include="class2id(comp)">
</div>
<div ng-if="subSection.sections"
ng-init="section=subSection;$chapter=$chapter+($index+1)+'.'"
ng-include="class2id(subSection)">
</div>
</div>
</div>
</script>
<script type="text/ng-template" id="index_builder">
<ul>
<li ng-model="section"
ng-repeat="subSection in section.sections">
<p>{{$chapter}}{{$index+1}} - {{subSection.title}}</p>
<ul ng-if="subSection.sections"
ng-init="section=subSection;$chapter=$chapter+($index+1)+'.'"
ng-include="'index_builder'">
</ul>
</li>
</ul>
</script>
<div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController">
<button class="btn btn-success" ng-click="generatePdf()">PDF</button>
<div ng-init="section=report;">
<h1>Índice</h1>
<div ng-include="'index_builder'">
</div>
<div ng-include="'pt_estgp_estgweb_utils_documentBuilder_DocumentSection'">
</div>
</div>
<!--<pre class="code">{{ report | json }}</pre>-->
</div><!--App-->
</div><!--Panel Body-->
</div><!--Panel-->
</div><!--container-fluid-->