first step

Signed-off-by: Jakob <jakob.roehrl@web.de>

1. try

Signed-off-by: Jakob <jakob.roehrl@web.de>

remote calls are working

Signed-off-by: Jakob <jakob.roehrl@web.de>

litte changes

Signed-off-by: Jakob <jakob.roehrl@web.de>

small fixes

Signed-off-by: Jakob <jakob.roehrl@web.de>

incremental fetching

Signed-off-by: Jakob <jakob.roehrl@web.de>

integrated tiptap suggestions for test

Signed-off-by: Jakob <jakob.roehrl@web.de>

Update package-lock after rebase

Signed-off-by: Julius Härtl <jus@bitgrid.net>

Fix various errors

Signed-off-by: Julius Härtl <jus@bitgrid.net>

Cleanup mention plugin use

Signed-off-by: Julius Härtl <jus@bitgrid.net>

Downgrade tippy

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Jakob
2019-09-10 12:31:25 +02:00
committed by Julius Härtl
parent 3adadc23d0
commit 739a92e9a3
9 changed files with 1094 additions and 71 deletions

126
src/services/CommentApi.js Normal file
View File

@@ -0,0 +1,126 @@
/*
* @copyright Copyright (c) 2018 Michael Weimann <mail@michael-weimann.eu>
*
* @author Michael Weimann <mail@michael-weimann.eu>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import axios from 'nextcloud-axios'
import { getCurrentUser } from '@nextcloud/auth'
export class CommentApi {
url(url) {
url = `dav/comments/deckCard/${url}`
return OC.linkToRemote(url)
}
listComments(card) {
return axios({
method: 'REPORT',
url: this.url(`${card.id}`),
data: `<?xml version="1.0" encoding="utf-8" ?>
<oc:filter-comments xmlns:D="DAV:" xmlns:oc="http://owncloud.org/ns">
<oc:limit>${card.limit}</oc:limit>
<oc:offset>${card.offset}</oc:offset>
</oc:filter-comments>`
}).then(
(response) => {
return Promise.resolve(response.data)
},
(err) => {
return Promise.reject(err)
}
)
.catch((err) => {
return Promise.reject(err)
})
}
createComment(commentObj) {
return axios({
method: 'POST',
url: this.url(`${commentObj.cardId}`),
data: { actorType: 'users', message: `${commentObj.comment}`, verb: 'comment' }
}).then(
(response) => {
let header = response.headers['content-location']
let headerArray = header.split('/')
let id = headerArray[headerArray.length - 1]
let ret = {
cardId: (commentObj.cardId).toString(),
id: id,
uId: getCurrentUser().uid,
creationDateTime: (new Date()).toString(),
message: commentObj.comment
}
return Promise.resolve(ret)
},
(err) => {
return Promise.reject(err)
}
)
.catch((err) => {
return Promise.reject(err)
})
}
updateComment(data) {
return axios({
method: 'PROPPATCH',
url: this.url(`${data.cardId}/${data.commentId}`),
data: `<?xml version="1.0"?>
<d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:set>
<d:prop>
<oc:message>${data.comment}</oc:message>
</d:prop>
</d:set>
</d:propertyupdate>`
}).then(
(response) => {
return Promise.resolve(response.data)
},
(err) => {
return Promise.reject(err)
}
)
.catch((err) => {
return Promise.reject(err)
})
}
deleteComment(data) {
return axios({
method: 'DELETE',
url: this.url(`${data.cardId}/${data.commentId}`)
}).then(
(response) => {
return Promise.resolve(response.data)
},
(err) => {
return Promise.reject(err)
}
)
.catch((err) => {
return Promise.reject(err)
})
}
}