Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RocketChat PWA with Angular, Service Worker, Apollo and GraphQL #25

Closed
wants to merge 178 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
566dc74
initial commit
May 27, 2017
352a43a
add mock server
eitanfr May 28, 2017
4b7e987
initial commit
May 28, 2017
b392901
make image a bit smaller
eitanfr May 28, 2017
c2786c6
apollo client config
eitanfr May 28, 2017
13e9b1b
add cors and example
eitanfr May 28, 2017
64a8125
add cors and example
eitanfr May 28, 2017
4b17271
add cors and example
eitanfr May 28, 2017
c8738e7
graphql plugin
eitanfr May 28, 2017
5b6e750
added chat-message component
May 28, 2017
f7f58c0
Merge pull request #2 from tomermoshe/chat-message
tomermoshe May 28, 2017
bbcf4a7
added basic manifest
May 28, 2017
99d1062
Merge branch 'PWA' into feat/mock-server
eitanfr May 28, 2017
04dd630
add generator and types
eitanfr May 28, 2017
96870eb
channel-component
May 28, 2017
5e28769
Merge pull request #1 from tomermoshe/feat/mock-server
tomermoshe May 28, 2017
613c84e
Merge pull request #3 from tomermoshe/feat/graphql-code-generator
tomermoshe May 28, 2017
a96f56d
Merge branch 'PWA' into channel-component
May 28, 2017
89e7f32
Merge pull request #4 from tomermoshe/channel-component
tomermoshe May 28, 2017
3a83488
reorder modules
eitanfr May 28, 2017
77a6c3a
fix sidenav responsiveness
eitanfr May 28, 2017
a44c282
add image and change path
eitanfr May 28, 2017
c0ff745
welcome page and dirs changes
eitanfr May 28, 2017
6716e1c
Merge branch 'PWA' into feat/chat-container
eitanfr May 28, 2017
125496f
rename
eitanfr May 28, 2017
c52c1b0
Merge rename
eitanfr May 28, 2017
de96a55
more Merge rename
eitanfr May 28, 2017
933ad82
more Merge rename and more
eitanfr May 28, 2017
ee3005d
more Merge rename and more and more
eitanfr May 28, 2017
c372b1c
more Merge rename and more and more
eitanfr May 28, 2017
a0a8fbf
login validations
eitanfr May 28, 2017
c81ae77
temp
eitanfr May 29, 2017
214b3bc
pr fixes
eitanfr May 29, 2017
daa3ea1
Merge pull request #5 from tomermoshe/feat/chat-container
tomermoshe May 29, 2017
3107255
Merge branch 'PWA' into feat/refactor-chat-header
eitanfr May 29, 2017
b87186b
refactor to service and fixes
eitanfr May 29, 2017
1633093
rm comment
eitanfr May 29, 2017
926e818
add angular cli SW
eitanfr May 29, 2017
8b459aa
add pwa manifest icons and headers + no script message
eitanfr May 29, 2017
16e1afe
add dev server for dist-> view by mobile
eitanfr May 29, 2017
1695ed1
Merge pull request #7 from tomermoshe/feat/initial-service-worker
tomermoshe May 30, 2017
541bc22
Merge remote-tracking branch 'origin/PWA' into PWA
eitanfr May 30, 2017
f1c7b84
fix manifest
eitanfr May 30, 2017
1798c54
Merge branch 'PWA' into feat/pwa-index-and-icons
eitanfr May 30, 2017
0e2ebd1
image change
eitanfr May 30, 2017
aa64483
side menu styling for big screen
Jun 1, 2017
d4e244c
Merge pull request #8 from tomermoshe/feat/pwa-index-and-icons
tomermoshe Jun 1, 2017
0e6c172
workbox
eitanfr Jun 1, 2017
ac89bda
after pr
eitanfr Jun 1, 2017
5a98377
after pr
eitanfr Jun 1, 2017
67f7cc9
Merge pull request #6 from tomermoshe/feat/refactor-chat-header
tomermoshe Jun 1, 2017
9e1e550
ngSW configuration for static,routes,dynamic
eitanfr Jun 1, 2017
1616853
stated adding subscription
Jun 1, 2017
7e0aa17
change max age to a month
eitanfr Jun 1, 2017
8e95c89
fixing asyncIterator not recognized by typescript
Jun 1, 2017
1d42b0b
remove spaces
eitanfr Jun 1, 2017
eb36538
Merge branch 'PWA' into feat/pwa-precache
eitanfr Jun 1, 2017
ea5b0ab
small fix
eitanfr Jun 1, 2017
02f9e86
change to http-server
eitanfr Jun 1, 2017
ec97b19
fix scripts
eitanfr Jun 1, 2017
5314392
Merge pull request #9 from tomermoshe/feat/pwa-precache
tomermoshe Jun 4, 2017
cc867ca
Merge branch 'PWA' of /Users/eitanfrailich/programing/rocketchat/Rock…
eitanfr Jun 4, 2017
a9c3037
Merge remote-tracking branch 'origin/PWA' into PWA
eitanfr Jun 4, 2017
594a524
change routing to be the same as rocket chat
eitanfr Jun 4, 2017
ae27ae6
consider opened keyboard
eitanfr Jun 4, 2017
0b3018b
to new routes
eitanfr Jun 4, 2017
5121130
go back to lite-server , http-server keeps a cache and its very annoying
eitanfr Jun 4, 2017
ff60d77
change to ion icons
eitanfr Jun 4, 2017
f372a2c
initial commit
eitanfr Jun 4, 2017
4772219
fix icon
eitanfr Jun 4, 2017
018e59f
Merge branch 'feat/remove-font-awesome' into feat/side-nav-skeleton
eitanfr Jun 4, 2017
f6eda0a
add queries
eitanfr Jun 4, 2017
0a2041d
add graphql data to sidenav
eitanfr Jun 4, 2017
ef898b1
for text overflow add "..."
eitanfr Jun 4, 2017
38fd977
working side nav and channel item
eitanfr Jun 4, 2017
5653995
asyncIterator missing typings issue workaround
Jun 4, 2017
c9268aa
Merge pull request #11 from tomermoshe/bug/login-layout
tomermoshe Jun 4, 2017
9059a0f
Merge pull request #12 from tomermoshe/feat/remove-font-awesome
tomermoshe Jun 4, 2017
ee8b291
Merge pull request #10 from tomermoshe/feat/change-routing
tomermoshe Jun 4, 2017
3198890
Merge branch 'PWA' into chat-pagination
Jun 4, 2017
854635e
moved some files into graphql directories
Jun 4, 2017
1d6c220
Merge branch 'PWA' into feat/side-nav-skeleton
eitanfr Jun 5, 2017
85a337a
Merge pull request #13 from tomermoshe/feat/side-nav-skeleton
tomermoshe Jun 6, 2017
23fba66
add push notification service
eitanfr Jun 6, 2017
ba12bbb
should use ng-template
eitanfr Jun 6, 2017
1fddd7a
Merge remote-tracking branch 'origin/PWA' into PWA
eitanfr Jun 6, 2017
aada2b1
pagination and subscription works
Jun 7, 2017
7c6fb8a
Merge branch 'PWA' into chat-pagination
Jun 7, 2017
13edefc
finished merge
Jun 7, 2017
e15a933
changed graphql files into ts files
Jun 8, 2017
62aed6b
fixed naming
Jun 8, 2017
90c26b6
fix for frai
Jun 8, 2017
a680eea
fix for frai
Jun 8, 2017
bb95a75
added @types/graphql again
Jun 8, 2017
94668e2
fixed garphql typings
Jun 8, 2017
f2e97ac
spacing
Jun 8, 2017
cd43aae
moved server typings
Jun 8, 2017
d670fe8
spacing
Jun 8, 2017
75793b4
fixed optimistic response in chat view
Jun 8, 2017
f2d0ad3
fixed send message scroll down
Jun 8, 2017
a1866dc
added todo for jsaccounts
Jun 8, 2017
a931e3a
fixes from PR
Jun 8, 2017
c8183be
fixed scrolling and pagination
Jun 9, 2017
6fd5696
fixed channel name on top bar change on channel select
Jun 9, 2017
ba6a05c
added channelbyname query
Jun 9, 2017
c95573a
removed comments
Jun 9, 2017
38b8116
added me mock
Jun 9, 2017
fcf12f6
minor fix
Jun 9, 2017
45cd0d0
fixes from PR
Jun 11, 2017
cd29354
fixed chat resize
Jun 11, 2017
2c1b06c
add server accounts
eitanfr Jun 11, 2017
47ee082
Merge pull request #15 from tomermoshe/chat-pagination
eitanfr Jun 12, 2017
4773d3a
client working with accounts
eitanfr Jun 12, 2017
15bc2cb
fixed side-nav size - like in rocketchat
Jun 12, 2017
1a5bc49
add login spinner
eitanfr Jun 12, 2017
a252890
small fix
eitanfr Jun 12, 2017
6ed34a0
Merge branch 'PWA' of /Users/eitanfrailich/programing/rocketchat/Rock…
eitanfr Jun 12, 2017
f4aae3d
Merge remote-tracking branch 'origin/PWA' into PWA
eitanfr Jun 12, 2017
bbb30ee
merge
eitanfr Jun 12, 2017
6ff78e4
unused import
eitanfr Jun 12, 2017
3ad79a5
after pr
eitanfr Jun 13, 2017
7513b73
Merge pull request #16 from tomermoshe/feat/jsAccounts
tomermoshe Jun 13, 2017
34e81cc
offline package
eitanfr Jun 13, 2017
1241d50
Merge pull request #17 from tomermoshe/feat/offline-msg
tomermoshe Jun 13, 2017
6eb824a
spinner appear at the top of the messages
eitanfr Jun 13, 2017
5915a23
set loading to false if mutation didn't succeeded
eitanfr Jun 13, 2017
2575b3c
add user
eitanfr Jun 13, 2017
eb2e57e
removed empty line
Jun 13, 2017
b74db18
Merge branch 'PWA' into oauth
Jun 13, 2017
9d242a1
update readme
eitanfr Jun 13, 2017
858adec
oauth half way there :)
Jun 14, 2017
786fa7e
fix sidenav scroll
eitanfr Jun 14, 2017
352ddd7
change the display to standalone
eitanfr Jun 14, 2017
a1d6795
close sidenav when channel is clicked
eitanfr Jun 14, 2017
43159db
started working
Jun 14, 2017
99fdb0d
refactored code on server
Jun 15, 2017
30bca3f
minor change
Jun 15, 2017
c3ee554
refactored OAuth
Jun 15, 2017
db1fd16
changed accountsserver back to singleton - much easier to work with -…
Jun 15, 2017
e71bf9c
fixed authorization bug in client
Jun 15, 2017
9528582
removed unused dep
Jun 15, 2017
d4d4b8b
nowrap for msg content
eitanfr Jun 15, 2017
1a40de8
add jsaccounts authentication
Jun 15, 2017
52d81a1
virtual scroll
eitanfr Jun 15, 2017
0dd28e4
Merge pull request #18 from tomermoshe/bug/some-fixes
tomermoshe Jun 15, 2017
56cf649
Merge branch 'PWA' into oauth
Jun 15, 2017
75177ea
added find user by oauth id in db to oauth-service
Jun 15, 2017
2a1dec9
replaced console.log with console.error
Jun 15, 2017
d984359
added console.error to login page
Jun 15, 2017
2679520
added oauth id to user profile
Jun 19, 2017
b2e4e86
minor fix
Jun 19, 2017
e06d28a
fixed otimistic ui date
Jun 19, 2017
908520c
working with local virtual scroll
eitanfr Jun 19, 2017
d676a4c
add spinner
eitanfr Jun 19, 2017
2f628c7
fixed multiple apollo mutation result callbacks running
Jun 19, 2017
f0baa15
add my virtual scroll
eitanfr Jun 19, 2017
d781b37
fix
eitanfr Jun 19, 2017
e4669fb
fix
eitanfr Jun 19, 2017
5ecb636
Merge pull request #19 from tomermoshe/oauth
tomermoshe Jun 20, 2017
e86ba52
Merge branch 'PWA' into feat/virtual-scroll
eitanfr Jun 20, 2017
416a572
fix .do()
eitanfr Jun 20, 2017
ab59e78
Merge pull request #20 from tomermoshe/feat/virtual-scroll
tomermoshe Jun 21, 2017
97c805d
very very very massive penis
Jun 21, 2017
4ff9f93
added fetch policy
Jun 21, 2017
62746b6
fetchPolicy fix (check if loading)
Jun 21, 2017
a83234f
improved channel-not-found component
Jun 21, 2017
7113e5e
minor fix
Jun 22, 2017
83a6fe2
fixed bugs
Jun 22, 2017
92946c8
PR fixes
Jun 22, 2017
3e0fcc9
Merge pull request #21 from tomermoshe/offline
eitanfr Jun 22, 2017
0e29a1d
some ui improvements
Jun 22, 2017
9640f2a
Merge pull request #22 from tomermoshe/ui-fixes
tomermoshe Jun 22, 2017
2e54e92
added alt to images
Jun 22, 2017
f750583
use new virtual scroll
eitanfr Jun 22, 2017
1d16910
Merge pull request #23 from tomermoshe/bug/scroll-down
eitanfr Jun 22, 2017
9479c6b
Merge pull request #24 from tomermoshe/lighthouse
tomermoshe Jun 24, 2017
e802c64
added code-gen to package.json
Jun 25, 2017
85cdbcc
fixed offline issue
Jul 9, 2017
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
22 changes: 15 additions & 7 deletions .angular-cli.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "rocket-chat"
"name": "rocketchat-pwa"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
"favicon.ico",
"manifest.json"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"prefix": "",
"serviceWorker": true,
"styles": [
"styles.css"
"theme/variables.scss",
"styles.scss",
"assets/offline/offline-language-english.css",
"assets/offline/offline-theme-dark.css"
],
"scripts": [
"assets/offline/offline.min.js"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
Expand Down Expand Up @@ -51,7 +58,8 @@
}
},
"defaults": {
"styleExt": "css",
"component": {}
"styleExt": "scss",
"component": {
}
}
}
44 changes: 15 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
# Rocket.Chat PWA
## Progressive Web App GSoC Project
Web FTW! 🙂 **PWA** is a web app that make use of new Web and JavaScript API to deliver a new whole experience similar to an native app on the web.
# Rocketchat Pwa

