From 9259cb890b12b7ab2da8e6754419b94f5f72d3c4 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 27 Aug 2022 14:28:07 +0200 Subject: [PATCH 1/4] Added create board button --- webui-src/app/boards/board_view.js | 74 +++++++++++++++++++++++ webui-src/app/boards/boards.js | 94 +++++++++++++++++------------ webui-src/app/boards/boards_util.js | 19 ++++++ 3 files changed, 150 insertions(+), 37 deletions(-) diff --git a/webui-src/app/boards/board_view.js b/webui-src/app/boards/board_view.js index d723b1e..53cbfb7 100644 --- a/webui-src/app/boards/board_view.js +++ b/webui-src/app/boards/board_view.js @@ -4,6 +4,79 @@ const util = require('boards/boards_util'); const Data = util.Data; const peopleUtil = require('people/people_util'); +function createboard() { + let title; + let body; + let identity; + return { + oninit: (vnode) => { + if (vnode.attrs.authorId) { + identity = vnode.attrs.authorId[0]; + } + }, + view: (vnode) => + m('.widget', [ + m('h3', 'Create Board'), + m('hr'), + m('input[type=text][placeholder=Title]', { + oninput: (e) => (title = e.target.value), + }), + m('label[for=tags]', 'Select identity'), + m( + 'select[id=idtags]', + { + value: identity, + onchange: (e) => { + identity = vnode.attrs.authorId[e.target.selectedIndex]; + }, + }, + [ + vnode.attrs.authorId && + vnode.attrs.authorId.map((o) => + m( + 'option', + { value: o }, + rs.userList.userMap[o] ? rs.userList.userMap[o].toLocaleString() : 'No Signature' + ) + ), + ] + ), + m('textarea[rows=5][placeholder=Description]', { + style: { width: '90%', display: 'block' }, + oninput: (e) => (body = e.target.value), + value: body, + }), + m( + 'button', + { + onclick: async () => { + + + const res = await rs.rsJsonApiRequest('/rsposted/createBoardV2', { + name: title, + description: body, + ...((Number(identity) !== 0) && {authorId: identity}), + }); + if(res.body.retval) + { + util.updatedisplayboards(res.body.boardId); + m.redraw(); + } + res.body.retval === false + ? util.popupmessage([m('h3', 'Error'), m('hr'), m('p', res.body.errorMessage)]) + : util.popupmessage([ + m('h3', 'Success'), + m('hr'), + m('p', 'Board created successfully'), + ]); + }, + }, + 'Create' + ), + ]), + }; +} + const BoardView = () => { let bname = ''; let bimage = ''; @@ -139,4 +212,5 @@ const BoardView = () => { module.exports = { BoardView, + createboard, }; diff --git a/webui-src/app/boards/boards.js b/webui-src/app/boards/boards.js index add63a1..91d582c 100644 --- a/webui-src/app/boards/boards.js +++ b/webui-src/app/boards/boards.js @@ -3,6 +3,7 @@ const widget = require('widgets'); const rs = require('rswebui'); const util = require('boards/boards_util'); const viewUtil = require('boards/board_view'); +const peopleUtil = require('people/people_util'); const getBoards = { @@ -32,43 +33,62 @@ const sections = { OtherBoards: require('boards/other_boards') }; -const Layout = { - oninit : () => { - rs.setBackgroundTask(getBoards.load, 5000, () => { - }); - }, - // onupdate: getBoards.load, - view: (vnode) => - m('.tab-page', [ - Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mMsgId') - ? '' - : Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mGroupId') - ? m(util.SearchBar, { - category: 'posts', - boardId: vnode.attrs.pathInfo.mGroupId - }) - : m(util.SearchBar, { - category: 'boards' - }), - m(widget.Sidebar, { - tabs: Object.keys(sections), - baseRoute: '/boards/', - }), - m('.board-node-panel', - Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mMsgId') - ? m(viewUtil.PostView, { - msgId: vnode.attrs.pathInfo.mMsgId, - boardId: vnode.attrs.pathInfo.mGroupId, - }) - : Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mGroupId') - ? m(viewUtil.BoardView, { - id: vnode.attrs.pathInfo.mGroupId, - }) - : m(sections[vnode.attrs.pathInfo.tab], { - list: getBoards[vnode.attrs.pathInfo.tab], - }) - ), - ]), +const Layout = () => { + let ownId; + + return { + oninit: () => { + rs.setBackgroundTask(getBoards.load, 5000, () => { + // return m.route.get() === '/files/files'; + }); + peopleUtil.ownIds((data) => { + ownId = data; + for (let i = 0; i < ownId.length; i++) { + if (Number(ownId[i]) === 0) { + ownId.splice(i, 1); + } + } + ownId.unshift(0); + }); + }, + view: (vnode) => + m('.tab-page', [ + m(util.SearchBar, { + list: getBoards.All, + }), + m( + 'button', + { + style: {fontSize: '1.2em', width: '200px'}, + onclick: () => + util.popupmessage( + m(viewUtil.createboard, { + authorId: ownId, + }) + ), + }, + 'Create Board' + ), + m(widget.Sidebar, { + tabs: Object.keys(sections), + baseRoute: '/boards/', + }), + m('.board-node-panel', + Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mMsgId') + ? m(viewUtil.PostView, { + msgId: vnode.attrs.pathInfo.mMsgId, + forumId: vnode.attrs.pathInfo.mGroupId, + }) + : Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mGroupId') + ? m(viewUtil.BoardView, { + id: vnode.attrs.pathInfo.mGroupId, + }) + : m(sections[vnode.attrs.pathInfo.tab], { + list: getBoards[vnode.attrs.pathInfo.tab], + }) + ), + ]), + }; }; module.exports = { diff --git a/webui-src/app/boards/boards_util.js b/webui-src/app/boards/boards_util.js index 956530f..f39a449 100644 --- a/webui-src/app/boards/boards_util.js +++ b/webui-src/app/boards/boards_util.js @@ -122,6 +122,24 @@ const BoardTable = () => { }; }; +function popupmessage(message) { + const container = document.getElementById('modal-container'); + container.style.display = 'block'; + m.render( + container, + m('.modal-content', [ + m( + 'button.red', + { + onclick: () => (container.style.display = 'none'), + }, + m('i.fas.fa-times') + ), + message, + ]) + ); +} + const SearchBar = () => { let searchString = ''; return { @@ -145,6 +163,7 @@ const SearchBar = () => { module.exports = { Data, SearchBar, + popupmessage, BoardSummary, DisplayBoardsFromList, updateDisplayBoards, From 7ddfe81a3f781a32add976478f37290c2351195c Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 3 Sep 2022 15:00:51 +0200 Subject: [PATCH 2/4] Other boards display --- webui-src/app/boards/boards.js | 4 ++++ webui-src/app/boards/other_boards.js | 31 +++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/webui-src/app/boards/boards.js b/webui-src/app/boards/boards.js index 91d582c..d5c0964 100644 --- a/webui-src/app/boards/boards.js +++ b/webui-src/app/boards/boards.js @@ -11,11 +11,15 @@ const getBoards = PopularBoards : [], SubscribedBoards : [], MyBoards : [], + OtherBoards : [], async load(){ const res = await rs.rsJsonApiRequest('/rsPosted/getBoardsSummaries'); const data = res.body; getBoards.All = data.groupInfo; getBoards.PopularBoards = getBoards.All; + getBoards.PopularBoards.sort((a, b) => b.mPop - a.mPop); + getBoards.OtherBoards = getBoards.PopularBoards.slice(5); + getBoards.PopularBoards = getBoards.PopularBoards.slice(0, 5); getBoards.SubscribedBoards = getBoards.All.filter( (board) => board.mSubscribeFlags === util.GROUP_SUBSCRIBE_SUBSCRIBED diff --git a/webui-src/app/boards/other_boards.js b/webui-src/app/boards/other_boards.js index 5c813d4..c5fc7dd 100644 --- a/webui-src/app/boards/other_boards.js +++ b/webui-src/app/boards/other_boards.js @@ -1,11 +1,32 @@ const m = require('mithril'); +const util = require('boards/boards_util'); const Layout = () => { - return{ - view: () => [ - m('.widget', [m('h2', 'Other Boards'), m('hr'), ]) - ] - }; + return { + view: (v) => [ + m('.widget', [ + m('h3', 'Other Boards'), + m('hr'), + m( + util.BoardTable, + m('tbody', [ + v.attrs.list.map((board) => + m(util.BoardSummary, { + details: board, + category: 'OtherBoards', + }) + ), + v.attrs.list.map((board) => + m(util.DisplayBoardsFromList, { + id: board.mGroupId, + category: 'OtherBoards', + }) + ), + ]) + ), + ]), + ], + }; }; module.exports = Layout(); From a6b7122f16b324cc3e7c9e01f760de7c28c78f2a Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 7 Sep 2022 19:07:52 +0200 Subject: [PATCH 3/4] update create board --- webui-src/app/boards/board.css | 40 +++++---- webui-src/app/boards/board_view.js | 130 ++++++++++++++++++++++------ webui-src/app/boards/boards.js | 2 +- webui-src/app/boards/boards_util.js | 14 ++- 4 files changed, 142 insertions(+), 44 deletions(-) diff --git a/webui-src/app/boards/board.css b/webui-src/app/boards/board.css index 7977a29..d7eb72e 100644 --- a/webui-src/app/boards/board.css +++ b/webui-src/app/boards/board.css @@ -1,9 +1,9 @@ .board-node-panel { - position: relative; - bottom: 200px; - margin-left: 200px; - animation: fadein 0.5s; - } + position: relative; + bottom: 200px; + margin-left: 200px; + animation: fadein 0.5s; +} /* subject */ table.boards th:nth-child(1) { @@ -28,7 +28,7 @@ table.boards tr.hidden{ display: none; } -#searchboard{ +#searchboard { position:relative; margin-left: 250px; } @@ -39,15 +39,16 @@ img.boardpic { width:150px; padding: 25px; } -#boarddetails{ +#boarddetails { position: relative; margin-left: 150px; + padding: 10px; } .p{ margin:0; } -#toggleunsub{ +#toggleunsub { position: relative; background: gray; } @@ -60,22 +61,23 @@ img.boardpic { .card { width: 150px; - height: 150px; + height: 200px; border: 2px solid gray; cursor: pointer; text-align: center; } -.card-img{ +.card-img { width: 120px; height: 120px; } -.card-title{ - position: absolute; +.card-title { + position: relative; bottom: 0px; + overflow: auto; } /* subject */ -table.comments th{ +table.comments th { height: 40px; } table.comments th:nth-child(1) { @@ -89,14 +91,22 @@ table.comments td:nth-child(1){ border-radius: 25px; } -table.comments tr{ +table.comments tr { height: 40px; } -#options{ +#options { width: 100px; text-align: center; font-size: medium; margin-left: 20px; height: 40px; +} + +#mtags { + width: 160px; + text-align: center; + font-size: medium; + margin-left: 10px; + height: 40px; } \ No newline at end of file diff --git a/webui-src/app/boards/board_view.js b/webui-src/app/boards/board_view.js index 53cbfb7..e0ccbf8 100644 --- a/webui-src/app/boards/board_view.js +++ b/webui-src/app/boards/board_view.js @@ -4,45 +4,123 @@ const util = require('boards/boards_util'); const Data = util.Data; const peopleUtil = require('people/people_util'); +const messageGroups = ['Public', 'Restricted Circle', 'Restricted Node Group']; +const messageGroupsCode = [util.PUBLIC, util.EXTERNAL, util.NODES_GROUP]; //rsgxscirles.h:50 + function createboard() { let title; let body; let identity; + let thumbnail; + let selectedGroup = messageGroups[0]; + let selectedGroupCode = messageGroupsCode[0]; + let selectedCircle; + let circles; return { - oninit: (vnode) => { + oninit: async (vnode) => { if (vnode.attrs.authorId) { identity = vnode.attrs.authorId[0]; } + + const res = await rs.rsJsonApiRequest('/rsgxscircles/getCirclesSummaries'); + if (res.body.retval) { + circles = res.body.circles; + selectedCircle = circles[0].mGroupName; + } }, view: (vnode) => m('.widget', [ m('h3', 'Create Board'), m('hr'), m('input[type=text][placeholder=Title]', { + style: { float: 'left' }, oninput: (e) => (title = e.target.value), }), - m('label[for=tags]', 'Select identity'), - m( - 'select[id=idtags]', - { - value: identity, - onchange: (e) => { - identity = vnode.attrs.authorId[e.target.selectedIndex]; + m('div', { style: { float: 'right', marginTop: '10px', marginBottom: '10px' } }, [ + m('label[for=thumbnail]', 'Thumbnail: '), + m('input[type=file][name=files][id=thumbnail][accept=image/*]', { + onchange: async (e) => { + let reader = new FileReader(); + reader.onloadend = function () { + thumbnail = reader.result.substring(reader.result.indexOf(',') + 1); + }; + reader.readAsDataURL(e.target.files[0]); }, - }, - [ - vnode.attrs.authorId && - vnode.attrs.authorId.map((o) => - m( - 'option', - { value: o }, - rs.userList.userMap[o] ? rs.userList.userMap[o].toLocaleString() : 'No Signature' - ) + }), + ]), + + m('div', { style: { float: 'right', marginTop: '10px', marginBottom: '10px' } }, [ + m('label[for=idtags]', 'Select identity: '), + m( + 'select[id=idtags]', + { + value: identity, + onchange: (e) => { + identity = vnode.attrs.authorId[e.target.selectedIndex]; + }, + }, + [ + vnode.attrs.authorId && + vnode.attrs.authorId.map((o) => + m( + 'option', + { value: o }, + rs.userList.userMap[o] + ? rs.userList.userMap[o].toLocaleString() + : 'No Signature' + ) + ), + ] + ), + ]), + m('div', { style: { float: 'left', marginTop: '10px', marginBottom: '10px' } }, [ + m('label[for=mtags]', 'Message Distribution: '), + m( + 'select[id=mtags]', + { + value: selectedGroup, + onchange: (e) => { + selectedGroup = messageGroups[e.target.selectedIndex]; + selectedGroupCode = messageGroupsCode[e.target.selectedIndex]; + util.popupmessage(m(createboard, { authorId: vnode.attrs.authorId })); + }, + }, + [messageGroups.map((group) => m('option', { value: group }, group))] + ), + ]), + circles && + m( + 'div', + { + style: { + float: 'left', + marginTop: '10px', + marginBottom: '10px', + display: selectedGroupCode === util.EXTERNAL ? 'block' : 'none', + }, + }, + [ + m('label[for=circlestag]', 'Circles: '), + m( + 'select[id=circlestag]', + { + value: selectedCircle, + onchange: (e) => { + selectedCircle = circles[e.target.selectedIndex]; + console.log(selectedCircle); + // selectedGroupCode = messageGroupsCode[e.target.selectedIndex]; + }, + }, + [ + circles.map((circle) => + m('option', { value: circle.mGroupName }, circle.mGroupName) + ), + ] ), - ] - ), + ] + ), m('textarea[rows=5][placeholder=Description]', { - style: { width: '90%', display: 'block' }, + style: { width: '100%', display: 'block' }, oninput: (e) => (body = e.target.value), value: body, }), @@ -50,15 +128,16 @@ function createboard() { 'button', { onclick: async () => { - - const res = await rs.rsJsonApiRequest('/rsposted/createBoardV2', { name: title, description: body, - ...((Number(identity) !== 0) && {authorId: identity}), + thumbnail: { mData: { base64: thumbnail } }, + ...(Number(identity) !== 0 && { authorId: identity }), + circleType: selectedGroupCode, + ...(selectedGroupCode === util.EXTERNAL && + selectedCircle && { circleId: selectedCircle.mGroupId }), }); - if(res.body.retval) - { + if (res.body.retval) { util.updatedisplayboards(res.body.boardId); m.redraw(); } @@ -77,6 +156,7 @@ function createboard() { }; } + const BoardView = () => { let bname = ''; let bimage = ''; diff --git a/webui-src/app/boards/boards.js b/webui-src/app/boards/boards.js index d5c0964..8ec4464 100644 --- a/webui-src/app/boards/boards.js +++ b/webui-src/app/boards/boards.js @@ -65,7 +65,7 @@ const Layout = () => { { style: {fontSize: '1.2em', width: '200px'}, onclick: () => - util.popupmessage( + ownId && util.popupmessage( m(viewUtil.createboard, { authorId: ownId, }) diff --git a/webui-src/app/boards/boards_util.js b/webui-src/app/boards/boards_util.js index f39a449..182935c 100644 --- a/webui-src/app/boards/boards_util.js +++ b/webui-src/app/boards/boards_util.js @@ -9,10 +9,15 @@ const GROUP_MY_BOARD = GROUP_SUBSCRIBE_ADMIN + GROUP_SUBSCRIBE_SUBSCRIBED + GROU const GXS_VOTE_DOWN = 0x0001; const GXS_VOTE_UP = 0x0002; +//rsgxscircles.h:50 +const PUBLIC = 1; /// Public distribution +const EXTERNAL = 2; /// Restricted to an external circle, based on GxsIds +const NODES_GROUP = 3; + const Data = { - DisplayBoards: {}, - Posts: {}, - Comments: {}, + DisplayBoards: {}, // boardID -> board info + Posts: {}, // boardID, PostID -> {post, isSearched} + Comments: {}, // threadID, msgID -> {Comment, showReplies} }; async function updateContent(content, boardid) { @@ -175,4 +180,7 @@ module.exports = { GROUP_MY_BOARD, GXS_VOTE_DOWN, GXS_VOTE_UP, + PUBLIC, + EXTERNAL, + NODES_GROUP, }; From a4ae67b4241b3357c732ffd5502cbe0f89f913f1 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 8 Sep 2022 20:26:36 +0200 Subject: [PATCH 4/4] Fixed issue with the popup position --- webui-src/app/boards/board.css | 7 +++++++ webui-src/app/boards/boards_util.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/webui-src/app/boards/board.css b/webui-src/app/boards/board.css index d7eb72e..a5ed606 100644 --- a/webui-src/app/boards/board.css +++ b/webui-src/app/boards/board.css @@ -103,6 +103,13 @@ table.comments tr { height: 40px; } +#composepopup { + height: 80%; + width: 70%; + bottom: 50%; + right: 58%; +} + #mtags { width: 160px; text-align: center; diff --git a/webui-src/app/boards/boards_util.js b/webui-src/app/boards/boards_util.js index 182935c..15c72eb 100644 --- a/webui-src/app/boards/boards_util.js +++ b/webui-src/app/boards/boards_util.js @@ -132,7 +132,7 @@ function popupmessage(message) { container.style.display = 'block'; m.render( container, - m('.modal-content', [ + m('.modal-content[id=composepopup]', [ m( 'button.red', {