Skip to content

Commit 06e6e61

Browse files
committed
feat: support to edit environments
1 parent 57d75c0 commit 06e6e61

File tree

10 files changed

+164
-18
lines changed

10 files changed

+164
-18
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.12.1" width="250" />
2+
<img alt="Lynx Logo" src="/assets/img/logo.png?v=0.12.2" 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.12.1-1abc9c.svg">
10+
<img src="https://img.shields.io/badge/Version-0.12.2-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.12.1-1abc9c.svg">
13+
<img src="https://img.shields.io/badge/Docker-0.12.2-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.12.1
10+
version: 0.12.2
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.12.1
5+
image: clivern/lynx:0.12.2
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.12.1
30+
image: clivern/lynx:0.12.2
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.12.1
55+
image: clivern/lynx:0.12.2
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.12.1
5+
image: clivern/lynx:0.12.2
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.12.1
5+
image: clivern/lynx:0.12.2
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.12.1
25-
url: https://github.com/Clivern/Lynx/releases/tag/0.12.1
24+
label: Latest Release v0.12.2
25+
url: https://github.com/Clivern/Lynx/releases/tag/0.12.2
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.12.1")
136+
|> put_resp_header("x-server-version", "lynx/0.12.2")
137137
end
138138

139139
# Enables LiveDashboard only for development

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

+54-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
var _globals = {
33
new_environment: '<%= gettext "Environment created successfully!" %>',
44
delete_environment_message: '<%= gettext "Environment deleted successfully!" %>',
5+
update_environment_message: '<%= gettext "Environment updated successfully!" %>',
56
delete_environment_alert: '<%= gettext "You are trying to delete an environment! are you sure?" %>',
67
delete_environment_endpoint: '<%= Routes.environment_path(@conn, :delete, @data.uuid, "UUID") %>',
78
get_environment_endpoint: '<%= Routes.environment_path(@conn, :index, @data.uuid, "UUID") %>',
@@ -305,7 +306,7 @@
305306
<template v-if="environment.stateVersion != 'v0'">
306307
<a target="_blank" @click="downloadEnvironmentStateAction(environment.id)" class="btn btn-dashed btn-sm text-warning-100 border-warning-100 hp-hover-text-color-warning-80 hp-hover-border-color-warning-80"><%= gettext "Download State" %></a>
307308
</template>
308-
<!--<button @click="editEnvironmentAction(environment.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>-->
309+
<button @click="editEnvironmentAction(environment.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_environment_modal"><%= gettext "Edit" %></button>
309310
<button @click="deleteEnvironmentAction(environment.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>
310311
</td>
311312
</tr>
@@ -372,6 +373,58 @@
372373
</div>
373374
</div>
374375

376+
<div class="modal fade" id="edit_environment_modal" tabindex="-1" aria-labelledby="editEnvironmentLabel" aria-hidden="true">
377+
<div class="modal-dialog modal-dialog-centered">
378+
<div class="modal-content">
379+
<div class="modal-header py-16 px-24">
380+
<h5 class="modal-title" id="editEnvironmentLabel"><%= gettext "Edit Environment" %></h5>
381+
<button type="button" class="btn-close hp-bg-none d-flex align-items-center justify-content-center" data-bs-dismiss="modal" aria-label="Close">
382+
<i class="ri-close-line hp-text-color-dark-0 lh-1" style="font-size: 24px;"></i>
383+
</button>
384+
</div>
385+
<div class="divider m-0"></div>
386+
<form id="update_environment_form" action={Routes.environment_path(@conn, :update, @data.uuid, "UUID")} method="post" v-on:submit.prevent="updateEnvironmentAction">
387+
<input type="hidden" value="" name="uuid">
388+
<div class="modal-body">
389+
<div class="row gx-8">
390+
<div class="col-12">
391+
<div class="mb-24">
392+
<label class="form-label"><%= gettext "Name" %></label>
393+
<input type="text" class="form-control" name="name" required="required" minlength="2" maxlength="60">
394+
</div>
395+
</div>
396+
397+
<div class="col-12">
398+
<div class="mb-24">
399+
<label class="form-label"><%= gettext "Slug" %></label>
400+
<input type="text" class="form-control" name="slug" required="required" minlength="2" maxlength="60">
401+
</div>
402+
</div>
403+
404+
<div class="col-12">
405+
<div class="mb-24">
406+
<label class="form-label"><%= gettext "Username" %></label>
407+
<input type="text" class="form-control" name="username" required="required" minlength="2" maxlength="60">
408+
</div>
409+
</div>
410+
411+
<div class="col-12">
412+
<div class="mb-24">
413+
<label class="form-label"><%= gettext "Secret" %></label>
414+
<input type="text" class="form-control" name="secret" required="required" minlength="2" maxlength="60">
415+
</div>
416+
</div>
417+
</div>
418+
</div>
419+
<div class="modal-footer pt-0 px-24 pb-24">
420+
<div class="divider"></div>
421+
<button type="submit" class="m-0 btn btn-primary w-100" :disabled="isInProgress"><%= gettext "Submit" %></button>
422+
</div>
423+
</form>
424+
</div>
425+
</div>
426+
</div>
427+
375428
<div class="modal fade" id="show_environment_modal" tabindex="-1" aria-labelledby="showEnvironmentLabel" aria-hidden="true">
376429
<div class="modal-dialog modal-lg modal-dialog-centered">
377430
<div class="modal-content">

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.12.1"
8+
@version "0.12.2"
99

1010
def get_version, do: @version
1111

priv/static/theme/app/backend.js

+97-4
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,14 @@ lynx_app.teams_list = (Vue, axios, $) => {
432432
},
433433
methods: {
434434
editTeamAction(id) {
435-
$('input[name="uuid"]').val(id);
435+
let current = $('form#update_team_form input[name="uuid"]').val()
436+
if (current != "") {
437+
$('form#update_team_form').attr('action', function(i, val) {
438+
return val.replace(current, "UUID");
439+
});
440+
}
436441

442+
$('form#update_team_form input[name="uuid"]').val(id);
437443
$('form#update_team_form').attr('action', function(i, val) {
438444
return val.replace('UUID', id);
439445
});
@@ -602,7 +608,14 @@ lynx_app.users_list = (Vue, axios, $) => {
602608
},
603609
methods: {
604610
editUserAction(id) {
605-
$('input[name="uuid"]').val(id);
611+
let current = $('form#update_user_form input[name="uuid"]').val()
612+
if (current != "") {
613+
$('form#update_user_form').attr('action', function(i, val) {
614+
return val.replace(current, "UUID");
615+
});
616+
}
617+
618+
$('form#update_user_form input[name="uuid"]').val(id);
606619
$('form#update_user_form').attr('action', function(i, val) {
607620
return val.replace('UUID', id);
608621
});
@@ -750,8 +763,14 @@ lynx_app.projects_list = (Vue, axios, $) => {
750763
},
751764
methods: {
752765
editProjectAction(id) {
753-
$('form#update_project_form input[name="uuid"]').val(id);
766+
let current = $('form#update_project_form input[name="uuid"]').val()
767+
if (current != "") {
768+
$('form#update_project_form').attr('action', function(i, val) {
769+
return val.replace(current, "UUID");
770+
});
771+
}
754772

773+
$('form#update_project_form input[name="uuid"]').val(id);
755774
$('form#update_project_form').attr('action', function(i, val) {
756775
return val.replace('UUID', id);
757776
});
@@ -1046,7 +1065,30 @@ lynx_app.environments_list = (Vue, axios, $) => {
10461065
},
10471066
methods: {
10481067
editEnvironmentAction(id) {
1049-
console.log("Edit environment with ID:", id);
1068+
let current = $('form#update_environment_form input[name="uuid"]').val()
1069+
if (current != "") {
1070+
$('form#update_environment_form').attr('action', function(i, val) {
1071+
return val.replace(current, "UUID");
1072+
});
1073+
}
1074+
1075+
$('form#update_environment_form input[name="uuid"]').val(id);
1076+
$('form#update_environment_form').attr('action', function(i, val) {
1077+
return val.replace('UUID', id);
1078+
});
1079+
1080+
axios.get($("#update_environment_form").attr("action"))
1081+
.then((response) => {
1082+
if (response.status >= 200) {
1083+
$('form#update_environment_form input[name="name"]').val(response.data.name);
1084+
$('form#update_environment_form input[name="slug"]').val(response.data.slug);
1085+
$('form#update_environment_form input[name="username"]').val(response.data.username);
1086+
$('form#update_environment_form input[name="secret"]').val(response.data.secret);
1087+
}
1088+
})
1089+
.catch((error) => {
1090+
show_notification(error.response.data.errorMessage);
1091+
});
10501092
},
10511093

10521094
formatDatetime(datatime) {
@@ -1135,6 +1177,49 @@ lynx_app.environments_list = (Vue, axios, $) => {
11351177
});
11361178
}
11371179

1180+
lynx_app.edit_environment_modal = (Vue, axios, $) => {
1181+
1182+
return new Vue({
1183+
delimiters: ['${', '}'],
1184+
el: '#edit_environment_modal',
1185+
data() {
1186+
return {
1187+
isInProgress: false
1188+
}
1189+
},
1190+
methods: {
1191+
updateEnvironmentAction(event) {
1192+
event.preventDefault();
1193+
this.isInProgress = true;
1194+
1195+
let inputs = {};
1196+
let _self = $(event.target);
1197+
let _form = _self.closest("form");
1198+
1199+
_form.serializeArray().map((item, index) => {
1200+
inputs[item.name] = item.value;
1201+
});
1202+
1203+
axios.put(_form.attr('action'), inputs)
1204+
.then((response) => {
1205+
if (response.status >= 200) {
1206+
show_notification(_globals.update_environment_message);
1207+
1208+
setTimeout(() => {
1209+
location.reload();
1210+
}, 2000);
1211+
}
1212+
})
1213+
.catch((error) => {
1214+
this.isInProgress = false;
1215+
// Show error
1216+
show_notification(error.response.data.errorMessage);
1217+
});
1218+
}
1219+
}
1220+
});
1221+
}
1222+
11381223
// Snapshots list
11391224
lynx_app.snapshots_list = (Vue, axios, $) => {
11401225

@@ -1495,4 +1580,12 @@ $(document).ready(() => {
14951580
$
14961581
);
14971582
}
1583+
1584+
if (document.getElementById("edit_environment_modal")) {
1585+
lynx_app.edit_environment_modal(
1586+
Vue,
1587+
axios,
1588+
$
1589+
);
1590+
}
14981591
});

0 commit comments

Comments
 (0)