diff --git a/app.py b/app.py index 4eeecff..40bfdf1 100644 --- a/app.py +++ b/app.py @@ -2,8 +2,6 @@ app = Flask(__name__, static_folder='static') -app.config['URL_VNC']="https://vnc.insa-cvl.com" -app.config['URL_VDI']="https://vdi.insa-cvl.com" app.config['URL_API']="https://api.insa-cvl.com" @app.route('/robots.txt') @@ -20,19 +18,19 @@ def login(): @app.route('/admin', methods=['GET', 'POST']) def admin(): - return render_template('admin.html') + return render_template('admin.html', URL_API=app.config['URL_API']) @app.route('/professor', methods=['GET', 'POST']) def professor(): - return render_template('professor.html') + return render_template('professor.html', URL_API=app.config['URL_API']) @app.route('/dashboard', methods=['GET', 'POST']) def dashboard(): - return render_template('dashboard.html') + return render_template('dashboard.html', URL_API=app.config['URL_API']) @app.route('/viewer', methods=['GET']) def viewer(): - return render_template('viewer.html') + return render_template('viewer.html', URL_API=app.config['URL_API']) if __name__ == '__main__': app.run(debug=True, host="0.0.0.0", port=5001) diff --git a/static/js/admin.js b/static/js/admin.js index f958cd1..1728331 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -5,7 +5,7 @@ async function deleteVmAdmin(id) { // showLoadingModal | checkIfVmAliveAdmin | h showLoadingModal(); $.ajax({ type: 'DELETE', - url: 'https://api.insa-cvl.com/vm/delete_admin', + url: URL_API + '/vm/delete_admin', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ vm_id: id }), xhrFields: { @@ -30,7 +30,7 @@ async function deleteVmAdmin(id) { // showLoadingModal | checkIfVmAliveAdmin | h function changePassword(userId, newPassword, newPassword2) { $.ajax({ type: 'POST', - url: 'https://api.insa-cvl.com/updatepasswordpa', + url: URL_API + '/updatepasswordpa', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ user_id: userId, new_password: newPassword, new_password2: newPassword2 }), xhrFields: { @@ -48,7 +48,7 @@ function changePassword(userId, newPassword, newPassword2) { function changeRole(userId, role) { $.ajax({ type: 'POST', - url: 'https://api.insa-cvl.com/updaterole', + url: URL_API + '/updaterole', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ user_id: userId, role: role }), xhrFields: { @@ -77,7 +77,7 @@ function createUser() { $.ajax({ type: 'POST', - url: 'https://api.insa-cvl.com/createuser', + url: URL_API + '/createuser', contentType: 'application/json;charset=UTF-8', data: JSON.stringify(userData), xhrFields: { @@ -96,7 +96,7 @@ function createUser() { function deleteUser(userId) { // $.ajax({ type: 'DELETE', - url: 'https://api.insa-cvl.com/deleteuser', + url: URL_API + '/deleteuser', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ user_id: userId }), xhrFields: { @@ -161,7 +161,7 @@ function addUserToTableAdmin(user) { // deleteUser function getUsers() { // addUserToTableAdmin $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/users', + url: URL_API + '/users', contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true @@ -207,7 +207,7 @@ function addTemplateToDOM(template) { // createTemplateCard function getTemplates() { // addTemplateToDOM $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/template', + url: URl_API + '/template', contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true @@ -269,7 +269,7 @@ function addVMToDOM(vm) { // createVmCard function getVms() { // addVMToDOM $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/vm', + url: URL_API + '/vm', contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true diff --git a/static/js/base.js b/static/js/base.js index 4bd55f4..d675cb3 100644 --- a/static/js/base.js +++ b/static/js/base.js @@ -5,7 +5,7 @@ function checkIfVmAliveAdmin(vmId) { showLoadingCardModal(vmId); $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/vm/status/id/' + vmId, + url: URL_API +'/vm/status/id/' + vmId, contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true @@ -31,7 +31,7 @@ function checkIfVmAlive(id) { // showLoadingCardModal | hideLoadingCardModal showLoadingCardModal(id); $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/vm/status/template/' + id, + url: URL_API + '/vm/status/template/' + id, contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true @@ -68,14 +68,14 @@ function showAlertModal(title, message) { // function logout() { // $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/logout', + url: URL_API + '/logout', contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true }, success: function (response) { if (response.cas === true) { - window.location = "https://cas.insa-cvl.fr/cas/logout?service=https://api.insa-cvl.com" + window.location = "https://cas.insa-cvl.fr/cas/logout?service=" + URL_API } setTimeout(function () { window.location = "/login?success=" + encodeURIComponent("Déconnecté avec succès"); @@ -104,7 +104,7 @@ function updateConnectionStatus(isConnected) { // function getUserProfile() { // updateConnectionStatus $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/profile', + url: URL_API + '/profile', contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true diff --git a/static/js/dashboard.js b/static/js/dashboard.js index 0c9bf81..4964a9d 100644 --- a/static/js/dashboard.js +++ b/static/js/dashboard.js @@ -31,7 +31,7 @@ function checkIfVmAlive(id) { // showLoadingCardModal | hideLoadingCardModal showLoadingCardModal(id); $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/vm/status/template/' + id, + url: URL_API + '/vm/status/template/' + id, contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true @@ -56,7 +56,7 @@ async function createVmFromTemplate(templateId) { // showLoadingModal | checkIfV showLoadingModal(); $.ajax({ type: 'POST', - url: 'https://api.insa-cvl.com/vm/create', + url: URL_API + '/vm/create', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ template_id: templateId }), xhrFields: { @@ -90,7 +90,7 @@ async function deleteVm(templateId) { // checkIfVmAlive | showLoadingModal | hid showLoadingModal(); $.ajax({ type: 'DELETE', - url: 'https://api.insa-cvl.com/vm/delete', + url: URL_API + '/vm/delete', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ template_id: templateId }), xhrFields: { @@ -241,7 +241,7 @@ function addTemplateToDOM(template, templatesDiv) { // createTemplateCard | getV function getTemplates() { $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/template', + url: URL_API + '/template', contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true diff --git a/static/js/login.js b/static/js/login.js index d64dd02..b863114 100644 --- a/static/js/login.js +++ b/static/js/login.js @@ -9,7 +9,7 @@ function updateAlert(message) { function getUserProfile() { $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/profile', + url: URL_API + '/profile', contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true diff --git a/static/js/prof.js b/static/js/prof.js index 4a3898d..18612f3 100644 --- a/static/js/prof.js +++ b/static/js/prof.js @@ -5,7 +5,7 @@ async function deleteVmProf(id) { // showLoadingModal | hideLoadingModal | check showLoadingModal(); $.ajax({ type: 'DELETE', - url: 'https://api.insa-cvl.com/vm/delete_admin', + url: URL_API + '/vm/delete_admin', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ vm_id: id }), xhrFields: { @@ -30,7 +30,7 @@ async function deleteVmProf(id) { // showLoadingModal | hideLoadingModal | check function changePassword(userId, newPassword, newPassword2) { $.ajax({ type: 'POST', - url: 'https://api.insa-cvl.com/updatepasswordpa', + url: URL_API + '/updatepasswordpa', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ user_id: userId, new_password: newPassword, new_password2: newPassword2 }), xhrFields: { @@ -58,7 +58,7 @@ function createUser() { $.ajax({ type: 'POST', - url: 'https://api.insa-cvl.com/createuser', + url: URL_API + '/createuser', contentType: 'application/json;charset=UTF-8', data: JSON.stringify(userData), xhrFields: { @@ -77,7 +77,7 @@ function createUser() { function deleteUser(userId) { // $.ajax({ type: 'DELETE', - url: 'https://api.insa-cvl.com/deleteuser', + url: URL_API + '/deleteuser', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ user_id: userId }), xhrFields: { @@ -128,7 +128,7 @@ function addUserToTableProf(user) { // deleteUser function getMyUsers() { // addUserToTableProf $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/myusers', + url: URL_API + '/myusers', contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true @@ -150,7 +150,7 @@ async function deleteVmAdmin(id) { // showLoadingModal | checkIfVmAliveAdmin | h showLoadingModal(); $.ajax({ type: 'DELETE', - url: 'https://api.insa-cvl.com/vm/delete_admin', + url: URL_API + '/vm/delete_admin', contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ vm_id: id }), xhrFields: { @@ -217,7 +217,7 @@ function addVMToDOM(vm) { // createVmCard function getVms() { // addVMToDOM $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/myvmsusers', + url: URL_API + '/myvmsusers', contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true diff --git a/static/js/viewer.js b/static/js/viewer.js index b337932..f2484d1 100644 --- a/static/js/viewer.js +++ b/static/js/viewer.js @@ -2,7 +2,7 @@ function regenerateUrl(templateId) { return new Promise(function (resolve, object) { $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/vm/regenerate_url/' + templateId, + url: URL_API + '/vm/regenerate_url/' + templateId, contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true @@ -37,7 +37,7 @@ function getUrl(templateId) { return new Promise(function (resolve, reject) { $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/vm/url/template/' + templateId, + url: URL_API + '/vm/url/template/' + templateId, contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true @@ -84,7 +84,7 @@ async function openVm(templateId) { // displayVNCViewer | getUrl function checkIfVmActive(templateId) { $.ajax({ type: 'GET', - url: 'https://api.insa-cvl.com/vm/active/' + templateId, + url: URL_API + '/vm/active/' + templateId, contentType: 'application/json;charset=UTF-8', xhrFields: { withCredentials: true diff --git a/templates/admin.html b/templates/admin.html index 7db940f..da3cf91 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -68,7 +68,9 @@

Templates

- + + @@ -201,7 +204,9 @@ - + + diff --git a/templates/professor.html b/templates/professor.html index 0b489f9..803bafd 100644 --- a/templates/professor.html +++ b/templates/professor.html @@ -53,7 +53,9 @@ - +