Merge branch 'master' of ssh.gitgud.io:lambadalambda/pleroma-fe

This commit is contained in:
Roger Braun 2016-11-07 11:56:14 +01:00
commit cf972e968c
36 changed files with 273 additions and 80 deletions

View file

@ -19,8 +19,8 @@ const Attachment = {
type = 'image';
}
if(this.attachment.mimetype.match(/video\/webm/)) {
type = 'webm';
if(this.attachment.mimetype.match(/video\/(webm|mp4)/)) {
type = 'video';
};
return type

View file

@ -6,7 +6,7 @@
<a class="image-attachment" v-if="type === 'image' && !nsfw" :href="attachment.url" target="_blank"><img :src="attachment.url"></img></a>
<video v-if="type === 'webm' && !nsfw" :src="attachment.url" controls></video>
<video v-if="type === 'video' && !nsfw" :src="attachment.url" controls></video>
<span v-if="type === 'unknown'">Don't know how to display this...</span>

View file

@ -0,0 +1,22 @@
/* eslint-env browser */
import statusPosterService from '../../services/status_poster/status_poster.service.js'
const mediaUpload = {
mounted () {
const store = this.$store
const input = this.$el.querySelector('input')
const self = this
input.addEventListener('change', ({target}) => {
const file = target.files[0];
const formData = new FormData();
formData.append('media', file);
statusPosterService.uploadMedia({ store, formData })
.then((fileData) => {
self.$emit('uploaded', fileData)
})
})
}
}
export default mediaUpload

View file

@ -0,0 +1,17 @@
<template>
<div class="media-upload">
<label class="btn btn-default">
<i class="fa icon-upload"></i>
<input type=file style="position: fixed; top: -100em"></input>
</label>
</div>
</template>
<script src="./media_upload.js" ></script>
<style>
.media-upload {
font-size: 26px;
flex: 1;
}
</style>

View file

@ -0,0 +1,4 @@
const NavPanel = {
}
export default NavPanel

View file

@ -0,0 +1,54 @@
<template>
<div class="nav-panel">
<div class="panel panel-default">
<ul>
<li ng-if='currentUser'>
<router-link to='/main/friends'>
Timeline
</router-link>
</li>
<li>
<router-link to='/main/public'>
Public Timeline
</router-link>
</li>
<li>
<router-link to='/main/all'>
The Whole Known Network
</router-link>
</li>
</ul>
</div>
</div>
</template>
<script src="./nav_panel.js" ></script>
<style lang="scss">
.nav-panel ul {
list-style: none;
margin: 0;
padding: 0;
}
.nav-panel li {
border-bottom: 1px solid silver;
padding: 0.5em;
padding-left: 1em;
}
.nav-panel li:last-child {
border: none;
}
.nav-panel a {
display: block;
width: 100%;
&.router-link-active {
font-weight: bold
}
}
</style>

View file

@ -1,4 +1,6 @@
import statusPoster from '../../services/status_poster/status_poster.service.js'
import MediaUpload from '../media_upload/media_upload.vue'
import { reject, map, uniqBy } from 'lodash';
const buildMentionsString = ({user, attentions}, currentUser) => {
@ -23,6 +25,9 @@ const PostStatusForm = {
'repliedUser',
'attentions'
],
components: {
MediaUpload
},
data () {
let statusText = ''
@ -33,7 +38,8 @@ const PostStatusForm = {
return {
newStatus: {
status: statusText
status: statusText,
files: []
}
}
},
@ -41,11 +47,18 @@ const PostStatusForm = {
postStatus (newStatus) {
statusPoster.postStatus({
status: newStatus.status,
media: newStatus.files,
store: this.$store,
inReplyToStatusId: this.replyTo
})
this.newStatus = { }
this.newStatus = {
status: '',
files: []
}
this.$emit('posted')
},
addMediaFile (fileInfo) {
this.newStatus.files.push(fileInfo)
}
}
}

View file

@ -10,7 +10,7 @@
</div>
</div>
<div class='form-bottom'>
<media-upload files="newStatus.files"></media-upload>
<media-upload v-on:uploaded="addMediaFile"></media-upload>
<button type="submit" class="btn btn-default" >Submit</button>
</div>
</form>

View file

@ -0,0 +1,11 @@
import Timeline from '../timeline/timeline.vue'
const PublicAndExternalTimeline = {
components: {
Timeline
},
computed: {
timeline () { return this.$store.state.statuses.timelines.publicAndExternal }
}
}
export default PublicAndExternalTimeline

View file

@ -0,0 +1,10 @@
<template>
<div class="timeline panel panel-default">
<div class="panel-heading">THE WHOLE KNOWN NETWORK</div>
<div class="panel-body">
<Timeline v-bind:timeline="timeline" v-bind:timeline-name="'publicAndExternal'"/>
</div>
</div>
</template>
<script src="./public_and_external_timeline.js"></script>

View file

@ -16,6 +16,9 @@ const Status = {
} else {
return this.statusoid
}
},
loggedIn () {
return !!this.$store.state.users.currentUser
}
},
components: {

View file

@ -32,7 +32,7 @@
</attachment>
</div>
<div>
<div v-if="loggedIn">
<div class='status-actions'>
<div>
<a href="#" v-on:click.prevent="toggleReplying">

View file

@ -1,4 +1,5 @@
import Status from '../status/status.vue'
import timelineFetcher from '../../services/timeline_fetcher/timeline_fetcher.service.js'
const Timeline = {
props: [
@ -8,9 +9,32 @@ const Timeline = {
components: {
Status
},
created () {
const store = this.$store
const credentials = store.state.users.currentUser.credentials
timelineFetcher.fetchAndUpdate({
store,
credentials,
timeline: this.timelineName,
showImmediately: true
})
},
methods: {
showNewStatuses () {
this.$store.commit('showNewStatuses', { timeline: this.timelineName })
},
fetchOlderStatuses () {
const store = this.$store
const credentials = store.state.users.currentUser.credentials
store.commit('setLoading', { timeline: this.timelineName, value: true });
timelineFetcher.fetchAndUpdate({
store,
credentials,
timeline: this.timelineName,
older: true,
showImmediately: true
}).then(() => store.commit('setLoading', { timeline: this.timelineName, value: false }))
}
}
}

View file

@ -8,6 +8,13 @@
</div>
</a>
<status v-for="status in timeline.visibleStatuses" :key="status.id" v-bind:statusoid="status"></status>
<a href="#" v-on:click.prevent='fetchOlderStatuses()' v-if="!timeline.loading">
<div class="new-status-notification">
<p class="text-center" >
Load older statuses.
</p>
</div>
</a>
</div>
</template>
<script src="./timeline.js"></script>