3434 </em >
3535 </p >
3636
37+ <!-- user settings iframe -->
38+ <div id =" user-cool-frame-section" class =" section" >
39+ <h2 >{{ t('richdocuments', 'Collabora User Settings') }}</h2 >
40+ <CoolFrame v-if =" tokenGenerated"
41+ :iframe-type =" 'user'"
42+ :public-wopi-url =" public_wopi_url"
43+ :access-token =" accessToken"
44+ :access-token-t-t-l =" accessTokenTTL"
45+ :wopi-setting-base-url =" wopiSettingBaseUrl" />
46+ </div >
47+
3748 <!-- Zotero -->
3849 <div class =" zotero-section" >
3950 <p ><strong >{{ t('richdocuments', 'Zotero') }}</strong ></p >
114125</template >
115126
116127<script >
117- import { generateFilePath } from ' @nextcloud/router'
128+ import { generateFilePath , generateUrl } from ' @nextcloud/router'
118129import { showError , showSuccess } from ' @nextcloud/dialogs'
119130import NcSettingsSection from ' @nextcloud/vue/dist/Components/NcSettingsSection.js'
120131import NcTextField from ' @nextcloud/vue/dist/Components/NcTextField.js'
121132import NcButton from ' @nextcloud/vue/dist/Components/NcButton.js'
122133import DocSigningField from ' ./DocSigningField.vue'
123134import DeleteIcon from ' vue-material-design-icons/Delete.vue'
124135import axios from ' @nextcloud/axios'
136+ import {
137+ getCurrentUser ,
138+ } from ' @nextcloud/auth'
139+
140+ import { isPublicShare , getSharingToken } from ' @nextcloud/sharing/public'
141+ import { getConfigFileUrl } from ' ../helpers/url.js'
142+ import CoolFrame from ' ./CoolFrame.vue'
125143
126144export default {
127145 name: ' PersonalSettings' ,
@@ -131,6 +149,7 @@ export default {
131149 NcButton,
132150 DocSigningField,
133151 DeleteIcon,
152+ CoolFrame,
134153 },
135154 props: {
136155 initial: {
@@ -147,9 +166,46 @@ export default {
147166 documentSigningCert: this .initial .documentSigningCert || ' ' ,
148167 documentSigningKey: this .initial .documentSigningKey || ' ' ,
149168 documentSigningCa: this .initial .documentSigningCa || ' ' ,
169+ tokenGenerated: false ,
170+ accessToken: ' ' ,
171+ accessTokenTTL: ' ' ,
172+ userId: ' ' ,
173+ wopiSettingBaseUrl: ' ' ,
174+ public_wopi_url: this .initial .publicWopiUrl || ' ' ,
175+ }
176+ },
177+ computed: {
178+ shareToken () {
179+ return getSharingToken ()
180+ },
181+ },
182+ async mounted () {
183+ const currentUser = getCurrentUser ()
184+ if (currentUser && currentUser .uid ) {
185+ this .userId = currentUser .uid
186+ await this .generateAccessToken ()
187+ if (this .accessToken ) {
188+ this .wopiSettingBaseUrl = getConfigFileUrl ()
189+ console .debug (' wopiSettingBaseUrl' , this .wopiSettingBaseUrl )
190+ this .tokenGenerated = true
191+ }
192+ } else {
193+ console .error (' User not authenticated' )
150194 }
151195 },
152196 methods: {
197+ async generateAccessToken () {
198+ const { data } = await axios .get (generateUrl (' /apps/richdocuments/settings/generateToken/user' ))
199+ if (data .token ) {
200+ this .accessToken = data .token
201+ this .accessTokenTTL = data .token_ttl
202+ console .debug (' Admin settings WOPI token generated:' , this .accessToken , this .accessTokenTTL )
203+ } else if (data .federatedUrl ) {
204+ console .error (' Federated URL returned, not expected for admin settings.' )
205+ } else {
206+ console .error (' Failed to generate token for admin settings' )
207+ }
208+ },
153209 setZoteroAPIKey (newVal ) {
154210 this .zoteroAPIKey = newVal
155211 },
0 commit comments