2019-02-11 02:20:21 +00:00
|
|
|
<template>
|
2021-04-28 02:15:31 +00:00
|
|
|
<div class="container mt-2 mt-md-5 bg-black">
|
2020-01-28 02:21:18 +00:00
|
|
|
<input type="file" id="pf-dz" name="media" class="d-none file-input" v-bind:accept="config.mimes">
|
2021-04-28 02:15:31 +00:00
|
|
|
<span class="fixed-top text-right m-3 cursor-pointer" @click="navigateTo()">
|
|
|
|
<i class="fas fa-times fa-lg text-white"></i>
|
|
|
|
</span>
|
2020-07-20 15:24:58 +00:00
|
|
|
<div v-if="loaded" class="row">
|
2021-04-28 02:15:31 +00:00
|
|
|
<div class="col-12 col-md-6 offset-md-3 bg-dark rounded-lg">
|
2019-02-11 02:20:21 +00:00
|
|
|
|
2020-01-07 06:20:36 +00:00
|
|
|
<!-- LANDING -->
|
|
|
|
<div v-if="page == 'landing'" class="card card-body bg-transparent border-0 shadow-none d-flex justify-content-center" style="height: 90vh;">
|
2021-04-28 02:15:31 +00:00
|
|
|
<div class="text-center flex-fill pt-3">
|
|
|
|
<p class="text-muted font-weight-light mb-1">
|
|
|
|
<i class="fas fa-history fa-5x"></i>
|
|
|
|
</p>
|
|
|
|
<p class="text-muted font-weight-bold mb-0">STORIES</p>
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
2020-07-20 15:24:58 +00:00
|
|
|
<div class="flex-fill py-4">
|
2021-04-28 02:15:31 +00:00
|
|
|
<div class="card w-100 shadow-none bg-transparent">
|
|
|
|
<div class="list-group bg-transparent">
|
2020-07-20 15:24:58 +00:00
|
|
|
<!-- <a class="list-group-item text-center lead text-decoration-none text-dark" href="#">Camera</a> -->
|
2021-04-28 02:15:31 +00:00
|
|
|
<a class="list-group-item bg-transparent lead text-decoration-none text-light font-weight-bold border-light" href="#" @click.prevent="upload()">
|
|
|
|
<i class="fas fa-plus-square mr-2"></i>
|
|
|
|
Add to Story
|
|
|
|
</a>
|
|
|
|
<a v-if="stories.length" class="list-group-item bg-transparent lead text-decoration-none text-lighter font-weight-bold border-muted" href="#" @click.prevent="edit()">
|
|
|
|
<i class="far fa-clone mr-2"></i>
|
|
|
|
My Story
|
|
|
|
</a>
|
|
|
|
<!-- <a v-if="stories.length" class="list-group-item bg-transparent lead text-decoration-none text-lighter font-weight-bold border-muted" href="#" @click.prevent="edit()">
|
|
|
|
<i class="fas fa-network-wired mr-1"></i>
|
|
|
|
Audience
|
|
|
|
</a> -->
|
|
|
|
<!-- <a v-if="stories.length" class="list-group-item bg-transparent lead text-decoration-none text-lighter font-weight-bold border-muted" href="#" @click.prevent="edit()">
|
|
|
|
<i class="far fa-chart-bar mr-2"></i>
|
|
|
|
Stats
|
|
|
|
</a> -->
|
|
|
|
<!-- <a class="list-group-item bg-transparent lead text-decoration-none text-lighter font-weight-bold border-muted" href="#" @click.prevent="edit()">
|
|
|
|
<i class="far fa-folder mr-2"></i>
|
|
|
|
Archived
|
|
|
|
</a> -->
|
|
|
|
<!-- <a class="list-group-item bg-transparent lead text-decoration-none text-lighter font-weight-bold border-muted" href="#" @click.prevent="edit()">
|
|
|
|
<i class="far fa-question-circle mr-2"></i>
|
|
|
|
Help
|
|
|
|
</a> -->
|
|
|
|
<a class="list-group-item bg-transparent lead text-decoration-none text-lighter font-weight-bold border-muted" href="/">
|
|
|
|
<i class="fas fa-arrow-left mr-2"></i>
|
|
|
|
Go back
|
|
|
|
</a>
|
2020-07-20 15:24:58 +00:00
|
|
|
<!-- <a class="list-group-item text-center lead text-decoration-none text-dark" href="#">Options</a> -->
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="text-center flex-fill">
|
2021-04-28 02:15:31 +00:00
|
|
|
<!-- <p class="text-lighter small text-uppercase">
|
2020-01-07 06:20:36 +00:00
|
|
|
<a href="/" class="text-muted font-weight-bold">Home</a>
|
|
|
|
<span class="px-2 text-lighter">|</span>
|
|
|
|
<a href="/i/my/story" class="text-muted font-weight-bold">View My Story</a>
|
|
|
|
<span class="px-2 text-lighter">|</span>
|
|
|
|
<a href="/site/help" class="text-muted font-weight-bold">Help</a>
|
2021-04-28 02:15:31 +00:00
|
|
|
</p> -->
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- CROP -->
|
2021-04-28 02:15:31 +00:00
|
|
|
<div v-if="page == 'crop'" class="card card-body bg-transparent border-0 shadow-none d-flex justify-content-center" style="height: 90vh;">
|
|
|
|
<div class="text-center py-3 d-flex justify-content-between align-items-center">
|
2020-01-07 06:20:36 +00:00
|
|
|
<div>
|
2021-04-28 02:15:31 +00:00
|
|
|
<button class="btn btn-outline-lighter btn-sm py-1 px-md-3" @click="deleteCurrentStory()"><i class="pr-2 fas fa-chevron-left fa-sm"></i> Delete</button>
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
2021-04-28 02:15:31 +00:00
|
|
|
<div class="">
|
|
|
|
<p class="text-muted font-weight-light mb-1">
|
|
|
|
<i class="fas fa-history fa-5x"></i>
|
|
|
|
</p>
|
|
|
|
<p class="text-muted font-weight-bold mb-0">STORIES</p>
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
|
|
|
<div>
|
2021-04-28 02:15:31 +00:00
|
|
|
<button class="btn btn-primary btn-sm py-1 px-md-3" @click="performCrop()">Crop <i class="pl-2 fas fa-chevron-right fa-sm"></i></button>
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex-fill">
|
|
|
|
<div class="card w-100 mt-3">
|
|
|
|
<div class="card-body p-0">
|
|
|
|
<vue-cropper
|
2021-04-28 02:15:31 +00:00
|
|
|
ref="croppa"
|
2020-01-07 06:20:36 +00:00
|
|
|
:relativeZoom="cropper.zoom"
|
|
|
|
:aspectRatio="cropper.aspectRatio"
|
|
|
|
:viewMode="cropper.viewMode"
|
|
|
|
:zoomable="cropper.zoomable"
|
|
|
|
:rotatable="true"
|
|
|
|
:src="mediaUrl"
|
|
|
|
>
|
|
|
|
</vue-cropper>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- ERROR -->
|
|
|
|
<div v-if="page == 'error'" class="card card-body bg-transparent border-0 shadow-none d-flex justify-content-center align-items-center" style="height: 90vh;">
|
2021-04-28 02:15:31 +00:00
|
|
|
<p class="h3 mb-0 text-light">Oops!</p>
|
2020-01-07 06:20:36 +00:00
|
|
|
<p class="text-muted lead">An error occurred, please try again later.</p>
|
|
|
|
<p class="text-muted mb-0">
|
|
|
|
<a class="btn btn-outline-secondary py-0 px-5 font-weight-bold" href="/">Go back</a>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
2020-01-28 03:23:13 +00:00
|
|
|
<!-- UPLOADING -->
|
|
|
|
<div v-if="page == 'uploading'" class="card card-body bg-transparent border-0 shadow-none d-flex justify-content-center align-items-center" style="height: 90vh;">
|
2021-04-28 02:15:31 +00:00
|
|
|
<p v-if="uploadProgress != 100" class="display-4 mb-0 text-muted">Uploading {{uploadProgress}}%</p>
|
|
|
|
<p v-else class="display-4 mb-0 text-muted">Processing ...</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- CROPPING -->
|
|
|
|
<div v-if="page == 'cropping'" class="card card-body bg-transparent border-0 shadow-none d-flex justify-content-center align-items-center" style="height: 90vh;">
|
|
|
|
<p class="display-4 mb-0 text-muted">Cropping ...</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- PREVIEW -->
|
|
|
|
<div v-if="page == 'preview'" class="card card-body bg-transparent border-0 shadow-none d-flex justify-content-center align-items-center" style="height: 90vh;">
|
|
|
|
<div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="durationSlider" class="text-light lead font-weight-bold">Story Duration</label>
|
|
|
|
<input type="range" class="custom-range" min="3" max="10" id="durationSlider" v-model="duration">
|
|
|
|
<p class="help-text text-center">
|
|
|
|
<span class="text-light">{{duration}} seconds</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<hr class="my-3">
|
|
|
|
<a class="btn btn-primary btn-block px-5 font-weight-bold my-3" href="#" @click.prevent="shareStoryToFollowers()">
|
|
|
|
Share Story with followers
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<a class="btn btn-outline-muted btn-block px-5 font-weight-bold" href="/" @click.prevent="deleteCurrentStory()">
|
|
|
|
Cancel
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<!-- <a class="btn btn-outline-secondary btn-block px-5 font-weight-bold" href="#">
|
|
|
|
Share Story with everyone
|
|
|
|
</a> -->
|
2020-01-28 03:23:13 +00:00
|
|
|
</div>
|
|
|
|
|
2021-04-28 02:15:31 +00:00
|
|
|
<!-- EDIT -->
|
2020-01-07 06:20:36 +00:00
|
|
|
<div v-if="page == 'edit'" class="card card-body bg-transparent border-0 shadow-none d-flex justify-content-center" style="height: 90vh;">
|
2021-04-28 02:15:31 +00:00
|
|
|
<div class="text-center flex-fill mt-5">
|
|
|
|
<p class="text-muted font-weight-light mb-1">
|
|
|
|
<i class="fas fa-history fa-5x"></i>
|
|
|
|
</p>
|
|
|
|
<p class="text-muted font-weight-bold mb-0">STORIES</p>
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
2021-04-28 02:15:31 +00:00
|
|
|
<div class="flex-fill py-4">
|
|
|
|
<div class="card w-100 shadow-none bg-transparent" style="max-height: 50vh; overflow-y: scroll">
|
2020-01-07 06:20:36 +00:00
|
|
|
<div class="list-group">
|
2021-04-28 02:15:31 +00:00
|
|
|
<div v-for="(story, index) in stories" class="list-group-item bg-transparent text-center border-muted text-lighter" href="#">
|
2020-01-07 06:20:36 +00:00
|
|
|
<div class="media align-items-center">
|
2020-03-14 19:14:26 +00:00
|
|
|
<div class="mr-3 cursor-pointer" @click="showLightbox(story)">
|
|
|
|
<img :src="story.src" class="img-fluid" width="70px" height="70px">
|
|
|
|
<p class="small text-muted text-center mb-0">(expand)</p>
|
|
|
|
</div>
|
2021-04-28 02:15:31 +00:00
|
|
|
<div class="media-body text-left">
|
2020-01-07 06:20:36 +00:00
|
|
|
<p class="mb-0">Expires</p>
|
2021-04-28 02:15:31 +00:00
|
|
|
<p class="mb-1 text-muted small"><span>{{expiresTimestamp(story.expires_at)}}</span></p>
|
|
|
|
<p class="mb-0">
|
|
|
|
<button class="btn btn-outline-muted btn-sm py-0 px-2">Followers Only</button>
|
|
|
|
</p>
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
|
|
|
<div class="float-right">
|
|
|
|
<button @click="deleteStory(story, index)" class="btn btn-danger btn-sm font-weight-bold text-uppercase">Delete</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex-fill text-center">
|
2021-04-28 02:15:31 +00:00
|
|
|
<a class="btn btn-outline-secondary btn-block px-5 font-weight-bold" href="/i/stories/new" @click.prevent="goBack()">Go back</a>
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
2019-02-11 02:20:21 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-07 06:20:36 +00:00
|
|
|
<b-modal
|
|
|
|
id="lightbox"
|
|
|
|
ref="lightboxModal"
|
|
|
|
hide-header
|
|
|
|
hide-footer
|
|
|
|
centered
|
|
|
|
size="lg"
|
|
|
|
body-class="p-0"
|
|
|
|
>
|
|
|
|
<div v-if="lightboxMedia" class="w-100 h-100">
|
2021-04-28 02:15:31 +00:00
|
|
|
<img :src="lightboxMedia.url" style="max-height: 90vh; width: 100%; object-fit: cover;">
|
2020-01-07 06:20:36 +00:00
|
|
|
</div>
|
|
|
|
</b-modal>
|
2019-02-11 02:20:21 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-04-28 02:15:31 +00:00
|
|
|
<style type="text/css">
|
|
|
|
.bg-black {
|
|
|
|
background-color: #262626;
|
|
|
|
}
|
2019-02-11 02:20:21 +00:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2020-01-07 06:20:36 +00:00
|
|
|
import VueTimeago from 'vue-timeago';
|
|
|
|
import VueCropper from 'vue-cropperjs';
|
|
|
|
import 'cropperjs/dist/cropper.css';
|
2019-02-11 02:20:21 +00:00
|
|
|
export default {
|
2021-04-28 02:15:31 +00:00
|
|
|
components: {
|
2020-01-07 06:20:36 +00:00
|
|
|
VueCropper,
|
|
|
|
VueTimeago
|
|
|
|
},
|
|
|
|
|
|
|
|
props: ['profile-id'],
|
2019-02-11 02:20:21 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-07-20 15:24:58 +00:00
|
|
|
loaded: false,
|
2020-01-07 06:20:36 +00:00
|
|
|
config: window.App.config,
|
|
|
|
mimes: [
|
|
|
|
'image/jpeg',
|
2020-07-20 15:24:58 +00:00
|
|
|
'image/png',
|
|
|
|
// 'video/mp4'
|
2020-01-07 06:20:36 +00:00
|
|
|
],
|
|
|
|
page: 'landing',
|
|
|
|
pages: [
|
|
|
|
'landing',
|
|
|
|
'crop',
|
|
|
|
'edit',
|
|
|
|
'confirm',
|
2020-01-28 03:23:13 +00:00
|
|
|
'error',
|
|
|
|
'uploading'
|
2020-01-07 06:20:36 +00:00
|
|
|
],
|
|
|
|
uploading: false,
|
2020-01-28 03:23:13 +00:00
|
|
|
uploadProgress: 0,
|
2020-01-07 06:20:36 +00:00
|
|
|
cropper: {
|
|
|
|
aspectRatio: 9/16,
|
|
|
|
viewMode: 1,
|
|
|
|
zoomable: true,
|
|
|
|
zoom: null
|
|
|
|
},
|
|
|
|
mediaUrl: null,
|
2021-04-28 02:15:31 +00:00
|
|
|
mediaId: null,
|
2020-01-07 06:20:36 +00:00
|
|
|
stories: [],
|
|
|
|
lightboxMedia: false,
|
2021-04-28 02:15:31 +00:00
|
|
|
duration: 3
|
2019-02-11 02:20:21 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2021-04-28 02:15:31 +00:00
|
|
|
$('body').addClass('bg-black');
|
2020-01-07 06:20:36 +00:00
|
|
|
this.mediaWatcher();
|
2020-02-05 04:04:58 +00:00
|
|
|
axios.get('/api/stories/v0/fetch/' + this.profileId)
|
2020-07-20 15:24:58 +00:00
|
|
|
.then(res => {
|
|
|
|
this.stories = res.data;
|
|
|
|
this.loaded = true;
|
|
|
|
});
|
2019-02-11 02:20:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-01-07 06:20:36 +00:00
|
|
|
|
|
|
|
upload() {
|
|
|
|
let fi = $('.file-input[name="media"]');
|
|
|
|
fi.trigger('click');
|
|
|
|
},
|
|
|
|
|
|
|
|
mediaWatcher() {
|
|
|
|
let self = this;
|
|
|
|
$(document).on('change', '#pf-dz', function(e) {
|
|
|
|
self.triggerUpload();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
triggerUpload() {
|
|
|
|
let self = this;
|
|
|
|
self.uploading = true;
|
|
|
|
let io = document.querySelector('#pf-dz');
|
2020-01-28 03:23:13 +00:00
|
|
|
self.page = 'uploading';
|
2020-01-07 06:20:36 +00:00
|
|
|
Array.prototype.forEach.call(io.files, function(io, i) {
|
|
|
|
if(self.media && self.media.length + i >= self.config.uploader.album_limit) {
|
|
|
|
swal('Error', 'You can only upload ' + self.config.uploader.album_limit + ' photos per album', 'error');
|
|
|
|
self.uploading = false;
|
|
|
|
self.page = 2;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let type = io.type;
|
|
|
|
let validated = $.inArray(type, self.mimes);
|
|
|
|
if(validated == -1) {
|
|
|
|
swal('Invalid File Type', 'The file you are trying to add is not a valid mime type. Please upload a '+self.mimes+' only.', 'error');
|
|
|
|
self.uploading = false;
|
|
|
|
self.page = 'error';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let form = new FormData();
|
|
|
|
form.append('file', io);
|
|
|
|
|
|
|
|
let xhrConfig = {
|
|
|
|
onUploadProgress: function(e) {
|
2020-01-28 03:23:13 +00:00
|
|
|
let progress = Math.floor( (e.loaded * 100) / e.total );
|
2020-01-07 06:20:36 +00:00
|
|
|
self.uploadProgress = progress;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-28 02:15:31 +00:00
|
|
|
io.value = null;
|
2020-02-05 04:04:58 +00:00
|
|
|
axios.post('/api/stories/v0/add', form, xhrConfig)
|
2020-01-07 06:20:36 +00:00
|
|
|
.then(function(e) {
|
|
|
|
self.uploadProgress = 100;
|
|
|
|
self.uploading = false;
|
|
|
|
self.mediaUrl = e.data.media_url;
|
2021-04-28 02:15:31 +00:00
|
|
|
self.mediaId = e.data.media_id;
|
|
|
|
self.page = 'crop';
|
|
|
|
// window.location.href = '/i/my/story';
|
2020-01-07 06:20:36 +00:00
|
|
|
}).catch(function(e) {
|
|
|
|
self.uploading = false;
|
|
|
|
io.value = null;
|
2020-01-28 02:21:18 +00:00
|
|
|
let msg = e.response.data.message ? e.response.data.message : 'Something went wrong.'
|
|
|
|
swal('Oops!', msg, 'warning');
|
2020-01-07 06:20:36 +00:00
|
|
|
});
|
|
|
|
self.uploadProgress = 0;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
expiresTimestamp(ts) {
|
|
|
|
ts = new Date(ts * 1000);
|
|
|
|
return ts.toDateString() + ' ' + ts.toLocaleTimeString();
|
|
|
|
},
|
|
|
|
|
|
|
|
edit() {
|
|
|
|
this.page = 'edit';
|
|
|
|
},
|
|
|
|
|
|
|
|
showLightbox(story) {
|
|
|
|
this.lightboxMedia = {
|
|
|
|
url: story.src
|
|
|
|
}
|
|
|
|
this.$refs.lightboxModal.show();
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteStory(story, index) {
|
|
|
|
if(window.confirm('Are you sure you want to delete this Story?') != true) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-05 04:04:58 +00:00
|
|
|
axios.delete('/api/stories/v0/delete/' + story.id)
|
2020-01-07 06:20:36 +00:00
|
|
|
.then(res => {
|
|
|
|
this.stories.splice(index, 1);
|
|
|
|
if(this.stories.length == 0) {
|
|
|
|
window.location.href = '/i/stories/new';
|
|
|
|
}
|
|
|
|
});
|
2021-04-28 02:15:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
navigateTo(path = '/') {
|
|
|
|
window.location.href = path;
|
|
|
|
},
|
|
|
|
|
|
|
|
goBack() {
|
|
|
|
this.page = 'landing';
|
|
|
|
},
|
|
|
|
|
|
|
|
performCrop() {
|
|
|
|
this.page = 'cropping';
|
|
|
|
let data = this.$refs.croppa.getData();
|
|
|
|
axios.post('/api/stories/v0/crop', {
|
|
|
|
media_id: this.mediaId,
|
|
|
|
width: data.width,
|
|
|
|
height: data.height,
|
|
|
|
x: data.x,
|
|
|
|
y: data.y
|
|
|
|
}).then(res => {
|
|
|
|
this.page = 'preview';
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteCurrentStory() {
|
|
|
|
let story = {
|
|
|
|
id: this.mediaId
|
|
|
|
};
|
|
|
|
this.deleteStory(story);
|
|
|
|
this.page = 'landing';
|
|
|
|
},
|
2020-01-07 06:20:36 +00:00
|
|
|
|
2021-04-28 02:15:31 +00:00
|
|
|
shareStoryToFollowers() {
|
|
|
|
axios.post('/api/stories/v0/publish', {
|
|
|
|
media_id: this.mediaId,
|
|
|
|
duration: this.duration
|
|
|
|
}).then(res => {
|
|
|
|
window.location.href = '/i/my/story?id=' + this.mediaId;
|
|
|
|
})
|
2019-02-11 02:20:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-28 02:15:31 +00:00
|
|
|
</script>
|