mirror of
https://github.com/RetroShare/RSNewWebUI.git
synced 2026-09-14 11:05:47 +05:00
create channel(without thumnail)
This commit is contained in:
parent
a6ea4c09c3
commit
d81e835459
@ -73,6 +73,77 @@ async function parsefile(file, type) {
|
||||
return ansList;
|
||||
}
|
||||
|
||||
function createchannel() {
|
||||
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 Channel'),
|
||||
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('/rsgxschannels/createChannelV2', {
|
||||
name: title,
|
||||
description: body,
|
||||
// thumbnail: {},
|
||||
...(Number(identity) !== 0 && { authorId: identity }),
|
||||
});
|
||||
if (res.body.retval) {
|
||||
util.updatedisplaychannels(res.body.channelId);
|
||||
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', 'Channel created successfully'),
|
||||
]);
|
||||
},
|
||||
},
|
||||
'Create'
|
||||
),
|
||||
]),
|
||||
};
|
||||
}
|
||||
|
||||
const AddPost = () => {
|
||||
let content = '';
|
||||
let ptitle = '';
|
||||
@ -111,7 +182,7 @@ const AddPost = () => {
|
||||
for (let i = 0; i < e.target.files.length; i++) {
|
||||
await parsefile(e.target.files[i], 'multiple');
|
||||
}
|
||||
// console.log(filesUploadHashes.PostFiles, filesUploadHashes.PostFiles.length);
|
||||
console.log(filesUploadHashes.PostFiles, filesUploadHashes.PostFiles.length);
|
||||
|
||||
if (filesUploadHashes.PostFiles.length === e.target.files.length) {
|
||||
for (let i = 0; i < e.target.files.length; i++) {
|
||||
@ -153,6 +224,8 @@ const AddPost = () => {
|
||||
m('hr'),
|
||||
m('p', 'Post added successfully'),
|
||||
]);
|
||||
util.updatedisplaychannels(vnode.attrs.chanId);
|
||||
m.redraw();
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -632,4 +705,5 @@ const PostView = () => {
|
||||
module.exports = {
|
||||
ChannelView,
|
||||
PostView,
|
||||
createchannel,
|
||||
};
|
||||
|
||||
@ -3,6 +3,8 @@ const widget = require('widgets');
|
||||
const rs = require('rswebui');
|
||||
const util = require('channels/channels_util');
|
||||
const viewUtil = require('channels/channel_view');
|
||||
const peopleUtil = require('people/people_util');
|
||||
|
||||
|
||||
const getChannels = {
|
||||
All: [],
|
||||
@ -32,46 +34,72 @@ const sections = {
|
||||
OtherChannels: require('channels/other_channels'),
|
||||
};
|
||||
|
||||
const Layout = {
|
||||
oninit: () => {
|
||||
rs.setBackgroundTask(getChannels.load, 5000, () => {
|
||||
// return m.route.get() === '/files/files';
|
||||
});
|
||||
},
|
||||
// onupdate: getChannels.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',
|
||||
channelId: vnode.attrs.pathInfo.mGroupId,
|
||||
})
|
||||
: m(util.SearchBar, {
|
||||
category: 'channels',
|
||||
}),
|
||||
m(widget.Sidebar, {
|
||||
tabs: Object.keys(sections),
|
||||
baseRoute: '/channels/',
|
||||
}),
|
||||
m(
|
||||
'.channel-node-panel',
|
||||
const Layout = () => {
|
||||
let ownId;
|
||||
|
||||
return {
|
||||
oninit: () => {
|
||||
rs.setBackgroundTask(getChannels.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);
|
||||
});
|
||||
},
|
||||
// onupdate: getChannels.load,
|
||||
view: (vnode) =>
|
||||
m('.tab-page', [
|
||||
Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mMsgId')
|
||||
? m(viewUtil.PostView, {
|
||||
msgId: vnode.attrs.pathInfo.mMsgId,
|
||||
? ''
|
||||
: Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mGroupId')
|
||||
? m(util.SearchBar, {
|
||||
category: 'posts',
|
||||
channelId: vnode.attrs.pathInfo.mGroupId,
|
||||
})
|
||||
: Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mGroupId')
|
||||
? m(viewUtil.ChannelView, {
|
||||
id: vnode.attrs.pathInfo.mGroupId,
|
||||
})
|
||||
: m(sections[vnode.attrs.pathInfo.tab], {
|
||||
list: getChannels[vnode.attrs.pathInfo.tab],
|
||||
})
|
||||
),
|
||||
]),
|
||||
: m(util.SearchBar, {
|
||||
category: 'channels',
|
||||
}),
|
||||
m(
|
||||
'button',
|
||||
{
|
||||
style: { fontSize: '1.2em', width: '200px' },
|
||||
onclick: () =>
|
||||
util.popupmessage(
|
||||
m(viewUtil.createchannel, {
|
||||
authorId: ownId,
|
||||
})
|
||||
),
|
||||
},
|
||||
'Create Channel'
|
||||
),
|
||||
m(widget.Sidebar, {
|
||||
tabs: Object.keys(sections),
|
||||
baseRoute: '/channels/',
|
||||
}),
|
||||
m(
|
||||
'.channel-node-panel',
|
||||
|
||||
Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mMsgId')
|
||||
? m(viewUtil.PostView, {
|
||||
msgId: vnode.attrs.pathInfo.mMsgId,
|
||||
channelId: vnode.attrs.pathInfo.mGroupId,
|
||||
})
|
||||
: Object.prototype.hasOwnProperty.call(vnode.attrs.pathInfo, 'mGroupId')
|
||||
? m(viewUtil.ChannelView, {
|
||||
id: vnode.attrs.pathInfo.mGroupId,
|
||||
})
|
||||
: m(sections[vnode.attrs.pathInfo.tab], {
|
||||
list: getChannels[vnode.attrs.pathInfo.tab],
|
||||
})
|
||||
),
|
||||
]),
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -4,7 +4,7 @@ const util = require('forums/forums_util');
|
||||
const peopleUtil = require('people/people_util');
|
||||
const { updatedisplayforums } = require('./forums_util');
|
||||
|
||||
function addpost() {
|
||||
function createforum() {
|
||||
let title;
|
||||
let body;
|
||||
let identity;
|
||||
@ -508,5 +508,5 @@ const ForumView = () => {
|
||||
module.exports = {
|
||||
ForumView,
|
||||
ThreadView,
|
||||
addpost,
|
||||
createforum,
|
||||
};
|
||||
|
||||
@ -60,7 +60,7 @@ const Layout = () => {
|
||||
style: {fontSize: '1.2em', width: '200px'},
|
||||
onclick: () =>
|
||||
util.popupmessage(
|
||||
m(viewUtil.addpost, {
|
||||
m(viewUtil.createforum, {
|
||||
authorId: ownId,
|
||||
})
|
||||
),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user