mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Merge branch 'ls-arq' of github.com:DJ2LS/FreeDATA into ls-arq
This commit is contained in:
commit
3aca773cd6
|
@ -44,6 +44,7 @@ var lastIsWritingBroadcast = new Date().getTime();
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
||||||
var chatDB = path.join(configFolder, "chatDB");
|
var chatDB = path.join(configFolder, "chatDB");
|
||||||
|
var userDB = path.join(configFolder, "chatDB");
|
||||||
// ---- MessageDB
|
// ---- MessageDB
|
||||||
try {
|
try {
|
||||||
var PouchDB = require("pouchdb");
|
var PouchDB = require("pouchdb");
|
||||||
|
@ -63,6 +64,7 @@ PouchDB.plugin(require("pouchdb-find"));
|
||||||
//PouchDB.plugin(require('pouchdb-replication'));
|
//PouchDB.plugin(require('pouchdb-replication'));
|
||||||
|
|
||||||
var db = new PouchDB(chatDB);
|
var db = new PouchDB(chatDB);
|
||||||
|
var users = new PouchDB(userDB);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// REMOTE SYNC ATTEMPTS
|
// REMOTE SYNC ATTEMPTS
|
||||||
|
@ -107,6 +109,7 @@ db.sync('http://172.20.10.4:5984/jojo', {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var dxcallsigns = new Set();
|
var dxcallsigns = new Set();
|
||||||
|
/* -------- CREATE DATABASE INDEXES */
|
||||||
db.createIndex({
|
db.createIndex({
|
||||||
index: {
|
index: {
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -133,6 +136,33 @@ db.createIndex({
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
users
|
||||||
|
.createIndex({
|
||||||
|
index: {
|
||||||
|
fields: [
|
||||||
|
"timestamp",
|
||||||
|
"callsign",
|
||||||
|
"gridsquare",
|
||||||
|
"name",
|
||||||
|
"age",
|
||||||
|
"location",
|
||||||
|
"radio",
|
||||||
|
"antenna",
|
||||||
|
"email",
|
||||||
|
"website",
|
||||||
|
"comments",
|
||||||
|
"_attachments",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(function (result) {
|
||||||
|
// handle result
|
||||||
|
console.log(result);
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
|
||||||
db.find({
|
db.find({
|
||||||
selector: {
|
selector: {
|
||||||
timestamp: {
|
timestamp: {
|
||||||
|
@ -174,6 +204,67 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
document.getElementById("bootstrap_theme").href = theme_path;
|
document.getElementById("bootstrap_theme").href = theme_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(config.mycall);
|
||||||
|
users
|
||||||
|
.find({
|
||||||
|
selector: {
|
||||||
|
callsign: config.mycall,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(function (result) {
|
||||||
|
// handle result
|
||||||
|
document.getElementById("user_info_callsign").value =
|
||||||
|
result.docs[0].callsign;
|
||||||
|
document.getElementById("user_info_gridsquare").value =
|
||||||
|
result.docs[0].gridsquare;
|
||||||
|
document.getElementById("user_info_name").value = result.docs[0].name;
|
||||||
|
document.getElementById("user_info_age").value = result.docs[0].age;
|
||||||
|
document.getElementById("user_info_location").value =
|
||||||
|
result.docs[0].location;
|
||||||
|
document.getElementById("user_info_radio").value = result.docs[0].radio;
|
||||||
|
document.getElementById("user_info_antenna").value =
|
||||||
|
result.docs[0].antenna;
|
||||||
|
document.getElementById("user_info_email").value = result.docs[0].email;
|
||||||
|
document.getElementById("user_info_website").value =
|
||||||
|
result.docs[0].website;
|
||||||
|
document.getElementById("user_info_comments").value =
|
||||||
|
result.docs[0].comments;
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
const userInfoFields = [
|
||||||
|
"user_info_callsign",
|
||||||
|
"user_info_gridsquare",
|
||||||
|
"user_info_name",
|
||||||
|
"user_info_age",
|
||||||
|
"user_info_location",
|
||||||
|
"user_info_radio",
|
||||||
|
"user_info_antenna",
|
||||||
|
"user_info_email",
|
||||||
|
"user_info_website",
|
||||||
|
"user_info_comments",
|
||||||
|
];
|
||||||
|
|
||||||
|
// user info bulk event listener for saving settings
|
||||||
|
userInfoFields.forEach(function (elem) {
|
||||||
|
try {
|
||||||
|
document.getElementById(elem).addEventListener("change", function () {
|
||||||
|
//config[elem] = document.getElementById(elem).value;
|
||||||
|
|
||||||
|
let obj = new Object();
|
||||||
|
userInfoFields.forEach(function (subelem) {
|
||||||
|
obj[subelem] = document.getElementById(subelem).value;
|
||||||
|
});
|
||||||
|
addUserToDatabaseIfNotExists(obj);
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
console.log(elem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
document
|
document
|
||||||
.querySelector("emoji-picker")
|
.querySelector("emoji-picker")
|
||||||
.addEventListener("emoji-click", (event) => {
|
.addEventListener("emoji-click", (event) => {
|
||||||
|
@ -1202,6 +1293,80 @@ add_obj_to_database = function (obj) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* users database functions */
|
||||||
|
addUserToDatabaseIfNotExists = function (obj) {
|
||||||
|
/*
|
||||||
|
"user_info_callsign",
|
||||||
|
"user_info_gridsquare",
|
||||||
|
"user_info_name",
|
||||||
|
"user_info_age",
|
||||||
|
"user_info_location",
|
||||||
|
"user_info_radio",
|
||||||
|
"user_info_antenna",
|
||||||
|
"user_info_email",
|
||||||
|
"user_info_website",
|
||||||
|
"user_info_comments",
|
||||||
|
*/
|
||||||
|
users
|
||||||
|
.find({
|
||||||
|
selector: {
|
||||||
|
callsign: obj.user_info_callsign,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(function (result) {
|
||||||
|
// handle result
|
||||||
|
console.log(result);
|
||||||
|
|
||||||
|
console.log(result.docs.length);
|
||||||
|
if (result.docs.length > 0) {
|
||||||
|
users
|
||||||
|
.put({
|
||||||
|
_id: result.docs[0]._id,
|
||||||
|
_rev: result.docs[0]._rev,
|
||||||
|
callsign: obj.user_info_callsign,
|
||||||
|
gridsquare: obj.user_info_gridsquare,
|
||||||
|
name: obj.user_info_name,
|
||||||
|
age: obj.user_info_age,
|
||||||
|
location: obj.user_info_location,
|
||||||
|
radio: obj.user_info_radio,
|
||||||
|
antenna: obj.user_info_antenna,
|
||||||
|
email: obj.user_info_email,
|
||||||
|
website: obj.user_info_website,
|
||||||
|
comments: obj.user_info_comments,
|
||||||
|
})
|
||||||
|
.then(function (response) {
|
||||||
|
console.log("UPDATED USER");
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
users
|
||||||
|
.post({
|
||||||
|
callsign: obj.user_info_callsign,
|
||||||
|
gridsquare: obj.user_info_gridsquare,
|
||||||
|
name: obj.user_info_name,
|
||||||
|
age: obj.user_info_age,
|
||||||
|
location: obj.user_info_location,
|
||||||
|
radio: obj.user_info_radio,
|
||||||
|
antenna: obj.user_info_antenna,
|
||||||
|
email: obj.user_info_email,
|
||||||
|
website: obj.user_info_website,
|
||||||
|
comments: obj.user_info_comments,
|
||||||
|
})
|
||||||
|
.then(function (response) {
|
||||||
|
console.log("NEW USER ADDED");
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Scroll to bottom of message-container
|
// Scroll to bottom of message-container
|
||||||
function scrollMessagesToBottom() {
|
function scrollMessagesToBottom() {
|
||||||
var messageBody = document.getElementById("message-container");
|
var messageBody = document.getElementById("message-container");
|
||||||
|
|
|
@ -241,7 +241,125 @@
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
|
||||||
Future feature... be patient :-)
|
Future feature... be patient :-)
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Callsign</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Callsign"
|
||||||
|
id="user_info_callsign"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Name</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Name"
|
||||||
|
id="user_info_name"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Age</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Age"
|
||||||
|
id="user_info_age"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Gridsquare</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Gridsquare"
|
||||||
|
id="user_info_gridsquare"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Location</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Location"
|
||||||
|
id="user_info_location"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Radio</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Radio"
|
||||||
|
id="user_info_radio"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Antenna</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Antenna"
|
||||||
|
id="user_info_antenna"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Email</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Email"
|
||||||
|
id="user_info_email"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Website</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Website"
|
||||||
|
id="user_info_website"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
<span class="input-group-text w-25">Comments</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Comments"
|
||||||
|
id="user_info_comments"
|
||||||
|
aria-label="Name"
|
||||||
|
aria-describedby="basic-addon1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -100,12 +100,13 @@ class CONFIG:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for i in range(0,2):
|
for _ in range(2):
|
||||||
try:
|
try:
|
||||||
if default in ["True", "true", True, "False", "false", False]:
|
parameter = (
|
||||||
parameter = self.config[area][key] in ["True", "true", True]
|
self.config[area][key] in ["True", "true", True]
|
||||||
else:
|
if default in ["True", "true", True, "False", "false", False]
|
||||||
parameter = self.config[area][key]
|
else self.config[area][key]
|
||||||
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.config[area][key] = str(default)
|
self.config[area][key] = str(default)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue