Skip to content

Commit 960566d

Browse files
committed
feat: allow super admins to update users profile
1 parent 4a7cb6b commit 960566d

11 files changed

+209
-19
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<p align="center">
2-
<img alt="Lynx Logo" src="/assets/img/logo.png?v=0.11.17" width="250" />
2+
<img alt="Lynx Logo" src="/assets/img/logo.png?v=0.12.0" width="250" />
33
<h3 align="center">Lynx</h3>
44
<p align="center">A Fast, Secure and Reliable Terraform Backend, Set up in Minutes.</p>
55
<p align="center">
66
<a href="https://github.com/Clivern/Lynx/actions/workflows/ci.yml">
77
<img src="https://github.com/Clivern/Lynx/actions/workflows/server_ci.yml/badge.svg"/>
88
</a>
99
<a href="https://github.com/Clivern/Lynx/releases">
10-
<img src="https://img.shields.io/badge/Version-0.11.17-1abc9c.svg">
10+
<img src="https://img.shields.io/badge/Version-0.12.0-1abc9c.svg">
1111
</a>
1212
<a href="https://hub.docker.com/r/clivern/lynx/tags">
13-
<img src="https://img.shields.io/badge/Docker-0.11.17-1abc9c.svg">
13+
<img src="https://img.shields.io/badge/Docker-0.12.0-1abc9c.svg">
1414
</a>
1515
<a href="https://github.com/Clivern/terraform-provider-lynx">
1616
<img src="https://img.shields.io/badge/Terraform-Provider-yellow.svg">

api.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ info:
77
license:
88
name: MIT License
99
url: https://github.com/Clivern/Lynx/blob/main/LICENSE
10-
version: 0.11.17
10+
version: 0.12.0
1111
externalDocs:
1212
description: Find out more about lynx
1313
url: https://github.com/Clivern/Lynx

docker-compose-cluster.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3.8'
22

33
services:
44
app1:
5-
image: clivern/lynx:0.11.17
5+
image: clivern/lynx:0.12.0
66
environment:
77
APP_NAME: Lynx
88
APP_PORT: 4001
@@ -27,7 +27,7 @@ services:
2727
- db
2828

2929
app2:
30-
image: clivern/lynx:0.11.17
30+
image: clivern/lynx:0.12.0
3131
environment:
3232
APP_NAME: Lynx
3333
APP_PORT: 4002
@@ -52,7 +52,7 @@ services:
5252
- db
5353

5454
app3:
55-
image: clivern/lynx:0.11.17
55+
image: clivern/lynx:0.12.0
5656
environment:
5757
APP_NAME: Lynx
5858
APP_PORT: 4003

docker-compose-nginx.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3.8'
22

33
services:
44
app:
5-
image: clivern/lynx:0.11.17
5+
image: clivern/lynx:0.12.0
66
environment:
77
APP_NAME: Lynx
88
APP_PORT: 4000

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3.8'
22

33
services:
44
app:
5-
image: clivern/lynx:0.11.17
5+
image: clivern/lynx:0.12.0
66
environment:
77
APP_NAME: Lynx
88
APP_PORT: 4000

docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ hero:
2121
icon: edit
2222

2323
download_link:
24-
label: Latest Release v0.11.17
25-
url: https://github.com/Clivern/Lynx/releases/tag/0.11.17
24+
label: Latest Release v0.12.0
25+
url: https://github.com/Clivern/Lynx/releases/tag/0.12.0
2626

2727
features:
2828
rows:

lib/lynx_web/router.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ defmodule LynxWeb.Router do
133133

134134
defp add_server_header(conn, _opts) do
135135
conn
136-
|> put_resp_header("x-server-version", "lynx/0.11.17")
136+
|> put_resp_header("x-server-version", "lynx/0.12.0")
137137
end
138138

139139
# Enables LiveDashboard only for development

lib/lynx_web/templates/page/teams.html.heex

+63-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
new_team: '<%= gettext "Team created successfully!" %>',
44
delete_team_message: '<%= gettext "Team deleted successfully!" %>',
55
delete_team_alert: '<%= gettext "You are trying to delete a team! are you sure?" %>',
6-
delete_team_endpoint: '<%= Routes.team_path(@conn, :delete, "UUID") %>'
6+
delete_team_endpoint: '<%= Routes.team_path(@conn, :delete, "UUID") %>',
7+
update_team_endpoint: '<%= Routes.team_path(@conn, :update, "UUID") %>'
78
}
89
</script>
910

@@ -294,7 +295,8 @@
294295
<td style="text-align: center">${formatDatetime(team.createdAt)}</td>
295296
<td>
296297
<!--
297-
<button @click="editTeamAction(team.id)" class="btn btn-dashed btn-sm text-black-100 border-black-100 hp-hover-text-color-black-80 hp-hover-border-color-black-80"><%= gettext "Edit" %></button>-->
298+
<button @click="editTeamAction(team.id)" class="btn btn-dashed btn-sm text-black-100 border-black-100 hp-hover-text-color-black-80 hp-hover-border-color-black-80" data-bs-toggle="modal" data-bs-target="#edit_team_modal"><%= gettext "Edit" %></button>
299+
-->
298300
<button @click="deleteTeamAction(team.id)" class="btn btn-dashed btn-sm text-danger border-danger hp-hover-text-color-danger-2 hp-hover-border-color-danger-2"><%= gettext "Delete" %></button>
299301
</td>
300302
</tr>
@@ -391,7 +393,66 @@
391393
</div>
392394
</div>
393395
</div>
396+
<!--
397+
<div class="modal fade" id="edit_team_modal" tabindex="-1" aria-labelledby="editTeamLabel" aria-hidden="true" data-action={Routes.user_path(@conn, :list)}>
398+
<div class="modal-dialog modal-dialog-centered">
399+
<div class="modal-content">
400+
<div class="modal-header py-16 px-24">
401+
<h5 class="modal-title" id="editTeamLabel"><%= gettext "Edit Team" %></h5>
402+
<button type="button" class="btn-close hp-bg-none d-flex align-items-center justify-content-center" data-bs-dismiss="modal" aria-label="Close">
403+
<i class="ri-close-line hp-text-color-dark-0 lh-1" style="font-size: 24px;"></i>
404+
</button>
405+
</div>
394406
407+
<div class="divider m-0"></div>
408+
409+
<form id="update_team_form" action={Routes.team_path(@conn, :update, "UUID")} method="post" v-on:submit.prevent="updateTeamAction">
410+
<input type="hidden" value="" name="uuid">
411+
<div class="modal-body">
412+
<div class="row gx-8">
413+
<div class="col-12">
414+
<div class="mb-24">
415+
<label class="form-label"><%= gettext "Name" %></label>
416+
<input type="text" v-model="teamName" @input="slugifyTeamName" class="form-control" name="name" required="required" minlength="2" maxlength="60">
417+
</div>
418+
</div>
419+
420+
<div class="col-12">
421+
<div class="mb-24">
422+
<label class="form-label"><%= gettext "Slug" %></label>
423+
<input type="text" v-model="teamSlug" class="form-control" name="slug" required="required" minlength="2" maxlength="60">
424+
</div>
425+
</div>
426+
427+
<div class="col-12">
428+
<div class="mb-24">
429+
<label class="form-label"><%= gettext "Description" %></label>
430+
<textarea name="description" class="form-control" required="required" minlength="2" maxlength="250"></textarea>
431+
</div>
432+
</div>
433+
434+
<div class="col-12">
435+
<div class="mb-24">
436+
<label class="form-label"><%= gettext "Members" %></label>
437+
<select class="form-select" multiple name="members" required="required">
438+
<template v-for="user in users">
439+
<option :value="user.id">${user.name} (${user.email})</option>
440+
</template>
441+
</select>
442+
</div>
443+
</div>
444+
</div>
445+
</div>
446+
447+
<div class="modal-footer pt-0 px-24 pb-24">
448+
<div class="divider"></div>
449+
<button type="submit" class="m-0 btn btn-primary w-100" :disabled="isInProgress"><%= gettext "Submit" %></button>
450+
</div>
451+
</form>
452+
</div>
453+
</div>
454+
</div>
455+
-->
395456
</div>
396457

397458
<footer class="w-100 py-18 px-16 py-sm-24 px-sm-32 hp-bg-color-black-20 hp-bg-color-dark-90">

lib/lynx_web/templates/page/users.html.heex

+62-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
var _globals = {
33
new_user: '<%= gettext "User created successfully!" %>',
44
delete_user_message: '<%= gettext "User deleted successfully!" %>',
5+
update_user_message: '<%= gettext "User updated successfully!" %>',
56
delete_user_alert: '<%= gettext "You are trying to delete a user! are you sure?" %>',
6-
delete_user_endpoint: '<%= Routes.user_path(@conn, :delete, "UUID") %>'
7+
delete_user_endpoint: '<%= Routes.user_path(@conn, :delete, "UUID") %>',
8+
update_user_endpoint: '<%= Routes.user_path(@conn, :update, "UUID") %>'
79
}
810
</script>
911

@@ -293,8 +295,7 @@
293295
<td style="text-align: center">${user.role}</td>
294296
<td style="text-align: center">${formatDatetime(user.createdAt)}</td>
295297
<td>
296-
<!--
297-
<button @click="editUserAction(user.id)" class="btn btn-dashed btn-sm text-black-100 border-black-100 hp-hover-text-color-black-80 hp-hover-border-color-black-80"><%= gettext "Edit" %></button>-->
298+
<button @click="editUserAction(user.id)" class="btn btn-dashed btn-sm text-black-100 border-black-100 hp-hover-text-color-black-80 hp-hover-border-color-black-80" data-bs-toggle="modal" data-bs-target="#edit_user_modal"><%= gettext "Edit" %></button>
298299
<button @click="deleteUserAction(user.id)" class="btn btn-dashed btn-sm text-danger border-danger hp-hover-text-color-danger-2 hp-hover-border-color-danger-2"><%= gettext "Delete" %></button>
299300
</td>
300301
</tr>
@@ -390,6 +391,64 @@
390391
</div>
391392
</div>
392393

394+
<div class="modal fade" id="edit_user_modal" tabindex="-1" aria-labelledby="editUserLabel" aria-hidden="true">
395+
<div class="modal-dialog modal-dialog-centered">
396+
<div class="modal-content">
397+
<div class="modal-header py-16 px-24">
398+
<h5 class="modal-title" id="editUserLabel"><%= gettext "Edit User" %></h5>
399+
<button type="button" class="btn-close hp-bg-none d-flex align-items-center justify-content-center" data-bs-dismiss="modal" aria-label="Close">
400+
<i class="ri-close-line hp-text-color-dark-0 lh-1" style="font-size: 24px;"></i>
401+
</button>
402+
</div>
403+
404+
<div class="divider m-0"></div>
405+
406+
<form id="update_user_form" action={Routes.user_path(@conn, :update, "UUID")} method="post" v-on:submit.prevent="updateUserAction">
407+
<input type="hidden" value="" name="uuid">
408+
<div class="modal-body">
409+
<div class="row gx-8">
410+
<div class="col-12">
411+
<div class="mb-24">
412+
<label class="form-label"><%= gettext "Nick Name" %></label>
413+
<input type="text" class="form-control" name="name" required="required" minlength="2" maxlength="60">
414+
</div>
415+
</div>
416+
417+
<div class="col-12">
418+
<div class="mb-24">
419+
<label class="form-label"><%= gettext "Role" %></label>
420+
<select class="form-select" name="role" required="required">
421+
<option value="regular" selected><%= gettext "Regular" %></option>
422+
<option value="super"><%= gettext "Super" %></option>
423+
</select>
424+
</div>
425+
</div>
426+
427+
<div class="col-12">
428+
<div class="mb-24">
429+
<label class="form-label"><%= gettext "Email" %></label>
430+
<input type="email" class="form-control" name="email" required="required">
431+
</div>
432+
</div>
433+
434+
<div class="col-12">
435+
<div class="mb-24">
436+
<label class="form-label"><%= gettext "New Password" %></label>
437+
<input type="password" class="form-control" name="password">
438+
</div>
439+
</div>
440+
</div>
441+
</div>
442+
443+
<div class="modal-footer pt-0 px-24 pb-24">
444+
<div class="divider"></div>
445+
<button type="submit" class="m-0 btn btn-primary w-100" :disabled="isInProgress"><%= gettext "Submit" %></button>
446+
</div>
447+
</form>
448+
</div>
449+
</div>
450+
</div>
451+
393452
</div>
394453

