Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl> Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>tags/v19.0.0RC2
@@ -69,6 +69,7 @@ | |||
import axios from '@nextcloud/axios' | |||
import { Multiselect } from '@nextcloud/vue' | |||
import _ from 'lodash' | |||
import { generateUrl, generateOcsUrl } from '@nextcloud/router' | |||
export default { | |||
name: 'AdminTwoFactor', | |||
@@ -124,7 +125,7 @@ export default { | |||
methods: { | |||
searchGroup: _.debounce(function(query) { | |||
this.loadingGroups = true | |||
axios.get(OC.linkToOCS(`cloud/groups?offset=0&search=${encodeURIComponent(query)}&limit=20`, 2)) | |||
axios.get(generateOcsUrl(`cloud/groups?offset=0&search=${encodeURIComponent(query)}&limit=20`, 2)) | |||
.then(res => res.data.ocs) | |||
.then(ocs => ocs.data.groups) | |||
.then(groups => { this.groups = _.sortedUniq(_.uniq(this.groups.concat(groups))) }) | |||
@@ -140,7 +141,7 @@ export default { | |||
enforcedGroups: this.enforcedGroups, | |||
excludedGroups: this.excludedGroups, | |||
} | |||
axios.put(OC.generateUrl('/settings/api/admin/twofactorauth'), data) | |||
axios.put(generateUrl('/settings/api/admin/twofactorauth'), data) | |||
.then(resp => resp.data) | |||
.then(state => { | |||
this.state = state |
@@ -24,6 +24,8 @@ | |||
<img :src="scoreImage" class="app-score-image"> | |||
</template> | |||
<script> | |||
import { imagePath } from '@nextcloud/router' | |||
export default { | |||
name: 'AppScore', | |||
props: ['score'], | |||
@@ -31,7 +33,7 @@ export default { | |||
scoreImage() { | |||
const score = Math.round(this.score * 10) | |||
const imageName = 'rating/s' + score + '.svg' | |||
return OC.imagePath('core', imageName) | |||
return imagePath('core', imageName) | |||
}, | |||
}, | |||
} |
@@ -37,6 +37,7 @@ | |||
<script> | |||
import axios from '@nextcloud/axios' | |||
import confirmPassword from '@nextcloud/password-confirmation' | |||
import { generateUrl } from '@nextcloud/router' | |||
import AuthTokenList from './AuthTokenList' | |||
import AuthTokenSetupDialogue from './AuthTokenSetupDialogue' | |||
@@ -80,7 +81,7 @@ export default { | |||
}, | |||
data() { | |||
return { | |||
baseUrl: OC.generateUrl('/settings/personal/authtokens'), | |||
baseUrl: generateUrl('/settings/personal/authtokens'), | |||
} | |||
}, | |||
methods: { |
@@ -29,7 +29,7 @@ | |||
<button class="button" | |||
:disabled="loading" | |||
@click="submit"> | |||
{{ t('settings', 'Create new app password') }} | |||
{{ t('settings', 'Create new app password') }} | |||
</button> | |||
</div> | |||
<div v-else> | |||
@@ -79,6 +79,7 @@ | |||
<script> | |||
import QR from '@chenfengyuan/vue-qrcode' | |||
import confirmPassword from '@nextcloud/password-confirmation' | |||
import { getRootUrl } from '@nextcloud/router' | |||
export default { | |||
name: 'AuthTokenSetupDialogue', | |||
@@ -141,7 +142,7 @@ export default { | |||
this.loginName = token.loginName | |||
this.appPassword = token.token | |||
const server = window.location.protocol + '//' + window.location.host + OC.getRootPath() | |||
const server = window.location.protocol + '//' + window.location.host + getRootUrl() | |||
this.qrUrl = `nc://login/user:${token.loginName}&password:${token.token}&server:${server}` | |||
this.$nextTick(() => { |
@@ -87,8 +87,8 @@ export default { | |||
httpWarning: Boolean, | |||
isHttps: { | |||
type: Boolean, | |||
default: false | |||
} | |||
default: false, | |||
}, | |||
}, | |||
data() { | |||
return { |
@@ -40,7 +40,7 @@ | |||
{{ t('settings', 'Your browser does not support WebAuthn.') }} | |||
</p> | |||
<AddDevice v-if="hasPublicKeyCredential" :isHttps="isHttps" @added="deviceAdded" /> | |||
<AddDevice v-if="hasPublicKeyCredential" :is-https="isHttps" @added="deviceAdded" /> | |||
</div> | |||
</template> | |||
@@ -20,6 +20,8 @@ | |||
* | |||
*/ | |||
import { generateUrl } from '@nextcloud/router' | |||
export default { | |||
props: { | |||
user: { | |||
@@ -158,7 +160,7 @@ export default { | |||
* @returns {string} | |||
*/ | |||
generateAvatar(user, size = 32) { | |||
return OC.generateUrl( | |||
return generateUrl( | |||
'/avatar/{user}/{size}?v={version}', | |||
{ | |||
user: user, |
@@ -23,6 +23,7 @@ | |||
import Vue from 'vue' | |||
import Router from 'vue-router' | |||
import { generateUrl } from '@nextcloud/router' | |||
// Dynamic loading | |||
const Users = () => import('./views/Users') | |||
@@ -43,7 +44,7 @@ export default new Router({ | |||
mode: 'history', | |||
// if index.php is in the url AND we got this far, then it's working: | |||
// let's keep using index.php in the url | |||
base: OC.generateUrl(''), | |||
base: generateUrl(''), | |||
linkActiveClass: 'active', | |||
routes: [ | |||
{ |
@@ -35,15 +35,15 @@ export default { | |||
* you'll need to be careful when using it. | |||
* e.g | |||
* // store | |||
* action(context) { | |||
* return api.requireAdmin().then((response) => { | |||
* return api.get('url') | |||
* .then((response) => {API success}) | |||
* .catch((error) => {API failure}); | |||
* }).catch((error) => {requireAdmin failure}); | |||
* } | |||
* action(context) { | |||
* return api.requireAdmin().then((response) => { | |||
* return api.get('url') | |||
* .then((response) => {API success}) | |||
* .catch((error) => {API failure}); | |||
* }).catch((error) => {requireAdmin failure}); | |||
* } | |||
* // vue | |||
* this.$store.dispatch('action').then(() => {always executed}) | |||
* this.$store.dispatch('action').then(() => {always executed}) | |||
* | |||
* Since Promise.then().catch().then() will always execute the last then | |||
* this.$store.dispatch('action').then will always be executed | |||
@@ -52,11 +52,11 @@ export default { | |||
* you will need to throw a new error in the api.get.catch() | |||
* | |||
* e.g | |||
* api.requireAdmin().then((response) => { | |||
* api.get('url') | |||
* .then((response) => {API success}) | |||
* .catch((error) => {throw error;}); | |||
* }).catch((error) => {requireAdmin OR API failure}); | |||
* api.requireAdmin().then((response) => { | |||
* api.get('url') | |||
* .then((response) => {API success}) | |||
* .catch((error) => {throw error;}); | |||
* }).catch((error) => {requireAdmin OR API failure}); | |||
* | |||
* @returns {Promise} | |||
*/ |
@@ -22,6 +22,7 @@ | |||
import api from './api' | |||
import Vue from 'vue' | |||
import { generateUrl } from '@nextcloud/router' | |||
const state = { | |||
apps: [], | |||
@@ -165,7 +166,7 @@ const actions = { | |||
return api.requireAdmin().then((response) => { | |||
context.commit('startLoading', apps) | |||
context.commit('startLoading', 'install') | |||
return api.post(OC.generateUrl(`settings/apps/enable`), { appIds: apps, groups: groups }) | |||
return api.post(generateUrl(`settings/apps/enable`), { appIds: apps, groups: groups }) | |||
.then((response) => { | |||
context.commit('stopLoading', apps) | |||
context.commit('stopLoading', 'install') | |||
@@ -174,7 +175,7 @@ const actions = { | |||
}) | |||
// check for server health | |||
return api.get(OC.generateUrl('apps/files')) | |||
return api.get(generateUrl('apps/files')) | |||
.then(() => { | |||
if (response.data.update_required) { | |||
OC.dialogs.info( | |||
@@ -223,7 +224,7 @@ const actions = { | |||
return api.requireAdmin().then(() => { | |||
context.commit('startLoading', apps) | |||
context.commit('startLoading', 'install') | |||
return api.post(OC.generateUrl(`settings/apps/force`), { appId }) | |||
return api.post(generateUrl(`settings/apps/force`), { appId }) | |||
.then((response) => { | |||
// TODO: find a cleaner solution | |||
location.reload() | |||
@@ -248,7 +249,7 @@ const actions = { | |||
} | |||
return api.requireAdmin().then((response) => { | |||
context.commit('startLoading', apps) | |||
return api.post(OC.generateUrl(`settings/apps/disable`), { appIds: apps }) | |||
return api.post(generateUrl(`settings/apps/disable`), { appIds: apps }) | |||
.then((response) => { | |||
context.commit('stopLoading', apps) | |||
apps.forEach(_appId => { | |||
@@ -265,7 +266,7 @@ const actions = { | |||
uninstallApp(context, { appId }) { | |||
return api.requireAdmin().then((response) => { | |||
context.commit('startLoading', appId) | |||
return api.get(OC.generateUrl(`settings/apps/uninstall/${appId}`)) | |||
return api.get(generateUrl(`settings/apps/uninstall/${appId}`)) | |||
.then((response) => { | |||
context.commit('stopLoading', appId) | |||
context.commit('uninstallApp', appId) | |||
@@ -282,7 +283,7 @@ const actions = { | |||
return api.requireAdmin().then((response) => { | |||
context.commit('startLoading', appId) | |||
context.commit('startLoading', 'install') | |||
return api.get(OC.generateUrl(`settings/apps/update/${appId}`)) | |||
return api.get(generateUrl(`settings/apps/update/${appId}`)) | |||
.then((response) => { | |||
context.commit('stopLoading', 'install') | |||
context.commit('stopLoading', appId) | |||
@@ -299,7 +300,7 @@ const actions = { | |||
getAllApps(context) { | |||
context.commit('startLoading', 'list') | |||
return api.get(OC.generateUrl(`settings/apps/list`)) | |||
return api.get(generateUrl(`settings/apps/list`)) | |||
.then((response) => { | |||
context.commit('setAllApps', response.data.apps) | |||
context.commit('stopLoading', 'list') | |||
@@ -310,7 +311,7 @@ const actions = { | |||
getCategories(context) { | |||
context.commit('startLoading', 'categories') | |||
return api.get(OC.generateUrl('settings/apps/categories')) | |||
return api.get(generateUrl('settings/apps/categories')) | |||
.then((response) => { | |||
if (response.data.length > 0) { | |||
context.commit('appendCategories', response.data) |
@@ -21,6 +21,7 @@ | |||
*/ | |||
import api from './api' | |||
import { generateOcsUrl } from '@nextcloud/router' | |||
const state = {} | |||
const mutations = {} | |||
@@ -38,7 +39,7 @@ const actions = { | |||
*/ | |||
setAppConfig(context, { app, key, value }) { | |||
return api.requireAdmin().then((response) => { | |||
return api.post(OC.linkToOCS(`apps/provisioning_api/api/v1/config/apps/${app}/${key}`, 2), { value: value }) | |||
return api.post(generateOcsUrl(`apps/provisioning_api/api/v1/config/apps/${app}/${key}`, 2), { value: value }) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { app, key, value, error })) | |||
}, |
@@ -21,6 +21,7 @@ | |||
*/ | |||
import api from './api' | |||
import { generateOcsUrl } from '@nextcloud/router' | |||
const orderGroups = function(groups, orderBy) { | |||
/* const SORT_USERCOUNT = 1; | |||
@@ -205,7 +206,7 @@ const actions = { | |||
search = typeof search === 'string' ? search : '' | |||
group = typeof group === 'string' ? group : '' | |||
if (group !== '') { | |||
return api.get(OC.linkToOCS(`cloud/groups/${encodeURIComponent(encodeURIComponent(group))}/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||
return api.get(generateOcsUrl(`cloud/groups/${encodeURIComponent(encodeURIComponent(group))}/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||
.then((response) => { | |||
if (Object.keys(response.data.ocs.data.users).length > 0) { | |||
context.commit('appendUsers', response.data.ocs.data.users) | |||
@@ -216,7 +217,7 @@ const actions = { | |||
.catch((error) => context.commit('API_FAILURE', error)) | |||
} | |||
return api.get(OC.linkToOCS(`cloud/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||
return api.get(generateOcsUrl(`cloud/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||
.then((response) => { | |||
if (Object.keys(response.data.ocs.data.users).length > 0) { | |||
context.commit('appendUsers', response.data.ocs.data.users) | |||
@@ -230,7 +231,7 @@ const actions = { | |||
getGroups(context, { offset, limit, search }) { | |||
search = typeof search === 'string' ? search : '' | |||
const limitParam = limit === -1 ? '' : `&limit=${limit}` | |||
return api.get(OC.linkToOCS(`cloud/groups?offset=${offset}&search=${search}${limitParam}`, 2)) | |||
return api.get(generateOcsUrl(`cloud/groups?offset=${offset}&search=${search}${limitParam}`, 2)) | |||
.then((response) => { | |||
if (Object.keys(response.data.ocs.data.groups).length > 0) { | |||
response.data.ocs.data.groups.forEach(function(group) { | |||
@@ -254,7 +255,7 @@ const actions = { | |||
*/ | |||
getUsersFromList(context, { offset, limit, search }) { | |||
search = typeof search === 'string' ? search : '' | |||
return api.get(OC.linkToOCS(`cloud/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||
return api.get(generateOcsUrl(`cloud/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||
.then((response) => { | |||
if (Object.keys(response.data.ocs.data.users).length > 0) { | |||
context.commit('appendUsers', response.data.ocs.data.users) | |||
@@ -275,7 +276,7 @@ const actions = { | |||
* @returns {Promise} | |||
*/ | |||
getUsersFromGroup(context, { groupid, offset, limit }) { | |||
return api.get(OC.linkToOCS(`cloud/users/${encodeURIComponent(encodeURIComponent(groupid))}/details?offset=${offset}&limit=${limit}`, 2)) | |||
return api.get(generateOcsUrl(`cloud/users/${encodeURIComponent(encodeURIComponent(groupid))}/details?offset=${offset}&limit=${limit}`, 2)) | |||
.then((response) => context.commit('getUsersFromList', response.data.ocs.data.users)) | |||
.catch((error) => context.commit('API_FAILURE', error)) | |||
}, | |||
@@ -297,7 +298,7 @@ const actions = { | |||
*/ | |||
addGroup(context, gid) { | |||
return api.requireAdmin().then((response) => { | |||
return api.post(OC.linkToOCS(`cloud/groups`, 2), { groupid: gid }) | |||
return api.post(generateOcsUrl(`cloud/groups`, 2), { groupid: gid }) | |||
.then((response) => { | |||
context.commit('addGroup', { gid: gid, displayName: gid }) | |||
return { gid: gid, displayName: gid } | |||
@@ -320,7 +321,7 @@ const actions = { | |||
*/ | |||
removeGroup(context, gid) { | |||
return api.requireAdmin().then((response) => { | |||
return api.delete(OC.linkToOCS(`cloud/groups/${encodeURIComponent(encodeURIComponent(gid))}`, 2)) | |||
return api.delete(generateOcsUrl(`cloud/groups/${encodeURIComponent(encodeURIComponent(gid))}`, 2)) | |||
.then((response) => context.commit('removeGroup', gid)) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { gid, error })) | |||
@@ -337,7 +338,7 @@ const actions = { | |||
*/ | |||
addUserGroup(context, { userid, gid }) { | |||
return api.requireAdmin().then((response) => { | |||
return api.post(OC.linkToOCS(`cloud/users/${userid}/groups`, 2), { groupid: gid }) | |||
return api.post(generateOcsUrl(`cloud/users/${userid}/groups`, 2), { groupid: gid }) | |||
.then((response) => context.commit('addUserGroup', { userid, gid })) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | |||
@@ -354,7 +355,7 @@ const actions = { | |||
*/ | |||
removeUserGroup(context, { userid, gid }) { | |||
return api.requireAdmin().then((response) => { | |||
return api.delete(OC.linkToOCS(`cloud/users/${userid}/groups`, 2), { groupid: gid }) | |||
return api.delete(generateOcsUrl(`cloud/users/${userid}/groups`, 2), { groupid: gid }) | |||
.then((response) => context.commit('removeUserGroup', { userid, gid })) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => { | |||
@@ -376,7 +377,7 @@ const actions = { | |||
*/ | |||
addUserSubAdmin(context, { userid, gid }) { | |||
return api.requireAdmin().then((response) => { | |||
return api.post(OC.linkToOCS(`cloud/users/${userid}/subadmins`, 2), { groupid: gid }) | |||
return api.post(generateOcsUrl(`cloud/users/${userid}/subadmins`, 2), { groupid: gid }) | |||
.then((response) => context.commit('addUserSubAdmin', { userid, gid })) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | |||
@@ -393,7 +394,7 @@ const actions = { | |||
*/ | |||
removeUserSubAdmin(context, { userid, gid }) { | |||
return api.requireAdmin().then((response) => { | |||
return api.delete(OC.linkToOCS(`cloud/users/${userid}/subadmins`, 2), { groupid: gid }) | |||
return api.delete(generateOcsUrl(`cloud/users/${userid}/subadmins`, 2), { groupid: gid }) | |||
.then((response) => context.commit('removeUserSubAdmin', { userid, gid })) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | |||
@@ -408,7 +409,7 @@ const actions = { | |||
*/ | |||
wipeUserDevices(context, userid) { | |||
return api.requireAdmin().then((response) => { | |||
return api.post(OC.linkToOCS(`cloud/users/${userid}/wipe`, 2)) | |||
return api.post(generateOcsUrl(`cloud/users/${userid}/wipe`, 2)) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | |||
}, | |||
@@ -422,7 +423,7 @@ const actions = { | |||
*/ | |||
deleteUser(context, userid) { | |||
return api.requireAdmin().then((response) => { | |||
return api.delete(OC.linkToOCS(`cloud/users/${userid}`, 2)) | |||
return api.delete(generateOcsUrl(`cloud/users/${userid}`, 2)) | |||
.then((response) => context.commit('deleteUser', userid)) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | |||
@@ -444,7 +445,7 @@ const actions = { | |||
*/ | |||
addUser({ commit, dispatch }, { userid, password, displayName, email, groups, subadmin, quota, language }) { | |||
return api.requireAdmin().then((response) => { | |||
return api.post(OC.linkToOCS(`cloud/users`, 2), { userid, password, displayName, email, groups, subadmin, quota, language }) | |||
return api.post(generateOcsUrl(`cloud/users`, 2), { userid, password, displayName, email, groups, subadmin, quota, language }) | |||
.then((response) => dispatch('addUserData', userid || response.data.ocs.data.id)) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => { | |||
@@ -462,7 +463,7 @@ const actions = { | |||
*/ | |||
addUserData(context, userid) { | |||
return api.requireAdmin().then((response) => { | |||
return api.get(OC.linkToOCS(`cloud/users/${userid}`, 2)) | |||
return api.get(generateOcsUrl(`cloud/users/${userid}`, 2)) | |||
.then((response) => context.commit('addUserData', response)) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | |||
@@ -479,7 +480,7 @@ const actions = { | |||
enableDisableUser(context, { userid, enabled = true }) { | |||
const userStatus = enabled ? 'enable' : 'disable' | |||
return api.requireAdmin().then((response) => { | |||
return api.put(OC.linkToOCS(`cloud/users/${userid}/${userStatus}`, 2)) | |||
return api.put(generateOcsUrl(`cloud/users/${userid}/${userStatus}`, 2)) | |||
.then((response) => context.commit('enableDisableUser', { userid, enabled })) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | |||
@@ -506,7 +507,7 @@ const actions = { | |||
) | |||
) { | |||
return api.requireAdmin().then((response) => { | |||
return api.put(OC.linkToOCS(`cloud/users/${userid}`, 2), { key: key, value: value }) | |||
return api.put(generateOcsUrl(`cloud/users/${userid}`, 2), { key: key, value: value }) | |||
.then((response) => context.commit('setUserData', { userid, key, value })) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | |||
@@ -524,7 +525,7 @@ const actions = { | |||
*/ | |||
sendWelcomeMail(context, userid) { | |||
return api.requireAdmin().then((response) => { | |||
return api.post(OC.linkToOCS(`cloud/users/${userid}/welcome`, 2)) | |||
return api.post(generateOcsUrl(`cloud/users/${userid}/welcome`, 2)) | |||
.then(response => true) | |||
.catch((error) => { throw error }) | |||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) |