Skip to content

Commit

Permalink
Merge pull request #66 from t0xic0der/version-information-on-template
Browse files Browse the repository at this point in the history
Added version information on template
  • Loading branch information
gridhead authored Mar 2, 2021
2 parents 0219190 + 8a9208a commit 5050203
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 37 deletions.
22 changes: 22 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
##########################################################################
*
* Copyright © 2019-2020 Akashdeep Dhar <t0xic0der@fedoraproject.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
##########################################################################
"""

__version__ = "v1.1.0-beta"
47 changes: 24 additions & 23 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

from hashlib import sha256
from json import dumps
from time import time

import click
from __init__ import __version__ as frntvers
from flask import (
Flask,
abort,
Expand All @@ -32,7 +34,6 @@
session,
url_for,
)
from time import time


main = Flask(__name__)
Expand All @@ -57,23 +58,23 @@ def e404page(ertx):
"""
Custom 404 ERROR page
"""
return render_template("e404page.html"), 404
return render_template("e404page.html", frntvers=frntvers), 404


@main.errorhandler(403)
def e403page(ertx):
"""
Custom 403 ERROR page
"""
return render_template("e403page.html"), 403
return render_template("e403page.html", frntvers=frntvers), 403


@main.errorhandler(500)
def e403page(ertx):
"""
Custom 500 ERROR page
"""
return render_template("e500page.html"), 500
return render_template("e500page.html", frntvers=frntvers), 500


@main.route("/credpull/", methods=["POST"])
Expand Down Expand Up @@ -178,7 +179,7 @@ def logepage():
session["sessiden"] = sessiden
sessdict[sessiden] = sessdata
return dumps({"retnmesg": "allow"})
return render_template("logepage.html")
return render_template("logepage.html", frntvers=frntvers)


@main.route("/dashbord/")
Expand All @@ -187,7 +188,7 @@ def dashbord():
Endpoint for station dashboard
"""
if "sessiden" in session:
return render_template("dashbard.html", darkmode=retnilum())
return render_template("dashbard.html", darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -198,7 +199,7 @@ def dockstat():
Endpoint for container station page
"""
if "sessiden" in session:
return render_template("dockstat.html", darkmode=retnilum())
return render_template("dockstat.html", darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -209,7 +210,7 @@ def contlist():
Endpoint for container listing page
"""
if "sessiden" in session:
return render_template("contlist.html", darkmode=retnilum())
return render_template("contlist.html", darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -220,7 +221,7 @@ def imejlist():
Endpoint for image listing page
"""
if "sessiden" in session:
return render_template("imejlist.html", darkmode=retnilum())
return render_template("imejlist.html", darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -231,7 +232,7 @@ def volmlist():
Endpoint for volume listing page
"""
if "sessiden" in session:
return render_template("volmlist.html", darkmode=retnilum())
return render_template("volmlist.html", darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -242,7 +243,7 @@ def ntwklist():
Endpoint for network listing page
"""
if "sessiden" in session:
return render_template("ntwklist.html", darkmode=retnilum())
return render_template("ntwklist.html", darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -253,7 +254,7 @@ def systdata():
Endpoint for host system performance data
"""
if "sessiden" in session:
return render_template("systdata.html", darkmode=retnilum())
return render_template("systdata.html", darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -264,7 +265,7 @@ def proclist():
Endpoint for host system process listing page
"""
if "sessiden" in session:
return render_template("proclist.html", darkmode=retnilum())
return render_template("proclist.html", darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -276,7 +277,7 @@ def imejdata(imejiden):
"""
if "sessiden" in session:
if len(imejiden) == 71:
return render_template("imejinfo.html", imejiden=imejiden, darkmode=retnilum())
return render_template("imejinfo.html", imejiden=imejiden, darkmode=retnilum(), frntvers=frntvers)
else:
abort(404)
else:
Expand All @@ -290,7 +291,7 @@ def imejrevs(imejiden):
"""
if "sessiden" in session:
if len(imejiden) == 71:
return render_template("imejrevs.html", imejiden=imejiden, darkmode=retnilum())
return render_template("imejrevs.html", imejiden=imejiden, darkmode=retnilum(), frntvers=frntvers)
else:
abort(404)
else:
Expand All @@ -304,7 +305,7 @@ def contdata(contiden):
"""
if "sessiden" in session:
if len(contiden) == 64:
return render_template("continfo.html", contiden=contiden, darkmode=retnilum())
return render_template("continfo.html", contiden=contiden, darkmode=retnilum(), frntvers=frntvers)
else:
abort(404)
else:
Expand All @@ -318,7 +319,7 @@ def ntwkdata(ntwkiden):
"""
if "sessiden" in session:
if len(ntwkiden) == 64:
return render_template("ntwkinfo.html", ntwkiden=ntwkiden, darkmode=retnilum())
return render_template("ntwkinfo.html", ntwkiden=ntwkiden, darkmode=retnilum(), frntvers=frntvers)
else:
abort(404)
else:
Expand All @@ -331,7 +332,7 @@ def volmdata(volmiden):
Endpoint for viewing volume information
"""
if "sessiden" in session:
return render_template("volminfo.html", volmiden=volmiden, darkmode=retnilum())
return render_template("volminfo.html", volmiden=volmiden, darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -343,7 +344,7 @@ def contlogs(contiden):
"""
if "sessiden" in session:
if len(contiden) == 64:
return render_template("contlogs.html", contiden=contiden, darkmode=retnilum())
return render_template("contlogs.html", contiden=contiden, darkmode=retnilum(), frntvers=frntvers)
else:
abort(404)
else:
Expand All @@ -357,7 +358,7 @@ def contstat(contiden):
"""
if "sessiden" in session:
if len(contiden) == 64:
return render_template("contstat.html", contiden=contiden, darkmode=retnilum())
return render_template("contstat.html", contiden=contiden, darkmode=retnilum(), frntvers=frntvers)
else:
abort(404)
else:
Expand All @@ -371,7 +372,7 @@ def conthtop(contiden):
"""
if "sessiden" in session:
if len(contiden) == 64:
return render_template("conthtop.html", contiden=contiden, darkmode=retnilum())
return render_template("conthtop.html", contiden=contiden, darkmode=retnilum(), frntvers=frntvers)
else:
abort(404)
else:
Expand All @@ -384,7 +385,7 @@ def termpage(contiden):
Endpoint for system console page
"""
if "sessiden" in session:
return render_template("termpage.html", contiden=contiden, darkmode=retnilum())
return render_template("termpage.html", contiden=contiden, darkmode=retnilum(), frntvers=frntvers)
else:
abort(403)

Expand All @@ -399,7 +400,7 @@ def mainfunc(portdata, netprotc):
Main function
"""
try:
click.echo(" * " + click.style("SuperVisor Frontend Service v1.1.0-beta", fg="green"))
click.echo(" * " + click.style("SuperVisor Frontend Service " + frntvers, fg="green"))
click.echo(" * " + click.style("Port number ", fg="magenta") + ": " + str(portdata))
netpdata = ""
if netprotc == "ipprotv6":
Expand Down
8 changes: 2 additions & 6 deletions static/jscn/termpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ function make_terminal(element, size, ws_url, contiden) {
document.title = title;
});
term.open(element);
term.write("\u001b[33m\u001b[1m" + "SuperVisor v1.1.0-beta" + "\u001b[0m\u001b[0m" +
term.write("\u001b[33m\u001b[1m" + "SuperVisor Web Console" + "\u001b[0m\u001b[0m" +
"\r\n" +
"\u001b[32m" + "Please press BACK button to return to SUPERVISOR" + "\u001b[0m" +
"\r\n" +
"\u001b[32m" + "Closing this tab will LOG you out of your current session" + "\u001b[0m" +
"\r\n\r\n"
);
if (contiden.length === 64) {
Expand Down Expand Up @@ -75,9 +73,7 @@ function make_terminal(element, size, ws_url, contiden) {
"\u001b[32m" +
"Please press BACK button to return to SUPERVISOR" +
"\u001b[0m" +
"\r\n" +
"\u001b[32m" + "Closing this tab will LOG you out of your current session" +
"\u001b[0m"
"\r\n"
);
break;
}
Expand Down
3 changes: 2 additions & 1 deletion templates/e403page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SuperVisor v1.1.0-beta</title>
<title>SuperVisor {{ frntvers }}</title>
<link rel="stylesheet" href="{{ url_for("static", filename="css3/custfrmt.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/fontsome.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/adminlte.css") }}">
Expand Down Expand Up @@ -63,6 +63,7 @@ <h3 class="condqant text-center">Access denied</h3>
<button type="button" class="btn btn-default btn-sm" onclick="document.location.href = '/'">Login</button>
<button type="button" class="btn btn-default btn-sm" onclick="window.history.back()">Go back</button>
</div>
<p class="text-center mt-4 text-bold">SuperVisor {{ frntvers }}</p>
</div>
</section>
</body>
Expand Down
3 changes: 2 additions & 1 deletion templates/e404page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SuperVisor v1.1.0-beta</title>
<title>SuperVisor {{ frntvers }}</title>
<link rel="stylesheet" href="{{ url_for("static", filename="css3/custfrmt.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/fontsome.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/adminlte.css") }}">
Expand Down Expand Up @@ -63,6 +63,7 @@ <h3 class="condqant text-center">Resource not found</h3>
<button type="button" class="btn btn-default btn-sm" onclick="document.location.href = '/dashbord/'">Dashboard</button>
<button type="button" class="btn btn-default btn-sm" onclick="window.history.back()">Go back</button>
</div>
<p class="text-center mt-4 text-bold">SuperVisor {{ frntvers }}</p>
</div>
</section>
</body>
Expand Down
3 changes: 2 additions & 1 deletion templates/e500page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SuperVisor v1.1.0-beta</title>
<title>SuperVisor {{ frntvers }}</title>
<link rel="stylesheet" href="{{ url_for("static", filename="css3/custfrmt.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/fontsome.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/adminlte.css") }}">
Expand Down Expand Up @@ -63,6 +63,7 @@ <h3 class="condqant text-center">Internal server error</h3>
<button type="button" class="btn btn-default btn-sm" onclick="document.location.href = '/dashbord/'">Dashboard</button>
<button type="button" class="btn btn-default btn-sm" onclick="window.history.back()">Go back</button>
</div>
<p class="text-center mt-4 text-bold">SuperVisor {{ frntvers }}</p>
</div>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions templates/frameset.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SuperVisor v1.1.0-beta</title>
<title>SuperVisor {{ frntvers }}</title>
<link rel="stylesheet" href="{{ url_for("static", filename="css3/custfrmt.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/fontsome.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/adminlte.css") }}">
Expand Down Expand Up @@ -136,7 +136,7 @@
</section>
</div>
<footer class="main-footer">
<div class="float-right d-none d-sm-inline">v1.1.0-beta</div>
<div class="float-right d-none d-sm-inline">{{ frntvers }}</div>
<strong data-widget="pushmenu" href="#">SuperVisor</strong>
</footer>
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/logepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SuperVisor v1.1.0-beta</title>
<title>SuperVisor {{ frntvers }}</title>
<link rel="stylesheet" href="{{ url_for("static", filename="css3/custfrmt.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/fontsome.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/adminlte.css") }}">
Expand Down Expand Up @@ -79,7 +79,7 @@
</form>
<br/>
<p class="mb-1" style="text-align: center;" id="versinfo">
v1.1.0-beta
{{ frntvers }}
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/termpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SuperVisor v1.1.0-beta</title>
<title>SuperVisor {{ frntvers }}</title>
<link rel="stylesheet" href="{{ url_for("static", filename="css3/fontsome.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/adminlte.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css3/custfrmt.css") }}">
Expand Down

0 comments on commit 5050203

Please sign in to comment.