2018-12-26 21:02:16 +01:00
|
|
|
import Vue from 'vue'
|
|
|
|
|
import { Component, Prop } from 'vue-property-decorator'
|
|
|
|
|
|
|
|
|
|
import { GlobalStore } from '@store'
|
|
|
|
|
import { IPost } from '../../../model/index'
|
|
|
|
|
|
|
|
|
|
import './messagePopover.scss'
|
2019-04-05 16:16:29 +02:00
|
|
|
import { tools } from '@src/store/Modules/tools'
|
2018-12-26 21:02:16 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
})
|
|
|
|
|
export default class MessagePopover extends Vue {
|
|
|
|
|
posts: IPost[] = []
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public created() {
|
2018-12-26 21:02:16 +01:00
|
|
|
if (GlobalStore.state.posts.length < 1) {
|
|
|
|
|
this.requestPosts()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get filteredPosts() {
|
|
|
|
|
if (this.posts.length >= 1)
|
|
|
|
|
return this.posts.slice(0, 5)
|
|
|
|
|
else
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public randomDate(): Date {
|
|
|
|
|
let myval = Math.floor(Math.random() * 10000000000)
|
2019-04-05 16:16:29 +02:00
|
|
|
return new Date(tools.getTimestampsNow() - myval)
|
2018-12-26 21:02:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public randomAvatarUrl() {
|
|
|
|
|
return `https://api.adorable.io/avatars/face/${this.randomEye()}/${this.randomNose()}/${this.randomMouth()}/${this.randomHexColor()}`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public randomHexColor() {
|
|
|
|
|
return Math.random().toString(16).slice(2, 8)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public randomEye() {
|
|
|
|
|
return this.randomArrayElement(['eyes1', 'eyes10', 'eyes2', 'eyes3', 'eyes4', 'eyes5', 'eyes6', 'eyes7', 'eyes9'])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public randomNose() {
|
|
|
|
|
return this.randomArrayElement(['nose2', 'nose3', 'nose4', 'nose5', 'nose6', 'nose7', 'nose8', 'nose9'])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public randomMouth() {
|
|
|
|
|
return this.randomArrayElement(['mouth1', 'mouth10', 'mouth11', 'mouth3', 'mouth5', 'mouth6', 'mouth7', 'mouth9'])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public randomArrayElement(array) {
|
|
|
|
|
return array[Math.floor((Math.random() * array.length))]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public requestPosts_old() {
|
|
|
|
|
/*this.$http.jsonplaceholder
|
|
|
|
|
.get('posts')
|
|
|
|
|
.then(response => { this.setPosts(response.data) })
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public requestPosts() {
|
|
|
|
|
// console.log('requestPosts...')
|
|
|
|
|
let prova = [{ title: 'primo' }, { title: 'Secondo' }]
|
|
|
|
|
this.posts.push(...prova)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|