Subversion Repositories bacoAlunos

Rev

Rev 1679 | Rev 1703 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1675 jmachado 1
<%@ page import="jomm.dao.impl.AbstractDao" %>
2
<%@ page import="pt.estgp.estgweb.domain.RepositoryDocumentCollection" %>
3
<%@ page import="pt.estgp.estgweb.domain.RepositoryDocumentCollectionImpl" %>
4
<%@ page import="pt.estgp.estgweb.domain.RepositoryDocumentImpl" %>
5
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
6
<%@ page import="java.util.List" %>
7
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.IServiceManager" %>
8
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.ServiceManager" %>
9
<%@ page import="org.json.JSONArray" %>
10
<%@ page import="pt.estgp.estgweb.web.utils.RequestUtils" %>
11
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
12
<%@ taglib prefix="bacoTags" tagdir="/WEB-INF/tags" %>
13
<%@ taglib prefix="logic" uri="/WEB-INF/tlds/struts-logic.tld" %>
14
<%@ taglib prefix="baco" uri="/WEB-INF/tlds/baco.tld" %>
15
 
16
<style>
17
    .btn {
18
        margin-right: 8px;
19
    }
20
 
21
    .tree-node,.angular-ui-tree-handle {
22
        background: #f8faff;
23
        border: 1px solid #dae2ea;
24
        color: #7c9eb2;
25
        padding: 10px 10px;
26
    }
27
 
28
    .ui-tree-node
29
    {
30
        padding: 10px;
31
    }
32
    .angular-ui-tree-handle:hover {
33
        color: #438eb9;
34
        background: #f4f6f7;
35
        border-color: #dce2e8;
36
    }
37
 
38
    .angular-ui-tree-placeholder {
39
        background: #f0f9ff;
40
        border: 2px dashed #bed2db;
41
        -webkit-box-sizing: border-box;
42
        -moz-box-sizing: border-box;
43
        box-sizing: border-box;
44
    }
45
 
46
    .nodeEmpty {
47
        height: 50px;
48
        margin:10px;
49
        margin-left: 30px;
50
        border: 1px dashed blue;
51
    }
52
 
53
    .group-title {
54
        background-color: #687074 !important;
55
        color: #FFF !important;
56
    }
57
 
58
 
59
    /* --- Tree --- */
60
    .tree-node {
61
        border: 1px solid #dae2ea;
62
        background: #f8faff;
63
        color: #7c9eb2;
64
    }
65
    .tree-node-document {
1679 jmachado 66
        border: 1px solid #000000;
67
        background: #ffffff;
68
        color: #000000;
1675 jmachado 69
    }
70
    .tree-node-file {
71
        border: 1px solid #e8ea99;
72
        background: #fffae7;
73
        color: #b2a418;
74
    }
75
 
76
    .tree-node-description {
77
        border: 1px dashed #7f7f7e;
78
        background: #e5e5e3;
79
        color: #0d0c01;
80
    }
81
 
82
    .nodrop {
83
        background-color: #f2dede;
84
    }
85
 
86
 
87
    .nodrag {
88
        background-color: #f2eec1;
89
    }
90
 
91
    .tree-node-content {
92
        margin: 10px;
93
    }
94
 
95
 
96
    /*Estilo adicionado por mim para os movidos*/
97
    .moved
98
    {
99
        border: 2px solid blue !important;
100
    }
101
 
102
    .modified
103
    {
104
        border: 4px dashed orange !important;
105
    }
106
</style>
107
<div class="container-fluid">
108
 
109
<%
110
 
111
    IServiceManager sm = ServiceManager.getInstance();
112
    String[] names = new String[]{};
113
    Object[] args = new Object[]{null};
114
    JSONArray roots = (JSONArray) sm.execute(RequestUtils.getRequester(request, response), "OpenRepositoryCollection", args, names);
115
 
116
    AbstractDao.getCurrentSession().beginTransaction();
117
    String collectionsJson = roots.toString();
118
    request.setAttribute("collectionsJson", collectionsJson);
119
 
120
%>
121
 
122
 
123
 
124
 
125
<div id="treeAppPageContent" ng-app="treeAppPageContent" ng-controller="treeAppPageContentController">
126
 
127
 
128
<script>
129
ping();
130
var treeAppPageContent = angular.module('treeAppPageContent', ['ui.tree']);
131
GLOBAL_BacoAngularAppDependencies.push('treeAppPageContent');
132
 
133
<!-- estes codigos todos do remove e do toggle e etc's não mechi em nada limitei-me a copiar dos gajos-->
134
treeAppPageContent.controller('treeAppPageContentController',  function ($scope) {
135
 
136
            $scope.data = ${collectionsJson};
137
 
1679 jmachado 138
            $scope.onlyVisibles = false;
139
 
1675 jmachado 140
            /*
141
             $scope.data = [
142
             {
143
             "id" : 1,
144
             "name" : "Nao deixa fazer drag",
145
             "nodrag" : true,
146
             "isDirectory" : true
147
 
148
             },
149
             {
150
             "id" : 2,
151
             "name" : "Nao deixa fazer drop",
152
             "nodrop" : true,
153
             "isDirectory" : true
154
             },
155
             {
156
             "id" : 3,
157
             "name" : "Deixa fazer Tudo",
158
             "isDirectory" : true
159
             },
160
             {
161
             "id" : 4,
162
             "name" : "Deixa fazer Tudo e ja foi movido",
163
             "moved" : true,
164
             "isDirectory" : true
165
             },
166
             {
167
             "id" : 5,
168
             "name" : "Exemplo de folha nao deixa abrir",
169
             "isDirectory" : false
170
             }
171
             ];*/
172
            $scope.treeOptions = {
173
                accept: function(sourceNodeScope, destNodesScope, destIndex) {
174
 
175
                    return true;
176
                },
177
                dropped: function(e) {
178
                    //console.log (e.source.nodeScope.$modelValue);
179
                    //alert ("Largado o nó com nome: " + e.source.nodeScope.$modelValue.name + " sobre " + e.dest.nodesScope.$parent.$modelValue.name);
180
                }
181
            };
182
 
183
            $scope.openedAndHasNotChilds = function(node)
184
            {
185
                if(node.childs == null)
186
                    return false;
187
                return node.childs.length == 0;
188
            }
189
 
190
            $scope.openItem = function(item)
191
            {
192
                //apenas deixa abrir neste caso
193
                if(item.open && item.open==true)
194
                {
195
                    item.open=false;
196
                    delete item.childs;
197
                    delete item.documents;
198
                }
199
                else
200
                {
201
                    widgetCallWithActionParameters(
202
                            "<%=request.getContextPath()%>/user/repositoryDoc.do",
203
                            "openRepositoryCollection",
204
                            {
205
                                "id" : item.id
206
                            },
207
                            "#treeAppPageContent",
208
                            function(json)
209
                            {
210
                                item.childs = json.collections;
211
                                item.open = true;
212
                                $scope.$apply();
213
                            });
214
 
215
                    widgetCallWithActionParameters(
216
                            "<%=request.getContextPath()%>/user/repositoryDoc.do",
217
                            "openRepositoryCollectionDocuments",
218
                            {
219
                                "id" : item.id
220
                            },
221
                            "#treeAppPageContent",
222
                            function(json)
223
                            {
224
                                item.documents = json.documents;
225
                                item.open = true;
226
                                $scope.$apply();
227
                                $('#treeAppPageContent [data-toggle="tooltip"]').tooltip();
228
                            });
229
 
230
 
231
                }
232
            }
233
            $scope.openDocumentsItem = function(item)
234
            {
235
                var collapseElement = $("#repositoryFiles" + item.id);
236
                if(item.open && item.open==true)
237
                {
238
                    item.open=false;
239
                    collapseElement.collapse("hide");
240
                }
241
                else
242
                {
243
                    item.open=true;
244
                    collapseElement.collapse("show");
245
                }
246
            }
1679 jmachado 247
 
248
 
249
            $scope.hideNode = function(node)
250
            {
251
                if(!node.visible && $scope.onlyVisibles)
252
                    return true;
253
                return false;
254
            }
255
 
256
            //COPIADAS DO ficheiro repositoryDocument.jsp
257
            $scope.setDocumentFileInvisible = function(docFile)
258
            {
259
                docFile.visible=false;
260
                docFile.repositoryFileProxy.repositoryFile.accessControl ="resource.access.privateDomain";
261
            }
262
            $scope.setDocumentFileVisible = function(docFile)
263
            {
264
                docFile.visible=true;
265
                alert("As permissões do ficheiro serão definidas como privadas, por favor escolha as permissões novas.");
266
                docFile.repositoryFileProxy.repositoryFile.accessControl ="resource.access.privateDomain";
267
            }
268
 
269
 
1675 jmachado 270
        }
271
);
272
 
