Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8afd4a81b0 | |||
| a0a6fdaf55 |
@@ -1,2 +1,2 @@
|
|||||||
# Chatenium On Web
|
# Chatenium Nexum
|
||||||
A modern web application for Chatenium compatible with a wide range of devices.
|
The next generation Web application for Chatenium, built on modern standards powered by Chatenium SDK (TypeScript).
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -16,7 +16,7 @@
|
|||||||
"@angular/platform-browser": "^21.2.0",
|
"@angular/platform-browser": "^21.2.0",
|
||||||
"@angular/router": "^21.2.0",
|
"@angular/router": "^21.2.0",
|
||||||
"@angular/service-worker": "^21.2.0",
|
"@angular/service-worker": "^21.2.0",
|
||||||
"@chatenium/chatenium-sdk": "^1.1.10",
|
"@chatenium/chatenium-sdk": "^1.2.0",
|
||||||
"@fortawesome/angular-fontawesome": "^4.0.0",
|
"@fortawesome/angular-fontawesome": "^4.0.0",
|
||||||
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
||||||
@@ -1011,9 +1011,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@chatenium/chatenium-sdk": {
|
"node_modules/@chatenium/chatenium-sdk": {
|
||||||
"version": "1.1.10",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@chatenium/chatenium-sdk/-/chatenium-sdk-1.1.10.tgz",
|
"resolved": "https://registry.npmjs.org/@chatenium/chatenium-sdk/-/chatenium-sdk-1.2.0.tgz",
|
||||||
"integrity": "sha512-FRVKyOzkKQ5wWFL/m3G731VXhvqo3IHpKFcseWfpX5TxBq6Kh9GxpjN8/JQgQ5X+KDES1Nrm4FqOHkVw5CVHyA==",
|
"integrity": "sha512-myNvjsMbxRji6MEHufhgEbCmltLL+Azb2UUA+ovUDuf5+LcdYiLYcIF4A4/NAxRVYx3IcPB4uOVF2f5SqW2sLA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@faker-js/faker": "^10.4.0",
|
"@faker-js/faker": "^10.4.0",
|
||||||
"axios": "^1.14.0",
|
"axios": "^1.14.0",
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
"@angular/platform-browser": "^21.2.0",
|
"@angular/platform-browser": "^21.2.0",
|
||||||
"@angular/router": "^21.2.0",
|
"@angular/router": "^21.2.0",
|
||||||
"@angular/service-worker": "^21.2.0",
|
"@angular/service-worker": "^21.2.0",
|
||||||
"@chatenium/chatenium-sdk": "^1.1.10",
|
"@chatenium/chatenium-sdk": "^1.2.0",
|
||||||
"@fortawesome/angular-fontawesome": "^4.0.0",
|
"@fortawesome/angular-fontawesome": "^4.0.0",
|
||||||
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "3.0 Beta 6 (April 14, 2026)",
|
"version": "Chatenium Nexum 3.0 Beta 8 (April 17, 2026)",
|
||||||
"ok": "Ok",
|
"ok": "Ok",
|
||||||
"back": "Back",
|
"back": "Back",
|
||||||
"aChatProgram": "A messaging platform that you can trust.",
|
"aChatProgram": "A messaging platform that you can trust.",
|
||||||
@@ -10,13 +10,14 @@
|
|||||||
"whatIsChtn": "Chatenium is a chat platform aiming to provide a secure, well integrated fast chatting experience across any devices. You can create a new account for free and start chatting and broadcasting messages.",
|
"whatIsChtn": "Chatenium is a chat platform aiming to provide a secure, well integrated fast chatting experience across any devices. You can create a new account for free and start chatting and broadcasting messages.",
|
||||||
"updating": "Updating...",
|
"updating": "Updating...",
|
||||||
"home": {
|
"home": {
|
||||||
|
"soon": "Coming soon...",
|
||||||
"chtn": "Chatenium ",
|
"chtn": "Chatenium ",
|
||||||
"chtnIs": "Chatenium is ",
|
"chtnIs": "Chatenium is ",
|
||||||
"help": "Help",
|
"help": "Help",
|
||||||
"blog": "Blog",
|
"blog": "Blog",
|
||||||
"apiSpecs": "API specifications",
|
"apiSpecs": "API specifications",
|
||||||
"adaptsToYou": "adapts to you",
|
"adaptsTo": "Chatenium adapts to ",
|
||||||
"adaptsToYouDesc": "We actively work on bringing Chatenium to every device, but not the fast way, the good way by developing a native application for each platform.",
|
"adaptsToYouDesc": "Choose your platform:",
|
||||||
"chtnOnWeb": "Chatenium On Web",
|
"chtnOnWeb": "Chatenium On Web",
|
||||||
"chtnOnWebDesc": "Built for maximum compatibility. The Web will work on every device you have.",
|
"chtnOnWebDesc": "Built for maximum compatibility. The Web will work on every device you have.",
|
||||||
"chtnOnAndroid": "Chatenium On Android™",
|
"chtnOnAndroid": "Chatenium On Android™",
|
||||||
@@ -102,11 +103,71 @@
|
|||||||
"tab3": "Pictures",
|
"tab3": "Pictures",
|
||||||
"tab4": "Settings"
|
"tab4": "Settings"
|
||||||
},
|
},
|
||||||
|
"network": {
|
||||||
|
"tabs": {
|
||||||
|
"channels": "Channels",
|
||||||
|
"members": "Members",
|
||||||
|
"settings": "Settings"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"options": {
|
||||||
|
"categories": {
|
||||||
|
"apps": "Apps",
|
||||||
|
"moderation": "Moderation",
|
||||||
|
"community": "Community"
|
||||||
|
},
|
||||||
|
"overview": "Overview",
|
||||||
|
"rank": "Ranks",
|
||||||
|
"emoji": "Emojis",
|
||||||
|
"embed": "Embed",
|
||||||
|
"invite": "Invites",
|
||||||
|
"webhook": "Webhooks",
|
||||||
|
"bots": "Bots",
|
||||||
|
"activityHistory": "Activity history",
|
||||||
|
"bans": "Bans",
|
||||||
|
"communityChannels": "Community channels",
|
||||||
|
"networkIntroducer": "Network introducer",
|
||||||
|
"members": "Members"
|
||||||
|
},
|
||||||
|
"overviewPage": {
|
||||||
|
"networkPicture": "Network picture",
|
||||||
|
"networkName": "Network name",
|
||||||
|
"networkVisibility": "Network visibility",
|
||||||
|
"uploadNewPicture": "Upload new picture",
|
||||||
|
"setNewName": "Set new name",
|
||||||
|
"changeToPrivate": "Change to private",
|
||||||
|
"changeToPrivateDialog": {
|
||||||
|
"label": "You are about to make your network private",
|
||||||
|
"warn": {
|
||||||
|
"1": "Your network will be delisted from Network Discovery.",
|
||||||
|
"2": "Users will no longer be able to freely join your network without an invite.",
|
||||||
|
"3": "Your broadcasts may be unavailable to users outside your network."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"changeToPublic": "Change to public",
|
||||||
|
"changeToPublicDialog": {
|
||||||
|
"label": "You are about to make your network public",
|
||||||
|
"warn": {
|
||||||
|
"1": "Your network will be listed in Network Discovery.",
|
||||||
|
"2": "Users will be able to freely join your network without an invite.",
|
||||||
|
"3": "Your broadcasts will be available to users outside your network."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"setNewNameDialog": {
|
||||||
|
"label": "New name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"changeLogDialog": {
|
"changeLogDialog": {
|
||||||
"label": "Chatenium has been updated",
|
"label": "Chatenium has been updated",
|
||||||
"changeLog": {
|
"changeLog": {
|
||||||
"1": "UI issue fixes in the message box",
|
"1": "Optimized the loading of chats and networks",
|
||||||
"2": "Added caching to improve performance"
|
"2": "Added skeleton loaders for messages inside DMs and channels",
|
||||||
|
"3": "Added tabs in networks",
|
||||||
|
"4": "Added option to edit network name",
|
||||||
|
"5": "Added option to change network visibility",
|
||||||
|
"6": "Fixed overflow issues in the mobile UI"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chatnav": {
|
"chatnav": {
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>{{ "chat.changeLogDialog.changeLog.1"|translate }}</li>
|
<li>{{ "chat.changeLogDialog.changeLog.1"|translate }}</li>
|
||||||
<li>{{ "chat.changeLogDialog.changeLog.2"|translate }}</li>
|
<li>{{ "chat.changeLogDialog.changeLog.2"|translate }}</li>
|
||||||
|
<li>{{ "chat.changeLogDialog.changeLog.3"|translate }}</li>
|
||||||
|
<li>{{ "chat.changeLogDialog.changeLog.4"|translate }}</li>
|
||||||
|
<li>{{ "chat.changeLogDialog.changeLog.5"|translate }}</li>
|
||||||
|
<li>{{ "chat.changeLogDialog.changeLog.6"|translate }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<button tuiButton iconStart="@tui.check"
|
<button tuiButton iconStart="@tui.check"
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#navigation_content {
|
#navigation_content {
|
||||||
|
overflow-y: scroll;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@for (chat of serviceManager.chats(); track chat.chatid) {
|
@for (chat of serviceManager.chats(); track chat.chatid) {
|
||||||
<button [class.enlarge]="breakpoint() == 'mobile'" tuiButton [appearance]="router.url == '/chat/dm/' + chat.chatid ? 'primary' : 'flat'" [routerLink]="'/chat/dm/' + chat.chatid">
|
<button [class.enlarge]="breakpoint() == 'mobile'" tuiButton
|
||||||
|
[appearance]="router.url == '/chat/dm/' + chat.chatid ? 'primary' : 'flat'"
|
||||||
|
[routerLink]="'/chat/dm/' + chat.chatid">
|
||||||
<oimg [src]="chat.pfp" height="35px" width="35px" [radius]="10"></oimg>
|
<oimg [src]="chat.pfp" height="35px" width="35px" [radius]="10"></oimg>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
@if (chat.displayName == "") {
|
@if (chat.displayName == "") {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {Component, inject, input, OnInit, signal} from '@angular/core';
|
import {Component, inject, input, OnInit} from '@angular/core';
|
||||||
import {ChatService} from '@chatenium/chatenium-sdk/services/chatService';
|
import {ChatService} from '@chatenium/chatenium-sdk/services/chatService';
|
||||||
import {IndexedDB} from '../../storage/indexed-db';
|
import {IndexedDB} from '../../storage/indexed-db';
|
||||||
import {Chat} from '@chatenium/chatenium-sdk/domain/chatService.schema';
|
|
||||||
import {TUI_BREAKPOINT, TuiButton, TuiLoader} from '@taiga-ui/core';
|
import {TUI_BREAKPOINT, TuiButton, TuiLoader} from '@taiga-ui/core';
|
||||||
import {Oimg} from '../elements/oimg/oimg';
|
import {Oimg} from '../elements/oimg/oimg';
|
||||||
import {Router, RouterLink} from '@angular/router';
|
import {Router, RouterLink} from '@angular/router';
|
||||||
@@ -31,6 +30,7 @@ export class DmList implements OnInit {
|
|||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.serviceManager.chatService = new ChatService(this.userid(), this.token(), this.indexedDb.getApi(), () => {})
|
this.serviceManager.chatService = new ChatService(this.userid(), this.token(), this.indexedDb.getApi(), () => {})
|
||||||
|
if (this.serviceManager.chatsStatus() != LoadStatus.loaded) {
|
||||||
try {
|
try {
|
||||||
this.serviceManager.chats.set(await this.serviceManager.chatService.getQuick())
|
this.serviceManager.chats.set(await this.serviceManager.chatService.getQuick())
|
||||||
this.serviceManager.chatsStatus.set(LoadStatus.updating)
|
this.serviceManager.chatsStatus.set(LoadStatus.updating)
|
||||||
@@ -45,6 +45,7 @@ export class DmList implements OnInit {
|
|||||||
this.serviceManager.chatsStatus.set(LoadStatus.error)
|
this.serviceManager.chatsStatus.set(LoadStatus.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected readonly LoadStatus = LoadStatus;
|
protected readonly LoadStatus = LoadStatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</navbar>
|
</navbar>
|
||||||
|
|
||||||
<messages [messageBoxViewModel]="store.messageBox" [messages]="store.messages()" id="scrollContainer" (onDelete)="deleteMessage($event)"/>
|
<messages (scrollend)="handleMessagesScroll($event)" [loading]="store.messagesStatus() == LoadStatus.loading" [messageBoxViewModel]="store.messageBox" [messages]="store.messages()" id="scrollContainer" (onDelete)="deleteMessage($event)"/>
|
||||||
|
|
||||||
<message-box [viewModel]="store.messageBox"/>
|
<message-box [viewModel]="store.messageBox"/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||||
import {DmStorage, ServiceManager} from '../../service-manager';
|
import {DmStorage, LoadStatus, ServiceManager} from '../../service-manager';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {DMService} from '@chatenium/chatenium-sdk/services/dmService';
|
import {DMService} from '@chatenium/chatenium-sdk/services/dmService';
|
||||||
import {IndexedDB} from '../../storage/indexed-db';
|
import {IndexedDB} from '../../storage/indexed-db';
|
||||||
@@ -11,9 +11,10 @@ import {Messages} from '../elements/messages/messages';
|
|||||||
import {Chat} from '@chatenium/chatenium-sdk/domain/chatService.schema';
|
import {Chat} from '@chatenium/chatenium-sdk/domain/chatService.schema';
|
||||||
import {Message} from '@chatenium/chatenium-sdk/domain/dmService.schema';
|
import {Message} from '@chatenium/chatenium-sdk/domain/dmService.schema';
|
||||||
import {MessageBoxViewModel} from '../elements/message-box/message-box-viewmodel';
|
import {MessageBoxViewModel} from '../elements/message-box/message-box-viewmodel';
|
||||||
import {WebSocketHandler} from '@chatenium/chatenium-sdk/core/webSocketHandler';
|
import {FileUploadProgressListener} from '@chatenium/chatenium-sdk/domain/fileUploadService.schema';
|
||||||
import {FileData, FileUploadProgressListener} from '@chatenium/chatenium-sdk/domain/fileUploadService.schema';
|
|
||||||
import {Attachment} from '@chatenium/chatenium-sdk/domain/common.schema';
|
import {Attachment} from '@chatenium/chatenium-sdk/domain/common.schema';
|
||||||
|
import {MessagesViewModel} from '../elements/messages/messages-viewmodel';
|
||||||
|
import {v4 as uuidv4} from 'uuid';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dm',
|
selector: 'app-dm',
|
||||||
@@ -42,6 +43,7 @@ export class Dm implements OnInit {
|
|||||||
|
|
||||||
async sendMessage(message: string, files: FileDataWithPreview[] | null) {
|
async sendMessage(message: string, files: FileDataWithPreview[] | null) {
|
||||||
if (!files && message.trim() == "") return
|
if (!files && message.trim() == "") return
|
||||||
|
this.scrollToBottom("smooth")
|
||||||
|
|
||||||
const session = this.serviceManager.currentSession();
|
const session = this.serviceManager.currentSession();
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
@@ -66,8 +68,11 @@ export class Dm implements OnInit {
|
|||||||
|
|
||||||
let attachments: Attachment[] = []
|
let attachments: Attachment[] = []
|
||||||
files?.forEach(file => {
|
files?.forEach(file => {
|
||||||
const extraMetaData: Record<string, string> = {}
|
const extraMetaData: Record<string, any> = {}
|
||||||
extraMetaData["thumbnailMetaData"] = file.videoThumbnail ?? ""
|
extraMetaData["thumbnailMetaData"] = file.videoThumbnail ?? ""
|
||||||
|
extraMetaData["progressShown"] = true
|
||||||
|
extraMetaData["totalChunks"] = 0
|
||||||
|
extraMetaData["uploadedChunks"] = 0
|
||||||
|
|
||||||
attachments.push({
|
attachments.push({
|
||||||
fileName: file.name,
|
fileName: file.name,
|
||||||
@@ -81,6 +86,7 @@ export class Dm implements OnInit {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const tempMsgId = uuidv4()
|
||||||
this.store.messages.update(value => [...value, {
|
this.store.messages.update(value => [...value, {
|
||||||
message: message,
|
message: message,
|
||||||
chatid: this.chatid,
|
chatid: this.chatid,
|
||||||
@@ -88,7 +94,7 @@ export class Dm implements OnInit {
|
|||||||
replyTo: "",
|
replyTo: "",
|
||||||
author: session.userData.userid,
|
author: session.userData.userid,
|
||||||
seen: false,
|
seen: false,
|
||||||
msgid: "",
|
msgid: tempMsgId,
|
||||||
forwardedFrom: "",
|
forwardedFrom: "",
|
||||||
isEdited: false,
|
isEdited: false,
|
||||||
sent_at: {T: 0, I: 0},
|
sent_at: {T: 0, I: 0},
|
||||||
@@ -98,14 +104,13 @@ export class Dm implements OnInit {
|
|||||||
|
|
||||||
this.scrollToBottom("smooth")
|
this.scrollToBottom("smooth")
|
||||||
|
|
||||||
await this.store.service.sendMessage("", message, null, null, files, <FileUploadProgressListener>{
|
const respMessage = await this.store.service.sendMessage(tempMsgId, message, null, null, files, <FileUploadProgressListener>{
|
||||||
fileProgressUpdate: (tempMsgId, fileId, allChunks, chunksDone) => {
|
fileProgressUpdate: (tempMsgId, fileId, allChunks, chunksDone) => {
|
||||||
this.uploadProgressUpdate(tempMsgId, fileId, allChunks, chunksDone)
|
this.uploadProgressUpdate(tempMsgId, fileId, allChunks, chunksDone)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
this.updateTempMessage(tempMsgId, respMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.store.messageBox.message.set("")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteMessage(messageId: string) {
|
async deleteMessage(messageId: string) {
|
||||||
@@ -125,15 +130,61 @@ export class Dm implements OnInit {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const scrollContainer = <HTMLDivElement>document.querySelector("#scrollContainer")
|
const scrollContainer = <HTMLDivElement>document.querySelector("#scrollContainer")
|
||||||
scrollContainer.scroll({
|
scrollContainer.scroll({
|
||||||
top: scrollContainer.scrollHeight,
|
top: this.store.messagesVm.scrollBarStatus() == -1 ? scrollContainer.scrollHeight : this.store.messagesVm.scrollBarStatus(),
|
||||||
left: 0,
|
left: 0,
|
||||||
behavior: anim
|
behavior: anim
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.store.messagesVm.scrollBarStatus() == -1) {
|
||||||
|
this.store.messagesVm.scrollBarStatus.set(scrollContainer.scrollHeight)
|
||||||
|
}
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleMessagesScroll(e: any) {
|
||||||
|
this.store.messagesVm.scrollBarStatus.set(e.target.scrollTop)
|
||||||
|
}
|
||||||
|
|
||||||
uploadProgressUpdate(tempMsgId: string, fileId: string, allChunks: number, chunksDone: number) {
|
uploadProgressUpdate(tempMsgId: string, fileId: string, allChunks: number, chunksDone: number) {
|
||||||
console.log(fileId, allChunks, chunksDone)
|
console.log(tempMsgId, fileId, allChunks, chunksDone)
|
||||||
|
this.store.messages.update(messages =>
|
||||||
|
messages.map(m => {
|
||||||
|
if (m.msgid !== tempMsgId) return m;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...m,
|
||||||
|
files: m.files.map(f => {
|
||||||
|
if (f.fileId !== fileId) return f;
|
||||||
|
return {
|
||||||
|
...f,
|
||||||
|
extraMetaData: {
|
||||||
|
...f.extraMetaData,
|
||||||
|
totalChunks: allChunks,
|
||||||
|
uploadedChunks: chunksDone
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTempMessage(tempMsgId: string, message: Message) {
|
||||||
|
this.store.messages.update(messages =>
|
||||||
|
messages.map(m => {
|
||||||
|
if (m.msgid !== tempMsgId) return m;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...m,
|
||||||
|
msgid: message.msgid,
|
||||||
|
sent_at: message.sent_at,
|
||||||
|
files: m.files.map(f => {
|
||||||
|
f.extraMetaData["progressShown"] = false
|
||||||
|
return f
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The chatid parameter ensures isolation
|
// The chatid parameter ensures isolation
|
||||||
@@ -169,7 +220,9 @@ export class Dm implements OnInit {
|
|||||||
const newStore = {
|
const newStore = {
|
||||||
chatData: signal<Chat>(chatData),
|
chatData: signal<Chat>(chatData),
|
||||||
messages: signal<Message[]>([]),
|
messages: signal<Message[]>([]),
|
||||||
|
messagesStatus: signal<LoadStatus>(LoadStatus.loading),
|
||||||
messageBox: new MessageBoxViewModel((msg, files) => this.sendMessage(msg, files)),
|
messageBox: new MessageBoxViewModel((msg, files) => this.sendMessage(msg, files)),
|
||||||
|
messagesVm: new MessagesViewModel(),
|
||||||
wsListener: (action, data) => this.onWsListen(action, data, chatid),
|
wsListener: (action, data) => this.onWsListen(action, data, chatid),
|
||||||
} as DmStorage;
|
} as DmStorage;
|
||||||
|
|
||||||
@@ -187,15 +240,22 @@ export class Dm implements OnInit {
|
|||||||
try {
|
try {
|
||||||
const messagesCache = await currentStore.service.getQuick();
|
const messagesCache = await currentStore.service.getQuick();
|
||||||
currentStore.messages.set(messagesCache);
|
currentStore.messages.set(messagesCache);
|
||||||
|
this.store.messagesStatus.set(LoadStatus.updating)
|
||||||
|
this.scrollToBottom("instant")
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(`Cache load failed: ${e}. Skipping cache load...`)
|
console.warn(`Cache load failed: ${e}. Skipping cache load...`)
|
||||||
}
|
}
|
||||||
const messages = await currentStore.service.get();
|
const messages = await currentStore.service.get();
|
||||||
currentStore.messages.set(messages);
|
currentStore.messages.set(messages);
|
||||||
|
this.store.messagesStatus.set(LoadStatus.loaded)
|
||||||
this.scrollToBottom("instant")
|
this.scrollToBottom("instant")
|
||||||
|
|
||||||
await currentStore.service.joinWebSocketRoom();
|
await currentStore.service.joinWebSocketRoom();
|
||||||
|
} else {
|
||||||
|
this.scrollToBottom("instant")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected readonly LoadStatus = LoadStatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,12 +80,12 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="items-middle">
|
<div class="items-middle">
|
||||||
<textarea (keydown.enter)="viewModel().message.set(''); handleEnterKeydown($event); viewModel().onMessageSend(message.value, null)" [style]="'height:'+textareaHeight+'px;'" #message (input)="onTextAreaInput(message)" [(ngModel)]="viewModel().message"></textarea>
|
<textarea (keydown.enter)="viewModel().onMessageSend(message.value, null); viewModel().message.set(''); viewModel().editingMessage.set(null); handleEnterKeydown($event)" [style]="'height:'+textareaHeight+'px;'" #message (input)="onTextAreaInput(message)" [(ngModel)]="viewModel().message"></textarea>
|
||||||
<span class="placeholder"
|
<span class="placeholder"
|
||||||
[class.hidden]="message.value != ''">{{ "chat.elements.messageBox.placeholder"|translate }}</span>
|
[class.hidden]="message.value != ''">{{ "chat.elements.messageBox.placeholder"|translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="items-right">
|
<div class="items-right">
|
||||||
<button [disabled]="message.value.trim() == ''" tuiButton appearance="flat" (click)="viewModel().message.set(''); viewModel().onMessageSend(message.value, null)">
|
<button [disabled]="message.value.trim() == ''" tuiButton appearance="flat" (click)="viewModel().onMessageSend(message.value, null); viewModel().message.set(''); viewModel().editingMessage.set(null);">
|
||||||
<tui-icon icon="@tui.send"/>
|
<tui-icon icon="@tui.send"/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
6
src/app/chat/elements/messages/messages-viewmodel.ts
Normal file
6
src/app/chat/elements/messages/messages-viewmodel.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import {signal} from '@angular/core';
|
||||||
|
|
||||||
|
export class MessagesViewModel {
|
||||||
|
// Saves scrolling state. First value initialized when scrolling to bottom on the message load
|
||||||
|
scrollBarStatus = signal<number>(-1)
|
||||||
|
}
|
||||||
@@ -1,3 +1,17 @@
|
|||||||
|
@if (loading()) {
|
||||||
|
@for (_ of [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}]; track _; let i = $index) {
|
||||||
|
<div class="message"
|
||||||
|
[class.chained_start]="i == 0 || i == 3 || i == 6"
|
||||||
|
[class.chained_end]="i == 2 || i == 5 || i == 9"
|
||||||
|
[class.chained_middle]="i != 0 && i != 3 && i != 6 && i != 2 && i != 5 && i != 9"
|
||||||
|
[class.author]="i == 3 || i == 4 || i == 5"
|
||||||
|
>
|
||||||
|
<div class="bubble" [tuiSkeleton]="true">
|
||||||
|
{{i}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
} @else {
|
||||||
@if (serviceManager.currentSession != null) {
|
@if (serviceManager.currentSession != null) {
|
||||||
@for (message of messages(); track message.msgid; let i = $index) {
|
@for (message of messages(); track message.msgid; let i = $index) {
|
||||||
<div
|
<div
|
||||||
@@ -17,6 +31,16 @@
|
|||||||
<span class="message-text">{{ message.message }}</span>
|
<span class="message-text">{{ message.message }}</span>
|
||||||
<masonry style="max-height: 300px">
|
<masonry style="max-height: 300px">
|
||||||
@for (file of filterExpressedMedia(message.files); track file) {
|
@for (file of filterExpressedMedia(message.files); track file) {
|
||||||
|
<div style="position:relative;">
|
||||||
|
@if (file.extraMetaData && Object.keys(file.extraMetaData).length > 0) {
|
||||||
|
@if (file.extraMetaData['progressShown']) {
|
||||||
|
<tui-progress-circle
|
||||||
|
style="position: absolute; top: 0; right: 0; z-index: 10; transform: translate(-50%, -50%)"
|
||||||
|
[max]="file.extraMetaData['totalChunks']"
|
||||||
|
[value]="file.extraMetaData['uploadedChunks']"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
}
|
||||||
@if (file.type == "image") {
|
@if (file.type == "image") {
|
||||||
<img [src]="file.path"
|
<img [src]="file.path"
|
||||||
style="width: 100%; height: 100%; max-height: 300px; object-fit: cover; border-radius: 25px"/>
|
style="width: 100%; height: 100%; max-height: 300px; object-fit: cover; border-radius: 25px"/>
|
||||||
@@ -28,13 +52,26 @@
|
|||||||
<video-player maxHeight="300px" maxWidth="300px" [src]="file.path"></video-player>
|
<video-player maxHeight="300px" maxWidth="300px" [src]="file.path"></video-player>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</masonry>
|
</masonry>
|
||||||
|
|
||||||
<div tuiGroup orientation="vertical" style="width: 100%">
|
<div tuiGroup orientation="vertical" style="width: 100%">
|
||||||
@for (file of filterNonExpressedMedia(message.files); track file) {
|
@for (file of filterNonExpressedMedia(message.files); track file) {
|
||||||
<div style="width: 100%; height: 50px; display: flex; align-items: center; padding: 0 10px; background: var(--tui-background-accent-1); gap: 5px">
|
<div style="width: 100%; height: 50px; display: flex; align-items: center; padding: 0 10px; background: var(--tui-background-base-alt); gap: 5px">
|
||||||
|
@if (file.extraMetaData && Object.keys(file.extraMetaData).length > 0) {
|
||||||
|
@if (file.extraMetaData['progressShown']) {
|
||||||
|
<tui-progress-circle
|
||||||
|
size="xs"
|
||||||
|
[max]="file.extraMetaData['totalChunks']"
|
||||||
|
[value]="file.extraMetaData['uploadedChunks']"
|
||||||
|
/>
|
||||||
|
} @else {
|
||||||
<tui-icon icon="@tui.file"/>
|
<tui-icon icon="@tui.file"/>
|
||||||
|
}
|
||||||
|
} @else {
|
||||||
|
<tui-icon icon="@tui.file"/>
|
||||||
|
}
|
||||||
<span>{{ file.fileName }}</span>
|
<span>{{ file.fileName }}</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -67,3 +104,5 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,24 @@
|
|||||||
.bubble {
|
.bubble {
|
||||||
background: var(--tui-background-accent-1-hover);
|
background: var(--tui-background-accent-1-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.chained_start {
|
||||||
|
.bubble {
|
||||||
|
border-radius: 10px 25px 10px 10px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.chained_middle {
|
||||||
|
.bubble {
|
||||||
|
border-radius: 10px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.chained_end {
|
||||||
|
.bubble {
|
||||||
|
border-radius: 10px 10px 25px 10px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.chained_start {
|
&.chained_start {
|
||||||
@@ -65,7 +83,7 @@
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
.message-text {
|
.message-text {
|
||||||
white-space: none;
|
white-space: break-spaces;
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {TranslatePipe} from '@ngx-translate/core';
|
|||||||
import {MessageBoxViewModel} from '../message-box/message-box-viewmodel';
|
import {MessageBoxViewModel} from '../message-box/message-box-viewmodel';
|
||||||
import {FileDataWithPreview} from '../message-box/message-box';
|
import {FileDataWithPreview} from '../message-box/message-box';
|
||||||
import {Attachment} from '@chatenium/chatenium-sdk/domain/common.schema';
|
import {Attachment} from '@chatenium/chatenium-sdk/domain/common.schema';
|
||||||
|
import {TuiProgressCircle, TuiSkeleton} from '@taiga-ui/kit';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'messages',
|
selector: 'messages',
|
||||||
@@ -32,7 +33,9 @@ import {Attachment} from '@chatenium/chatenium-sdk/domain/common.schema';
|
|||||||
TranslatePipe,
|
TranslatePipe,
|
||||||
TuiDataListComponent,
|
TuiDataListComponent,
|
||||||
TuiGroup,
|
TuiGroup,
|
||||||
TuiIcon
|
TuiIcon,
|
||||||
|
TuiProgressCircle,
|
||||||
|
TuiSkeleton
|
||||||
],
|
],
|
||||||
templateUrl: './messages.html',
|
templateUrl: './messages.html',
|
||||||
styleUrl: './messages.scss',
|
styleUrl: './messages.scss',
|
||||||
@@ -42,6 +45,7 @@ export class Messages {
|
|||||||
|
|
||||||
messages = input.required<Message[] | NetworkMessage[]>()
|
messages = input.required<Message[] | NetworkMessage[]>()
|
||||||
messageBoxViewModel = input.required<MessageBoxViewModel>()
|
messageBoxViewModel = input.required<MessageBoxViewModel>()
|
||||||
|
loading = input(false)
|
||||||
|
|
||||||
@Output() onDelete = new EventEmitter<string>()
|
@Output() onDelete = new EventEmitter<string>()
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {IndexedDB} from '../../storage/indexed-db';
|
|||||||
import {Router, RouterLink} from '@angular/router';
|
import {Router, RouterLink} from '@angular/router';
|
||||||
import {LoadStatus, ServiceManager} from '../../service-manager';
|
import {LoadStatus, ServiceManager} from '../../service-manager';
|
||||||
import {TUI_BREAKPOINT, TuiButton, TuiLoader} from '@taiga-ui/core';
|
import {TUI_BREAKPOINT, TuiButton, TuiLoader} from '@taiga-ui/core';
|
||||||
import {ChatService} from '@chatenium/chatenium-sdk/services/chatService';
|
|
||||||
import {NetworkService} from '@chatenium/chatenium-sdk/services/networkService';
|
import {NetworkService} from '@chatenium/chatenium-sdk/services/networkService';
|
||||||
import {Oimg} from '../elements/oimg/oimg';
|
import {Oimg} from '../elements/oimg/oimg';
|
||||||
import {TranslatePipe} from '@ngx-translate/core';
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
@@ -31,6 +30,7 @@ export class NetworkList implements OnInit {
|
|||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.serviceManager.networkService = new NetworkService(this.userid(), this.token(), "", this.indexedDb.getApi(), () => {})
|
this.serviceManager.networkService = new NetworkService(this.userid(), this.token(), "", this.indexedDb.getApi(), () => {})
|
||||||
|
if (this.serviceManager.networksStatus() != LoadStatus.loaded) {
|
||||||
try {
|
try {
|
||||||
this.serviceManager.networks.set(await this.serviceManager.networkService.getQuick())
|
this.serviceManager.networks.set(await this.serviceManager.networkService.getQuick())
|
||||||
this.serviceManager.networksStatus.set(LoadStatus.updating)
|
this.serviceManager.networksStatus.set(LoadStatus.updating)
|
||||||
@@ -45,6 +45,7 @@ export class NetworkList implements OnInit {
|
|||||||
this.serviceManager.networksStatus.set(LoadStatus.error)
|
this.serviceManager.networksStatus.set(LoadStatus.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected readonly LoadStatus = LoadStatus;
|
protected readonly LoadStatus = LoadStatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</navbar>
|
</navbar>
|
||||||
|
|
||||||
<messages [messageBoxViewModel]="store!.messageBox" [messages]="store!.messages()" id="scrollContainer"
|
<messages [loading]="store!.messagesStatus() == LoadStatus.loading" (scrollend)="handleMessagesScroll($event)" [messageBoxViewModel]="store!.messageBox" [messages]="store!.messages()" id="scrollContainer"
|
||||||
(onDelete)="deleteMessage($event)"/>
|
(onDelete)="deleteMessage($event)"/>
|
||||||
|
|
||||||
<message-box [viewModel]="store!.messageBox"/>
|
<message-box [viewModel]="store!.messageBox"/>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Component, inject, signal} from '@angular/core';
|
import {Component, inject, signal} from '@angular/core';
|
||||||
import {DmStorage, ServiceManager, TextChannelStorage} from '../../../../service-manager';
|
import {DmStorage, LoadStatus, ServiceManager, TextChannelStorage} from '../../../../service-manager';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {IndexedDB} from '../../../../storage/indexed-db';
|
import {IndexedDB} from '../../../../storage/indexed-db';
|
||||||
import {TUI_BREAKPOINT, TuiButton, TuiIcon} from '@taiga-ui/core';
|
import {TUI_BREAKPOINT, TuiButton, TuiIcon} from '@taiga-ui/core';
|
||||||
@@ -12,6 +12,8 @@ import {Message} from '@chatenium/chatenium-sdk/domain/textChannelService.schema
|
|||||||
import {Messages} from '../../../elements/messages/messages';
|
import {Messages} from '../../../elements/messages/messages';
|
||||||
import {Navbar} from '../../../elements/navbar/navbar';
|
import {Navbar} from '../../../elements/navbar/navbar';
|
||||||
import {Oimg} from '../../../elements/oimg/oimg';
|
import {Oimg} from '../../../elements/oimg/oimg';
|
||||||
|
import {MessagesViewModel} from '../../../elements/messages/messages-viewmodel';
|
||||||
|
import {v4 as uuidv4} from 'uuid';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-text',
|
selector: 'app-text',
|
||||||
@@ -65,15 +67,16 @@ export class Text {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.store.messageBox.editingMessage.set(null)
|
|
||||||
this.store.messageBox.message.set("")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let attachments: Attachment[] = []
|
let attachments: Attachment[] = []
|
||||||
files?.forEach(file => {
|
files?.forEach(file => {
|
||||||
const extraMetaData: Record<string, string> = {}
|
const extraMetaData: Record<string, any> = {}
|
||||||
extraMetaData["thumbnailMetaData"] = file.videoThumbnail ?? ""
|
extraMetaData["thumbnailMetaData"] = file.videoThumbnail ?? ""
|
||||||
|
extraMetaData["progressShown"] = true
|
||||||
|
extraMetaData["totalChunks"] = 0
|
||||||
|
extraMetaData["uploadedChunks"] = 0
|
||||||
|
|
||||||
attachments.push({
|
attachments.push({
|
||||||
fileName: file.name,
|
fileName: file.name,
|
||||||
@@ -87,6 +90,7 @@ export class Text {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const tempMsgId = uuidv4()
|
||||||
this.store.messages.update(value => [...value, {
|
this.store.messages.update(value => [...value, {
|
||||||
author: {
|
author: {
|
||||||
userid: session.userData.userid,
|
userid: session.userData.userid,
|
||||||
@@ -94,7 +98,7 @@ export class Text {
|
|||||||
username: session.userData.username,
|
username: session.userData.username,
|
||||||
displayName: session.userData.displayName
|
displayName: session.userData.displayName
|
||||||
},
|
},
|
||||||
msgid: "",
|
msgid: tempMsgId,
|
||||||
message: message,
|
message: message,
|
||||||
sent_at: {
|
sent_at: {
|
||||||
T: 0,
|
T: 0,
|
||||||
@@ -104,7 +108,7 @@ export class Text {
|
|||||||
channelId: "",
|
channelId: "",
|
||||||
networkId: "",
|
networkId: "",
|
||||||
categoryId: "",
|
categoryId: "",
|
||||||
files: [],
|
files: attachments,
|
||||||
seen: false,
|
seen: false,
|
||||||
replyTo: "",
|
replyTo: "",
|
||||||
replyToId: "",
|
replyToId: "",
|
||||||
@@ -114,11 +118,12 @@ export class Text {
|
|||||||
|
|
||||||
this.scrollToBottom("smooth")
|
this.scrollToBottom("smooth")
|
||||||
|
|
||||||
await this.store.service.sendMessage("", message, null, null, files, <FileUploadProgressListener>{
|
const respMessage = await this.store.service.sendMessage(tempMsgId, message, null, null, files, <FileUploadProgressListener>{
|
||||||
fileProgressUpdate: (tempMsgId, fileId, allChunks, chunksDone) => {
|
fileProgressUpdate: (tempMsgId, fileId, allChunks, chunksDone) => {
|
||||||
this.uploadProgressUpdate(tempMsgId, fileId, allChunks, chunksDone)
|
this.uploadProgressUpdate(tempMsgId, fileId, allChunks, chunksDone)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
this.updateTempMessage(tempMsgId, respMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,19 +143,69 @@ export class Text {
|
|||||||
|
|
||||||
scrollToBottom(anim: 'instant' | 'smooth'): void {
|
scrollToBottom(anim: 'instant' | 'smooth'): void {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (!this.store) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const scrollContainer = <HTMLDivElement>document.querySelector("#scrollContainer")
|
const scrollContainer = <HTMLDivElement>document.querySelector("#scrollContainer")
|
||||||
scrollContainer.scroll({
|
scrollContainer.scroll({
|
||||||
top: scrollContainer.scrollHeight,
|
top: this.store.messagesVm.scrollBarStatus() == -1 ? scrollContainer.scrollHeight : this.store.messagesVm.scrollBarStatus(),
|
||||||
left: 0,
|
left: 0,
|
||||||
behavior: anim
|
behavior: anim
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.store.messagesVm.scrollBarStatus() == -1) {
|
||||||
|
this.store.messagesVm.scrollBarStatus.set(scrollContainer.scrollHeight)
|
||||||
|
}
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadProgressUpdate(tempMsgId: string, fileId: string, allChunks: number, chunksDone: number) {
|
handleMessagesScroll(e: any) {
|
||||||
console.log(fileId, allChunks, chunksDone)
|
if (!this.store) return
|
||||||
|
this.store.messagesVm.scrollBarStatus.set(e.target.scrollTop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uploadProgressUpdate(tempMsgId: string, fileId: string, allChunks: number, chunksDone: number) {
|
||||||
|
if (!this.store) return
|
||||||
|
this.store.messages.update(messages =>
|
||||||
|
messages.map(m => {
|
||||||
|
if (m.msgid !== tempMsgId) return m;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...m,
|
||||||
|
files: m.files.map(f => {
|
||||||
|
if (f.fileId !== fileId) return f;
|
||||||
|
return {
|
||||||
|
...f,
|
||||||
|
extraMetaData: {
|
||||||
|
...f.extraMetaData,
|
||||||
|
totalChunks: allChunks,
|
||||||
|
uploadedChunks: chunksDone
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTempMessage(tempMsgId: string, message: Message) {
|
||||||
|
if (!this.store) return
|
||||||
|
this.store.messages.update(messages =>
|
||||||
|
messages.map(m => {
|
||||||
|
if (m.msgid !== tempMsgId) return m;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...m,
|
||||||
|
msgid: message.msgid,
|
||||||
|
sent_at: message.sent_at,
|
||||||
|
files: m.files.map(f => {
|
||||||
|
f.extraMetaData["progressShown"] = false
|
||||||
|
return f
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
// The chatid parameter ensures isolation
|
// The chatid parameter ensures isolation
|
||||||
onWsListen(action: string, message: string, networkId: string, channelId: string) {
|
onWsListen(action: string, message: string, networkId: string, channelId: string) {
|
||||||
const data = JSON.parse(message);
|
const data = JSON.parse(message);
|
||||||
@@ -205,6 +260,8 @@ export class Text {
|
|||||||
categoryData: signal(categoryData),
|
categoryData: signal(categoryData),
|
||||||
channelData: signal(channelData),
|
channelData: signal(channelData),
|
||||||
messages: signal<Message[]>([]),
|
messages: signal<Message[]>([]),
|
||||||
|
messagesVm: new MessagesViewModel(),
|
||||||
|
messagesStatus: signal<LoadStatus>(LoadStatus.loading),
|
||||||
messageBox: new MessageBoxViewModel((msg, files) => this.sendMessage(msg, files)),
|
messageBox: new MessageBoxViewModel((msg, files) => this.sendMessage(msg, files)),
|
||||||
wsListener: (action, data) => this.onWsListen(action, data, networkId, categoryId),
|
wsListener: (action, data) => this.onWsListen(action, data, networkId, categoryId),
|
||||||
} as TextChannelStorage;
|
} as TextChannelStorage;
|
||||||
@@ -225,14 +282,22 @@ export class Text {
|
|||||||
try {
|
try {
|
||||||
const messagesCache = await currentStore.service.getQuick();
|
const messagesCache = await currentStore.service.getQuick();
|
||||||
currentStore.messages.set(messagesCache);
|
currentStore.messages.set(messagesCache);
|
||||||
|
this.scrollToBottom("instant")
|
||||||
|
currentStore.messagesStatus.set(LoadStatus.updating)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(`Cache load failed: ${e}. Skipping cache load...`)
|
console.warn(`Cache load failed: ${e}. Skipping cache load...`)
|
||||||
}
|
}
|
||||||
const messages = await currentStore.service.get();
|
const messages = await currentStore.service.get();
|
||||||
currentStore.messages.set(messages);
|
currentStore.messages.set(messages);
|
||||||
|
currentStore.messagesStatus.set(LoadStatus.loaded)
|
||||||
|
this.scrollToBottom("instant")
|
||||||
|
|
||||||
await currentStore.service.joinWebSocketRoom();
|
await currentStore.service.joinWebSocketRoom();
|
||||||
|
} else {
|
||||||
|
this.scrollToBottom("instant")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected readonly LoadStatus = LoadStatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,37 @@
|
|||||||
<div class="items-right"></div>
|
<div class="items-right"></div>
|
||||||
</navbar>
|
</navbar>
|
||||||
|
|
||||||
|
<tui-tabs [(activeItemIndex)]="tabActiveIndex">
|
||||||
|
<button
|
||||||
|
iconStart="@tui.hash"
|
||||||
|
tuiTab
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{{"chat.network.tabs.channels"|translate}}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
disabled
|
||||||
|
iconStart="@tui.users"
|
||||||
|
tuiTab
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{{"chat.network.tabs.members"|translate}}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
iconStart="@tui.cog"
|
||||||
|
tuiTab
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{{"chat.network.tabs.settings"|translate}}
|
||||||
|
</button>
|
||||||
|
</tui-tabs>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
@switch (tabActiveIndex) {
|
||||||
|
@case (0) {
|
||||||
<main tuiGroup orientation="vertical" style="width: 100%">
|
<main tuiGroup orientation="vertical" style="width: 100%">
|
||||||
@for (category of store.networkData().categories; track category) {
|
@for (category of store.networkData().categories; track category) {
|
||||||
<div class="category">
|
<div class="category">
|
||||||
@@ -39,6 +70,13 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</main>
|
</main>
|
||||||
|
}
|
||||||
|
@case (2) {
|
||||||
|
<main id="settings">
|
||||||
|
<network-settings [networkStore]="this.store"></network-settings>
|
||||||
|
</main>
|
||||||
|
}
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
padding: 15px;
|
padding: 15px;
|
||||||
transition: 0.2s;
|
transition: 0.2s;
|
||||||
|
|
||||||
|
#network-data {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
&.routerOutletActive {
|
&.routerOutletActive {
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -42,4 +47,11 @@
|
|||||||
justify-content: start;
|
justify-content: start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#settings {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: var(--tui-background-base-alt);
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ import {IndexedDB} from '../../storage/indexed-db';
|
|||||||
import {Navbar} from '../elements/navbar/navbar';
|
import {Navbar} from '../elements/navbar/navbar';
|
||||||
import {Oimg} from '../elements/oimg/oimg';
|
import {Oimg} from '../elements/oimg/oimg';
|
||||||
import {TUI_BREAKPOINT, TuiButton, TuiGroup, TuiIcon} from '@taiga-ui/core';
|
import {TUI_BREAKPOINT, TuiButton, TuiGroup, TuiIcon} from '@taiga-ui/core';
|
||||||
|
import {TuiTab, TuiTabsHorizontal, TuiTabsWithMore} from '@taiga-ui/kit';
|
||||||
|
import {TuiItem} from '@taiga-ui/cdk';
|
||||||
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
|
import {Settings} from './settings/settings';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-network',
|
selector: 'app-network',
|
||||||
@@ -21,7 +25,13 @@ import {TUI_BREAKPOINT, TuiButton, TuiGroup, TuiIcon} from '@taiga-ui/core';
|
|||||||
TuiGroup,
|
TuiGroup,
|
||||||
TuiButton,
|
TuiButton,
|
||||||
TuiIcon,
|
TuiIcon,
|
||||||
RouterLink
|
RouterLink,
|
||||||
|
TuiTabsWithMore,
|
||||||
|
TuiItem,
|
||||||
|
TuiTab,
|
||||||
|
TranslatePipe,
|
||||||
|
TuiTabsHorizontal,
|
||||||
|
Settings
|
||||||
],
|
],
|
||||||
templateUrl: './network.html',
|
templateUrl: './network.html',
|
||||||
styleUrl: './network.scss',
|
styleUrl: './network.scss',
|
||||||
@@ -33,6 +43,8 @@ export class Network implements OnInit {
|
|||||||
breakpoint = inject(TUI_BREAKPOINT)
|
breakpoint = inject(TUI_BREAKPOINT)
|
||||||
router = inject(Router)
|
router = inject(Router)
|
||||||
|
|
||||||
|
tabActiveIndex = 2
|
||||||
|
|
||||||
routerOutletActive = signal(false)
|
routerOutletActive = signal(false)
|
||||||
|
|
||||||
networkId = ""
|
networkId = ""
|
||||||
|
|||||||
114
src/app/chat/network/settings/overview/overview.html
Normal file
114
src/app/chat/network/settings/overview/overview.html
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<div tuiGroup id="options" orientation="vertical">
|
||||||
|
<div>
|
||||||
|
<header>
|
||||||
|
<tui-icon icon="@tui.image"></tui-icon>
|
||||||
|
{{ "chat.network.settings.overviewPage.networkPicture"|translate }}
|
||||||
|
<oimg [src]="networkStore().networkData().picture" height="25px" width="25px" [radius]="6"/>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<button tuiButton appearance="outline" disabled iconEnd="@tui.file-up">
|
||||||
|
{{ "chat.network.settings.overviewPage.uploadNewPicture"|translate }}
|
||||||
|
</button>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<ng-template [(tuiDialog)]="setNewNameDialogOpen"
|
||||||
|
[tuiDialogOptions]="{label: 'chat.network.settings.overviewPage.setNewName'|translate}">
|
||||||
|
|
||||||
|
<tui-textfield #newName iconStart="@tui.signature">
|
||||||
|
<label tuiLabel>{{"chat.network.settings.overviewPage.setNewNameDialog.label"|translate}}</label>
|
||||||
|
<input type="text" tuiInput>
|
||||||
|
</tui-textfield>
|
||||||
|
@if (setNewNameError() != "") {
|
||||||
|
<tui-error [error]="setNewNameError()"></tui-error>
|
||||||
|
}
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<button tuiButton iconStart="@tui.check" [loading]="setNewNamePending()" [disabled]="setNewNamePending()" (click)="setNewName(newName.value())">
|
||||||
|
{{'chat.network.settings.overviewPage.setNewName'|translate}}
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
<tui-icon icon="@tui.network"></tui-icon>
|
||||||
|
{{ "chat.network.settings.overviewPage.networkName"|translate }}
|
||||||
|
<b style="color: gray">{{ networkStore().networkData().name }}</b>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<button (click)="setNewNameDialogOpen.set(true)" tuiButton appearance="outline" iconEnd="@tui.pencil">
|
||||||
|
{{ "chat.network.settings.overviewPage.setNewName"|translate }}
|
||||||
|
</button>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<ng-template [(tuiDialog)]="makeNetworkPrivateWarnDialogOpen"
|
||||||
|
[tuiDialogOptions]="{label: 'chat.network.settings.overviewPage.changeToPrivateDialog.label'|translate}">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<tui-icon icon="@tui.eye-off"/>
|
||||||
|
{{ "chat.network.settings.overviewPage.changeToPrivateDialog.warn.1"|translate }}
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<tui-icon icon="@tui.ticket"/>
|
||||||
|
{{ "chat.network.settings.overviewPage.changeToPrivateDialog.warn.2"|translate }}
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<tui-icon icon="@tui.radio"/>
|
||||||
|
{{ "chat.network.settings.overviewPage.changeToPrivateDialog.warn.3"|translate }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<footer>
|
||||||
|
<button tuiButton iconStart="@tui.eye-off" [loading]="networkVisChangePending()" [disabled]="networkVisChangePending()" (click)="changeVisibility('private')">
|
||||||
|
{{'chat.network.settings.overviewPage.changeToPrivate'|translate}}
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<ng-template [(tuiDialog)]="makeNetworkPublicWarnDialogOpen"
|
||||||
|
[tuiDialogOptions]="{label: 'chat.network.settings.overviewPage.changeToPublicDialog.label'|translate}">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<tui-icon icon="@tui.eye"/>
|
||||||
|
{{ "chat.network.settings.overviewPage.changeToPublicDialog.warn.1"|translate }}
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<tui-icon icon="@tui.ticket"/>
|
||||||
|
{{ "chat.network.settings.overviewPage.changeToPublicDialog.warn.2"|translate }}
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<tui-icon icon="@tui.radio"/>
|
||||||
|
{{ "chat.network.settings.overviewPage.changeToPublicDialog.warn.3"|translate }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<footer>
|
||||||
|
<button tuiButton iconStart="@tui.eye" [loading]="networkVisChangePending()" [disabled]="networkVisChangePending()" (click)="changeVisibility('public')">
|
||||||
|
{{'chat.network.settings.overviewPage.changeToPublic'|translate}}
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
@if (networkStore().networkData().visibility == "public") {
|
||||||
|
<tui-icon icon="@tui.eye"></tui-icon>
|
||||||
|
} @else {
|
||||||
|
<tui-icon icon="@tui.eye-off"></tui-icon>
|
||||||
|
}
|
||||||
|
{{ "chat.network.settings.overviewPage.networkVisibility"|translate }}
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
@if (networkStore().networkData().visibility == "public") {
|
||||||
|
<button tuiButton appearance="outline" iconEnd="@tui.eye-off" (click)="makeNetworkPrivateWarnDialogOpen.set(true)">
|
||||||
|
{{ "chat.network.settings.overviewPage.changeToPrivate"|translate }}
|
||||||
|
</button>
|
||||||
|
} @else {
|
||||||
|
<button tuiButton appearance="outline" iconEnd="@tui.eye" (click)="makeNetworkPublicWarnDialogOpen.set(true)">
|
||||||
|
{{ "chat.network.settings.overviewPage.changeToPublic"|translate }}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
31
src/app/chat/network/settings/overview/overview.scss
Normal file
31
src/app/chat/network/settings/overview/overview.scss
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#options {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
div {
|
||||||
|
width: 100%;
|
||||||
|
height: 60px;
|
||||||
|
background: var(--tui-background-base-alt);
|
||||||
|
padding: 15px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
header {
|
||||||
|
display: flex;
|
||||||
|
gap: 5px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: end;
|
||||||
|
|
||||||
|
button {
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/app/chat/network/settings/overview/overview.spec.ts
Normal file
22
src/app/chat/network/settings/overview/overview.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { Overview } from './overview';
|
||||||
|
|
||||||
|
describe('Overview', () => {
|
||||||
|
let component: Overview;
|
||||||
|
let fixture: ComponentFixture<Overview>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [Overview],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(Overview);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
await fixture.whenStable();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
79
src/app/chat/network/settings/overview/overview.ts
Normal file
79
src/app/chat/network/settings/overview/overview.ts
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import {Component, inject, input, signal} from '@angular/core';
|
||||||
|
import {NetworkStorage} from '../../../../service-manager';
|
||||||
|
import {
|
||||||
|
TuiAlertService,
|
||||||
|
TuiButton,
|
||||||
|
TuiDialog,
|
||||||
|
TuiErrorComponent,
|
||||||
|
TuiGroup,
|
||||||
|
TuiIcon,
|
||||||
|
TuiInputDirective
|
||||||
|
} from '@taiga-ui/core';
|
||||||
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
|
import {Oimg} from '../../../elements/oimg/oimg';
|
||||||
|
import {environment} from '../../../../../environments/environment';
|
||||||
|
import {TuiButtonLoading, TuiComboBox} from '@taiga-ui/kit';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'network-settings-overview',
|
||||||
|
imports: [
|
||||||
|
TuiGroup,
|
||||||
|
TranslatePipe,
|
||||||
|
TuiIcon,
|
||||||
|
Oimg,
|
||||||
|
TuiButton,
|
||||||
|
TuiDialog,
|
||||||
|
TuiComboBox,
|
||||||
|
TuiInputDirective,
|
||||||
|
TuiButtonLoading,
|
||||||
|
TuiErrorComponent
|
||||||
|
],
|
||||||
|
templateUrl: './overview.html',
|
||||||
|
styleUrl: './overview.scss',
|
||||||
|
})
|
||||||
|
export class Overview {
|
||||||
|
networkStore = input.required<NetworkStorage>()
|
||||||
|
protected readonly environment = environment;
|
||||||
|
protected readonly localStorage = localStorage;
|
||||||
|
|
||||||
|
setNewNameDialogOpen = signal(false)
|
||||||
|
setNewNamePending = signal(false)
|
||||||
|
setNewNameError = signal("")
|
||||||
|
|
||||||
|
makeNetworkPrivateWarnDialogOpen = signal(false)
|
||||||
|
makeNetworkPublicWarnDialogOpen = signal(false)
|
||||||
|
networkVisChangePending = signal(false)
|
||||||
|
|
||||||
|
async setNewName(name: string) {
|
||||||
|
this.setNewNameError.set("")
|
||||||
|
this.setNewNamePending.set(true)
|
||||||
|
try {
|
||||||
|
await this.networkStore().service.editName(name)
|
||||||
|
this.setNewNamePending.set(false)
|
||||||
|
this.setNewNameDialogOpen.set(false)
|
||||||
|
this.networkStore().networkData.update(
|
||||||
|
value => {
|
||||||
|
value.name = name
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} catch (e) {
|
||||||
|
this.setNewNamePending.set(false)
|
||||||
|
this.setNewNameError.set(e as string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async changeVisibility(newVisibility: "public" | "private") {
|
||||||
|
this.networkVisChangePending.set(true)
|
||||||
|
await this.networkStore().service.changeVisibility(newVisibility)
|
||||||
|
this.networkStore().networkData.update(
|
||||||
|
value => {
|
||||||
|
value.visibility = newVisibility
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
)
|
||||||
|
this.networkVisChangePending.set(false)
|
||||||
|
this.makeNetworkPrivateWarnDialogOpen.set(false)
|
||||||
|
this.makeNetworkPublicWarnDialogOpen.set(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/app/chat/network/settings/settings.html
Normal file
29
src/app/chat/network/settings/settings.html
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<aside>
|
||||||
|
@for (category of networkSettingsOptions; track category) {
|
||||||
|
<header>
|
||||||
|
<tui-icon [icon]="'@tui.'+category.icon"></tui-icon>
|
||||||
|
@if (category.name == "networkName") {
|
||||||
|
{{networkStore().networkData().name}}
|
||||||
|
} @else {
|
||||||
|
{{'chat.network.settings.options.categories.'+category.name|translate}}
|
||||||
|
}
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="optionList">
|
||||||
|
@for (option of category.options; track option;) {
|
||||||
|
<button (click)="selectedOption = option.name" [appearance]="selectedOption == option.name ? 'primary' : 'flat'" tuiButton [disabled]="!option.implemented || !optionRequiredPermissionsGranted(networkStore().networkData().permissions, option.requiredAtLeastOneOf ?? [])">
|
||||||
|
<tui-icon [icon]="'@tui.'+option.icon"></tui-icon>
|
||||||
|
{{'chat.network.settings.options.'+option.name|translate}}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
@switch (selectedOption) {
|
||||||
|
@case ("overview") {
|
||||||
|
<network-settings-overview [networkStore]="networkStore()"/>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</main>
|
||||||
37
src/app/chat/network/settings/settings.scss
Normal file
37
src/app/chat/network/settings/settings.scss
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
:host {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 300px 1fr;
|
||||||
|
|
||||||
|
aside {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 20px 0 0 20px;
|
||||||
|
padding: 15px;
|
||||||
|
|
||||||
|
header {
|
||||||
|
display: flex;
|
||||||
|
gap: 5px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1px;
|
||||||
|
padding: 5px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
background: var(--tui-background-neutral-2);
|
||||||
|
border-radius: 0 20px 20px 0;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/app/chat/network/settings/settings.spec.ts
Normal file
22
src/app/chat/network/settings/settings.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { Settings } from './settings';
|
||||||
|
|
||||||
|
describe('Settings', () => {
|
||||||
|
let component: Settings;
|
||||||
|
let fixture: ComponentFixture<Settings>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [Settings],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(Settings);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
await fixture.whenStable();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
150
src/app/chat/network/settings/settings.ts
Normal file
150
src/app/chat/network/settings/settings.ts
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
import {Component, inject, input} from '@angular/core';
|
||||||
|
import {TuiButton, TuiGroup, TuiIcon} from '@taiga-ui/core';
|
||||||
|
import {permissionGranted, permissions} from '@chatenium/chatenium-sdk/core/permissions';
|
||||||
|
import {NetworkStorage, ServiceManager} from '../../../service-manager';
|
||||||
|
import {Session} from '@chatenium/chatenium-sdk/domain/sessionManager.schema';
|
||||||
|
import {SessionManager} from '@chatenium/chatenium-sdk/services/sessionManager';
|
||||||
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
|
import {Overview} from './overview/overview';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'network-settings',
|
||||||
|
imports: [
|
||||||
|
TuiGroup,
|
||||||
|
TuiIcon,
|
||||||
|
TranslatePipe,
|
||||||
|
TuiButton,
|
||||||
|
Overview
|
||||||
|
],
|
||||||
|
templateUrl: './settings.html',
|
||||||
|
styleUrl: './settings.scss',
|
||||||
|
})
|
||||||
|
export class Settings {
|
||||||
|
serviceManager = inject(ServiceManager)
|
||||||
|
networkStore = input.required<NetworkStorage>()
|
||||||
|
|
||||||
|
selectedOption = "overview"
|
||||||
|
|
||||||
|
optionRequiredPermissionsGranted(permissions: number, required: number[]) {
|
||||||
|
if (!this.serviceManager.currentSession) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
let granted = false;
|
||||||
|
|
||||||
|
if (this.networkStore().networkData().createdBy == this.serviceManager.currentSession()!.userData.userid) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
required.forEach((permission) => {
|
||||||
|
if (permissionGranted(permissions, permission)) {
|
||||||
|
granted = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return granted
|
||||||
|
}
|
||||||
|
|
||||||
|
networkSettingsOptions: {
|
||||||
|
name: string,
|
||||||
|
icon: string,
|
||||||
|
options: {
|
||||||
|
name: string, // ? channel.settings.[name]
|
||||||
|
icon: string // ? Class name
|
||||||
|
requiredAtLeastOneOf?: number[],
|
||||||
|
implemented: boolean
|
||||||
|
}[]
|
||||||
|
}[] = [
|
||||||
|
{
|
||||||
|
name: "networkName", // ? UI Will show network name
|
||||||
|
icon: "network",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
icon: "eye",
|
||||||
|
name: "overview",
|
||||||
|
implemented: true,
|
||||||
|
requiredAtLeastOneOf: [permissions.changeNetworkNamePictureAndVisibility]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "rank",
|
||||||
|
icon: "book",
|
||||||
|
requiredAtLeastOneOf: [permissions.createAndEditRanks, permissions.deleteRanks],
|
||||||
|
implemented: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emoji",
|
||||||
|
icon: "smile",
|
||||||
|
implemented: false,
|
||||||
|
requiredAtLeastOneOf: [permissions.createEmojis]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "embed",
|
||||||
|
icon: "code",
|
||||||
|
implemented: false,
|
||||||
|
requiredAtLeastOneOf: [permissions.manageEmbed]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "invite",
|
||||||
|
icon: "ticket",
|
||||||
|
implemented: false,
|
||||||
|
requiredAtLeastOneOf: [permissions.createInvites, permissions.deleteInvites]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "apps",
|
||||||
|
icon: "layout-panel-left",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "webhook",
|
||||||
|
icon: "globe",
|
||||||
|
implemented: false,
|
||||||
|
requiredAtLeastOneOf: [permissions.deleteWebhooks, permissions.createWebhooks]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "bots",
|
||||||
|
icon: "bot",
|
||||||
|
implemented: false,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "moderation",
|
||||||
|
icon: "shield-half",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "activityHistory",
|
||||||
|
icon: "scroll-text",
|
||||||
|
implemented: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "bans",
|
||||||
|
icon: "gavel",
|
||||||
|
implemented: false,
|
||||||
|
requiredAtLeastOneOf: [permissions.banMembers]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "community",
|
||||||
|
icon: "users",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "communityChannels",
|
||||||
|
icon: "hash",
|
||||||
|
implemented: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "networkIntroducer",
|
||||||
|
icon: "network",
|
||||||
|
implemented: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "members",
|
||||||
|
icon: "users",
|
||||||
|
implemented: false,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@ export class PictureList implements OnInit {
|
|||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.serviceManager.chatService = new ChatService(this.userid(), this.token(), this.indexedDb.getApi(), () => {})
|
this.serviceManager.chatService = new ChatService(this.userid(), this.token(), this.indexedDb.getApi(), () => {})
|
||||||
|
if (this.serviceManager.chatsStatus() != LoadStatus.loaded) {
|
||||||
try {
|
try {
|
||||||
this.serviceManager.chats.set(await this.serviceManager.chatService.getQuick())
|
this.serviceManager.chats.set(await this.serviceManager.chatService.getQuick())
|
||||||
this.serviceManager.chatsStatus.set(LoadStatus.updating)
|
this.serviceManager.chatsStatus.set(LoadStatus.updating)
|
||||||
@@ -45,3 +46,4 @@ export class PictureList implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -70,6 +70,11 @@
|
|||||||
{{'home.enterChtnOnWeb'|translate}}
|
{{'home.enterChtnOnWeb'|translate}}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button style="width: 350px" tuiButton appearance="secondary" (click)="openGit()">
|
||||||
|
<fa-icon [icon]="faGitAlt" style="font-size: 25px; display: flex; justify-content: center; width: 10px"></fa-icon>
|
||||||
|
Git
|
||||||
|
</button>
|
||||||
|
|
||||||
<button style="width: 350px" appearance="secondary" (click)="openRoadmap()" tuiButton iconStart="@tui.chart-no-axes-gantt">
|
<button style="width: 350px" appearance="secondary" (click)="openRoadmap()" tuiButton iconStart="@tui.chart-no-axes-gantt">
|
||||||
Roadmap
|
Roadmap
|
||||||
</button>
|
</button>
|
||||||
@@ -82,71 +87,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="detailedFeature">
|
|
||||||
<div class="style">
|
|
||||||
<h1>{{ 'home.chtn'|translate }} <span style="color: var(--tui-status-negative)"><tui-icon icon="@tui.circle-gauge"></tui-icon>
|
|
||||||
{{ 'home.adaptsToYou'|translate }}</span></h1>
|
|
||||||
<p>{{ 'home.adaptsToYouDesc'|translate }}</p>
|
|
||||||
|
|
||||||
<div class="cardList">
|
|
||||||
<div tuiCardLarge>
|
|
||||||
<tui-icon icon="@tui.globe" style="font-size: 80px"></tui-icon>
|
|
||||||
|
|
||||||
<h2>{{ 'home.chtnOnWeb'|translate }}</h2>
|
|
||||||
<p>{{ 'home.chtnOnWebDesc'|translate }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div tuiCardLarge>
|
|
||||||
<fa-icon [icon]="faAndroid"></fa-icon>
|
|
||||||
|
|
||||||
<h2>{{ 'home.chtnOnAndroid'|translate }}</h2>
|
|
||||||
<div tuiBadge>{{'home.openBeta'|translate}}</div>
|
|
||||||
<p>{{ 'home.chtnOnAndroidDesc'|translate }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div tuiCardLarge>
|
|
||||||
<fa-icon [icon]="faApple"></fa-icon>
|
|
||||||
|
|
||||||
<h2>{{ 'home.chtnOnApple'|translate }}</h2>
|
|
||||||
<div tuiBadge>{{'home.openBeta'|translate}}</div>
|
|
||||||
<p>{{ 'home.chtnOnAppleDesc'|translate }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div tuiCardLarge>
|
|
||||||
<fa-icon [icon]="faWindows"></fa-icon>
|
|
||||||
|
|
||||||
<h2>{{ 'home.chtnOnWindows'|translate }}</h2>
|
|
||||||
<div tuiBadge>{{'home.openBeta'|translate}}</div>
|
|
||||||
<p>{{ 'home.chtnOnWindowsDesc'|translate }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div tuiCardLarge>
|
|
||||||
<fa-icon [icon]="faLinux"></fa-icon>
|
|
||||||
|
|
||||||
<h2>{{ 'home.chtnOnLinux'|translate }}</h2>
|
|
||||||
<div tuiBadge>{{'home.openBeta'|translate}}</div>
|
|
||||||
<p>{{ 'home.chtnOnLinuxDesc'|translate }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div tuiCardLarge>
|
|
||||||
<fa-icon [icon]="faRecordVinyl"></fa-icon>
|
|
||||||
|
|
||||||
<h2>{{ 'home.chtnEcho'|translate }}</h2>
|
|
||||||
<div tuiBadge>{{'home.openBeta'|translate}}</div>
|
|
||||||
<p>{{ 'home.chtnEchoDesc'|translate }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div tuiCardLarge>
|
|
||||||
<fa-icon [icon]="faDesktop"></fa-icon>
|
|
||||||
|
|
||||||
<h2>{{ 'home.chtnReson'|translate }}</h2>
|
|
||||||
<div tuiBadge>{{'home.openBeta'|translate}}</div>
|
|
||||||
<p>{{ 'home.chtnResonDesc'|translate }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="detailedFeature">
|
<section class="detailedFeature">
|
||||||
<div class="style">
|
<div class="style">
|
||||||
<h1>{{ 'home.chtnIs'|translate }} <span style="color: var(--tui-status-positive)"><tui-icon icon="@tui.lock"></tui-icon>
|
<h1>{{ 'home.chtnIs'|translate }} <span style="color: var(--tui-status-positive)"><tui-icon icon="@tui.lock"></tui-icon>
|
||||||
@@ -192,48 +132,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="detailedFeature" style="margin-bottom: 5%;">
|
<section class="detailedFeature" id="platformList" style="margin-bottom: 5%;">
|
||||||
<div class="style">
|
<div class="style">
|
||||||
<h1>{{ 'home.weAreExcitedFor'|translate }} <span style="color: var(--tui-status-negative)"><tui-icon icon="@tui.heart"></tui-icon>
|
<h1>{{ 'home.adaptsTo'|translate }} <span style="color: var(--tui-status-negative)"><tui-icon icon="@tui.heart"></tui-icon>
|
||||||
{{ 'home.you'|translate }}</span></h1>
|
{{ 'home.you'|translate }}</span></h1>
|
||||||
<p>{{ 'home.weAreExcitedForYouDesc'|translate }}</p>
|
<p>{{ 'home.adaptsToYouDesc'|translate }}</p>
|
||||||
|
|
||||||
<div class="cardList">
|
<div class="cardList">
|
||||||
<div tuiCardLarge>
|
<div class="disabled card">
|
||||||
<tui-icon icon="@tui.globe" style="font-size: 80px"></tui-icon>
|
<fa-icon [icon]="faLinux"></fa-icon>
|
||||||
|
<h2>Linux</h2>
|
||||||
<h2><a routerLink="/chat">{{ 'home.enterChtnOnWeb'|translate }}</a></h2>
|
<div tuiBadge appearance="accent">{{'home.soon'|translate}}</div>
|
||||||
<p>{{ 'home.enterChtnOnWebDesc'|translate }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div tuiCardLarge>
|
<div class="disabled card">
|
||||||
<fa-icon [icon]="faGooglePlay"></fa-icon>
|
<fa-icon [icon]="faGoogle"></fa-icon>
|
||||||
|
<h2>Google</h2>
|
||||||
<h2>{{ 'home.downloadChtnOnAndroid'|translate }}</h2>
|
<div tuiBadge appearance="accent">{{'home.soon'|translate}}</div>
|
||||||
<div tuiBadge>{{'home.openBeta'|translate}}</div>
|
|
||||||
<p>{{'home.openBetaDesc'|translate}}</p>
|
|
||||||
|
|
||||||
<button (click)="androidBetaTestDialogOpen = true" tuiButton iconStart="@tui.door-open">{{'home.requestAlphaAccess'|translate}}</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div tuiCardLarge>
|
<div class="disabled card">
|
||||||
<fa-icon [icon]="faAppStoreIos"></fa-icon>
|
<fa-icon [icon]="faApple"></fa-icon>
|
||||||
|
<h2>Apple</h2>
|
||||||
<h2>{{ 'home.downloadChtnOnApple'|translate }}</h2>
|
<div tuiBadge appearance="accent">{{'home.soon'|translate}}</div>
|
||||||
<div tuiBadge>{{'home.openBeta'|translate}}</div>
|
|
||||||
<p>{{'home.openBetaDesc'|translate}}</p>
|
|
||||||
|
|
||||||
<button (click)="appleBetaTestDialogOpen = true" tuiButton iconStart="@tui.door-open">{{'home.requestAlphaAccess'|translate}}</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div tuiCardLarge>
|
<div class="disabled card">
|
||||||
<fa-icon [icon]="faMicrosoft"></fa-icon>
|
<fa-icon [icon]="faMicrosoft"></fa-icon>
|
||||||
|
<h2>Microsoft</h2>
|
||||||
<h2>{{ 'home.downloadOnWindows'|translate }}</h2>
|
<div tuiBadge appearance="accent">{{'home.soon'|translate}}</div>
|
||||||
<div tuiBadge>{{'home.openBeta'|translate}}</div>
|
|
||||||
<p>{{'home.openBetaDesc'|translate}}</p>
|
|
||||||
|
|
||||||
<button (click)="msBetaTestDialogOpen = true" tuiButton iconStart="@tui.door-open">{{'home.requestAlphaAccess'|translate}}</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -117,6 +117,35 @@ main {
|
|||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#platformList {
|
||||||
|
.cardList {
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||||
|
|
||||||
|
.card {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
aspect-ratio: 1/1;
|
||||||
|
background: var(--tui-background-base);
|
||||||
|
border-radius: 1.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
fa-icon {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {FaIconComponent} from '@fortawesome/angular-fontawesome';
|
|||||||
import {
|
import {
|
||||||
faAndroid,
|
faAndroid,
|
||||||
faApple,
|
faApple,
|
||||||
faAppStoreIos,
|
faAppStoreIos, faGitAlt, faGitee, faGoogle,
|
||||||
faGooglePlay,
|
faGooglePlay,
|
||||||
faLinux,
|
faLinux,
|
||||||
faMicrosoft,
|
faMicrosoft,
|
||||||
@@ -97,6 +97,10 @@ export class Homepage {
|
|||||||
window.open('https://help.chatenium.hu/s/169154db-df3e-44cb-980d-2db1915ecdf8', '_blank')
|
window.open('https://help.chatenium.hu/s/169154db-df3e-44cb-980d-2db1915ecdf8', '_blank')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openGit() {
|
||||||
|
window.open('https://git.chatenium.hu', '_blank')
|
||||||
|
}
|
||||||
|
|
||||||
openMsStore() {
|
openMsStore() {
|
||||||
window.open('https://apps.microsoft.com/detail/9p1xq5vb62b0?ocid=webpdpshare', '_blank')
|
window.open('https://apps.microsoft.com/detail/9p1xq5vb62b0?ocid=webpdpshare', '_blank')
|
||||||
}
|
}
|
||||||
@@ -150,4 +154,7 @@ export class Homepage {
|
|||||||
protected readonly faGooglePlay = faGooglePlay;
|
protected readonly faGooglePlay = faGooglePlay;
|
||||||
protected readonly faAppStoreIos = faAppStoreIos;
|
protected readonly faAppStoreIos = faAppStoreIos;
|
||||||
protected readonly faMicrosoft = faMicrosoft;
|
protected readonly faMicrosoft = faMicrosoft;
|
||||||
|
protected readonly faGoogle = faGoogle;
|
||||||
|
protected readonly faGitee = faGitee;
|
||||||
|
protected readonly faGitAlt = faGitAlt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {Message as NetworkMessage} from '@chatenium/chatenium-sdk/domain/textCha
|
|||||||
import {PictureService} from '@chatenium/chatenium-sdk/services/pictureService';
|
import {PictureService} from '@chatenium/chatenium-sdk/services/pictureService';
|
||||||
import {Album} from '@chatenium/chatenium-sdk/domain/pictureService.schema';
|
import {Album} from '@chatenium/chatenium-sdk/domain/pictureService.schema';
|
||||||
import {PublicUserData} from '@chatenium/chatenium-sdk/domain/common.schema';
|
import {PublicUserData} from '@chatenium/chatenium-sdk/domain/common.schema';
|
||||||
|
import {MessagesViewModel} from './chat/elements/messages/messages-viewmodel';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -52,6 +53,8 @@ export enum LoadStatus {
|
|||||||
export interface DmStorage {
|
export interface DmStorage {
|
||||||
service: DMService
|
service: DMService
|
||||||
messages: WritableSignal<Message[]>
|
messages: WritableSignal<Message[]>
|
||||||
|
messagesStatus: WritableSignal<LoadStatus>
|
||||||
|
messagesVm: MessagesViewModel
|
||||||
chatData: WritableSignal<Chat>
|
chatData: WritableSignal<Chat>
|
||||||
messageBox: MessageBoxViewModel
|
messageBox: MessageBoxViewModel
|
||||||
wsListener: (action: string, message: string) => void
|
wsListener: (action: string, message: string) => void
|
||||||
@@ -73,6 +76,8 @@ export interface NetworkStorage {
|
|||||||
export interface TextChannelStorage {
|
export interface TextChannelStorage {
|
||||||
service: TextChannelServiceService
|
service: TextChannelServiceService
|
||||||
messages: WritableSignal<NetworkMessage[]>
|
messages: WritableSignal<NetworkMessage[]>
|
||||||
|
messagesVm: MessagesViewModel
|
||||||
|
messagesStatus: WritableSignal<LoadStatus>
|
||||||
channelData: WritableSignal<NetworkChannel>
|
channelData: WritableSignal<NetworkChannel>
|
||||||
categoryData: WritableSignal<NetworkCategory>
|
categoryData: WritableSignal<NetworkCategory>
|
||||||
messageBox: MessageBoxViewModel
|
messageBox: MessageBoxViewModel
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
version: "3.0-beta6",
|
version: "3.0-beta8",
|
||||||
api_url: "http://localhost:3000",
|
api_url: "http://localhost:3000",
|
||||||
cdn_url: "http://localhost:4000",
|
cdn_url: "http://localhost:4000",
|
||||||
ws_url: "ws://localhost:3000",
|
ws_url: "ws://localhost:3000",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
version: "3.0-beta6",
|
version: "3.0-beta8",
|
||||||
api_url: "https://api.chatenium.hu",
|
api_url: "https://api.chatenium.hu",
|
||||||
cdn_url: "https://cdn.chatenium.hu",
|
cdn_url: "https://cdn.chatenium.hu",
|
||||||
ws_url: "wss://api.chatenium.hu",
|
ws_url: "wss://api.chatenium.hu",
|
||||||
|
|||||||
Reference in New Issue
Block a user