Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
prière
Browse files Browse the repository at this point in the history
  • Loading branch information
loimax committed Feb 1, 2024
1 parent d82deac commit 9422494
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 39 deletions.
10 changes: 4 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
16 changes: 8 additions & 8 deletions static/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions static/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion static/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions static/js/prof.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -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
Expand All @@ -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: {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions static/js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion templates/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ <h1 class="mb-0">Templates</h1>
</div>
</div>
</div>

<script>
var URL_API = "{{ URL_API }}";
</script>
<script src="{{ url_for('static', filename='js/admin.js' ) }}"></script>
<script>
$(document).ready(function () {
Expand Down
7 changes: 6 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script>
var URL_API = "{{ URL_API }}";
</script>
<script src="{{ url_for('static', filename='js/base.js' ) }}"></script>

<link rel="icon" href="{{ url_for('static', filename='icons/vdi.png' ) }}" />
Expand Down Expand Up @@ -201,7 +204,9 @@ <h5 class="modal-title" id="selectRoleModalLabel">Sélectionner le rôle</h5>
</div>
</div>
</div>

<script>
var URL_API = "{{ URL_API }}";
</script>
<script>
$(document).ready(function () {
getUserProfile();
Expand Down
4 changes: 3 additions & 1 deletion templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
</div>
</div>
</div>

<script>
var URL_API = "{{ URL_API }}";
</script>
<script src="{{ url_for('static', filename='js/dashboard.js' ) }}"></script>
<script>
$(document).ready(function () {
Expand Down
3 changes: 3 additions & 0 deletions templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script>
var URL_API = "{{ URL_API }}";
</script>
<script src="{{ url_for('static', filename='js/login.js' ) }}"></script>

<link rel="icon" href="{{ url_for('static', filename='icons/vdi.png' ) }}" />
Expand Down
4 changes: 3 additions & 1 deletion templates/professor.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
</div>
</div>
</div>

<script>
var URL_API = "{{ URL_API }}";
</script>
<script src="{{ url_for('static', filename='js/prof.js' ) }}"></script>
<script>
$(document).ready(function () {
Expand Down
4 changes: 3 additions & 1 deletion templates/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@


{% block content %}

<script>
var URL_API = "{{ URL_API }}";
</script>
<script src="{{ url_for('static', filename='js/base.js' ) }}"></script>

<div id="vncViewerContainer" style="height:88vh"></div>
Expand Down

0 comments on commit 9422494

Please sign in to comment.