To achieve this experience this app needs to meet some requirements:
Rocketchat progressive web app built on Angular and apollo graphql stack using angular CLI.

* **Safety** - must be served via HTTPS to ensure that the real content has not been tampered.
* **Responsive** - can fit all resolutions like desktop, tablet and mobile.
* **Progressive**- work in all modern browsers because they use progressive enhancement concepts.
* **Connectivity independent** - need to work on any type of connection, including offline.
* **Engageable** - using push notifications, “add to home” feature to be more app-like.
* mock server requires mongo for the accounts
* mock users to login with:
* username: eitan pass: eitan
* username: tomer pass: tomer
* run client & mock server:
```bash
yarn start
```

You can find more specific requirements at Google Documentation
* build production ready PWA with service worker support:
```bash
yarn build
```

To build this app we will use a specific framework - Angular and tools like WebSocket and Service Worker

## Communication

For help in preparing your winning proposal, you can email me at [karl.prieb@rocket.chat](mailto:karl.prieb@rocket.chat) or DM me at the [demo server](https://demo.rocket.chat/direct/karl.prieb).

After (if) your proposal is selected, the communication between mentor and students should be daily.
For public conversations Github issues must be used and for more private subjects you can use Rocket.Chat direct messages on [demo server](https://demo.rocket.chat/direct/karl.prieb).

## Milestones

To start the project we created a few milestones:
* **Project Architecture** - All architect decision for our future app.
* **Realtime API Implementation** - Implementation of the Rocket.Chat Realtime API with WebSocket
* **Basic features** - Some basic as user registration and login system, channels and users lists, working channels with messages.

Others milestones will be created with the student when we start to work on the project.

**NOTE**: Please check back frequently. We will keep this document updated all the time.
* additional scripts in `package.json`
3 changes: 3 additions & 0 deletions bs-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"port": 4200
}
8 changes: 4 additions & 4 deletions e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { RocketChatPage } from './app.po';
import { RocketchatPwaPage } from './app.po';

describe('rocket-chat App', () => {
let page: RocketChatPage;
describe('rocketchat-pwa App', () => {
let page: RocketchatPwaPage;

beforeEach(() => {
page = new RocketChatPage();
page = new RocketchatPwaPage();
});

it('should display message saying app works', () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/app.po.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { browser, by, element } from 'protractor';

export class RocketChatPage {
export class RocketchatPwaPage {
navigateTo() {
return browser.get('/');
}
Expand Down
36 changes: 36 additions & 0 deletions graphql.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{

"README_schema" : "Specifies how to load the GraphQL schema that completion, error highlighting, and documentation is based on in the IDE",
"schema": {

"README_file" : "Remove 'file' to use request url below. A relative or absolute path to the JSON from a schema introspection query, e.g. '{ data: ... }'. Changes to the file are watched.",
"README_request" : "To request the schema from a url instead, remove the 'file' JSON property above (and optionally delete the default graphql.schema.json file).",
"request": {
"url" : "http://localhost:3000/graphql",
"method" : "POST",
"README_postIntrospectionQuery" : "Whether to POST an introspectionQuery to the url. If the url always returns the schema JSON, set to false and consider using GET",
"postIntrospectionQuery" : true,
"README_options" : "See the 'Options' section at https://github.com/then/then-request",
"options" : {
"headers": {
"user-agent" : "JS GraphQL"
}
}
}

},

"README_endpoints": "A list of GraphQL endpoints that can be queried from '.graphql' files in the IDE",
"endpoints" : [
{
"name": "Default (http://localhost:3000/graphql)",
"url": "http://localhost:3000/graphql",
"options" : {
"headers": {
"user-agent" : "JS GraphQL"
}
}
}
]

}
52 changes: 52 additions & 0 deletions mock-server/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import AccountsServer from '@accounts/server';
import MongoAdapter from '@accounts/mongo';
import * as faker from 'faker';
import { getMongoClient } from './db';


const initUsers = () => {
const users = [{ username: 'eitan', password: 'eitan' }, {
username: 'Eitan',
password: 'Eitan'
}, { username: 'tomer', password: 'tomer' }];

users.map(async (userData) => {
const { username, password } = userData;
const user = await AccountsServer.findUserByUsername(username);
if (!user) {
AccountsServer.createUser({
username,
password,
profile: {
avatar: faker.image.avatar(),
name: username + ' ' + username,
}
});
}
});
};

export const initAccounts = async () => {
let mongoAdapter = null;
try {
mongoAdapter = await getMongoClient().then(db => new MongoAdapter(db));
}
catch (e) {
console.error('Failed connecting to the mongoDb ', e);
return;
}
AccountsServer.config({
tokenConfigs: {
accessToken: {
expiresIn: '3d',
},
refreshToken: {
expiresIn: '30d',
},
}
}, mongoAdapter);

initUsers();

return AccountsServer;
};
24 changes: 24 additions & 0 deletions mock-server/db.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { MongoClient } from 'mongodb';

let mongoDB;

const MONGO_URL = 'mongodb://localhost:27017/rocketchatMock';

const initMongoClient = async () => {
try {
mongoDB = await MongoClient.connect(MONGO_URL);
}
catch (e) {
console.error('cannot connect to db', e);
}
return mongoDB;
};


export const getMongoClient = async () => {
if (!mongoDB) {
await initMongoClient();
}
return mongoDB;
};

83 changes: 83 additions & 0 deletions mock-server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import 'babel-polyfill';
import * as express from 'express';
import * as session from 'express-session';
import * as Grant from 'grant-express';
import * as bodyParser from 'body-parser';
import * as cors from 'cors';
import { graphiqlExpress, graphqlExpress } from 'graphql-server-express';
import { createSchemeWithAccounts } from './schema';
import { JSAccountsContext } from '@accounts/graphql-api';
import { SubscriptionServer } from 'subscriptions-transport-ws';
import { execute, subscribe } from 'graphql';
import { createServer } from 'http';
import { initAccounts } from './accounts';
import { initializeOAuthResolver } from './oauth/oauth-service';
import { GRANT_PATH, grantConfig } from './oauth/grant-config';
import AccountsServer from '@accounts/server';

const PORT = 3000;
const WS_GQL_PATH = '/subscriptions';
const STATIC_SERVER = 'http://localhost:4200';

async function main() {
const app = express();
app.use(cors());

await initAccounts();

app.use(session({
secret: 'grant',
resave: true,
saveUninitialized: true,
}));

app.use(bodyParser.urlencoded({ extended: true }));

const grant = new Grant(grantConfig);

app.use(GRANT_PATH, grant);

app.get(`${GRANT_PATH}/handle_facebook_callback`, function (req, res) {
const accessToken = req.query.access_token;
res.redirect(`${STATIC_SERVER}/login?service=facebook&access_token=${accessToken}`);
});

app.get(`${GRANT_PATH}/handle_google_callback`, function (req, res) {
const accessToken = req.query.access_token;
res.redirect(`${STATIC_SERVER}/login?service=google&access_token=${accessToken}`);
});

initializeOAuthResolver();

const schema = createSchemeWithAccounts(AccountsServer);

app.use('/graphql', bodyParser.json(), graphqlExpress(request => ({
schema,
context: JSAccountsContext(request),
debug: true,
})));

app.use('/graphiql', graphiqlExpress({
endpointURL: '/graphql',
}));

const server = createServer(app);

new SubscriptionServer(
{
schema,
execute,
subscribe,
},
{
path: WS_GQL_PATH,
server,
}
);

server.listen(PORT, () => {
console.log('Mock server running on: ' + PORT);
});
}

main().catch((e) => console.error('Failed to start mock server', e));
Loading