Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 11.25 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <head>
  4.     <meta name="_csrf" th:content="${_csrf.token}"/>
  5.     <meta name="_csrf_header" th:content="${_csrf.headerName}"/>
  6.     <link rel="stylesheet" href="css/logowanie.css"/>
  7.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
  8.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  9.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  10.     <script src="https://rawgit.com/makeusabrew/bootbox/f3a04a57877cab071738de558581fbc91812dce9/bootbox.js"></script>
  11.     <title>Przekazywanie uprawnień</title>
  12. </head>
  13. <body >
  14.     <div class="container dashboard">
  15.         <h2>Moduł przekazywania uprawnień</h2>
  16.             <h4 th:text="'Aktywny użytkownik: '+${username}"/>
  17.         <h5 th:if="${userPrivileges.getTake()}" style="text-align: right;">Ma prawo przejmij</h5>
  18.             <h4>
  19.                 <form style="display: inline" action="/" method="get">
  20.                     <button type="submit" class="btn btn-md btn-primary">Zarządzaj danymi</button>
  21.                 </form>
  22.                 <form method="get" th:action="@{/adminview}" style="display: inline">
  23.                     <button type="submit" class="btn btn-md btn-primary">Zarządzaj uprawnieniami</button>
  24.                 </form>
  25.                 <form method="post" th:action="@{/logout}">
  26.                     <input type="hidden"
  27.                           th:name="${_csrf.parameterName}"
  28.                           th:value="${_csrf.token}"/>
  29.                     <button type="submit" class="btn btn-md btn-warning">Wyloguj</button>
  30.                 </form>
  31.             </h4>
  32.         <div class="panel panel-default main dashboard" style="padding-left: 12px; padding-top: 0px">
  33.             <div th:if="${!userPrivileges.hasAnyGrantRight()}">
  34.                 <h4 style="text-align: center">Nie masz żadnego prawa, które mógłbyś przekazać!</h4>
  35.             </div>
  36.             <div th:if="${userPrivileges.hasAnyGrantRight()}">
  37.                 <div class="row space-for-div">
  38.                     <div class="col-md-4"></div>
  39.                     <div class="col-md-4">
  40.                         <h4 style="color: green" th:if="${successfullyGranted}">Przekazano poprawnie uprawnienia</h4>
  41.                         <h4 style="color: green" th:if="${successfullyModify}">Zmodyfikowano poprawnie uprawnienia</h4>
  42.                         <h4 style="color: green" th:if="${successfullyGift}">Oddano poprawnie uprawnienia</h4>
  43.                         <h4 style="color: red" th:if="${failedGranted}">Nie można przekazać takiego uprawnienia</h4>
  44.                         <h4 style="color: red" th:if="${noGrants}">Nie wybrano żadnych uprawnień</h4>
  45.  
  46.                     </div>
  47.                     <div class="col-md-4"></div>
  48.                 </div>
  49.                 <form th:action="@{'/privilege/process'}"
  50.                      th:object="${sentPrivilege}"
  51.                      th:method="post"
  52.                      th:id="createForm">
  53.                     <div class="row space-for-div">
  54.                         <div class="col-md-7">
  55.                             <div class="divTable" th:with=" privilegesList = ${privilegeInfo.getColumnNamesInHb()}">
  56.                                 <div class="divTableHeading">
  57.                                     <div class="divTableHead"
  58.                                         th:text="Tabele"></div>
  59.                                     <div class="divTableHead"
  60.                                         th:each=" privilege: ${privilegesList}"
  61.                                         th:text=" ${T(org.springframework.util.StringUtils).capitalize(privilege)}"
  62.                                         th:if="${privilege} != 'id'">
  63.                                     </div>
  64.                                 </div>
  65.                                 <div class="divTableBody">
  66.                                     <div class="divTableRow"
  67.                                         th:with=" capitalizeTableHbName=  ${T(org.springframework.util.StringUtils).capitalize(tableName.getValue())},
  68.                                                grantRights=${'userPrivileges.get'+ capitalizeTableHbName +'().hasAnyGrantRight()'}"
  69.                                         th:each="tableName : ${grantedPrivilegeInfo.getColumnNamesDbHbMap()}"
  70.                                         th:if="${tableName.getKey()} != 'Dawca' and ${tableName.getKey()} != 'Przejmij'"
  71.                                         th:field="*{__${tableName.getValue()}__}">
  72.                                         <div class="divTableName" th:text="${tableName.getKey()}"
  73.                                             th:style="${__${grantRights}__} == false ?'display:none':''"></div>
  74.                                         <div class="divPrivilege" th:each="privilege: ${privilegesList}"
  75.                                             th:style="${__${grantRights}__} == false ?'display:none':''"
  76.                                             th:if="${privilege} != 'id'"
  77.                                             th:with="capitalizedPrivilegeName= ${T(org.springframework.util.StringUtils).capitalize(privilege)},
  78.                                             getterName=${'userPrivileges.get'+ capitalizeTableHbName +'().get'+capitalizedPrivilegeName+'()'}">
  79.                                             <select class=" list yellow rounded"
  80.                                                    th:field="*{__${tableName.getValue() + '.' + privilege}__}">
  81.                                                 <option style="color:gray" th:selected="true"
  82.                                                        th:if="${__${getterName}__} == 'NONE' or ${__${getterName}__} == 'ACCESS'"
  83.                                                        value="NONE">Brak praw
  84.                                                 </option>
  85.                                                 <option th:if="${grantMode} == 'update' or ${grantMode} == 'create' and ${__${getterName}__} == 'GRANT'"
  86.                                                        value="NONE">
  87.                                                     Nie nadawaj
  88.                                                 </option>
  89.                                                 <option th:if="${grantMode} != 'update' and ${grantMode} != 'create' and ${__${getterName}__} == 'GRANT'"
  90.                                                        value="NONE">Nie
  91.                                                     przekazuj
  92.                                                 </option>
  93.                                                 <option th:if="${__${getterName}__} == 'GRANT'" value="ACCESS">Bez
  94.                                                     delegacji
  95.                                                 </option>
  96.                                                 <option th:if="${__${getterName}__} == 'GRANT'" value="GRANT">Z
  97.                                                     delegacją
  98.                                                 </option>
  99.                                             </select>
  100.                                         </div>
  101.                                     </div>
  102.                                 </div>
  103.                             </div>
  104.                         </div>
  105.                         <div class="col-lg-1"></div>
  106.                         <div class="col-md-3">
  107.                             <h5>Wybierz użytkownika</h5>
  108.                             <select id="userSelect" class=" list yellow rounded" th:field="*{receiverName}"
  109.                                    required="required">
  110.                                 <option th:each="user : ${users}" th:value="${user}" th:text="${user}"></option>
  111.                             </select>
  112.                             <div th:if="${userPrivileges.getGrantPrivilegePK() != null and userPrivileges.getGrantPrivilegePK().isAdmin()}">
  113.                                 <h5>Nadaj prawo przejmij</h5>
  114.                                 <select class=" list yellow rounded" th:field="*{take}">
  115.                                     <option th:selected="true" th:value="false">Nie</option>
  116.                                     <option th:value="true">Tak</option>
  117.                                 </select>
  118.                                 <href/>
  119.                             </div>
  120.                         </div>
  121.                         <div class="col-lg-1"></div>
  122.                     </div>
  123.                     <div class="row space-for-div">
  124.                         <div class="col-md-9"></div>
  125.                         <div class="col-md-2">
  126.                             <button id="sendPrivilegeButton" type="submit" th:form="createForm"
  127.                                    class="btn btn-sq btn-block btn-space btn-info" th:text="Wyślij">
  128.                             </button>
  129.                         </div>
  130.                     </div>
  131.                     <input type="hidden" name="grantMode" th:value="${grantMode}"/>
  132.                 </form>
  133.             </div>
  134.         </div>
  135.     </div>
  136.     <script th:inline="javascript">
  137.         /*<![CDATA[*/
  138.        function changeGrantMode(mode) {
  139.            var token = $("meta[name='_csrf']").attr("content");
  140.            //$('body').load("/offering?grantMode=" + mode);
  141.            $.ajax({
  142.                url: "/offering?grantMode=" + mode,
  143.                headers: {'X-CSRF-TOKEN': token},
  144.                type: "GET"
  145.            }).done(function (data) {
  146.                $('body').html(data);
  147.            });
  148.        }
  149.  
  150.        $('#sendPrivilegeButton').click(function (event) {
  151.            event.preventDefault();
  152.            var user = $('#userSelect').find(":selected").text();
  153.            var token = $("meta[name='_csrf']").attr("content");
  154.            //$('body').load("/offering?grantMode=" + mode);
  155.            $.ajax({
  156.                url: "/privilege/checkTake?username=" + user,
  157.                headers: {'X-CSRF-TOKEN': token},
  158.                type: "GET",
  159.                async: false,
  160.                success: function (data) {
  161.                    if (data == true) {
  162.                        bootbox.confirm({
  163.                            message: "<p style='font-size: 22px'>Stracisz wszystkie swoje prawa - użytkownik ma prawo przejmij!</p>",
  164.                            size: "large",
  165.                            callback: function (result) {
  166.                                if (result) $("#createForm").submit();
  167.                            },
  168.                            buttons: {
  169.                                confirm: {
  170.                                    label: 'Potwierdź',
  171.                                    className: 'btn-success',
  172.                                },
  173.                                cancel: {
  174.                                    label: 'Rezygnuj',
  175.                                    className: 'btn-danger'
  176.                                }
  177.                            }
  178.                        });
  179.                    }
  180.                    else $("#createForm").submit();
  181.                },
  182.            }).done(function (data) {
  183.            });
  184.        });
  185.  
  186.        function process() {
  187.            return true;
  188.        }
  189.        /*]]>*/
  190.     </script>
  191. </body>
  192. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement