UNPKG

auth-center

Version:
121 lines (119 loc) 4.25 kB
{% extends './layout.html' %} {% block head %} <title>Roles</title> {% endblock %} {% block content %} {% if messages.success %} <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button> {{messages.success}} </div> {% endif %} {% if messages.error %} <div class="alert alert-warning"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button> {{messages.error}} </div> {% endif %} <div class="clearfix mb-3"> <button type="button" class="btn btn-success float-right" data-toggle="modal" data-target="#roleModal"> Add Role </button> <form action="?" class="form-inline" method="GET"> <div class="form-group mr-sm-2"> <input type="text" name="q" value="{{query}}" class="form-control" style="width: 200px;" placeholder="Email"> </div> <div class="form-group mr-sm-2"> <select class="form-control" name="client"> <option value="">All clients</option> {% for c in clients %} <option value="{{c.id}}" {{ "selected" if client==c.id }}>{{c.name}}</option> {% endfor %} </select> </div> <button type="submit" class="btn btn-primary">Search</button> </form> </div> <table class="table"> <thead> <tr> <th>User</th> <th>Client</th> <th>Role</th> <th>Operation</th> </tr> </thead> <tbody> {% if roles.rows.length == 0 %} <tr> <td colspan="4" class="text-center">No data available in table</td> </tr> {% else %} {% for d in roles.rows %} <tr> <td>{{userMap[d.user_id]}}</td> <td>{{clientMap[d.client_id]}}</td> <td>{{d.role}}</td> <td> <form action="{{_routes.admin.delete_role}}" method="post"> <input type="hidden" name="_csrf" value="{{_csrf}}"> <input type="hidden" name="id" value="{{d.id}}"> <button class="btn btn-danger btn-sm" type="submit">Delete</button> </form> </td> </tr> {% endfor %} {% endif %} </tbody> </table> <nav> {{pagination(page, total, link) | safe}} </nav> <div class="modal fade" id="roleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="myModalLabel">Add New Role</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <form action="{{_routes.admin.add_role}}" method="post"> <input type="hidden" name="_csrf" value="{{_csrf}}"> <div class="modal-body"> <div class="form-group"> <label for="recipient-name" class="control-label">User</label> <div id="J_userList" class="dropdown" data-url="{{_routes.admin.search_user}}"> <input type="text" name="email" class="form-control" autocomplete="off" placeholder="Select email"> <div class="dropdown-menu w-100"></div> </div> </div> <div class="form-group"> <label for="recipient-name" class="control-label">Client</label> <select class="form-control" name="client"> {% for c in clients %} <option value="{{c.id}}">{{c.name}}</option> {% endfor %} </select> </div> <div class="form-group"> <label for="recipient-name" class="control-label">Role</label> <select class="form-control" name="role"> {% for r in dics %} <option value="{{r.name}}">{{r.name}}</option> {% endfor %} </select> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> <button type="submit" class="btn btn-primary">Submit</button> </div> </form> </div> </div> </div> {% endblock %} {% block foot %} <script src="{{staticRoot}}/roles.js"></script> {% endblock %}