Skip to content

Commit 8b83eda

Browse files
author
sternbach
committed
updated project
1 parent 9314ddd commit 8b83eda

29 files changed

+814
-91
lines changed

.firebaserc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "tasks-162620"
4+
}
5+
}

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: node_js
2+
3+
node_js:
4+
- "7"
5+
6+
branches:
7+
only:
8+
- master
9+
10+
before_script:
11+
- npm install -g firebase-tools
12+
13+
script:
14+
- npm run build
15+
16+
after_success:
17+
- firebase deploy --token $FIREBASE_TOKEN
18+

firebase.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"hosting": {
3+
"public": "dist",
4+
"rewrites": [
5+
{
6+
"source": "**",
7+
"destination": "/index.html"
8+
}
9+
]
10+
}
11+
}

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
"dependencies": {
3030
"angular": "^1.6.3",
3131
"angular-sanitize": "^1.6.3",
32-
"angular-ui-router": "^1.0.0-rc.1",
33-
"ng-tags-input": "^3.0.0"
32+
"angular-ui-router": "^1.0.0-rc.1"
3433
},
3534
"scripts": {
3635
"prestart": "npm install",

src/app.routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IComponentState } from './main';
2-
import { AppComponent } from './app.component';
2+
import { AppComponent } from './components/app.component';
33

44
export const routes: IComponentState[] = [
55
{ state: 'root', url: '/', component: AppComponent }

src/assets/mock.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/assets/ng-tags-input.min.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/auth.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { EventEmitter } from 'eventemitter3';
2+
import { singleton } from './decorators';
3+
4+
export interface IGapiOAuthInitArgs {
5+
/**
6+
* The API Key to use.
7+
*/
8+
apiKey?: string;
9+
/**
10+
* An array of discovery doc URLs or discovery doc JSON objects.
11+
*/
12+
discoveryDocs?: string[];
13+
/**
14+
* The app's client ID, found and created in the Google Developers Console.
15+
*/
16+
clientId?: string;
17+
/**
18+
* The scopes to request, as a space-delimited string.
19+
*/
20+
scope?: string;
21+
}
22+
23+
@singleton
24+
export class OAuth extends EventEmitter {
25+
26+
constructor(private args: IGapiOAuthInitArgs = {}) {
27+
super();
28+
console.log('OAuth instantiated');
29+
// Loads the client library and the auth2 library together for efficiency.
30+
// Loading the auth2 library is optional here since `gapi.client.init` function will load
31+
// it if not already loaded. Loading it upfront can save one network request.
32+
gapi.load('client:auth2', () => this.initClient());
33+
}
34+
35+
isSignedIn(): boolean {
36+
return gapi.auth2.getAuthInstance().isSignedIn.get();
37+
}
38+
39+
signIn() {
40+
gapi.auth2.getAuthInstance().signIn();
41+
}
42+
43+
signOut() {
44+
gapi.auth2.getAuthInstance().signOut();
45+
}
46+
47+
private async initClient() {
48+
// Initialize the client with API key and People API, and initialize OAuth with an
49+
// OAuth 2.0 client ID and scopes (space delimited string) to request access.
50+
try {
51+
await gapi.client.init(this.args);
52+
// Listen for sign-in state changes.
53+
gapi.auth2.getAuthInstance().isSignedIn.listen((val) => {
54+
this.updateSigninStatus(val);
55+
});
56+
// Handle the initial sign-in state.
57+
this.updateSigninStatus(this.isSignedIn());
58+
} catch (e) {
59+
console.error(e);
60+
}
61+
}
62+
63+
private updateSigninStatus(isSignedIn) {
64+
this.emit('gapi.auth2.isSignedIn', isSignedIn);
65+
if (!isSignedIn) {
66+
this.signIn();
67+
}
68+
}
69+
}

src/bootstrap.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as angular from 'angular';
2+
import { NgModuleDecorated } from 'angular-ts-decorators';
3+
import { AppModule } from './main';
4+
5+
angular.element(document).ready(() => {
6+
angular.bootstrap(document, [(<NgModuleDecorated>AppModule).module.name], {strictDi: true});
7+
});

src/components/app.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Component } from 'angular-ts-decorators';
2+
3+
@Component({
4+
selector: 'app',
5+
template: `<task-manager></task-manager>`
6+
})
7+
export class AppComponent {}

0 commit comments

Comments
 (0)