From ccf66905e721afcb97c044ad67db883eb5ffa5d7 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Thu, 5 Jul 2018 14:19:24 +0200 Subject: Dockerfile: use set -o xtrace This allows to see the progress of the generation of the Docker image. --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 76517c07..21cb72ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -136,6 +136,7 @@ ENV BUILD_DEPS="apt-utils bsdtar gnupg gosu wget curl bzip2 build-essential pyth COPY ${SRC_PATH} /home/wekan/app RUN \ + set -o xtrace && \ # Add non-root user wekan useradd --user-group --system --home-dir /home/wekan wekan && \ \ -- cgit v1.2.3-1-g7c22 From 24f66c9f8873e56dcd3a0a176b3fcbbdc6e5fae7 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 23 Oct 2018 18:00:56 +0200 Subject: fix cards export 6eeb708e4d2eb82f (Fix cards export and add customFields export.) is incomplete as it allows to export newer cards inserted in the db after the linkedId has been set, but not older cards present in an earlier version of wekan. Allow both null and empty value to be retrieved to match all cards. related #1873 --- models/export.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/export.js b/models/export.js index 0911a631..62d2687a 100644 --- a/models/export.js +++ b/models/export.js @@ -48,7 +48,7 @@ class Exporter { build() { const byBoard = { boardId: this._boardId }; - const byBoardNoLinked = { boardId: this._boardId, linkedId: '' }; + const byBoardNoLinked = { boardId: this._boardId, linkedId: {$in: ['', null] } }; // we do not want to retrieve boardId in related elements const noBoardId = { fields: { -- cgit v1.2.3-1-g7c22 From 9aa5584c9c7a5bf7d9755dd266a0b0035f57ebf0 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 26 Jun 2018 11:10:16 +0200 Subject: models: make the REST API more uniform All of the other REST API are in the form 'modelId' but a few ones in boards.js and users.js. Change it for a more uniform API. --- models/boards.js | 12 ++++++------ models/users.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/models/boards.js b/models/boards.js index 52d0ca87..a44de8fa 100644 --- a/models/boards.js +++ b/models/boards.js @@ -823,9 +823,9 @@ if (Meteor.isServer) { } }); - JsonRoutes.add('GET', '/api/boards/:id', function (req, res) { + JsonRoutes.add('GET', '/api/boards/:boardId', function (req, res) { try { - const id = req.params.id; + const id = req.params.boardId; Authentication.checkBoardAccess(req.userId, id); JsonRoutes.sendResult(res, { @@ -878,10 +878,10 @@ if (Meteor.isServer) { } }); - JsonRoutes.add('DELETE', '/api/boards/:id', function (req, res) { + JsonRoutes.add('DELETE', '/api/boards/:boardId', function (req, res) { try { Authentication.checkUserId(req.userId); - const id = req.params.id; + const id = req.params.boardId; Boards.remove({ _id: id }); JsonRoutes.sendResult(res, { code: 200, @@ -898,9 +898,9 @@ if (Meteor.isServer) { } }); - JsonRoutes.add('PUT', '/api/boards/:id/labels', function (req, res) { + JsonRoutes.add('PUT', '/api/boards/:boardId/labels', function (req, res) { Authentication.checkUserId(req.userId); - const id = req.params.id; + const id = req.params.boardId; try { if (req.body.hasOwnProperty('label')) { const board = Boards.findOne({ _id: id }); diff --git a/models/users.js b/models/users.js index 4f2184e4..630f4703 100644 --- a/models/users.js +++ b/models/users.js @@ -713,10 +713,10 @@ if (Meteor.isServer) { } }); - JsonRoutes.add('GET', '/api/users/:id', function (req, res) { + JsonRoutes.add('GET', '/api/users/:userId', function (req, res) { try { Authentication.checkUserId(req.userId); - const id = req.params.id; + const id = req.params.userId; JsonRoutes.sendResult(res, { code: 200, data: Meteor.users.findOne({ _id: id }), @@ -730,10 +730,10 @@ if (Meteor.isServer) { } }); - JsonRoutes.add('PUT', '/api/users/:id', function (req, res) { + JsonRoutes.add('PUT', '/api/users/:userId', function (req, res) { try { Authentication.checkUserId(req.userId); - const id = req.params.id; + const id = req.params.userId; const action = req.body.action; let data = Meteor.users.findOne({ _id: id }); if (data !== undefined) { @@ -872,10 +872,10 @@ if (Meteor.isServer) { } }); - JsonRoutes.add('DELETE', '/api/users/:id', function (req, res) { + JsonRoutes.add('DELETE', '/api/users/:userId', function (req, res) { try { Authentication.checkUserId(req.userId); - const id = req.params.id; + const id = req.params.userId; Meteor.users.remove({ _id: id }); JsonRoutes.sendResult(res, { code: 200, -- cgit v1.2.3-1-g7c22 From 53c8e63a09b513a37d308d2301b2925e239dabfe Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Mon, 2 Jul 2018 18:34:46 +0200 Subject: models: customFields: fix GET api Calling GET on /api/board/XXXX/customfields returns a 500 error: TypeError: Converting circular structure to JSON --- models/customFields.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models/customFields.js b/models/customFields.js index 38481d8c..203e46d0 100644 --- a/models/customFields.js +++ b/models/customFields.js @@ -87,7 +87,13 @@ if (Meteor.isServer) { const paramBoardId = req.params.boardId; JsonRoutes.sendResult(res, { code: 200, - data: CustomFields.find({ boardId: paramBoardId }), + data: CustomFields.find({ boardId: paramBoardId }).map(function (cf) { + return { + _id: cf._id, + name: cf.name, + type: cf.type, + }; + }), }); }); -- cgit v1.2.3-1-g7c22 From 33d4ad76caefede0680a7868b9772f9917fd4d90 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 26 Jun 2018 11:11:55 +0200 Subject: models: cards: add members PUT entry point Allows to change the members from the API --- models/cards.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/models/cards.js b/models/cards.js index 25692c25..e7649657 100644 --- a/models/cards.js +++ b/models/cards.js @@ -1514,6 +1514,11 @@ if (Meteor.isServer) { Cards.direct.update({_id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false}, {$set: {customFields: newcustomFields}}); } + if (req.body.hasOwnProperty('members')) { + const newmembers = req.body.members; + Cards.direct.update({_id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false}, + {$set: {members: newmembers}}); + } JsonRoutes.sendResult(res, { code: 200, data: { -- cgit v1.2.3-1-g7c22 From f61942e5cb672d3e0fd4df6c5ff9b3f15f7cb778 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 26 Jun 2018 11:55:11 +0200 Subject: models: boards: add PUT members entry point Allows to change the members from the API. --- models/boards.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/models/boards.js b/models/boards.js index a44de8fa..cae6cf9f 100644 --- a/models/boards.js +++ b/models/boards.js @@ -276,6 +276,10 @@ Boards.helpers({ return Users.find({ _id: { $in: _.pluck(this.members, 'userId') } }); }, + getMember(id) { + return _.findWhere(this.members, { userId: id }); + }, + getLabel(name, color) { return _.findWhere(this.labels, { name, color }); }, @@ -841,6 +845,34 @@ if (Meteor.isServer) { } }); + JsonRoutes.add('PUT', '/api/boards/:boardId/members', function (req, res) { + Authentication.checkUserId(req.userId); + try { + const boardId = req.params.boardId; + const board = Boards.findOne({ _id: boardId }); + const userId = req.body.userId; + const user = Users.findOne({ _id: userId }); + + if (!board.getMember(userId)) { + user.addInvite(boardId); + board.addMember(userId); + JsonRoutes.sendResult(res, { + code: 200, + data: id, + }); + } else { + JsonRoutes.sendResult(res, { + code: 200, + }); + } + } + catch (error) { + JsonRoutes.sendResult(res, { + data: error, + }); + } + }); + JsonRoutes.add('POST', '/api/boards', function (req, res) { try { Authentication.checkUserId(req.userId); -- cgit v1.2.3-1-g7c22 From dfdba25ea0b9c3bcca81a9c8ba6a3e9ed7f4eec7 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Thu, 26 Jul 2018 08:45:44 +0200 Subject: api: add the ability to change the Swimlane of a card --- models/cards.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/models/cards.js b/models/cards.js index e7649657..9bb67f41 100644 --- a/models/cards.js +++ b/models/cards.js @@ -1519,6 +1519,11 @@ if (Meteor.isServer) { Cards.direct.update({_id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false}, {$set: {members: newmembers}}); } + if (req.body.hasOwnProperty('swimlaneId')) { + const newParamSwimlaneId = req.body.swimlaneId; + Cards.direct.update({_id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false}, + {$set: {swimlaneId: newParamSwimlaneId}}); + } JsonRoutes.sendResult(res, { code: 200, data: { -- cgit v1.2.3-1-g7c22