Skip to content

Commit

Permalink
Merge branch 'PWA' into channel-component
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
#	src/app/app.module.ts
#	src/app/components/login-page/login-page.component.scss
#	src/app/components/login-page/login-page.component.ts
  • Loading branch information
tomermoshe committed May 28, 2017
2 parents 96870eb + 613c84e commit a96f56d
Show file tree
Hide file tree
Showing 15 changed files with 1,111 additions and 91 deletions.
29 changes: 3 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
# RocketchatPwa
# Rocketchat Pwa

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.4.
Rocketchat progressive web app built on Angular and apollo graphql stack .

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
This project was generated with [Angular CLI](https://github.com/angular/angular-cli).
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"
}
}
}
]

}
27 changes: 27 additions & 0 deletions mock-server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as express from 'express';
import * as bodyParser from 'body-parser';
import * as cors from 'cors';
import { graphiqlExpress, graphqlExpress } from 'graphql-server-express';
import { addMockFunctionsToSchema, makeExecutableSchema } from 'graphql-tools';
import Schema from './schema';

const PORT = 3000;

const executableSchema = makeExecutableSchema({
typeDefs: Schema,
logger: { log: (e) => console.log(e) },
});
// Add mocks, modifies schema in place
addMockFunctionsToSchema({ schema: executableSchema });

const app = express();
app.use(cors());
app.use('/graphql', bodyParser.json(), graphqlExpress({
schema : executableSchema,
debug : true,
}));
app.use('/graphiql', graphiqlExpress({
endpointURL : '/graphql',
}));

app.listen(PORT, () => console.log('Mock server running on: ' + PORT));
172 changes: 172 additions & 0 deletions mock-server/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
export default `
type scheme {
query: Query
mutation: Mutation
}
type Mutation {
leaveChannel(channelId: String!): Boolean
hideChannel(channelId: String!): Boolean
setStatus(status: UserStatus!): User
logout: Boolean #JSAccount
createChannel(name: String!, private: Boolean = false, readOnly: Boolean = false, membersId: [String!]): Channel
sendMessage(channelId: String!, messageInput: MessageInput!): Message
deleteMessage(messageId: MessageIdentifier!): Boolean
editMessage(messageId: MessageIdentifier!, messageInput: MessageInput!): Message
addReactionToMassage(messageId: MessageIdentifier!, icon: String!): Message
updateUserSettings(userSettings: UserSettings): User
#updateUserChannelSettings(channelId: String!,settings: ChannelSettings )
}
type Query {
me: User
messages(channelId: String!, paginationId: String, count: Int, SearchRegex: String): [Message]
channelsByUser(userId: String): [Channel]
channels(filter: ChannelFilter = {privacy: ALL, joinedChannels: false, sortBy: NAME}): [Channel]
}
input ChannelFilter {
nameFilter: String
privacy: Privacy
joinedChannels: Boolean
sortBy: ChannelSort
}
enum Privacy {
PRIVATE
PUBLIC
ALL
}
enum ChannelSort {
NAME
NUMBER_OF_MESSAGES
}
type Message {
id: String!
user: User!
content: String!
creationTime: String!
fromServer: Boolean #when user joins a channel we get a message from server - text is grey
tags: [String]
userRef: [User]
channelRef: [Channel]
reactions: [Reaction]
}
input MessageInput {
content: String!
userRef: [String] #userId
channelRef: [String] #channelId
}
input MessageIdentifier {
channelId: String!
messageId: String!
}
type Reaction {
username: String!
icon: String!
}
type User {
username: String!
status: UserStatus
email: String!
avatar: String
name: String
lastLogin: String
userPreferences: UserPreferences!
channels: [Channel]
directMessages: [Channel]
}
enum UserStatus {
ONLINE
AWAY
BUSY
INVISIBLE
}
type UserPreferences {
language: String
notificationDuration: Float
unreadTrayIconAlert: Boolean
useEmojis: Boolean
convertAsciiToEmoji: Boolean
autoLoadImages: Boolean
saveMobileBandwith: Boolean
collapseEmbeddedMeida: Boolean
unreadRoomsMode: Boolean
hideUserName: Boolean
hideRoles: Boolean
hideRightSideBarWithClick: Boolean
hideAvatars: Boolean
mergePrivateGroupsWithChannels: Boolean
enterKeyBehaviour: String
viewMode: String
offlineEmailNotifications: String
highlights: String
newRoomNotificationSound: String
newMessageNotificationSound: String
}
input UserSettings {
language: String
notificationDuration: Float
unreadTrayIconAlert: Boolean
useEmojis: Boolean
convertAsciiToEmoji: Boolean
autoLoadImages: Boolean
saveMobileBandwith: Boolean
collapseEmbeddedMeida: Boolean
unreadRoomsMode: Boolean
hideUserName: Boolean
hideRoles: Boolean
hideRightSideBarWithClick: Boolean
hideAvatars: Boolean
mergePrivateGroupsWithChannels: Boolean
enterKeyBehaviour: String
viewMode: String
offlineEmailNotifications: String
highlights: String
newRoomNotificationSound: String
newMessageNotificationSound: String
email: String
avatar: String
name: String
}
type ChannelSettings {
disableNotification: Boolean
audio: String
desktop: String
duration: Int
mobile: String
mail: String
hideUnreadRoomStatus : Boolean
unreadTrayIconAlert: String
}
type Channel {
id: String!
title: String!
# topic: TODO
# userNotificationSettings: ChannelSettings
description: String!
announcement: String!
numberOfMembers: Int!
members: [User]
owners: [User]
direct: Boolean
private: Boolean
readOnly: Boolean
archived: Boolean
favorite: Boolean
unseenMessages: Int
}
`;
28 changes: 22 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"start": "concurrently \"yarn server\" \"ng serve\" ",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"server": "nodemon --exec ts-node mock-server/index.ts",
"generate:types": "gql-gen --url http://localhost:3000/graphql --template typescript --out src/app/graphql/types/types.ts -- ./src/**/*.graphql "
},
"private": true,
"dependencies": {
Expand All @@ -20,20 +22,33 @@
"@angular/platform-browser": "^4.1.0",
"@angular/platform-browser-dynamic": "^4.1.0",
"@angular/router": "^4.0.0",
"@types/graphql": "^0.9.1",
"apollo-angular": "^0.13.0",
"apollo-client": "^1.3.0",
"core-js": "^2.4.1",
"global": "^4.3.2",
"graphql-tag": "^2.2.0",
"font-awesome": "^4.7.0",
"ionic-angular": "^3.2.1",
"ionicons": "^3.0.0",
"momentjs": "^2.0.0",
"moment": "^2.18.1",
"rxjs": "^5.1.1",
"zone.js": "^0.8.10"
},
"devDependencies": {
"@angular/cli": "1.0.4",
"@angular/cli": "^1.0.6",
"@angular/compiler-cli": "^4.1.0",
"@types/express": "^4.0.35",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"@types/node": "^7.0.22",
"body-parser": "^1.17.2",
"codelyzer": "~2.0.0",
"concurrently": "^3.4.0",
"cors": "^2.8.3",
"express": "^4.15.3",
"graphql": "^0.10.1",
"graphql-server-express": "^0.7.2",
"graphql-tools": "^0.11.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
Expand All @@ -42,8 +57,9 @@
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"nodemon": "^1.11.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"ts-node": "^3.0.4",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { ChannelViewComponent } from './components/channel-view/channel-view.com
import { WelcomePageComponent } from './components/welcome-page/welcome-page.component';
import { ChatMessageComponent } from './components/chat-message/chat-message.component';
import { ChannelItemComponent } from './components/channel-item/channel-item.component';
import { ApolloModule } from 'apollo-angular';
import { getClient } from './graphql/client/apollo-client';
import { GetChatDummyService } from './graphql/get-chat-dummy.service';

@NgModule({
declarations: [
Expand All @@ -29,12 +32,13 @@ import { ChannelItemComponent } from './components/channel-item/channel-item.com
],
imports: [
IonicModule.forRoot(AppComponent, { mode: 'md' }),
ApolloModule.forRoot(getClient),
BrowserModule,
FormsModule,
HttpModule,
AppRouting,
],
providers: [AuthGuard, AuthenticationService],
providers: [AuthGuard, AuthenticationService, GetChatDummyService],
bootstrap: [IonicApp]
})
export class AppModule {
Expand Down
12 changes: 8 additions & 4 deletions src/app/components/login-page/login-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { AuthenticationService } from '../../services/authentication.service';
import { ToastController } from 'ionic-angular';
import { GetChatDummyService } from '../../graphql/get-chat-dummy.service';

@Component({
moduleId: module.id,
Expand All @@ -17,12 +18,15 @@ export class LoginPageComponent implements OnInit {
constructor(private route: ActivatedRoute,
private router: Router,
private authenticationService: AuthenticationService,
private toastCtrl: ToastController) {
private toastCtrl: ToastController,
private chatDummy: GetChatDummyService) {
}

ngOnInit() {
this.authenticationService.logout();
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';

this.chatDummy.queryChat().subscribe((data) => console.log(data));
}

login() {
Expand All @@ -32,8 +36,8 @@ export class LoginPageComponent implements OnInit {
}
else {
const toast = this.toastCtrl.create({
message: 'Invalid username or password',
duration: 5000
message : 'Invalid username or password',
duration : 5000
});
toast.present();
}
Expand Down
Loading

0 comments on commit a96f56d

Please sign in to comment.