Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/js/services/projectsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,13 @@ angular.module('Teem')

if (newStatus) {
need.completionDate = (new Date()).toJSON();
trelloSvc.archiveCard(this.trello,need).
then(data => need.closed = true)
.catch(err => console.log(err));
} else {
trelloSvc.unarchiveCard(this.trello,need).
then(data => {need.closed = false;})
.catch(err => console.log(err));
delete need.completionDate;
}
}
Expand All @@ -376,6 +382,10 @@ angular.module('Teem')
var i = this.needs.indexOf(need);

this.needs.splice(i, 1);

trelloSvc.archiveNeed(this.trello,need).
then(data => need.removed = true)
.catch(err => console.log(err));
}

addNeedComment(need, comment) {
Expand Down
12 changes: 11 additions & 1 deletion src/js/services/trelloService.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
return deferred.promise;
}

function archiveCard(trelloObj, need){
let deferred = $q.defer();
const archiveCardURL = `https://api.trello.com/1/cards/${need.trelloId}?closed="true"&key=09e4aced60041e389dbb27b9accadd65&token=${trelloObj.token}`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key should go to the configuration file, and now be changed probably. Please let me know the new key so I can add it to the secrets file to be used by travis.

$http.put(archiveCardURL).
then(result => deferred.resolve(result.data))
.catch(err => deferred.reject(result.data));
return deferred.promise;
}

function registerWebhook(trelloObj){
const webhookURL = `https://api.trello.com/1/webhooks/?idModel=${trelloObj.boardId}&key=09e4aced60041e389dbb27b9accadd65&token=${trelloObj.token}&callbackURL=http://13.126.145.126:9000/`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, key to config file.

$http.post(webhookURL)
Expand All @@ -82,7 +91,8 @@
createTrelloBoard: createTrelloBoard,
createNewList: createNewList,
addNewCard: addNewCard,
registerWebhook: registerWebhook
registerWebhook: registerWebhook,
archiveCard: archiveCard
};
}
})();