Rev 1616 | Rev 1618 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1616 | Rev 1617 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <%@ tag import="jomm.dao.impl.AbstractDao" %> |
1 | <%@ tag import="jomm.dao.impl.AbstractDao" %> |
2 | <%@ tag import="pt.estgp.estgweb.domain.User" %> |
- | |
- | 2 | ||
3 | <%@ tag import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
3 | <%@ tag import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
- | 4 | ||
4 | <%@ tag import="java.util.List" %> |
5 | <%@ tag import="jomm.utils.BytesUtils" %> |
5 | <%@tag description="Tag to Call Ajax Request" pageEncoding="UTF-8"%> |
6 | <%@tag description="Tag to Call Ajax Request" pageEncoding="UTF-8"%> |
6 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
7 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
7 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
8 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
8 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
9 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
9 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
10 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
10 | <%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> |
11 | <%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> |
11 | <%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
12 | <%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
12 | <%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
13 | <%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
- | 14 | <%@taglib prefix="bacoTags" tagdir="/WEB-INF/tags" %> |
|
- | 15 | ||
13 | <%@attribute name="role" type="java.lang.String" required="true" %> |
16 | <%@attribute name="role" type="java.lang.String" required="true" %> |
14 | <%@attribute name="title" type="java.lang.String" required="false" %> |
17 | <%@attribute name="title" type="java.lang.String" required="false" %> |
15 | <%@attribute name="transactional" type="java.lang.Boolean" required="true" %> |
18 | <%@attribute name="transactional" type="java.lang.Boolean" required="true" %> |
- | 19 | <%@attribute name="printOnlyList" type="java.lang.Boolean" required="false" %> |
|
- | 20 | <%@attribute name="ignoreUserId" type="java.lang.Long" required="false" %> |
|
- | 21 | <%@attribute name="useWellTitle" type="java.lang.Boolean" required="false" %> |
|
16 | 22 | ||
17 | - | ||
18 | <% |
- | |
19 | if(!transactional) |
- | |
20 | AbstractDao.getCurrentSession().beginTransaction(); |
- | |
21 | - | ||
22 | List<User> users = DaoFactory.getUserDaoImpl().loadRoleUsers(role); |
- | |
23 | request.setAttribute("users",users); |
- | |
24 | %> |
- | |
25 | <logic:notEmpty name="title"> |
- | |
26 | <h3 class="well well-sm">${title}</h3> |
- | |
27 | </logic:notEmpty> |
- | |
28 | <logic:empty name="title"> |
- | |
29 | <h3 class="well well-sm"><bean:message key="user.role.${role}"/></h3> |
- | |
30 | </logic:empty> |
- | |
31 | <ul> |
- | |
32 | <logic:iterate id="user" name="users" type="pt.estgp.estgweb.domain.UserImpl"> |
- | |
33 | <li>${user.name} (${user.possibleSigesCode})</li> |
- | |
34 | </logic:iterate> |
- | |
35 | </ul> |
- | |
36 | <% |
23 | <% |
37 | if(!transactional) |
- | |
38 | AbstractDao.getCurrentSession().getTransaction().commit(); |
24 | String idTemp = BytesUtils.generateHexKey() + role.replaceAll(" ", "_").replaceAll("\\.","_"); |
39 | %> |
25 | %> |
40 | 26 | ||
- | 27 | <!-- Usar o Angular para Printar os Roles --> |
|
- | 28 | <div class="clearfix"> |
|
- | 29 | ||
- | 30 | <div class="col-md-12" id="printRoleModule<%=idTemp%>" ng-app="printRoleModule<%=idTemp%>" ng-controller="printRoleModuleController<%=idTemp%>"> |
|
- | 31 | ||
- | 32 | <% |
|
- | 33 | if(printOnlyList == null || printOnlyList == false) |
|
- | 34 | { |
|
- | 35 | %> |
|
- | 36 | <logic:notEmpty name="title"> |
|
- | 37 | <h3 <%if(useWellTitle != null && useWellTitle){%>class="well well-sm"<%}%>>${title}</h3> |
|
- | 38 | </logic:notEmpty> |
|
- | 39 | <logic:empty name="title"> |
|
- | 40 | <h3 <%if(useWellTitle != null && useWellTitle){%>class="well well-sm"<%}%>><bean:message key="user.role.${role}"/></h3> |
|
- | 41 | </logic:empty> |
|
- | 42 | <% |
|
- | 43 | } |
|
- | 44 | %> |
|
- | 45 | <div class="col-md-6"> |
|
- | 46 | <ul> |
|
- | 47 | <li ng-repeat="u in roleUsers" class="roleUser{{u.id}}"> |
|
- | 48 | <baco:isAdmin> |
|
- | 49 | <bacoTags:confirm icon="glyphicon glyphicon-remove" btnClass="btn btn-danger btn-xs"> |
|
- | 50 | <jsp:attribute name="targetFunction">removeUser<%=idTemp%>({{u.id}})</jsp:attribute> |
|
- | 51 | <jsp:attribute name="msg">Tem a certeza que deseja remover o utilizador {{u.name}} do grupo <bean:message key="user.role.${role}"/></jsp:attribute> |
|
- | 52 | </bacoTags:confirm> |
|
- | 53 | </baco:isAdmin> |
|
- | 54 | ||
- | 55 | {{u.username}} |
|
- | 56 | <label ng-if="u.name"> |
|
- | 57 | - {{u.name}} |
|
- | 58 | </label> |
|
- | 59 | <label ng-if="u.sigesCode"> |
|
- | 60 | ({{u.sigesCode}}) |
|
- | 61 | </label> |
|
- | 62 | <%--</label>--%> |
|
- | 63 | ||
- | 64 | </li> |
|
- | 65 | </ul> |
|
- | 66 | </div> |
|
- | 67 | <baco:isAdmin> |
|
- | 68 | <div class="col-md-6"> |
|
- | 69 | ||
- | 70 | <div class="panel panel-default"> |
|
- | 71 | <div class="panel-heading"> |
|
- | 72 | Adicionar elemento ao grupo <bean:message key="user.role.${role}"/> |
|
- | 73 | </div> |
|
- | 74 | <div class="panel-body"> |
|
- | 75 | <div class="web-messages"> </div> |
|
- | 76 | ||
- | 77 | <div class="input-group"> |
|
- | 78 | <input type="text" id="queryPersons<%=idTemp%>" class="form-control" placeholder="Pesquisar..."> |
|
- | 79 | <span class="input-group-btn"> |
|
- | 80 | <button class="btn btn-secondary" type="button" onclick="searchPersons<%=idTemp%>();return false;"><span class="glyphicon glyphicon-search"/></button> |
|
- | 81 | </span> |
|
- | 82 | </div> |
|
- | 83 | <div ng-show="findUser.length > 0" class="clearfix" id="personsResults<%=idTemp%>" style="position: absolute; background-color: gray;border: 1px solid gray;z-index: 1000; right: 30px;left:30px;"> |
|
- | 84 | <div class="clearfix" style="padding:0"> |
|
- | 85 | <table class="tablesorter-blue" style="margin:0"> |
|
- | 86 | <thead> |
|
- | 87 | <tr> |
|
- | 88 | <th>Nome</th> |
|
- | 89 | <th>Tipo</th> |
|
- | 90 | <th>Código</th> |
|
- | 91 | <th><button ng-click="removeAllUsers()" type="button" class="btn btn-danger btn-xs pull-right clearfix"><span class="glyphicon glyphicon-remove"/></button></th> |
|
- | 92 | </tr> |
|
- | 93 | </thead> |
|
- | 94 | <tbody> |
|
- | 95 | <tr ng-repeat="f in findUser"> |
|
- | 96 | <td>{{f.name}}</td> |
|
- | 97 | <td ng-if="f.type == 'student'"> |
|
- | 98 | Estudante |
|
- | 99 | </td> |
|
- | 100 | <td ng-if="f.type == 'teacher'"> |
|
- | 101 | Professor |
|
- | 102 | </td> |
|
- | 103 | <td ng-if="f.type != 'teacher' && f.type != 'student'"> |
|
- | 104 | User |
|
- | 105 | </td> |
|
- | 106 | <td>{{f.sigesCode}}</td> |
|
- | 107 | </tr> |
|
- | 108 | </tbody> |
|
- | 109 | </table> |
|
- | 110 | </div> |
|
- | 111 | </div> |
|
- | 112 | ||
- | 113 | </div> |
|
- | 114 | </div> |
|
- | 115 | ||
- | 116 | <script> |
|
- | 117 | //DECLARACAO DA APLICACAO LOCAL EM ANGULAR |
|
- | 118 | var printRoleModule<%=idTemp%> = angular.module('printRoleModule<%=idTemp%>', []); |
|
- | 119 | GLOBAL_BacoAngularAppDependencies.push('printRoleModule<%=idTemp%>'); |
|
- | 120 | printRoleModule<%=idTemp%>.controller('printRoleModuleController<%=idTemp%>', function($scope) { |
|
- | 121 | //variavel para a pesquisa de users |
|
- | 122 | $scope.findUser = []; |
|
- | 123 | $scope.roleUsers = []; |
|
- | 124 | $scope.removeAllUsers = function() |
|
- | 125 | { |
|
- | 126 | $scope.findUser = []; |
|
- | 127 | } |
|
- | 128 | }); |
|
- | 129 | </script> |
|
- | 130 | <script language="javascript"> |
|
- | 131 | ||
- | 132 | $(document).ready(function() |
|
- | 133 | { |
|
- | 134 | loadUserRoles<%=idTemp%>(); |
|
- | 135 | }); |
|
- | 136 | ||
- | 137 | function removeUser<%=idTemp%>(id) |
|
- | 138 | { |
|
- | 139 | widgetCallWithActionParameters( |
|
- | 140 | '<%=request.getContextPath()%>/user/json/model.do', |
|
- | 141 | 'removeRole2User', |
|
- | 142 | { |
|
- | 143 | q : |
|
- | 144 | "{ userId : " + id + ", role : '${role}' }" |
|
- | 145 | } |
|
- | 146 | , |
|
- | 147 | $("#printRoleModule<%=idTemp%>"), |
|
- | 148 | function(response) |
|
- | 149 | { |
|
- | 150 | angular.element($("#printRoleModule<%=idTemp%>")).scope().roleUsers = response.results; |
|
- | 151 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
|
- | 152 | }, |
|
- | 153 | function(response) |
|
- | 154 | { |
|
- | 155 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
|
- | 156 | }); |
|
- | 157 | ||
- | 158 | } |
|
- | 159 | function loadUserRoles<%=idTemp%>() |
|
- | 160 | { |
|
- | 161 | widgetCallWithActionParameters( |
|
- | 162 | '<%=request.getContextPath()%>/user/json/model.do', |
|
- | 163 | 'findUserRoles', |
|
- | 164 | { |
|
- | 165 | q : "${role}" |
|
- | 166 | } |
|
- | 167 | , |
|
- | 168 | $("#printRoleModule<%=idTemp%>"), |
|
- | 169 | function(response) |
|
- | 170 | { |
|
- | 171 | angular.element($("#printRoleModule<%=idTemp%>")).scope().roleUsers = response.results; |
|
- | 172 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
|
- | 173 | }, |
|
- | 174 | function(response) |
|
- | 175 | { |
|
- | 176 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
|
- | 177 | }); |
|
- | 178 | } |
|
- | 179 | ||
- | 180 | function searchPersons<%=idTemp%>() |
|
- | 181 | { |
|
- | 182 | ||
- | 183 | widgetCallWithActionParameters( |
|
- | 184 | '<%=request.getContextPath()%>/user/json/model.do', |
|
- | 185 | 'findUser', |
|
- | 186 | { |
|
- | 187 | q : $('#queryPersons<%=idTemp%>').val() |
|
- | 188 | } |
|
- | 189 | , |
|
- | 190 | $("#printRoleModule<%=idTemp%>"), |
|
- | 191 | function(response) |
|
- | 192 | { |
|
- | 193 | angular.element($("#printRoleModule<%=idTemp%>")).scope().findUser = response.results; |
|
- | 194 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
|
- | 195 | setTimeout(function() { evaluateTableSortersInside("#personsResults<%=idTemp%>"); }, 500); |
|
- | 196 | ||
- | 197 | //evaluateTableSortersInside("#personsResults"); |
|
- | 198 | }, |
|
- | 199 | function(response) |
|
- | 200 | { |
|
- | 201 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
|
- | 202 | }); |
|
- | 203 | ||
- | 204 | } |
|
- | 205 | ||
- | 206 | </script> |
|
- | 207 | </div> |
|
- | 208 | </baco:isAdmin> |
|
- | 209 | </div> |
|
- | 210 | </div> |
|
41 | 211 |