395454
<footer class="w-100 py-18 px-16 py-sm-24 px-sm-32 hp-bg-color-black-20 hp-bg-color-dark-90">

mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
defmodule Lynx.MixProject do
66
use Mix.Project
77

8-
@version "0.11.17"
8+
@version "0.12.0"
99

1010
def get_version, do: @version
1111

priv/static/theme/app/backend.js

+71-1
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ lynx_app.teams_list = (Vue, axios, $) => {
433433
methods: {
434434
editTeamAction(id) {
435435
console.log("Edit team with ID:", id);
436+
//$('input[name="uuid"]').val(id);
437+
//$('form#update_team_form').attr('action', function(i, val) {
438+
// return val.replace('UUID', id);
439+
//});
436440
},
437441

438442
formatDatetime(datatime) {
@@ -520,7 +524,21 @@ lynx_app.users_list = (Vue, axios, $) => {
520524
},
521525
methods: {
522526
editUserAction(id) {
523-
console.log("Edit user with ID:", id);
527+
$('input[name="uuid"]').val(id);
528+
$('form#update_user_form').attr('action', function(i, val) {
529+
return val.replace('UUID', id);
530+
});
531+
axios.get($("#update_user_form").attr("action"))
532+
.then((response) => {
533+
if (response.status >= 200) {
534+
$('form#update_user_form input[name="name"]').val(response.data.name);
535+
$('form#update_user_form select[name="role"]').val(response.data.role);
536+
$('form#update_user_form input[name="email"]').val(response.data.email);
537+
}
538+
})
539+
.catch((error) => {
540+
show_notification(error.response.data.errorMessage);
541+
});
524542
},
525543

526544
formatDatetime(datatime) {
@@ -585,6 +603,50 @@ lynx_app.users_list = (Vue, axios, $) => {
585603
});
586604
}
587605

606+
607+
lynx_app.edit_user_modal = (Vue, axios, $) => {
608+
609+
return new Vue({
610+
delimiters: ['${', '}'],
611+
el: '#edit_user_modal',
612+
data() {
613+
return {
614+
isInProgress: false
615+
}
616+
},
617+
methods: {
618+
updateUserAction(event) {
619+
event.preventDefault();
620+
this.isInProgress = true;
621+
622+
let inputs = {};
623+
let _self = $(event.target);
624+
let _form = _self.closest("form");
625+
626+
_form.serializeArray().map((item, index) => {
627+
inputs[item.name] = item.value;
628+
});
629+
630+
axios.put(_form.attr('action'), inputs)
631+
.then((response) => {
632+
if (response.status >= 200) {
633+
show_notification(_globals.update_user_message);
634+
635+
setTimeout(() => {
636+
location.reload();
637+
}, 2000);
638+
}
639+
})
640+
.catch((error) => {
641+
this.isInProgress = false;
642+
// Show error
643+
show_notification(error.response.data.errorMessage);
644+
});
645+
}
646+
}
647+
});
648+
}
649+
588650
// Projects list
589651
lynx_app.projects_list = (Vue, axios, $) => {
590652

@@ -1249,4 +1311,12 @@ $(document).ready(() => {
12491311
$
12501312
);
12511313
}
1314+
1315+
if (document.getElementById("edit_user_modal")) {
1316+
lynx_app.edit_user_modal(
1317+
Vue,
1318+
axios,
1319+
$
1320+
);
1321+
}
12521322
});

0 commit comments

Comments
 (0)