1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
<template>
<div class="app-social" v-if="!serverData.setup">
<div v-if="!serverData.public" id="app-navigation">
<app-navigation :menu="menu" />
</div>
<div id="app-content">
<router-view :key="$route.fullPath" />
</div>
</div>
<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>
</template>
<style scoped>
.app-social {
width: 100%;
}
.setup {
margin: auto;
width: 700px;
}
.setup input[type=url] {
width: 300px;
}
</style>
<script>
import {
PopoverMenu,
AppNavigation,
Multiselect,
Avatar
} from 'nextcloud-vue'
import axios from 'nextcloud-axios'
import TimelineEntry from './components/TimelineEntry'
import ProfileInfo from './components/ProfileInfo'
export default {
name: 'App',
components: {
PopoverMenu,
AppNavigation,
TimelineEntry,
Multiselect,
Avatar,
ProfileInfo
},
data: function() {
return {
infoHidden: false,
state: [],
cloudAddress: '',
}
},
computed: {
url: function() {
return OC.linkTo('social', 'img/nextcloud.png')
},
currentUser: function() {
return OC.getCurrentUser()
},
socialId: function() {
return '@' + OC.getCurrentUser().uid + '@' + OC.getHost()
},
timeline: function() {
return this.$store.getters.getTimeline
},
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',
text: t('social', 'Profile'),
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
},
text: t('social', 'Direct messages')
}
]
return {
items: defaultCategories,
loading: false
}
}
},
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
},
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);
});
}
}
}
</script>
|