273
</script>
274
 
275
<!--TEMPLATE RECURSIVO-->
276
<script type="text/ng-template" id="childs_renderer.html">
277
    <!--Para nao deixar fazer drag-->
1679 jmachado 278
    <div data-nodrag class="tree-node tree-node-content clearfix" ng-class="{modified: node.modified, nodrop: node.nodrop, nodrag: node.nodrag, moved: node.moved, bacoInvisible: !node.visible, hidden: hideNode(node)}">
1675 jmachado 279
 
1679 jmachado 280
 
281
 
282
 
283
 
1675 jmachado 284
            <a class="btn btn-xs" ng-class="{
285
                                            'btn-default': !node.open,
286
                                            'btn-success': node.open,
287
                                          }"
288
                data-nodrag ng-click="openItem(node)">
289
                            <span
290
                                    class="glyphicon"
291
                                    ng-class="{
292
 
293
                                            'glyphicon-chevron-right': !node.open,
294
                                            'glyphicon-chevron-down': node.open
295
 
296
                                          }">
297
                            </span>
298
            </a>
1679 jmachado 299
 
300
             <span style="margin-right: 5px" class="glyphicon "
301
                   ng-class="{
302
                                                'glyphicon-folder-close': !node.open,
303
                                                'glyphicon-folder-open': node.open,
304
                                              }"
305
                     ></span>
306
 
307
            <label data-toggle="tooltip" title="Esta colecção está oculta!"  ng-show="node.visible == false">
308
                <span class="glyphicon glyphicon-ban-circle"/>
309
            </label>
310
 
311
            {{node.name}}
312
 
313
 
1675 jmachado 314
    </div>
315
 
316
 
1679 jmachado 317
    <ol data-nodrag ui-tree-nodes="" data-nodrop-enabled="true" ng-model="node" ng-class="{hidden: collapsed }">
1675 jmachado 318
        <li ng-repeat="node in node.childs" ui-tree-node ng-include="'childs_renderer.html'">
319
        </li>
320
        <li ng-repeat="node in node.documents" ui-tree-node ng-include="'documents_renderer.html'">
321
        </li>
322
    </ol>
323
 
1679 jmachado 324
 
1675 jmachado 325
</script>
326
 
327
<!--TEMPLATE RECURSIVO-->
328
<script type="text/ng-template" id="documents_renderer.html">
329
    <!--Para nao deixar fazer drag-->
1679 jmachado 330
    <div data-nodrag class="tree-node tree-node-document tree-node-content clearfix" ng-class="{modified: node.modified, nodrop: node.nodrop, nodrag: node.nodrag, moved: node.moved, bacoInvisible: !node.visible, hidden: hideNode(node)}">
1675 jmachado 331
 
1679 jmachado 332
        <a class="btn btn-xs" ng-class="{
333
                                        'btn-default': !node.open,
334
                                        'btn-success': node.open,
335
                                      }"
336
           data-nodrag data-toggle="collapse" ng-click="openDocumentsItem(node)">
337
                        <span
338
                                class="glyphicon"
339
                                ng-class="{
1675 jmachado 340
 
1679 jmachado 341
                                        'glyphicon-chevron-right': !node.open,
342
                                        'glyphicon-chevron-down': node.open
1675 jmachado 343
 
1679 jmachado 344
                                      }">
345
                        </span>
346
        </a>
1675 jmachado 347
 
1679 jmachado 348
        <label data-toggle="tooltip" title="Este documento está oculto!" ng-show="node.visible == false">
349
            <span class="glyphicon glyphicon-ban-circle"/>
350
        </label>
1675 jmachado 351
 
1679 jmachado 352
 
353
 
354
 
355
 
1675 jmachado 356
        <span class="glyphicon glyphicon-file"></span>  {{node.title}}
357
 
358
        <baco:hasRole role="admin,all,repositoryDocs">
359
            <a target="_blank" class="pull-right btn btn-warning btn-xs" href="<%=request.getContextPath()%>/user/editRepositoryDoc.do?repositoryDocumentId={{node.id}}">
360
                <span class="glyphicon glyphicon-pencil"></span>
