Update - still working

This commit is contained in:
Astatin3
2024-02-09 18:52:05 -07:00
parent 0ea56990de
commit ef75228361
22 changed files with 461 additions and 85 deletions
+33
View File
@@ -0,0 +1,33 @@
<link rel="stylesheet" href="https://unpkg.com/xterm@4.11.0/css/xterm.css"/>
<script src="https://unpkg.com/xterm@4.11.0/lib/xterm.js"></script>
<script src="https://unpkg.com/xterm-addon-fit@0.5.0/lib/xterm-addon-fit.js"></script>
<script src="https://unpkg.com/xterm-addon-web-links@0.4.0/lib/xterm-addon-web-links.js"></script>
<script src="https://unpkg.com/xterm-addon-search@0.8.0/lib/xterm-addon-search.js"></script>
<h4>This is an example chat module</h4>
<div id="term"></div>
<script>
window.main = ()=>{
const term = new Terminal({
cursorBlink: true,
macOptionIsMeta: true,
scrollback: true,
});
const fit = new FitAddon.FitAddon()
term.loadAddon(fit)
term.loadAddon(new WebLinksAddon.WebLinksAddon())
term.loadAddon(new SearchAddon.SearchAddon())
term.open(utils.getEl("term"))
fit.fit()
term.onData((data) => {
term.write(data);
})
function resize(){fit.fit()}
window.onresize = resize
}
</script>
+12
View File
@@ -0,0 +1,12 @@
mm = None
def test(ac, data):
mm.sendPopupColor(ac.rawClient, 'test!', 'test!', '#600060', True)
def init(moduleMaster):
global mm
mm = moduleMaster
mm.addAuthEventListener('exampleTest', test)
def main():
pass
+20
View File
@@ -0,0 +1,20 @@
{
"name": "chat",
"creators": ["ASTATIN3"],
"version": "1.0",
"entrypoint": "modules/chat/main.py",
"tabs": [
{
"name": "chat",
"defaultPage": "chat",
"pages": [
{
"type": "page",
"name": "chat",
"requiredPermGroup": "",
"location": "modules/chat/chat.html"
}
]
}
]
}
+11
View File
@@ -0,0 +1,11 @@
<h4>This is a very simple example module!</h4>
<button id="testButton" onclick="testFunc()">test!</button>
<script>
function getel(el) {return document.getElementById(el)}
function testFunc() {
window.sendRaw('test1', {
data: 'test!'
})
}
</script>
+12
View File
@@ -0,0 +1,12 @@
mm = None
def test(ac, data):
mm.sendPopupColor(ac.rawClient, 'test!', 'test!', '#600060', True)
def init(moduleMaster):
global mm
mm = moduleMaster
mm.addAuthEventListener('exampleTest', test)
def main():
pass
+20
View File
@@ -0,0 +1,20 @@
{
"name": "example",
"creators": ["ASTATIN3"],
"version": "1.0",
"entrypoint": "modules/example/main.py",
"tabs": [
{
"name": "example",
"defaultPage": "example",
"pages": [
{
"type": "page",
"name": "example",
"requiredPermGroup": "",
"location": "modules/example/example.html"
}
]
}
]
}
-1
View File
@@ -1 +0,0 @@
<p>Test123123!</p>
+11
View File
@@ -0,0 +1,11 @@
<p>Test!</p>
<button id="testButton" onclick="testFunc()">test!</button>
<script>
function getel(el) {return document.getElementById(el)}
function testFunc() {
window.sendRaw('test1', {
data: 'test!'
})
}
</script>
+34 -5
View File
@@ -1,14 +1,43 @@
from modules.main import test as test
mm = None
def test1(ac, data):
mm.sendPopupColor(ac.rawClient, 'test!', 'test!', '#600060', True)
def logout(ac, data):
ac.send('redir', {
"location": "/"
})
mm.authServer.unauth(ac)
def loadSessions(ac):
obj = []
for client in mm.authServer.clients:
if client.user != ac.user:
continue
obj.append({
'username': client.username,
'address': client.rawClient.address,
'currentPage': client.currentPage,
'clientid': client.rawClient.clientid,
'timeout': client.timeout
})
# obj.append(client.session)
ac.send('sessions', obj)
def unauth(ac, data):
removeClient = mm.getAuthClientByID(data['data'])
if removeClient == None:
return
if removeClient.user == ac.user:
removeClient.send('redir', {
"location": "/"
})
mm.unauth(removeClient)
loadSessions(ac)
def init(moduleMaster):
global mm
mm = moduleMaster
mm.addAuthEventListener('test1', test1)
mm.addAuthEventListener('logout', logout)
mm.addAuthEventListener('unauth', unauth)
mm.addPageEventListener('/main/User', loadSessions)
def main():
pass
+15 -12
View File
@@ -11,27 +11,30 @@
{
"type": "page",
"name": "dashboard",
"requiredPermGroup": "",
"location": "modules/main/Dashboard.html"
},
{
"type": "folder",
"name": "folder 1",
"name": "Settings",
"pages": [
{
"type": "page",
"name": "dashboardcopy",
"location": "modules/main/Dashboard-copy.html"
"name": "User",
"requiredPermGroup": "",
"location": "modules/main/userSettings.html"
},
{
"type": "folder",
"name": "folder 2",
"pages": [
{
"type": "page",
"name": "dashboardcopy",
"location": "modules/main/Dashboard-copy.html"
}
]
"type": "page",
"name": "Program",
"requiredPermGroup": "Admin",
"location": "modules/main/programSettings.html"
},
{
"type": "page",
"name": "Admin",
"requiredPermGroup": "Admin",
"location": "modules/main/adminSettings.html"
}
]
}
+11
View File
@@ -0,0 +1,11 @@
<p>Test!</p>
<button id="testButton" onclick="testFunc()">test!</button>
<script>
function getel(el) {return document.getElementById(el)}
function testFunc() {
window.sendRaw('test1', {
data: 'test!'
})
}
</script>
-2
View File
@@ -1,2 +0,0 @@
def test():
return "testsjdhgkjrhsgkhjertestsjdhgkjrhsgkhjertestsjdhgkjrhsgkhjer"
+86
View File
@@ -0,0 +1,86 @@
<main class="container">
<h3>User Settings</h3>
<p>Sessions</p>
<table role="grid">
<thead>
<tr>
<th scope="col">Username</th>
<th scope="col">Address</th>
<th scope="col">Path</th>
<th scope="col">Expires</th>
<th scope="col">Remove</th>
</tr>
</thead>
<tbody id="sessionTable"></tbody>
</table>
<button id="changePassword" onclick="changePassword()">Change Password</button>
<button id="logoutButton" onclick="promptLogout()">Logout</button>
</main>
<script>
function promptLogout() {
utils.confirmBox('var(--card-sectionning-background-color)', true, 'Are you sure you want to log out?', 'logout()', '')
}
function promptUnauth(clientid) {
utils.confirmBox('var(--card-sectionning-background-color)', true, 'Are you sure you want to log this session out?', `unauthClient('${clientid}')`, '')
}
function logout() {
window.sendRaw('logout', {})
utils.setCookie('session', '')
}
function unauthClient(id) {
window.sendRaw('unauth', id)
}
function changePassword() {
const elem = document.body
const bgcolor = 'var(--card-sectionning-background-color)'
const header = 'rgba(255,255,255,0.05)'
const textColor = 'text-white'
const title = "Change password"
utils.modal(elem, 'document.body',bgcolor, header, textColor, title, `
<input type="password" placeholder="Old Password"></input>
<input type="password" placeholder="New Password"></input>
<input type="password" placeholder="Retype new Password"></input>
<button>Submit</button>`)
}
window.main = ()=>{
const sessionTable = document.getElementById('sessionTable')
window.addListener("sessions", (data)=>{
sessions = data.data
let html = ""
for(let i=0;i<sessions.length;i++){
html += `
<tr>
<td>${sessions[i].username}</td>
<td>${sessions[i].address}</td>
<td>${sessions[i].currentPage}</td>
<td>${utils.formatTime(sessions[i].timeout)}</td>
<td><a href="#" onclick="promptUnauth('${sessions[i].clientid}')">Logout</a></td>
</tr>
`
}
sessionTable.innerHTML = html
})
}
</script>
<!--
#################################################
New Credentials - THESE ONLY WILL BE PRINTED ONCE
########
Username: User
Password: 67FFCdfb9dB827fB
########
Username: Admin
Password: eB0BB402900DfE5A
#################################################
-->