From c7ba47204254a3b1563f3399470428d3567da009 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Sun, 23 May 2021 15:49:31 +0530 Subject: [PATCH] Add view and vm for RoomInformation Signed-off-by: RMidhunSuresh --- .../session/rightpanel/RoomInfoViewModel.js | 25 +++++++++++++++++++ .../web/ui/session/rightpanel/RoomInfoView.js | 13 ++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/domain/session/rightpanel/RoomInfoViewModel.js create mode 100644 src/platform/web/ui/session/rightpanel/RoomInfoView.js diff --git a/src/domain/session/rightpanel/RoomInfoViewModel.js b/src/domain/session/rightpanel/RoomInfoViewModel.js new file mode 100644 index 00000000..c132acf8 --- /dev/null +++ b/src/domain/session/rightpanel/RoomInfoViewModel.js @@ -0,0 +1,25 @@ +import { ViewModel } from "../../ViewModel.js"; + +export class RoomInfoViewModel extends ViewModel { + constructor(options) { + super(options); + this._room = options.room; + this._roomSummary = this._room._summary._data; + } + + get roomId() { + return this._room.id; + } + + get name() { + return this._roomSummary.name || this._room._heroes._roomName; + } + + get isEncrypted() { + return !!this._roomSummary.encryption; + } + + get memberCount() { + return this._roomSummary.joinCount; + } +} diff --git a/src/platform/web/ui/session/rightpanel/RoomInfoView.js b/src/platform/web/ui/session/rightpanel/RoomInfoView.js new file mode 100644 index 00000000..226b6c5e --- /dev/null +++ b/src/platform/web/ui/session/rightpanel/RoomInfoView.js @@ -0,0 +1,13 @@ +import { TemplateView } from "../../general/TemplateView.js"; +import { text } from "../../general/html.js"; + +export class RoomInfoView extends TemplateView { + render(t, vm) { + return t.div({ className: "RoomInfo" }, [ + t.div({ className: "RoomName" }, [text(vm.name)]), + t.div({ className: "RoomId" }, [text(vm.roomId)]), + t.div({ className: "RoomMemberCount" }, [text(vm.memberCount)]), + t.div({ className: "RoomEncryption" }, [vm.isEncrypted ? "Encrypted" : "Not Encrypted"]) + ]); + } +}