Householding update 2

* Fixed missing cross_origin() tags on various functions
* Added popper javascript library for tooltips
* Added material design icons font and css locally
projects
Domeniko Gentner 4 years ago
parent 0cdd3a16dc
commit 11b2fe5942
  1. 1
      Pipfile
  2. 135
      Pipfile.lock
  3. 2
      labertasche/blueprints/bp_dashboard/comments.py
  4. 2
      labertasche/blueprints/bp_dashboard/mail.py
  5. 8
      labertasche/blueprints/bp_dashboard/projects.py
  6. 2
      labertasche/blueprints/bp_dashboard/spam.py
  7. 5
      labertasche/blueprints/bp_jsconnector/comments.py
  8. 7
      labertasche/blueprints/bp_jsconnector/mail.py
  9. 7
      labertasche/blueprints/bp_jsconnector/projects.py
  10. 2
      static/css/labertasche.css
  11. BIN
      static/css/materialdesignicons-webfont.woff2
  12. 3
      static/css/materialdesignicons.min.css
  13. 5
      static/css/sass/labertasche.scss
  14. 52
      static/js/dashboard.js
  15. 6
      static/js/popper.min.js
  16. 1
      static/js/tippy-bundle.umd.min.js
  17. 208
      static/js/upgrade_to_v2.js

@ -15,7 +15,6 @@ flask-login = "*"
sqlalchemy = "*"
requests = "*"
py3-validate-email = "*"
flask-migrate = "*"
[requires]
python_version = "3.8"

135
Pipfile.lock generated

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "bda9276f38dcb49704cadb2f9097ecdfa1dafdd4e4b3d6666dfcb92d24f0ea57"
"sha256": "57134ef6f8a30aa46c1ab6263e62e14edbb27d6df2911fc6b2140dde8c49d27c"
},
"pipfile-spec": 6,
"requires": {
@ -16,13 +16,6 @@
]
},
"default": {
"alembic": {
"hashes": [
"sha256:4e02ed2aa796bd179965041afa092c55b51fb077de19d61835673cc80672c01c",
"sha256:5334f32314fb2a56d86b4c4dd1ae34b08c03cae4cb888bc699942104d66bc245"
],
"version": "==1.4.3"
},
"antispam": {
"hashes": [
"sha256:e188b424ea9b76c408a592a5ff60eb1280f45f26b404db4d5e96123f485de39b"
@ -32,17 +25,17 @@
},
"certifi": {
"hashes": [
"sha256:1f422849db327d534e3d0c5f02a263458c3955ec0aae4ff09b95f195c59f4edd",
"sha256:f05def092c44fbf25834a51509ef6e631dc19765ab8a57b4e7ab85531f0a9cf4"
"sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c",
"sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"
],
"version": "==2020.11.8"
"version": "==2020.12.5"
},
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
"sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa",
"sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"
],
"version": "==3.0.4"
"version": "==4.0.0"
},
"click": {
"hashes": [
@ -89,14 +82,6 @@
"index": "pypi",
"version": "==0.5.0"
},
"flask-migrate": {
"hashes": [
"sha256:4dc4a5cce8cbbb06b8dc963fd86cf8136bd7d875aabe2d840302ea739b243732",
"sha256:a69d508c2e09d289f6e55a417b3b8c7bfe70e640f53d2d9deb0d056a384f37ee"
],
"index": "pypi",
"version": "==2.5.3"
},
"flask-sqlalchemy": {
"hashes": [
"sha256:05b31d2034dd3f2a685cbbae4cfc4ed906b2a733cff7964ada450fd5e462b84e",
@ -126,13 +111,6 @@
],
"version": "==2.11.2"
},
"mako": {
"hashes": [
"sha256:8195c8c1400ceb53496064314c6736719c6f25e7479cd24c77be3d9361cddc27",
"sha256:93729a258e4ff0747c876bd9e20df1b9758028946e976324ccd2d68245c7b6a9"
],
"version": "==1.1.3"
},
"markupsafe": {
"hashes": [
"sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
@ -178,21 +156,6 @@
"index": "pypi",
"version": "==0.2.12"
},
"python-dateutil": {
"hashes": [
"sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c",
"sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"
],
"version": "==2.8.1"
},
"python-editor": {
"hashes": [
"sha256:1bf6e860a8ad52a14c3ee1252d5dc25b2030618ed80c022598f00176adc8367d",
"sha256:51fda6bcc5ddbbb7063b2af7509e43bd84bfc32a4ff71349ec7847713882327b",
"sha256:5f98b069316ea1c2ed3f67e7f5df6c0d8f10b689964a4a811ff64f0106819ec8"
],
"version": "==1.0.4"
},
"pyyaml": {
"hashes": [
"sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97",
@ -214,11 +177,11 @@
},
"requests": {
"hashes": [
"sha256:7f1a0b932f4a60a1a65caa4263921bb7d9ee911957e0ae4a23a6dd08185ad5f8",
"sha256:e786fa28d8c9154e6a4de5d46a1d921b8749f8b74e28bde23768e5e16eece998"
"sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804",
"sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e"
],
"index": "pypi",
"version": "==2.25.0"
"version": "==2.25.1"
},
"six": {
"hashes": [
@ -229,47 +192,47 @@
},
"sqlalchemy": {
"hashes": [
"sha256:009e8388d4d551a2107632921320886650b46332f61dc935e70c8bcf37d8e0d6",
"sha256:0157c269701d88f5faf1fa0e4560e4d814f210c01a5b55df3cab95e9346a8bcc",
"sha256:0a92745bb1ebbcb3985ed7bda379b94627f0edbc6c82e9e4bac4fb5647ae609a",
"sha256:0cca1844ba870e81c03633a99aa3dc62256fb96323431a5dec7d4e503c26372d",
"sha256:166917a729b9226decff29416f212c516227c2eb8a9c9f920d69ced24e30109f",
"sha256:1f5f369202912be72fdf9a8f25067a5ece31a2b38507bb869306f173336348da",
"sha256:2909dffe5c9a615b7e6c92d1ac2d31e3026dc436440a4f750f4749d114d88ceb",
"sha256:2b5dafed97f778e9901b79cc01b88d39c605e0545b4541f2551a2fd785adc15b",
"sha256:2e9bd5b23bba8ae8ce4219c9333974ff5e103c857d9ff0e4b73dc4cb244c7d86",
"sha256:3aa6d45e149a16aa1f0c46816397e12313d5e37f22205c26e06975e150ffcf2a",
"sha256:4bdbdb8ca577c6c366d15791747c1de6ab14529115a2eb52774240c412a7b403",
"sha256:53fd857c6c8ffc0aa6a5a3a2619f6a74247e42ec9e46b836a8ffa4abe7aab327",
"sha256:5cdfe54c1e37279dc70d92815464b77cd8ee30725adc9350f06074f91dbfeed2",
"sha256:5d92c18458a4aa27497a986038d5d797b5279268a2de303cd00910658e8d149c",
"sha256:632b32183c0cb0053194a4085c304bc2320e5299f77e3024556fa2aa395c2a8b",
"sha256:7c735c7a6db8ee9554a3935e741cf288f7dcbe8706320251eb38c412e6a4281d",
"sha256:7cd40cb4bc50d9e87b3540b23df6e6b24821ba7e1f305c1492b0806c33dbdbec",
"sha256:84f0ac4a09971536b38cc5d515d6add7926a7e13baa25135a1dbb6afa351a376",
"sha256:8dcbf377529a9af167cbfc5b8acec0fadd7c2357fc282a1494c222d3abfc9629",
"sha256:950f0e17ffba7a7ceb0dd056567bc5ade22a11a75920b0e8298865dc28c0eff6",
"sha256:9e379674728f43a0cd95c423ac0e95262500f9bfd81d33b999daa8ea1756d162",
"sha256:b15002b9788ffe84e42baffc334739d3b68008a973d65fad0a410ca5d0531980",
"sha256:b6f036ecc017ec2e2cc2a40615b41850dc7aaaea6a932628c0afc73ab98ba3fb",
"sha256:bad73f9888d30f9e1d57ac8829f8a12091bdee4949b91db279569774a866a18e",
"sha256:bbc58fca72ce45a64bb02b87f73df58e29848b693869e58bd890b2ddbb42d83b",
"sha256:bca4d367a725694dae3dfdc86cf1d1622b9f414e70bd19651f5ac4fb3aa96d61",
"sha256:be41d5de7a8e241864189b7530ca4aaf56a5204332caa70555c2d96379e18079",
"sha256:bf53d8dddfc3e53a5bda65f7f4aa40fae306843641e3e8e701c18a5609471edf",
"sha256:c092fe282de83d48e64d306b4bce03114859cdbfe19bf8a978a78a0d44ddadb1",
"sha256:c3ab23ee9674336654bf9cac30eb75ac6acb9150dc4b1391bec533a7a4126471",
"sha256:ce64a44c867d128ab8e675f587aae7f61bd2db836a3c4ba522d884cd7c298a77",
"sha256:d05cef4a164b44ffda58200efcb22355350979e000828479971ebca49b82ddb1",
"sha256:d2f25c7f410338d31666d7ddedfa67570900e248b940d186b48461bd4e5569a1",
"sha256:d3b709d64b5cf064972b3763b47139e4a0dc4ae28a36437757f7663f67b99710",
"sha256:e32e3455db14602b6117f0f422f46bc297a3853ae2c322ecd1e2c4c04daf6ed5",
"sha256:ed53209b5f0f383acb49a927179fa51a6e2259878e164273ebc6815f3a752465",
"sha256:f605f348f4e6a2ba00acb3399c71d213b92f27f2383fc4abebf7a37368c12142",
"sha256:fcdb3755a7c355bc29df1b5e6fb8226d5c8b90551d202d69d0076a8a5649d68b"
"sha256:04f995fcbf54e46cddeb4f75ce9dfc17075d6ae04ac23b2bacb44b3bc6f6bf11",
"sha256:0c6406a78a714a540d980a680b86654feadb81c8d0eecb59f3d6c554a4c69f19",
"sha256:0c72b90988be749e04eff0342dcc98c18a14461eb4b2ad59d611b57b31120f90",
"sha256:108580808803c7732f34798eb4a329d45b04c562ed83ee90f09f6a184a42b766",
"sha256:1418f5e71d6081aa1095a1d6b567a562d2761996710bdce9b6e6ba20a03d0864",
"sha256:17610d573e698bf395afbbff946544fbce7c5f4ee77b5bcb1f821b36345fae7a",
"sha256:216ba5b4299c95ed179b58f298bda885a476b16288ab7243e89f29f6aeced7e0",
"sha256:2ff132a379838b1abf83c065be54cef32b47c987aedd06b82fc76476c85225eb",
"sha256:314f5042c0b047438e19401d5f29757a511cfc2f0c40d28047ca0e4c95eabb5b",
"sha256:318b5b727e00662e5fc4b4cd2bf58a5116d7c1b4dd56ffaa7d68f43458a8d1ed",
"sha256:3ab5b44a07b8c562c6dcb7433c6a6c6e03266d19d64f87b3333eda34e3b9936b",
"sha256:426ece890153ccc52cc5151a1a0ed540a5a7825414139bb4c95a868d8da54a52",
"sha256:491fe48adc07d13e020a8b07ef82eefc227003a046809c121bea81d3dbf1832d",
"sha256:4a84c7c7658dd22a33dab2e2aa2d17c18cb004a42388246f2e87cb4085ef2811",
"sha256:54da615e5b92c339e339fe8536cce99fe823b6ed505d4ea344852aefa1c205fb",
"sha256:5a7f224cdb7233182cec2a45d4c633951268d6a9bcedac37abbf79dd07012aea",
"sha256:61628715931f4962e0cdb2a7c87ff39eea320d2aa96bd471a3c293d146f90394",
"sha256:62285607a5264d1f91590abd874d6a498e229d5840669bd7d9f654cfaa599bd0",
"sha256:62fb881ba51dbacba9af9b779211cf9acff3442d4f2993142015b22b3cd1f92a",
"sha256:68428818cf80c60dc04aa0f38da20ad39b28aba4d4d199f949e7d6e04444ea86",
"sha256:6aaa13ee40c4552d5f3a59f543f0db6e31712cc4009ec7385407be4627259d41",
"sha256:70121f0ae48b25ef3e56e477b88cd0b0af0e1f3a53b5554071aa6a93ef378a03",
"sha256:715b34578cc740b743361f7c3e5f584b04b0f1344f45afc4e87fbac4802eb0a0",
"sha256:758fc8c4d6c0336e617f9f6919f9daea3ab6bb9b07005eda9a1a682e24a6cacc",
"sha256:7d4b8de6bb0bc736161cb0bbd95366b11b3eb24dd6b814a143d8375e75af9990",
"sha256:81d8d099a49f83111cce55ec03cc87eef45eec0d90f9842b4fc674f860b857b0",
"sha256:888d5b4b5aeed0d3449de93ea80173653e939e916cc95fe8527079e50235c1d2",
"sha256:95bde07d19c146d608bccb9b16e144ec8f139bcfe7fd72331858698a71c9b4f5",
"sha256:9bf572e4f5aa23f88dd902f10bb103cb5979022a38eec684bfa6d61851173fec",
"sha256:bab5a1e15b9466a25c96cda19139f3beb3e669794373b9ce28c4cf158c6e841d",
"sha256:bd4b1af45fd322dcd1fb2a9195b4f93f570d1a5902a842e3e6051385fac88f9c",
"sha256:bde677047305fe76c7ee3e4492b545e0018918e44141cc154fe39e124e433991",
"sha256:c389d7cc2b821853fb018c85457da3e7941db64f4387720a329bc7ff06a27963",
"sha256:d055ff750fcab69ca4e57b656d9c6ad33682e9b8d564f2fbe667ab95c63591b0",
"sha256:d53f59744b01f1440a1b0973ed2c3a7de204135c593299ee997828aad5191693",
"sha256:f115150cc4361dd46153302a640c7fa1804ac207f9cc356228248e351a8b4676",
"sha256:f1e88b30da8163215eab643962ae9d9252e47b4ea53404f2c4f10f24e70ddc62",
"sha256:f8191fef303025879e6c3548ecd8a95aafc0728c764ab72ec51a0bdf0c91a341"
],
"index": "pypi",
"version": "==1.3.20"
"version": "==1.3.22"
},
"urllib3": {
"hashes": [

@ -9,11 +9,13 @@
from . import bp_dashboard
from flask import render_template, request, redirect, url_for
from flask_login import login_required
from flask_cors import cross_origin
from labertasche.database import labertasche_db as db
from labertasche.models import TLocation, TComments
from labertasche.helper import export_location, get_id_from_project_name
@cross_origin
@bp_dashboard.route('<project>/manage-comments/', methods=["GET"])
@login_required
def dashboard_manage_regular_comments(project: str):

@ -9,11 +9,13 @@
from . import bp_dashboard
from flask import render_template, redirect, url_for
from flask_login import login_required
from flask_cors import cross_origin
from labertasche.database import labertasche_db as db
from labertasche.models import TEmail
from labertasche.helper import get_id_from_project_name
@cross_origin()
@bp_dashboard.route('<project>/manage-mail/')
@login_required
def dashboard_manage_mail(project: str):

@ -10,6 +10,7 @@ from . import bp_dashboard
from flask import render_template, redirect, url_for
from flask_login import login_required
from sqlalchemy import func
from sqlalchemy.exc import OperationalError
from labertasche.database import labertasche_db as db
from labertasche.models import TComments, TProjects
from labertasche.helper import get_id_from_project_name, dates_of_the_week
@ -22,7 +23,12 @@ def dashboard_project_list():
Displays an overview of all projects.
:return: The overview template.
"""
t_projects = db.session.query(TProjects).all()
try:
t_projects = db.session.query(TProjects).all()
except OperationalError:
# Database not up-to-date
return redirect(url_for('bp_dbupgrades.upgrade_db_to_v2'))
projects = list()
for each in t_projects:
comments = db.session.query(TComments).filter(TComments.project_id == each.id_project) \

@ -9,11 +9,13 @@
from . import bp_dashboard
from flask import render_template, request, redirect, url_for
from flask_login import login_required
from flask_cors import cross_origin
from labertasche.database import labertasche_db as db
from labertasche.models import TLocation, TComments
from labertasche.helper import export_location, get_id_from_project_name
@cross_origin()
@bp_dashboard.route('<project>/manage-spam/', methods=["GET"])
@login_required
def dashboard_review_spam(project: str):

@ -9,6 +9,7 @@
from . import bp_jsconnector
from flask import request, redirect
from flask_login import login_required
from flask_cors import cross_origin
from labertasche.database import labertasche_db as db
from labertasche.helper import export_location
from labertasche.models import TComments, TEmail
@ -17,6 +18,7 @@ from labertasche.models import TComments, TEmail
# They are called via GET
@cross_origin()
@bp_jsconnector.route('/comment-delete/<int:comment_id>', methods=['GET'])
@login_required
def api_comments_delete_comment(comment_id):
@ -30,6 +32,7 @@ def api_comments_delete_comment(comment_id):
return redirect(request.referrer)
@cross_origin()
@bp_jsconnector.route('/comment-allow/<int:comment_id>', methods=['GET'])
@login_required
def api_comment_allow_comment(comment_id):
@ -46,6 +49,7 @@ def api_comment_allow_comment(comment_id):
return redirect(request.referrer)
@cross_origin()
@bp_jsconnector.route('/comment-allow-user/<int:comment_id>', methods=["GET"])
@login_required
def api_comment_allow_user(comment_id):
@ -79,6 +83,7 @@ def api_comment_allow_user(comment_id):
return redirect(request.referrer)
@cross_origin()
@bp_jsconnector.route('/comment-block-mail/<int:comment_id>', methods=["GET"])
@login_required
def api_comment_block_mail(comment_id):

@ -9,12 +9,12 @@
from . import bp_jsconnector
from flask import request, redirect
from flask_login import login_required
from flask_cors import cross_origin
from labertasche.database import labertasche_db as db
from labertasche.helper import get_id_from_project_name, export_location
from labertasche.models import TEmail, TComments
from re import match
from labertasche.models import TEmail
@cross_origin()
@bp_jsconnector.route('/mail-toggle-status/<int:id_email>')
@login_required
def api_toggle_email_reputation(id_email):
@ -26,6 +26,7 @@ def api_toggle_email_reputation(id_email):
return redirect(request.referrer)
@cross_origin()
@bp_jsconnector.route('/mail-reset-reputation/<int:id_email>')
@login_required
def api_reset_mail_reputation(id_email):

@ -7,14 +7,16 @@
# * _license : This project is under MIT License
# *********************************************************************************/
from . import bp_jsconnector
from flask import request, make_response, jsonify, redirect, url_for
from flask import request, make_response, jsonify
from flask_login import login_required
from flask_cors import cross_origin
from labertasche.database import labertasche_db as db
from labertasche.helper import get_id_from_project_name
from labertasche.models import TProjects, TComments, TEmail, TLocation
import re
@cross_origin()
@bp_jsconnector.route("/project/new", methods=['POST'])
@login_required
def api_create_project():
@ -38,6 +40,7 @@ def api_create_project():
return make_response(jsonify(status='ok'), 200)
@cross_origin()
@bp_jsconnector.route('project/edit/<name>', methods=['POST'])
@login_required
def api_edit_project_name(name: str):
@ -63,6 +66,7 @@ def api_edit_project_name(name: str):
return make_response(jsonify(status='ok'), 200)
@cross_origin()
@bp_jsconnector.route('project/delete/<project>', methods=['GET'])
@login_required
def api_delete_project(project: str):
@ -72,7 +76,6 @@ def api_delete_project(project: str):
:param project: The name of the project
:return: A string with an error code and 'ok' as string on success.
"""
# TODO: Javascript
proj_id = get_id_from_project_name(project)
if proj_id == -1:
return make_response(jsonify(status='not-found'), 400)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -65,6 +65,11 @@ canvas{
height: auto;
}
.code{
background-color: #4a4a4a;
color: white;
}
.bg-yayellow{
background-color: #feda6a;
}

@ -84,6 +84,48 @@ function new_project_save() {
})
}
function project_delete()
{
let modal = document.getElementById('modal-project-delete');
let modal_ok = document.getElementById('modal-delete-ok');
let modal_cancel = document.getElementById('modal-delete-cancel');
const project = modal.dataset.project;
console.log("Project: " + project);
if (project === null || project.length === 0){
console.log("Couldn't find a valid dataset");
return;
}
modal_ok.classList.add('is-loading');
modal_cancel.classList.add('is-hidden');
fetch(window.location.protocol + "//" + window.location.host + '/api/project/delete/' + project,
{
mode: "cors",
headers: {
'Access-Control-Allow-Origin': '*',
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "GET"
})
.then(async function (response) {
let result = await response.json();
result = result['status'];
modal_ok.classList.remove('is-loading');
modal_cancel.classList.remove('is-hidden');
if (result === "ok") {
hide_modal('modal-project-delete');
window.location.reload(true);
}
console.log(result);
})
.catch(function (exc) {
console.log(exc);
})
}
// ------------------------------------------------------
// Hides any modal
@ -102,3 +144,13 @@ function show_modal(id_name)
let el = document.getElementById(id_name);
el.classList.add("is-active");
}
// ------------------------------------------------------
// Shows any modal
// ------------------------------------------------------
function show_modal_with_project(id_name, proj_name)
{
let el = document.getElementById(id_name);
el.classList.add("is-active");
el.setAttribute('data-project', proj_name)
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,208 @@
// # /**********************************************************************************
// # * _author : Domeniko Gentner
// # * _mail : code@tuxstash.de
// # * _repo : https://git.tuxstash.de/gothseidank/labertasche
// # * _license : This project is under MIT License
// # *********************************************************************************/
let base_url = window.location.protocol + "//" + window.location.host + '/upgrade/db_v2';
function mdi_message(message, success=true)
{
let msgpane = document.getElementById('update-messages');
let icon = document.createElement('i');
icon.classList.add('mdi');
icon.classList.add('mdi-24px');
if (success){
icon.classList.add('has-text-success');
icon.classList.add('mdi-check-bold');
}
else {
icon.classList.add('has-text-danger');
icon.classList.add('mdi-alpha-x-box-outline');
}
let text = document.createElement('span');
text.classList.add('has-text-white');
text.innerHTML = "&nbsp;" + message
msgpane.appendChild(icon);
msgpane.appendChild(text);
msgpane.appendChild(document.createElement('br'));
}
async function start_upgrade_to_v2()
{
console.log('helo');
let start_btn = document.getElementById('start-button');
start_btn.remove();
// Add progress bar instead of button
let progressbar = document.createElement('progress');
progressbar.setAttribute('value', '0');
progressbar.setAttribute('max', '100');
progressbar.classList.add('progress');
progressbar.classList.add('is-medium');
progressbar.classList.add('is-success');
progressbar.innerHTML = '&nbsp;';
document.getElementById('controls').appendChild(progressbar);
let success;
success = await backup();
if(success){
progressbar.setAttribute('value', '25');
success = await export_db();
if (success){
progressbar.setAttribute('value', '50');
success = await recreate_db();
if (success){
progressbar.setAttribute('value', '75');
success = await import_db();
progressbar.setAttribute('value', '100');
}
}
}
if (!success){
progressbar.classList.remove('is-success');
progressbar.classList.add('is-danger');
}
else{
progressbar.remove();
}
// reset button
start_btn.classList.remove('is-loading');
}
async function backup()
{
let status = false;
await fetch(base_url + "/backup/", {
mode: "cors",
headers: {
'Access-Control-Allow-Origin': window.location.host,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "GET"
})
.then(async function (response){
let j = await response.json();
if (j['status'] === 'ok'){
mdi_message("Backup successfully created", true);
status = true;
}
if (j['status'] === 'exception-write-json') {
mdi_message(j['msg'], false)
mdi_message("A server-side exception occured while writing the json, please check writing rights in the root directory.", true);
}
if (j['status'] === 'exception-copy-db') {
mdi_message(j['msg'], false)
mdi_message("A server-side exception occured while copying the database, please check writing rights in the root directory.", false);
}
})
.catch(function (exc) {
mdi_message(exc, false);
mdi_message("An exception occured, please report this bug to code@tuxstash.de", false);
});
return status;
}
async function export_db()
{
let status = false;
await fetch(base_url + "/export/", {
mode: "cors",
headers: {
'Access-Control-Allow-Origin': window.location.host,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "GET"
})
.then(async function (response){
let j = await response.json();
if (j['status'] === 'ok'){
mdi_message("Tables successfully exported", true);
status = true;
}
if (j['status'] === 'exception') {
mdi_message(j['msg'], false)
mdi_message("A server-side exception occured.", false);
}
})
.catch(function (exc) {
mdi_message(exc, false);
mdi_message("A Javascript exception occured, please report this bug to code@tuxstash.de", false);
})
return status
}
async function recreate_db()
{
let status = false;
await fetch(base_url + "/recreate/", {
mode: "cors",
headers: {
'Access-Control-Allow-Origin': window.location.host,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "GET"
})
.then(async function (response){
let j = await response.json();
console.log(j);
if (j['status'] === 'ok'){
mdi_message("Database deleted and recreated", true);
status = true;
}
if (j['status'] === 'exception') {
mdi_message(j['msg'], false)
mdi_message("A server-side exception occured.", false);
}
})
.catch(function (exc) {
mdi_message(exc, false);
mdi_message("A Javascript exception occured, please report this bug to code@tuxstash.de", false);
})
return status
}
async function import_db()
{
let status = false;
await fetch(base_url + "/import/", {
mode: "cors",
headers: {
'Access-Control-Allow-Origin': window.location.host,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "GET"
})
.then(async function (response){
let j = await response.json();
console.log(j);
if (j['status'] === 'ok'){
mdi_message("New tables preseeded and data imported. You may now return to the dashboard.", true);
status = true;
}
if (j['status'] === 'exception-database') {
mdi_message(j['msg'], false)
mdi_message("An error occured while adding the data to the database.", false);
}
if (j['status'] === 'exception-filenotfound') {
mdi_message(j['msg'], false)
mdi_message("The exported files have not been found. Please check the file permissions.", false);
}
})
.catch(function (exc) {
mdi_message(exc, false);
mdi_message("A Javascript exception occured, please report this bug to code@tuxstash.de", false);
})
return status
}
Loading…
Cancel
Save