Use @nextcloud/router

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-03-03 20:19:34 +01:00
parent 841fa0d4dd
commit cc4e544eef
4 changed files with 11 additions and 7 deletions

View File

@@ -21,6 +21,7 @@
*/ */
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import './../models' import './../models'
/** /**
@@ -30,7 +31,7 @@ export class BoardApi {
url(url) { url(url) {
url = `/apps/deck${url}` url = `/apps/deck${url}`
return OC.generateUrl(url) return generateUrl(url)
} }
/** /**

View File

@@ -21,12 +21,13 @@
*/ */
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
export class CardApi { export class CardApi {
url(url) { url(url) {
url = `/apps/deck${url}` url = `/apps/deck${url}`
return OC.generateUrl(url) return generateUrl(url)
} }
addCard(card) { addCard(card) {

View File

@@ -21,6 +21,7 @@
*/ */
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import xmlToTagList from '../helpers/xml' import xmlToTagList from '../helpers/xml'
export class CommentApi { export class CommentApi {
@@ -31,7 +32,7 @@ export class CommentApi {
} }
async loadComments({ cardId, limit, offset }) { async loadComments({ cardId, limit, offset }) {
const api = await axios.get(OC.generateUrl(`/apps/deck/api/v1.0/boards/0/stacks/0/cards/${cardId}/comments`), { const api = await axios.get(generateUrl(`/apps/deck/api/v1.0/boards/0/stacks/0/cards/${cardId}/comments`), {
headers: { 'OCS-APIRequest': 'true' }, headers: { 'OCS-APIRequest': 'true' },
}) })
return api.data return api.data
@@ -61,7 +62,7 @@ export class CommentApi {
} }
async createComment({ cardId, comment, replyTo }) { async createComment({ cardId, comment, replyTo }) {
const api = await axios.post(OC.generateUrl(`/apps/deck/api/v1.0/boards/0/stacks/0/cards/${cardId}/comments`), { const api = await axios.post(generateUrl(`/apps/deck/api/v1.0/boards/0/stacks/0/cards/${cardId}/comments`), {
message: `${comment}`, message: `${comment}`,
parentId: replyTo ? replyTo.id : null, parentId: replyTo ? replyTo.id : null,
}) })
@@ -69,14 +70,14 @@ export class CommentApi {
} }
async updateComment({ cardId, commentId, comment }) { async updateComment({ cardId, commentId, comment }) {
const api = await axios.put(OC.generateUrl(`/apps/deck/api/v1.0/boards/0/stacks/0/cards/${cardId}/comments/${commentId}`), { const api = await axios.put(generateUrl(`/apps/deck/api/v1.0/boards/0/stacks/0/cards/${cardId}/comments/${commentId}`), {
message: `${comment}`, message: `${comment}`,
}) })
return api.data return api.data
} }
async deleteComment({ cardId, commentId }) { async deleteComment({ cardId, commentId }) {
const api = await axios.delete(OC.generateUrl(`/apps/deck/api/v1.0/boards/0/stacks/0/cards/${cardId}/comments/${commentId}`)) const api = await axios.delete(generateUrl(`/apps/deck/api/v1.0/boards/0/stacks/0/cards/${cardId}/comments/${commentId}`))
return api.data return api.data
} }

View File

@@ -21,13 +21,14 @@
*/ */
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import './../models' import './../models'
export class StackApi { export class StackApi {
url(url) { url(url) {
url = `/apps/deck${url}` url = `/apps/deck${url}`
return OC.generateUrl(url) return generateUrl(url)
} }
loadStacks(boardId) { loadStacks(boardId) {