diff options
Diffstat (limited to 'src/web')
| -rw-r--r-- | src/web/app/common/scripts/channel-stream.js | 14 | ||||
| -rw-r--r-- | src/web/app/desktop/tags/pages/channel.tag | 87 | ||||
| -rw-r--r-- | src/web/app/desktop/tags/pages/drive-chooser.tag | 44 |
3 files changed, 145 insertions, 0 deletions
diff --git a/src/web/app/common/scripts/channel-stream.js b/src/web/app/common/scripts/channel-stream.js new file mode 100644 index 0000000000..38e7d91132 --- /dev/null +++ b/src/web/app/common/scripts/channel-stream.js @@ -0,0 +1,14 @@ +'use strict'; + +import Stream from './stream'; + +/** + * Channel stream connection + */ +class Connection extends Stream { + constructor() { + super('channel'); + } +} + +export default Connection; diff --git a/src/web/app/desktop/tags/pages/channel.tag b/src/web/app/desktop/tags/pages/channel.tag index 4fa172f99d..8a3034f40c 100644 --- a/src/web/app/desktop/tags/pages/channel.tag +++ b/src/web/app/desktop/tags/pages/channel.tag @@ -2,6 +2,8 @@ <mk-ui ref="ui"> <main if={ !parent.fetching }> <h1>{ parent.channel.title }</h1> + <mk-channel-post each={ parent.posts } post={ this }/> + <mk-channel-form channel={ parent.channel }/> </main> </mk-ui> <style> @@ -14,12 +16,15 @@ </style> <script> import Progress from '../../../common/scripts/loading'; + import ChannelStream from '../../../common/scripts/channel-stream'; this.mixin('api'); this.id = this.opts.id; this.fetching = true; this.channel = null; + this.posts = null; + this.connection = new ChannelStream(); this.on('mount', () => { document.documentElement.style.background = '#efefef'; @@ -38,6 +43,88 @@ document.title = channel.title + ' | Misskey' }); + + this.api('channels/posts', { + channel_id: this.id + }).then(posts => { + this.update({ + posts: posts + }); + }); }); </script> </mk-channel-page> + +<mk-channel-post> + <header> + <b>{ post.user.name }</b> + </header> + <div> + { post.text } + </div> + <style> + :scope + display block + margin 0 + padding 0 + + > header + > b + color #008000 + + </style> + <script> + this.post = this.opts.post; + </script> +</mk-channel-post> + +<mk-channel-form> + <p if={ reply }>{ reply.user.name }への返信: (or <a onclick={ clearReply }>キャンセル</a>)</p> + <textarea ref="text" disabled={ wait }></textarea> + <button class={ wait: wait } ref="submit" disabled={ wait || (refs.text.value.length == 0) } onclick={ post }> + { wait ? 'やってます' : 'やる' }<mk-ellipsis if={ wait }/> + </button> + + <style> + :scope + display block + + </style> + <script> + this.mixin('api'); + + this.channel = this.opts.channel; + + this.clearReply = () => { + this.update({ + reply: null + }); + }; + + this.clear = () => { + this.clearReply(); + this.refs.text.value = ''; + }; + + this.post = e => { + this.update({ + wait: true + }); + + this.api('posts/create', { + text: this.refs.text.value, + reply_to_id: this.reply ? this.reply.id : undefined, + channel_id: this.channel.id + }).then(data => { + this.clear(); + }).catch(err => { + alert('失敗した'); + }).then(() => { + this.update({ + wait: false + }); + }); + }; + + </script> +</mk-channel-form> diff --git a/src/web/app/desktop/tags/pages/drive-chooser.tag b/src/web/app/desktop/tags/pages/drive-chooser.tag new file mode 100644 index 0000000000..49741ad40c --- /dev/null +++ b/src/web/app/desktop/tags/pages/drive-chooser.tag @@ -0,0 +1,44 @@ +<mk-drive-chooser> + <mk-drive-browser ref="browser" multiple={ parent.multiple }/> + <div> + <button class="upload" title="PCからドライブにファイルをアップロード" onclick={ upload }><i class="fa fa-upload"></i></button> + <button class="cancel" onclick={ close }>キャンセル</button> + <button class="ok" onclick={ parent.ok }>決定</button> + </div> + + <style> + :scope + display block + height 100% + + </style> + <script> + this.multiple = this.opts.multiple != null ? this.opts.multiple : false; + + this.on('mount', () => { + this.refs.browser.on('selected', file => { + this.files = [file]; + this.ok(); + }); + + this.refs.browser.on('change-selection', files => { + this.update({ + files: files + }); + }); + }); + + this.upload = () => { + this.refs.browser.selectLocalFile(); + }; + + this.close = () => { + window.close(); + }; + + this.ok = () => { + window.opener.cb(this.multiple ? this.files : this.files[0]); + window.close(); + }; + </script> +</mk-drive-chooser> |