Add user page with profile picture, number and about. change font to Selawik.
This commit is contained in:
parent
0af3395ad7
commit
cce7b74068
12 changed files with 219 additions and 29 deletions
BIN
fonts/selawk.ttf
Normal file
BIN
fonts/selawk.ttf
Normal file
Binary file not shown.
BIN
fonts/selawkb.ttf
Normal file
BIN
fonts/selawkb.ttf
Normal file
Binary file not shown.
BIN
fonts/selawkl.ttf
Normal file
BIN
fonts/selawkl.ttf
Normal file
Binary file not shown.
BIN
fonts/selawksb.ttf
Normal file
BIN
fonts/selawksb.ttf
Normal file
Binary file not shown.
BIN
fonts/selawksl.ttf
Normal file
BIN
fonts/selawksl.ttf
Normal file
Binary file not shown.
29
index.html
29
index.html
|
|
@ -16,10 +16,11 @@
|
|||
<body>
|
||||
<div class="app-container no-active-chat">
|
||||
<aside id="desktop-aside">
|
||||
<button id="profile-sidebar-btn" class="icon-btn mif-person mif-2x" data-page="profile-page"></button>
|
||||
<button id="chats-sidebar-btn" class="icon-btn mif-qa mif-2x" data-page="chat-page"></button>
|
||||
<button id="settings-sidebar-btn" class="icon-btn mif-cog mif-2x" data-page="settings-page"></button>
|
||||
</aside>
|
||||
|
||||
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<header class="sidebar-header">
|
||||
|
|
@ -27,7 +28,7 @@
|
|||
<div class="user-profile">
|
||||
<!-- <div id="pandora-user-icon" class="avatar user-avatar">P</div> -->
|
||||
<div class="user-info">
|
||||
<h3 id="pandora-username">Pandora User</h3>
|
||||
<h3 id="pandora-username" data-content="app-user">Pandora User</h3>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
|
@ -54,13 +55,6 @@
|
|||
<!-- Chats will be dynamically injected here -->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-footer">
|
||||
<div class="api-status-badge">
|
||||
<span class="pulse-dot"></span>
|
||||
<span id="backend-status-text">Backend connected</span>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="extra-page" id="chat-page">
|
||||
|
|
@ -119,6 +113,17 @@
|
|||
</main>
|
||||
</div>
|
||||
|
||||
<section class="extra-page" id="profile-page">
|
||||
<h2 data-content="app-user">Pandora User</h2>
|
||||
<div class="content">
|
||||
<img id="profile-page-picture" data-resource="app-user-image">
|
||||
<div id="profile-page-user-info">
|
||||
<p id="profile-page-user-number" data-content="app-user-number">Pandora User</p>
|
||||
<input id="profile-page-status-input" placeholder="enter your status" data-value="app-user-status">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="extra-page" id="settings-page">
|
||||
<div class="modal-content">
|
||||
<header class="modal-header">
|
||||
|
|
@ -152,6 +157,12 @@
|
|||
<footer class="modal-footer">
|
||||
<button class="btn primary-btn" id="save-settings">Save</button>
|
||||
</footer>
|
||||
<div class="sidebar-footer">
|
||||
<div class="api-status-badge">
|
||||
<span class="pulse-dot"></span>
|
||||
<span id="backend-status-text">Backend connected</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
|||
36
js/app.js
36
js/app.js
|
|
@ -2,8 +2,8 @@ import { config } from "./config.js";
|
|||
import { waha } from "./waha.js";
|
||||
import { ui, elements } from "./ui.js";
|
||||
import { websocket } from "./websocket.js";
|
||||
import { compensateMessageOrdering, formatTime, normalizeId } from "./utils.js";
|
||||
import { fetchChats, getAppUser, getChatMessages, getChats, updateOnlineStatus } from "./storage.js";
|
||||
import { compensateMessageOrdering, debounce, formatTime, normalizeId } from "./utils.js";
|
||||
import { fetchChats, getAppUser, getChatMessages, getChatPicture, getChats, getUser, getUserAbout, sendStatus, updateOnlineStatus } from "./storage.js";
|
||||
import { upsertMessages } from "./db.js";
|
||||
|
||||
let activeChatState = null;
|
||||
|
|
@ -20,7 +20,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
await updateOnlineStatus();
|
||||
setupEventListeners();
|
||||
try {
|
||||
elements.loggedUserName.textContent = (await getAppUser()).pushName;
|
||||
setupElementsData();
|
||||
loadChats();
|
||||
checkWahaStatus();
|
||||
initWebSocket();
|
||||
|
|
@ -29,6 +29,25 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
});
|
||||
|
||||
async function setupElementsData() {
|
||||
const usr = await getAppUser();
|
||||
const usrPic = (await getChatPicture(usr.id))?.url;
|
||||
const usrInfo = await getUser(usr.id);
|
||||
const usrAbout = (await getUserAbout(usr.id)).about;
|
||||
elements.contentUserName.forEach(e => {
|
||||
e.innerHTML = usr.pushName;
|
||||
})
|
||||
elements.contentUserNumber.forEach(async e => {
|
||||
e.innerHTML = usrInfo.number;
|
||||
})
|
||||
elements.resourceUserPic.forEach(async e => {
|
||||
e.src = usrPic;
|
||||
})
|
||||
elements.valueUserStatus.forEach(async e => {
|
||||
e.value = usrAbout.trim();
|
||||
})
|
||||
}
|
||||
|
||||
function loadChats() {
|
||||
elements.chatsLoader.classList.remove('hidden');
|
||||
try {
|
||||
|
|
@ -168,6 +187,17 @@ function setupEventListeners() {
|
|||
})
|
||||
|
||||
elements.saveSettingsBtn.addEventListener('click', saveSettings);
|
||||
|
||||
elements.inputUserStatus.addEventListener('input', debounce(async function() {
|
||||
const result = await sendStatus(elements.inputUserStatus.value);
|
||||
console.log(result);
|
||||
}, 2000))
|
||||
|
||||
// elements.selectable.forEach(e => {
|
||||
// e.addEventListener('pointerdown', () => {
|
||||
|
||||
// })
|
||||
// })
|
||||
}
|
||||
|
||||
function initWebSocket() {
|
||||
|
|
|
|||
|
|
@ -43,8 +43,20 @@ export function getGroups() {
|
|||
return chats.filter(c => c.id.endsWith("@g.us"));
|
||||
}
|
||||
|
||||
export function getUser(number) {
|
||||
return users.find(user => user.id === number);
|
||||
export async function getUser(number) {
|
||||
if (online) {
|
||||
return await waha.getUser(number);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getUserAbout(userId) {
|
||||
if (online) {
|
||||
return await waha.getUserAbout(userId);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export function getChats() {
|
||||
|
|
@ -125,4 +137,14 @@ export async function getChatPicture(chatId) {
|
|||
|
||||
export function isOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
export async function sendStatus(text) {
|
||||
if (online) {
|
||||
return await waha.setStatus(text);
|
||||
} else {
|
||||
return {
|
||||
success: false
|
||||
}
|
||||
}
|
||||
}
|
||||
12
js/ui.js
12
js/ui.js
|
|
@ -33,7 +33,13 @@ export const elements = {
|
|||
attachmentInput: document.getElementById('attachment-input'),
|
||||
attachmentBtn: document.getElementById('attachment-btn'),
|
||||
extraPages: document.querySelectorAll('.extra-page'),
|
||||
desktopSidebarButtons: document.querySelectorAll("#desktop-aside button")
|
||||
desktopSidebarButtons: document.querySelectorAll("#desktop-aside button"),
|
||||
contentUserName: document.querySelectorAll('[data-content="app-user"]'),
|
||||
contentUserNumber: document.querySelectorAll('[data-content="app-user-number"]'),
|
||||
resourceUserPic: document.querySelectorAll('[data-resource="app-user-image"]'),
|
||||
valueUserStatus: document.querySelectorAll('[data-value="app-user-status"]'),
|
||||
inputUserStatus: document.getElementById('profile-page-status-input'),
|
||||
selectable: document.querySelectorAll('.selectable'),
|
||||
};
|
||||
|
||||
export const ui = {
|
||||
|
|
@ -92,7 +98,7 @@ export const ui = {
|
|||
|
||||
for (const chat of chats) {
|
||||
const li = document.createElement('li');
|
||||
li.className = `chat-item ${activeChat && activeChat.id === chat.id ? 'active' : ''}`;
|
||||
li.className = `chat-item selectable ${activeChat && activeChat.id === chat.id ? 'active' : ''}`;
|
||||
li.dataset.id = chat.id;
|
||||
|
||||
const initials = chat.name ? chat.name.substring(0, 1).toUpperCase() : '?';
|
||||
|
|
@ -235,7 +241,7 @@ export const ui = {
|
|||
const prevMsgEl = getPrevMessageElem();
|
||||
|
||||
const groupDiv = document.createElement('div');
|
||||
groupDiv.className = `message-group ${isOutgoing ? 'outgoing' : 'incoming'}`;
|
||||
groupDiv.className = `message-group selectable ${isOutgoing ? 'outgoing' : 'incoming'}`;
|
||||
groupDiv.id = normalizeId(msg._serialized ? msg : msg.id);
|
||||
groupDiv.dataset.timestamp = msg.timestamp;
|
||||
groupDiv.dataset.from = msg.participant || msg.from;
|
||||
|
|
|
|||
|
|
@ -112,4 +112,12 @@ export function normalizeId(raw) {
|
|||
return raw._serialized || raw.user || JSON.stringify(raw);
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
export function debounce(func, delay) {
|
||||
let timeoutId;
|
||||
return function() {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(func, delay);
|
||||
};
|
||||
}
|
||||
17
js/waha.js
17
js/waha.js
|
|
@ -102,6 +102,14 @@ export const waha = {
|
|||
return request(`/api/${config.session}/chats/${chatId}/picture`);
|
||||
},
|
||||
|
||||
async getUser(chatId) {
|
||||
return request(`/api/${config.session}/contacts/${chatId}`);
|
||||
},
|
||||
|
||||
async getUserAbout(chatId) {
|
||||
return request(`/api/contacts/about?contactId=${chatId}&session=${config.session}`);
|
||||
},
|
||||
|
||||
async readChat(chatId) {
|
||||
return request('/api/sendSeen', {
|
||||
method: 'POST',
|
||||
|
|
@ -143,6 +151,15 @@ export const waha = {
|
|||
});
|
||||
},
|
||||
|
||||
async setStatus(text) {
|
||||
return request(`/api/${config.session}/profile/status`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
status: text
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
async sendFileMessage(chatId, file) {
|
||||
const fileBase64 = await getBase64(file);
|
||||
const body = {
|
||||
|
|
|
|||
120
style.css
120
style.css
|
|
@ -1,3 +1,33 @@
|
|||
@font-face {
|
||||
font-family: Selawik;
|
||||
src: url(./fonts/selawk.ttf);
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Selawik;
|
||||
src: url(./fonts/selawkl.ttf);
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Selawik;
|
||||
src: url(./fonts/selawksl.ttf);
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Selawik;
|
||||
src: url(./fonts/selawkb.ttf);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Selawik;
|
||||
src: url(./fonts/selawkb.ttf);
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
:root {
|
||||
--bg-main: black;
|
||||
--bg-secondary: #242424;
|
||||
|
|
@ -44,7 +74,7 @@ body.light {
|
|||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-family: Selawik, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +136,7 @@ input:focus {
|
|||
}
|
||||
|
||||
.app-name {
|
||||
font-weight: bolder;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Sidebar Styling */
|
||||
|
|
@ -299,15 +329,28 @@ input:focus {
|
|||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.selected {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
transform: scale(0.98) skewX(10deg);
|
||||
filter: blur(.1px);
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.chat-item:hover {
|
||||
background: rgba(255, 255, 255, 0.04); transform: scale(0.98) skewX(10deg); filter: blur(.1px); opacity: .6;
|
||||
.selectable:hover {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
transform: scale(0.98) skewX(10deg);
|
||||
filter: blur(.1px);
|
||||
opacity: .6;
|
||||
}
|
||||
}
|
||||
|
||||
@media (hover: none) {
|
||||
.chat-item:active {
|
||||
background: rgba(255, 255, 255, 0.04); transform: scale(0.98) skewX(10deg); filter: blur(.1px); opacity: .6;
|
||||
.selectable:active {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
transform: scale(0.98) skewX(10deg);
|
||||
filter: blur(.1px);
|
||||
opacity: .6;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -351,6 +394,7 @@ input:focus {
|
|||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-weight: 300;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
|
|
@ -403,11 +447,6 @@ input:focus {
|
|||
}
|
||||
|
||||
/* Sidebar Footer */
|
||||
.sidebar-footer {
|
||||
padding: 14px 20px;
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.api-status-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
@ -555,7 +594,7 @@ input:focus {
|
|||
|
||||
.active-contact-info h3 {
|
||||
font-size: 1rem;
|
||||
font-weight: bolder;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.contact-status {
|
||||
|
|
@ -604,6 +643,7 @@ input:focus {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
max-width: 65%;
|
||||
transition: .1s;
|
||||
}
|
||||
|
||||
.message-group.incoming {
|
||||
|
|
@ -826,6 +866,49 @@ input:focus {
|
|||
display: flex;
|
||||
}
|
||||
|
||||
#profile-page {
|
||||
flex-direction: column;
|
||||
background-color: var(--bg-main);
|
||||
}
|
||||
|
||||
#profile-page .content {
|
||||
padding: 1.4rem;
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
#profile-page-user-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
#profile-page h2 {
|
||||
padding: 1.4rem;
|
||||
font-size: 5rem;
|
||||
text-wrap-mode: nowrap;
|
||||
overflow: hidden;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
#profile-page-picture {
|
||||
width: 100%;
|
||||
max-width: 10%;
|
||||
height: auto;
|
||||
aspect-ratio: 1/1;
|
||||
}
|
||||
|
||||
#profile-page-status-input {
|
||||
width: 100%;
|
||||
background-color: var(--bg-main);
|
||||
font-size: xx-large;
|
||||
border-bottom: medium solid transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#profile-page-status-input:focus {
|
||||
color: var(--text-primary);
|
||||
border-bottom-color: var(--text-primary);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.app-container {
|
||||
width: 100%;
|
||||
|
|
@ -901,6 +984,19 @@ input:focus {
|
|||
#desktop-aside {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#profile-page .content {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#profile-page-picture {
|
||||
max-width: 50%;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#profile-page-user-number {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* Modal Styling */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue