Subversion Repositories bacoAlunos

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1934 grupo2 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
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.css">
11
<script src="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.min.js"></script>
12
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/flora-commons/flora.resizable.css">
13
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>-->
14
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.debug.js"></script>
15
 
16
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
17
<script src='http://cdnjs.cloudflare.com/ajax/libs/textAngular/1.5.0/textAngular-rangy.min.js'></script>
18
<script src='http://cdnjs.cloudflare.com/ajax/libs/textAngular/1.5.0/textAngular-sanitize.min.js'></script>
19
<script src='http://cdnjs.cloudflare.com/ajax/libs/textAngular/1.5.0/textAngular.min.js'></script>
20
 
21
<jsp:useBean id="courseReportJson" type="java.lang.String" scope="request"/>
22
<jsp:useBean id="course" type="pt.estgp.estgweb.domain.CourseImpl" scope="request"/>
23
 
24
<div class="container-fluid">
25
 
26
    <style>
27
        .separatorSection
28
        {
29
            border: 1px solid #ddd;
30
        }
31
    </style>
32
 
33
 
34
    <!-- Apresentacao da Unidade -->
35
 
36
    <div class="panel panel-default" id="document">
37
        <div class="panel-heading">
38
            Relatório Anual do curso: ${course.name}
39
        </div>
40
        <div class="panel-body">
41
 
42
            <p><b class="label-info">Tipo de Curso:</b> <bean:message key="course.${course.degree}"/></p>
43
            <p><b class="label-info">Ano Lectivo:</b> ${course.importYear}</p>
44
            <p><b class="label-info">Departamento:</b> ${course.department.name}</p>
45
            <p><b class="label-info">Escola:</b> ${course.department.courseSchool.name}</p>
46
 
47
            <script>
48
                //Especifico da aplicacao
49
                var courseReportApp = angular.module('courseReportApp', ['ngSanitize']);
50
                GLOBAL_BacoAngularAppDependencies.push('courseReportApp');
51
 
52
 
53
                courseReportApp.controller('courseReportAppController', function ($scope) {
54
                    $scope.docAppSelector = "#courseReportApp";
55
                    $scope.report = ${courseReportJson}
56
 
57
                        /**
58
                         * @classe class to match
59
                         * @superClasses array of strings
60
                         * */
61
                        $scope.contains = function (obj, classe) {
62
                            if (obj['@class'] && obj['@class'] == classe)
63
                                return true;
64
                            if (obj.allSuperClasses) {
65
                                for (var i in obj.allSuperClasses) {
66
                                    if (classe == obj.allSuperClasses[i])
67
                                        return true;
68
                                }
69
                            }
70
                            return false;
71
                        }
72
 
73
                    /**
74
                     * Este metodo devolve o template mais profundo na hierarquia de classes
75
                     * permitindo emular o override, quanto mais especifica for a classe
76
                     * e caso exista template é esse o template devolvido
77
                     * procura um script com o id da classe e se nao existir
78
                     * vai subindo nas super classes
79
                     * @param obj
80
                     * @returns {*}
81
                     */
82
                    $scope.class2id = function (obj) {
83
                        var objClassId = obj["@class"].replaceAll(".", "_");
84
                        if ($("script#" + objClassId).length > 0) {
85
                            return objClassId;
86
                        }
87
                        if (obj.allSuperClasses) {
88
                            var s;
89
                            for (s in obj.allSuperClasses) {
90
                                var superClass = obj.allSuperClasses[s];
91
                                var superClassId = superClass.replaceAll(".", "_");
92
                                if ($("script#" + superClassId).length > 0) {
93
                                    return superClassId;
94
                                }
95
                            }
96
                        }
97
                        return obj["@class"].replaceAll(".", "_");
98
                    }
99
 
100
                    $scope.generatePdf = function () {
101
                        var pdf = new jsPDF('p', 'pt', 'letter');
102
                        // source can be HTML-formatted string, or a reference
103
                        // to an actual DOM element from which the text will be scraped.
104
                        //source = $('#courseReportApp', html)[0];
105
                        source = $('#document')[0];
106
 
107
                        // we support special element handlers. Register them with jQuery-style
108
                        // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
109
                        // There is no support for any other type of selectors
110
                        // (class, of compound) at this time.
111
                        specialElementHandlers = {
112
                            // element with id of "bypass" - jQuery style selector
113
                            '#bypassme': function (element, renderer) {
114
                                // true = "handled elsewhere, bypass text extraction"
115
                                return true
116
                            }
117
                        };
118
                        margins = {
119
                            top: 80,
120
                            bottom: 60,
121
                            left: 40,
122
                            width: 522
123
                        };
124
                        // all coords and widths are in jsPDF instance's declared units
125
                        // 'inches' in this case
126
                        pdf.fromHTML(
127
                            source, // HTML string or DOM elem ref.
128
                            margins.left, // x coord
129
                            margins.top, { // y coord
130
                                'width': margins.width, // max width of content on PDF
131
                                'elementHandlers': specialElementHandlers
132
                            },
133
 
134
                            function (dispose) {
135
                                // dispose: object with X, Y of the last line add to the PDF
136
                                //          this allow the insertion of new lines after html
137
                                var pdfDocument = pdf.save('Test.pdf');
138
                            }, margins
139
                        );
140
                    }
141
                });
142
            </script>
143
 
144
            <!--TEMPLATES FOR DOCUMENT BUILDER-->
145
            <script type="text/ng-template" id="pt_estgp_estgweb_utils_documentBuilder_CustomPane">
146
                <div class="customComponent clearfix component">
147
                    <div class="componentBody">
148
                        <div class="clearfix" ng-repeat="subComp in comp.components" ng-init="parent=comp;comp=subComp" ng-include="class2id(subComp)">
149
 
150
                        </div>
151
                    </div>
152
                </div>
153
            </script>
154
 
155
            <script type="text/ng-template" id="pt_estgp_estgweb_utils_documentBuilder_ImageComponent">
156
                <div class="imageComponent component">
157
                    <div class="componentBody">
158
                        <h2>{{ comp.title }}</h2>
159
                        <div style="width: {{comp.width}}px;height: {{comp.height}}px; max-width: 500px; max-height: 750px">
160
                            <img style="width: 100%;height: 100%"  ng-src="{{'<%=request.getContextPath()%>/repositoryStream/' + comp.image.identifier}}">
161
                        </div>
162
                    </div>
163
                </div>
164
            </script>
165
 
166
            <script type="text/ng-template" id="pt_estgp_estgweb_utils_documentBuilder_TextComponent">
167
                <div class="textComponent component">
168
                    <div class="componentBody">
169
                        <div ng-if="parent['@class']=='pt.estgp.estgweb.utils.documentBuilder.CustomPane'" class="form-group clearfix">
170
                            <h2>{{ comp.title }}</h2>
171
                        </div>
172
                        <p ng-bind-html="comp.text"></p>
173
                    </div>
174
                </div>
175
            </script>
176
 
177
            <script type="text/ng-template" id="pt_estgp_estgweb_utils_documentBuilder_DocumentSection">
178
                <div class="sections">
179
                    <div ng-model="subSection"
180
                         ng-repeat="subSection in section.sections">
181
                        <h1>{{$chapter}}{{$index+1}} - {{subSection.title}}</h1>
182
                        <div ng-repeat="comp in subSection.components"
183
                             ng-include="class2id(comp)">
184
                        </div>
185
                        <div ng-if="subSection.sections"
186
                             ng-init="section=subSection;$chapter=$chapter+($index+1)+'.'"
187
                             ng-include="class2id(subSection)">
188
                        </div>
189
                    </div>
190
                </div>
191
            </script>
192
 
193
            <script type="text/ng-template" id="index_builder">
194
                <ul>
195
                    <li ng-model="section"
196
                        ng-repeat="subSection in section.sections">
197
                        <p>{{$chapter}}{{$index+1}} - {{subSection.title}}</p>
198
                        <ul ng-if="subSection.sections"
199
                            ng-init="section=subSection;$chapter=$chapter+($index+1)+'.'"
200
                            ng-include="'index_builder'">
201
                        </ul>
202
                    </li>
203
                </ul>
204
            </script>
205
 
206
 
207
            <div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController">
208
                <button class="btn btn-success" ng-click="generatePdf()">PDF</button>
209
                <div ng-init="section=report;">
210
                    <h1>Índice</h1>
211
                    <div ng-include="'index_builder'">
212
 
213
                    </div>
214
 
215
                    <div ng-include="'pt_estgp_estgweb_utils_documentBuilder_DocumentSection'">
216
 
217
                    </div>
218
                </div>
219
 
220
 
221
                <!--<pre class="code">{{ report | json }}</pre>-->
222
 
223
            </div><!--App-->
224
 
225
        </div><!--Panel Body-->
226
 
227
    </div><!--Panel-->
228
 
229
</div><!--container-fluid-->