361
            </a>
362
        </baco:hasRole>
363
    </div>
364
    <div id="repositoryFiles{{node.id}}" class="collapse">
365
 
1679 jmachado 366
       <ol data-nodrag ui-tree-nodes="" data-nodrop-enabled="true" ng-model="node" ng-class="{hidden: collapsed }">
367
           <li >
368
               <div data-nodrag class="tree-node tree-node-description tree-node-content clearfix">
369
                   <div ng-if="node.description">
370
                       <div class="col-md-2" style="text-align: right">
371
                           <span class="glyphicon glyphicon-tag"></span>
372
                           <span class="label label-primary">Descrição:</span>
373
                       </div>
374
                       <div class="col-md-10" style="border: 1px dashed black">
375
                           {{node.description}}
376
                       </div>
377
                   </div>
1675 jmachado 378
 
1679 jmachado 379
                   <div ng-if="node.internalIdentifier">
380
                       <div class="col-md-2" style="text-align: right">
381
                           <span class="glyphicon glyphicon-tag"></span>
382
                           <span class="label label-primary">ID INTERNO:</span>
383
                       </div>
384
                       <div class="col-md-10" style="border: 1px dashed black">
385
                           {{node.internalIdentifier}}
386
                       </div>
387
                   </div>
1675 jmachado 388
 
1679 jmachado 389
                   <div ng-if="node.publishDateStr">
390
                       <div class="col-md-2" style="text-align: right">
391
                           <span class="glyphicon glyphicon-tag"></span>
392
                           <span class="label label-primary">Data de Publicação:</span>
393
                       </div>
394
                       <div class="col-md-10" style="border: 1px dashed black">
395
                           {{node.publishDateStr}}
396
                       </div>
397
                   </div>
1675 jmachado 398
 
1679 jmachado 399
                   <div ng-if="node.closeDateStr">
400
                       <div class="col-md-2" style="text-align: right">
401
                           <span class="glyphicon glyphicon-tag"></span>
402
                           <span class="label label-primary">Data de Fim:</span>
403
                       </div>
404
                       <div class="col-md-10" style="border: 1px dashed black">
405
                           {{node.closeDateStr}}
406
                       </div>
407
                   </div>
1675 jmachado 408
 
1679 jmachado 409
                   <div ng-if="node.authorsJson" ng-repeat="autor in node.authorsJson.persons">
410
                       <div class="col-md-2" style="text-align: right">
411
                           <span class="glyphicon glyphicon-tag"></span>
412
                           <span class="label label-primary">Autor:</span>
413
                       </div>
414
                       <div class="col-md-10" style="border: 1px dashed black">
415
                           {{autor.firstNames}} {{autor.lastName}}
416
                       </div>
417
                   </div>
418
                   <div ng-if="node.contributorsJson" ng-repeat="autor in node.contributorsJson.persons">
419
                       <div class="col-md-2" style="text-align: right">
420
                           <span class="glyphicon glyphicon-tag"></span>
421
                           <span class="label label-primary">Colaborador:</span>
422
                       </div>
423
                       <div class="col-md-10" style="border: 1px dashed black">
424
                           {{autor.firstNames}} {{autor.lastName}}
425
                       </div>
426
                   </div>
427
                   <div ng-if="node.publisher">
428
                       <div class="col-md-2" style="text-align: right">
429
                           <span class="glyphicon glyphicon-tag"></span>
430
                           <span class="label label-primary">Entidade Publicadora:</span>
431
                       </div>
432
                       <div class="col-md-10" style="border: 1px dashed black">
433
                           {{node.publisher}}
434
                       </div>
435
                   </div>
436
               </div>
437
           </li>
1675 jmachado 438
            <li ng-repeat="node in node.repositoryDocumentFiles" ui-tree-node ng-include="'files_renderer.html'">
439
            </li>
440
       </ol>
441
    </div>
442
 
443
</script>
444
 
445
 
446
 
447
<script type="text/ng-template" id="files_renderer.html">
448
    <!--Para nao deixar fazer drag-->
1679 jmachado 449
    <div data-nodrag class="tree-node tree-node-file tree-node-content clearfix" ng-class="{modified: node.modified, nodrop: node.nodrop, nodrag: node.nodrag, moved: node.moved, bacoInvisible: !node.visible, hidden: hideNode(node)}">
