Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22421959
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/bin/prometheus-modules/rest-users/rest-users.js b/bin/prometheus-modules/rest-users/rest-users.js
index 84acdd4c..c93775e9 100644
--- a/bin/prometheus-modules/rest-users/rest-users.js
+++ b/bin/prometheus-modules/rest-users/rest-users.js
@@ -1,53 +1,51 @@
module.exports.prepare_channel_www_server = function(channel, dispatcher, dependencies){
www_server = dependencies["channel.www_server"];
url = "/api/v1/user";
www_server.route({
method: "GET",
path: url,
handler: function(request, reply){
if(1){
dispatcher.users_get_all_users(dispatcher)
.then(function(users){ // wywołanie metody z dispatchera webowego
reply(users);
})
}else{
reply("No data received.")
}
}
// hanlder GET ma zwrócić dane użytkownika w obiekcie JSONowym
});
www_server.route({
method: "POST",
path: url,
handler: function(request, reply){
console.log("rest.js POST", request.payload)
dispatcher.users_create_user(request.payload.username, request.payload.password, dispatcher)
.then(function(response){
console.log("rest_users.js", response)
reply(response[0].userdata_id.toString());
})
.catch(function(error){
reply("Username is taken.").statusCode="409.1";
})
}
// handler POST ma stworzyć usera o podanej nazwie i haśle
});
-/*
www_server.route({
method: "DELETE",
path: url,
handler: function(request, reply){
console.log("rest.js DELETE", request.payload)
dispatcher.resources_delete(resource_type_name, request.payload).then(function(response){
reply();
});
}
// handler POST ma stworzyć zasób z podanymi wartościami
});
-*/
}
\ No newline at end of file
diff --git a/public/administrator.html b/public/administrator.html
index d7e28b79..53763d3f 100644
--- a/public/administrator.html
+++ b/public/administrator.html
@@ -1,74 +1,72 @@
<html>
<head>
<script src="/jquery.js"></script>
<meta charset="utf-8">
<title>Zarządzanie użytkownikami</title>
<style>
html{
background-color:gray;
}
body{
padding:20px;
background-color:white;
font-family:sans-serif;
max-width:50rem;
margin:0 auto;
}
.email{
color:gray;
font-size:0.8em;
}
li {
margin-bottom: 3px;
}
</style>
</head>
<body>
<center><h1>Zarządzanie użytkownikami</h1></center>
<ul id="lista-uzytkownikow">
</ul>
<hr>
<input type="text" placeholder="Nazwa użytkownika" id="username">
<input type="password" placeholder="Hasło" id="password">
<button id="confirm" onclick="addUser()">Dodaj</button>
</body>
<script>
- $(function(){
- readUserList();
- });
function readUserList(){
$("#lista-uzytkownikow").html("");
$.get("/api/v1/user", function(data) {
-
+ console.log(data);
for(var i in data) {
var entry = data[i];
var getVar = entry.username;
- var node = $("<li>"+entry.username+" <a href='/user.html#"+getVar+"'> <button onclick='editUser("+get+")'>Edytuj</button></a> <button onclick='deleteUser("+get+")'>Usuń</button></li>");
+ var node = $("<li>"+entry.username+" <a href='/user.html#"+getVar+"'> <button onclick='editUser("+getVar+")'>Edytuj</button></a> <button onclick='deleteUser("+getVar+")'>Usuń</button></li>");
$("#lista-uzytkownikow").append(node);
}
});
}
function addUser(){
var username = $("#username").val();
var password = $("#password").val();
$.post("/api/v1/user", {username: username, password: password}, function() {
readUserList();
});
}
function deleteUser(username){
$.ajax({
url: '/api/v1/user',
data: {username: username},
type: 'DELETE',
success: function(result) {
readUserList();
}
});
}
+ readUserList();
</script>
</html>
\ No newline at end of file
diff --git a/public/user.html b/public/user.html
index 86c1c2da..0dafb5cb 100644
--- a/public/user.html
+++ b/public/user.html
@@ -1,53 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<script src="/jquery.js"></script>
<meta charset="utf-8">
<title>Dane użytkownika</title>
<style>
html{
background-color:gray;
}
body{
padding:20px;
background-color:white;
font-family:sans-serif;
max-width:50rem;
margin:0 auto;
}
</style>
</head>
<body>
<center><h1>Dane użytkownika: <span class="insert-conversation-name"></span></h1></center>
<ul id="dane">
</ul>
<button id="confirm" onclick="changeData()">Zapisz</button>
<button id="confirm" onclick="changeData()">Zapisz</button>
</body>
<script>
var user_id = document.location.hash.slice(1);
var base_url = "/api/v1/chat/user/" + user_id;
function checkData(){
var userdata = $("#dane");
userdata.html("");
$.get(base_url, function(data) {
for(var i in data) {
var entry = data[i];
var node = $("<li><input type='text' id='username' value='"+entry.username+"'></li><li><input type='text' id='password' value='"+entry.password+"'></li><li><input type='text' id='email' value='"+entry.email+"'></li>");
userdata.append(node);
}
});
}
function updateData(){
-
+
}
checkData();
</script>
</html>
\ No newline at end of file
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 28, 03:15 (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1218142
Default Alt Text
(5 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline