Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RequestMapping(value = "/fisicHost/{id}/credentials", method = RequestMethod.GET, produces = APPLICATION_JSON_UTF8_VALUE)
- public List<Credential> credentialsByFisicHost(@PathVariable(value = "id") final Long fisicHostId, ModelMap modelMap){
- FisicHost optionalFisicHost = fisicHostDao.findById(fisicHostId);
- if (optionalFisicHost == null) {
- // Responder con 404
- }
- FisicHost fisicHost = optionalFisicHost;
- return fisicHost.getCredentials();
- }
- <!-- Modal -->
- <div class="modal fade" id="credentialsModal" tabindex="-1" role="dialog" aria-hidden="true">
- <div class="modal-dialog modal-dialog-centered" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="modal-title">Credenciales</h5>
- </div>
- <div class="modal-body">
- <table id="credentialsTable">
- <tr class="row">
- <th id="modal-user">Usuario</th>
- <th id="modal-pass">Clave</th>
- <th id="modal-notes">Notas</th>
- </tr>
- </table>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
- </div>
- </div>
- </div>
- </div>
- $(".credentialsButton").click(function(){
- var fisicHostId = $(this).data('fisic-host-id');
- $.get( "/fisicHost/" + fisicHostId + "/credentials", data => {
- console.log(data);
- $('#credentialsTable').empty();
- // var user = document.createElement('th');
- // user.textContent = "USUARIO";
- for (i = 0; i < data.length; ++i) {
- var fisicHost = data[i];
- var new_row = document.createElement('tr');
- new_row.className = "row fisichost";
- var userCol = document.createElement('td');
- userCol.textContent = fisicHost["user"];
- new_row.append(userCol);
- var passwordCol = document.createElement('td');
- passwordCol.textContent = fisicHost["password"];
- new_row.append(passwordCol);
- var notesCol = document.createElement('td');
- notesCol.textContent = fisicHost["notes"];
- new_row.append(notesCol);
- var editButton = document.createElement('button');
- editButton.textContent = "EDITAR"
- new_row.append(editButton);
- var deleteButton = document.createElement('button');
- deleteButton.id = buttonId;
- deleteButton.textContent = "BORRAR"
- new_row.append(deleteButton);
- $("#credentialsTable").append(new_row);
- // ACA ESTA EL TEMA
- $(deleteButton).on('click', () => {
- var credentialId = fisicHost["id"];
- console.log(credentialId);
- // $.post( "/fisicHost/" + credentialId + "/credentials", data => {});
- });
- }
- $('#credentialsModal').modal('show');
- }).fail(function(xhr, status, error) {
- console.error(error);
- alert('No se pudieron cargar las credenciales.');
- });
- });
- $('#credentialsModal').bind('hide', function () {
- $('#credentialsModal tr.fisichost').remove();
- });
- […]
- 0: {…}
- id: 2
- notes: "notas"
- password: "pass"
- role: "null"
- user: "usuario"
- __proto__: Object { … }
- 1: {…}
- id: 3
- notes: "notasssss"
- password: "pass"
- role: "null"
- user: "usuario"
- __proto__: Object { … }
- length: 2
Add Comment
Please, Sign In to add comment