Skip to content

Commit

Permalink
feat(board-page): Board collaborators
Browse files Browse the repository at this point in the history
Share your board with your team with the collaborators module
  • Loading branch information
andreasonny83 committed May 19, 2017
1 parent 171c2ed commit 320e5a8
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 19 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Andrea SonnY

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Online Board

[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

## Note

If you are updating from a version <= 0.1.0, you must reinstall all the
Expand Down Expand Up @@ -84,3 +86,24 @@ $ firebase login
$ firebase use default
$ firebase deploy
```

## Contributing

This package is using the AngularJS commit messages as default way to contribute
with [Commitizen node package](https://github.com/commitizen/cz-cli/blob/master/README.md)
integrated in this repository.

1. Fork it!
1. Create your feature branch: `git checkout -b my-new-feature`
1. Add your changes: `git add .`
1. Commit your changes: `npm run commit`
1. Push to the branch: `git push origin my-new-feature`
1. Submit a pull request :sunglasses:

## Changelog

Changelog available [here](https://github.com/andreasonny83/online-board/releases)

## License

[MIT License](https://github.com/andreasonny83/online-board/blob/master/LICENSE) © Andrea SonnY
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "online-board",
"version": "0.3.0",
"description": "Create and share interactive boards online",
"version": "0.4.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "webpack-dev-server --port=4200",
"commit": "git-cz",
"build": "webpack",
"predeploy": "npm run build",
"deploy": "firebase deploy",
Expand Down Expand Up @@ -46,8 +48,10 @@
"@types/node": "7.0.18",
"autoprefixer": "7.0.1",
"codelyzer": "3.0.1",
"commitizen": "2.9.6",
"css-loader": "0.28.1",
"cssnano": "3.10.0",
"cz-conventional-changelog": "2.0.0",
"exports-loader": "0.6.4",
"file-loader": "0.11.1",
"firebase-tools": "3.7.0",
Expand Down Expand Up @@ -79,5 +83,10 @@
"url-loader": "0.5.8",
"webpack": "2.5.1",
"webpack-dev-server": "2.4.5"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
12 changes: 7 additions & 5 deletions src/app/board-page/board-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export class BoardPageComponent implements OnInit {
this.boardID = params['id'];
return this.fireBase.getBoardObject(this.boardID);
})
.subscribe(res => {
.subscribe((res: IBoardObj) => {
this.board = this.fireBase.getBoard(this.boardID);
this.columns = this.fireBase.getBoard(`${this.boardID}/columns`);
});

this.fireBase.getBoardObject(this.boardID)
.subscribe(res => {
this.boardName = res['name'];
.subscribe((res: IBoardObj) => {
this.boardName = res.name;
});
}

Expand Down Expand Up @@ -135,12 +135,14 @@ export class BoardPageComponent implements OnInit {
.subscribe(
res => {
if (!!res.sent && /^250 OK/.test(res.sent)) {
self.collaboratorsForm.reset();
this.fireBase.inviteCollaborator(
self.fireBase.inviteCollaborator(
self.collaboratorsForm.controls.collaborator.value,
self.boardID,
self.boardName,
);

self.collaboratorsForm.reset();

self.snackBar.open('Your message has been correctly delivered.', null, { duration: 6000 });
} else {
self.errorHandler();
Expand Down
20 changes: 16 additions & 4 deletions src/firebase/firebase.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,19 @@ export class FirebaseService {
.subscribe(invites => {
invites.forEach((invite) => {
const boardElement = {};
const boardMember = {};
boardElement[invite.boardID] = invite.boardName;
boardMember[self.uid] = true;

self.getBoard(invite.boardID)
.update('members', boardMember);

self.userList
.update('boards', boardElement)
.update(`boards`, boardElement)
.then(() => {
self.db.list('/invites').remove(invite.$key);
self.snackBar.open(
`Wow! Looks like someone invited you to collaborate with a new board.
self.snackBar.open(`
Wow! Looks like someone invited you to collaborate with a new board.
Check out your dashboard.`,
null, { duration: 6000 });
});
Expand Down Expand Up @@ -151,7 +156,7 @@ export class FirebaseService {
return this.db.list(`/boards/${boardUID}`);
}

getBoardObject(boardUID: string): FirebaseObjectObservable<any[]> {
getBoardObject(boardUID: string): FirebaseObjectObservable<any> {
return this.db.object(`/boards/${boardUID}`);
}

Expand Down Expand Up @@ -199,6 +204,13 @@ export class FirebaseService {
}

inviteCollaborator(email: string, boardID: string, boardName: string) {
if (!email || !boardID || !boardName) {
return this.snackBar
.open(`
Ops! Something went wrong while trying to send the invitation. Please try again.`,
null, { duration: 6000 });
}

this.getBoard(`${boardID}/invites`)
.push({'email': email});

Expand Down
Loading

0 comments on commit 320e5a8

Please sign in to comment.