2018-08-26 09:35:53 +00:00
< template >
2018-11-19 20:54:26 +00:00
< div class = "app-social" v-if ="!serverData.setup" >
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 >
< input type = "url" :placeholder ="serverData.cliUrl" v -model = " cloudAddress " required / >
< input type = "submit" : value = "t('social', 'Finish setup')" class = "primary" / >
< / 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 : [ ] ,
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 : [ ] ,
icon : 'icon-category-monitoring' ,
text : t ( 'social' , 'Timeline' ) ,
router : {
name : 'timeline'
}
} ,
{
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 }
}
} ,
{
id : 'social-friends' ,
classes : [ ] ,
href : '#' ,
icon : 'icon-category-social' ,
text : t ( 'social' , 'Friends' )
} ,
{
id : 'social-favorites' ,
classes : [ ] ,
href : '#' ,
icon : 'icon-favorite' ,
text : t ( 'social' , 'Favorites' )
} ,
{
id : 'social-direct-messages' ,
classes : [ ] ,
href : '#' ,
icon : 'icon-comment' ,
utils : {
counter : 3
2018-08-26 09:35:53 +00:00
} ,
2018-10-26 08:33:27 +00:00
text : t ( 'social' , 'Direct messages' )
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 ( ) {
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-19 20:54:26 +00:00
< / script >