1675 jmachado 450
        <label data-toggle="tooltip" title="Este ficheiro está oculto!"  ng-show="node.visible == false">
451
            <span class="glyphicon glyphicon-ban-circle"/>
452
        </label>
453
 
1679 jmachado 454
        <div class="col-md-11">
455
            <div ng-if="node.title">
456
                <div class="col-md-2" style="text-align: right">
457
                    <span class="glyphicon glyphicon-tag"></span>
458
                    <span class="label label-primary">Titulo:</span>
459
                </div>
460
                <div class="col-md-10" style="border: 1px dashed black">
461
                    <i> {{node.title}} </i>
462
                </div>
463
            </div>
464
            <div ng-if="node.description">
465
                <div class="col-md-2" style="text-align: right">
466
                    <span class="glyphicon glyphicon-tag"></span>
467
                    <span class="label label-primary">Descrição:</span>
468
                </div>
469
                <div class="col-md-10" style="border: 1px dashed black">
470
                    <i>{{node.description}}</i>
471
                </div>
472
            </div>
473
            <div class="col-md-12" style="margin-top: 4px">
474
                <span class="glyphicon glyphicon-paperclip"></span>
475
                <bacoTags:repositoryFile btnXs="true" transactional="false" staticTag="true" repositoryStream="{{node.repositoryFileProxy.repositoryStream}}" showHistory="true"/>
476
                {{node.repositoryFileProxy.repositoryFile.lastVersion.name}}
477
                ({{node.repositoryFileProxy.repositoryFile.lastVersion.size / 1024 | number:0}} KB)
478
            </div>
479
        </div>
480
        <div class="col-md-1">
481
            <button data-toggle="tooltip" title="Ocultar ficheiro" ng-show="node.visible == true" class="btn btn-danger pull-right" type="button" ng-click="setDocumentFileInvisible(node)"><span class="glyphicon glyphicon-ban-circle"/></button>
482
            <button data-toggle="tooltip" title="Repor ficheiro" ng-show="node.visible == false" class="btn btn-default pull-right" type="button" ng-click="setDocumentFileVisible(node)"><span class="glyphicon glyphicon-ok-circle"/></button>
483
 
484
            <div ng-if="node.repositoryFileProxy.repositoryFile.accessControl == 'resource.access.publicDomain'">
485
                Público
486
            </div>
487
            <div ng-if="node.repositoryFileProxy.repositoryFile.accessControl == 'resource.access.privateDomain'">
488
                Privado
489
            </div>
490
            <div ng-if="node.repositoryFileProxy.repositoryFile.accessControl == 'resource.access.authenticatedDomain'">
491
                Interno
492
            </div>
493
 
494
 
495
        </div>
1675 jmachado 496
    </div>
497
</script>
498
 
1679 jmachado 499
 
500
 
1675 jmachado 501
<div class="panel panel-default">
502
    <div class="panel-heading clearfix">
503
        Administração de Coleções do Repositório de Documentos Digitais
1679 jmachado 504
 
505
        <baco:hasRole role="admin,all,repositoryDocs">
506
            <select class="chosenOff pull-right" type="text" ng-model="onlyVisibles" ng-options="o.v as o.n for o in [{ n: 'Ver Todos', v: false }, { n: 'Ocultar invisiveis', v: true }]">>
507
            </select>
508
        </baco:hasRole>
1675 jmachado 509
    </div>
510
    <div class="panel-body">
511
 
512
        <div class="web-messages"></div>
513
 
514
 
515
 
1680 jmachado 516
 
1675 jmachado 517
        <div class="row">
518
 
519
            <div class="col-sm-12 form-horizontal">
520
                <div ui-tree="treeOptions" id="page-content-root">
521
                    <ol ui-tree-nodes ng-model="data">
522
                        <li ng-repeat="node in data" ui-tree-node ng-include="'childs_renderer.html'"></li>
523
                    </ol>
524
                </div>
525
            </div>
526
 
527
        </div>
1679 jmachado 528
        <%-- <div class="col-sm-12">
1675 jmachado 529
             <pre class="code">{{ data | json }}</pre>
1679 jmachado 530
         </div>--%>
1675 jmachado 531
    </div>
532
 
533
 
534
</div>
535
</div>
536
 
537
<%--AbstractDao.getCurrentSession().getTransaction().commit();--%>
538
 
539
</div>