-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29c288a
commit f1f56c6
Showing
5 changed files
with
70 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,33 @@ | ||
|
||
$(document).ready(function() { | ||
$("#login-submit").click(function() { | ||
$(document).ready(function () { | ||
$("#login-submit").click(function () { | ||
const login_data = { | ||
login: $("#identifiant").val(), | ||
login: $("#identifiant").val(), | ||
password: $("#password").val(), | ||
id_application: $("#id-app").val() | ||
id_application: $("#id-app").val(), | ||
}; | ||
|
||
let url = (APPLICATION_ROOT + "/api/auth/login").replace("//", "/"); | ||
|
||
fetch(url, { | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
}, | ||
method: "POST", | ||
body: JSON.stringify(login_data) | ||
}).then( | ||
(response) => { | ||
$('#login-error').hide(); | ||
if (!response.ok) { | ||
return Promise.reject(response.json()); | ||
} | ||
|
||
return response.json() | ||
fetch(URL_LOGIN, { | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
}, | ||
method: "POST", | ||
body: JSON.stringify(login_data), | ||
}) | ||
.then((response) => { | ||
$("#login-error").hide(); | ||
if (!response.ok) { | ||
return Promise.reject(response.json()); | ||
} | ||
) | ||
|
||
return response.json(); | ||
}) | ||
.then((data) => { | ||
location.href = $("#return-url").val() | ||
location.href = $("#return-url").val(); | ||
}) | ||
.catch(error => { | ||
console.error('There was an error!', error); | ||
$('#login-error').show(); | ||
.catch((error) => { | ||
console.error("There was an error!", error); | ||
$("#login-error").show(); | ||
}); | ||
}) | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,31 @@ | ||
|
||
$(document).ready(function() { | ||
$(document).ready(function () { | ||
// Get value of regne and group_inpn | ||
let regne_group2 = {} | ||
|
||
let url = (APPLICATION_ROOT + "/api/taxref/regnewithgroupe2").replace("//", "/"); | ||
|
||
fetch(url) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
regne_group2 = data; | ||
|
||
// Populate value of regne | ||
let $dropdown = $("#regne"); | ||
$('#regne').empty(); | ||
$dropdown.append($("<option />").val("").text("---")); | ||
$.each(regne_group2, function(key, value) { | ||
$dropdown.append($("<option />").val(key).text(key)); | ||
let regne_group2 = {}; | ||
|
||
fetch(URL_GROUP_REGNE) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
regne_group2 = data; | ||
|
||
// Populate value of regne | ||
let $dropdown = $("#regne"); | ||
$("#regne").empty(); | ||
$dropdown.append($("<option />").val("").text("---")); | ||
$.each(regne_group2, function (key, value) { | ||
$dropdown.append($("<option />").val(key).text(key)); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
$('#regne').on('change', function() { | ||
$("#regne").on("change", function () { | ||
let $dropdown = $("#group2_inpn"); | ||
|
||
// Clear group2_inpn | ||
$('#group2_inpn').empty(); | ||
$("#group2_inpn").empty(); | ||
$("#group2_inpn").val(""); | ||
|
||
// Populate with regne selected value | ||
$.each(regne_group2[$('#regne').val()], function() { | ||
$.each(regne_group2[$("#regne").val()], function () { | ||
$dropdown.append($("<option />").val(this).text(this)); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
from flask import Blueprint, current_app, Response | ||
from flask import Blueprint, current_app, Response, url_for | ||
|
||
adresses = Blueprint("configs", __name__) | ||
|
||
|
||
@adresses.route("<variable_name>/<str_endpoint>", methods=["GET"]) | ||
def get_config(variable_name, str_endpoint): | ||
""" | ||
Route générant la configuration utile au frontend | ||
""" | ||
url = url_for(str_endpoint, _external=True) | ||
js = f"const {variable_name}='{url}'" | ||
|
||
resp = Response(response=js, status=200, mimetype="application/javascript") | ||
resp.headers["Access-Control-Allow-Origin"] = "*" | ||
return resp |