2018-08-26 09:35:53 +00:00
< template >
2018-11-21 11:49:31 +00:00
< div v-if ="!serverData.setup" class="app-social" >
2018-10-26 08:33:27 +00:00
< div v-if ="!serverData.public" id="app-navigation" >
< app -navigation :menu ="menu" / >
2018-08-26 09:35:53 +00:00
< / div >
< div id = "app-content" >
2018-10-26 08:33:27 +00:00
< router -view :key ="$route.fullPath" / >
2018-08-26 09:35:53 +00:00
< / div >
< / div >
2018-11-19 20:54:26 +00:00
< div v -else class = "setup" >
< template v-if ="serverData.isAdmin" >
< h2 > { { t ( 'social' , 'Social app setup' ) } } < / h2 >
< p > { { t ( 'social' , 'ActivityPub requires a fixed URL to make entries unique. Please configure a URL base. Note that this cannot be changed later without resetting the social app data.' ) } } < / p >
< form @submit.prevent ="setCloudAddress" >
< p >
< label class = "hidden" > { { t ( 'social' , 'ActivityPub URL base' ) } } < / label >
2018-11-21 11:49:31 +00:00
< input :placeholder ="serverData.cliUrl" v -model = " cloudAddress " type = "url"
required >
< input : value = "t('social', 'Finish setup')" type = "submit" class = "primary" >
2018-11-19 20:54:26 +00:00
< / p >
< / form >
< / template >
< template v-else >
< p > { { t ( 'social' , 'The social app requires to be setup by the server administrator.' ) } } < / p >
< / template >
< / div >
2018-08-26 09:35:53 +00:00
< / template >
2018-10-10 07:11:37 +00:00
< style scoped >
2018-10-23 13:38:03 +00:00
. app - social {
2018-10-10 07:11:37 +00:00
width : 100 % ;
}
2018-11-19 20:54:26 +00:00
. setup {
margin : auto ;
width : 700 px ;
}
. setup input [ type = url ] {
width : 300 px ;
}
2018-10-10 07:11:37 +00:00
< / style >
2018-08-26 09:35:53 +00:00
< script >
2018-10-26 08:33:27 +00:00
import {
PopoverMenu ,
AppNavigation ,
Multiselect ,
Avatar
} from 'nextcloud-vue'
2018-11-19 20:54:26 +00:00
import axios from 'nextcloud-axios'
2018-10-26 08:33:27 +00:00
import TimelineEntry from './components/TimelineEntry'
import ProfileInfo from './components/ProfileInfo'
export default {
name : 'App' ,
components : {
2018-08-26 09:35:53 +00:00
PopoverMenu ,
2018-10-23 13:38:03 +00:00
AppNavigation ,
2018-10-26 08:33:27 +00:00
TimelineEntry ,
2018-10-23 13:38:03 +00:00
Multiselect ,
2018-10-26 08:33:27 +00:00
Avatar ,
ProfileInfo
} ,
data : function ( ) {
return {
infoHidden : false ,
2018-11-19 20:54:26 +00:00
state : [ ] ,
2018-11-21 11:49:31 +00:00
cloudAddress : ''
2018-10-26 08:33:27 +00:00
}
} ,
computed : {
url : function ( ) {
return OC . linkTo ( 'social' , 'img/nextcloud.png' )
2018-08-26 09:35:53 +00:00
} ,
2018-10-26 08:33:27 +00:00
currentUser : function ( ) {
return OC . getCurrentUser ( )
2018-08-26 09:35:53 +00:00
} ,
2018-10-26 08:33:27 +00:00
socialId : function ( ) {
return '@' + OC . getCurrentUser ( ) . uid + '@' + OC . getHost ( )
2018-10-10 07:46:26 +00:00
} ,
2018-10-26 08:33:27 +00:00
timeline : function ( ) {
return this . $store . getters . getTimeline
2018-10-10 10:20:42 +00:00
} ,
2018-10-26 08:33:27 +00:00
serverData : function ( ) {
return this . $store . getters . getServerData
} ,
menu : function ( ) {
let defaultCategories = [
{
id : 'social-timeline' ,
classes : [ ] ,
2018-11-22 14:42:10 +00:00
icon : 'icon-home' ,
text : t ( 'social' , 'Home' ) ,
2018-10-26 08:33:27 +00:00
router : {
name : 'timeline'
}
} ,
2018-11-22 14:42:10 +00:00
{
id : 'social-direct-messages' ,
classes : [ ] ,
router : {
name : 'timeline' ,
params : { type : 'direct' }
} ,
icon : 'icon-comment' ,
text : t ( 'social' , 'Direct messages' )
} ,
2018-10-26 08:33:27 +00:00
{
id : 'social-account' ,
classes : [ ] ,
icon : 'icon-user' ,
2018-11-01 03:55:33 +00:00
text : t ( 'social' , 'Profile' ) ,
2018-10-26 08:33:27 +00:00
router : {
name : 'profile' ,
params : { account : this . currentUser . uid }
}
} ,
{
2018-11-22 14:42:10 +00:00
id : 'social-spacer' ,
classes : [ ]
} ,
{
2018-11-22 15:11:46 +00:00
id : 'social-local' ,
2018-10-26 08:33:27 +00:00
classes : [ ] ,
2018-11-22 14:42:10 +00:00
icon : 'icon-category-monitoring' ,
text : t ( 'social' , 'Local timeline' ) ,
router : {
name : 'timeline' ,
2018-11-22 15:11:46 +00:00
params : { type : 'timeline' }
2018-11-22 14:42:10 +00:00
}
2018-10-26 08:33:27 +00:00
} ,
{
2018-11-22 15:11:46 +00:00
id : 'social-global' ,
2018-10-26 08:33:27 +00:00
classes : [ ] ,
2018-11-22 14:42:10 +00:00
icon : 'icon-link' ,
text : t ( 'social' , 'Global timeline' ) ,
router : {
name : 'timeline' ,
2018-11-22 15:11:46 +00:00
params : { type : 'federated' }
2018-11-22 14:42:10 +00:00
}
2018-08-26 09:35:53 +00:00
}
2018-10-26 08:33:27 +00:00
]
return {
items : defaultCategories ,
loading : false
2018-08-26 09:35:53 +00:00
}
}
2018-10-26 08:33:27 +00:00
} ,
beforeMount : function ( ) {
// importing server data into the store
const serverDataElmt = document . getElementById ( 'serverData' )
if ( serverDataElmt !== null ) {
this . $store . commit ( 'setServerData' , JSON . parse ( document . getElementById ( 'serverData' ) . dataset . server ) )
}
} ,
methods : {
hideInfo ( ) {
this . infoHidden = true
2018-11-19 20:54:26 +00:00
} ,
setCloudAddress ( ) {
2018-11-21 11:49:31 +00:00
axios . post ( OC . generateUrl ( 'apps/social/api/v1/config/cloudAddress' ) , { cloudAddress : this . cloudAddress } ) . then ( ( response ) => {
this . $store . commit ( 'setServerDataEntry' , 'setup' , false )
this . $store . commit ( 'setServerDataEntry' , 'cloudAddress' , this . cloudAddress )
} )
2018-10-26 08:33:27 +00:00
}
2018-08-26 09:35:53 +00:00
}
2018-10-26 08:33:27 +00:00
}
2018-11-21 11:49:31 +00:00
< / script >