Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 1ed2745

Browse files
committed
Initial commit
0 parents  commit 1ed2745

27 files changed

+2011
-0
lines changed

.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "wwwroot/lib"
3+
}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
typings
3+
wwwroot/lib
4+
wwwroot/tsd.d.ts
5+
wwwroot/app/*.js
6+
wwwroot/app/*.map
7+
wwwroot/app/*/*.js
8+
wwwroot/app/*/*.js.map

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug in Chrome",
6+
"type": "chrome",
7+
"request": "launch",
8+
"url": "http://localhost:8080/index.html",
9+
"sourceMaps": true,
10+
"webRoot": "${workspaceRoot}"
11+
}
12+
]
13+
}

.vscode/settings.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"editor.insertSpaces": true,
3+
"files.trimTrailingWhitespace": true,
4+
"files.exclude": {
5+
".git": true,
6+
"obj": true,
7+
"bin": true,
8+
".vs": true,
9+
"*.sln": true,
10+
"*.csproj": true,
11+
"*.csproj.user": true,
12+
"Web.config": true,
13+
"web.Debug.config": true,
14+
"web.Release.config": true,
15+
"typings": true,
16+
"node_modules": true,
17+
"**/*.js.map": true,
18+
"**/*.js": {"when": "$(basename).ts"}
19+
},
20+
"search.exclude": {
21+
".git": true,
22+
"typings": true,
23+
"node_modules": true,
24+
"bin": true
25+
}
26+
}

.vscode/tasks.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": "0.1.0",
3+
"command": "gulp",
4+
"isShellCommand": true,
5+
"tasks": [
6+
{
7+
"taskName": "build",
8+
"isBuildCommand": true,
9+
"problemMatcher": [
10+
"$tsc"
11+
]
12+
},
13+
{
14+
"taskName": "watch",
15+
"isWatching": true,
16+
"problemMatcher": [
17+
"$tsc"
18+
]
19+
}
20+
]
21+
}

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Office
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

ReadMe.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# O365-Angular-Typescript-Microsoft-Graph-Snippets
2+
3+
This is a TypeScript port of the Microsoft Graph snippets with Angular sample from the OfficeDev developer center on GitHub: https://github.com/microsoftgraph/angular-snippets-rest-sample
4+
5+
** Note **: You will need to register the sample with an Azure AD tenant which has an Office 365 subscription. All of the instructions for obtaining test Azure and O365 subscriptions also apply to this sample.
6+
7+
## Building the Sample
8+
9+
After cloning the repository, run *npm install* from the root of the repository to restore Node dev-dependency packages.
10+
11+
Run "bower install to restore client side JavaScript packages.
12+
13+
Run *TSD install* to restore TypeScript definition files.
14+
15+
## Running the Sample
16+
17+
Open a command prompt at the root of the repository and run *gulp watch*. This launches the browser-sync static web server on port 8080 and watches for any changes to the TypeScript files.
18+
19+
![gulp watch output](./server-console.png)
20+
21+
You can change the server port in the gulpfile, but make make sure to use your port for Azure AD registration instructions below.
22+
23+
## Registering the Sample with Azure AD
24+
25+
Follow instructions from the [Microsoft Graph snippets with Angular](https://github.com/microsoftgraph/angular-snippets-rest-sample) sample to register the app with Azure AD and setup permissions for the Microsoft Graph. Update the client ID in the *settings.ts* file in the *wwwroot/app* directory.
26+
27+
## Debugging in Chrome from VSCode
28+
29+
This sample is configured for debugging in Chrome with [VSCode](https://code.visualstudio.com/). You will need to install the [Debugger for Chrome extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome).
30+
31+
### You must launch Chrome with remote debugging enabled in order for the extension to attach to it.
32+
33+
+ Windows
34+
35+
Right click the Chrome shortcut, and select properties
36+
In the "target" field, append --remote-debugging-port=9222
37+
Or in a command prompt, execute <path to chrome>/chrome.exe --remote-debugging-port=9222
38+
39+
+ OS X
40+
41+
In a terminal, execute /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
42+
43+
+ Linux
44+
45+
In a terminal, launch google-chrome --remote-debugging-port=9222
46+
47+
To start debugging with Chrome, select the debug icon in the main menu on the left, then press the play button (green right triangle) with "Debug in Chrome" selected:
48+
49+
![vscode debug view](./vscode-debug.png)
50+
51+
You should see output from console log messages in the Debug Console of VSCode, indicating that various Angular modules have been registered.
52+
53+
It is normal to see some error and warning messages from Chrome in the Debug Console. However, if you receive any connection refused messages, make sure close all running instances of Chrome before trying to start debugging.
54+
55+
This sample uses JavaScript Sourcemaps, so you should be able to set breakpoints and do source line debugging in the TypeScript source.
56+

bower.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "ASP.NET",
3+
"private": true,
4+
"dependencies": {
5+
"angular": "1.4.6",
6+
"angular-route": "1.4.6",
7+
"adal-angular": "1.0.8",
8+
"ladda-angular": "1.0.1",
9+
"angular-local-storage": "0.2.3"
10+
}
11+
}

gulpfile.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/// <reference path="wwwroot/tsd.d.ts" />
2+
3+
var gulp = require('gulp');
4+
var del = require('del');
5+
var tsb = require('gulp-tsb');
6+
var browserSync = require('browser-sync').create();
7+
var typescript = require('typescript');
8+
var ts = require('gulp-typescript');
9+
var sourcemaps = require('gulp-sourcemaps');
10+
11+
// TypeScript build using gulp-tsb
12+
var tsb = tsb.create({
13+
target: 'es5',
14+
module: 'commonjs',
15+
sourceMap: true,
16+
declaration: false
17+
},true);
18+
19+
gulp.task('tsb-build', function () {
20+
return gulp.src('wwwroot/**/*.ts')
21+
.pipe(tsb())
22+
.pipe(gulp.dest('wwwroot'));
23+
});
24+
25+
// Typescript build using gulp-typescript
26+
var projectConfig = {
27+
target: 'ES5',
28+
typescript: typescript
29+
30+
};
31+
// var tsProject = ts.createProject('tsconfig.json');
32+
gulp.task('build', function () {
33+
return gulp.src('wwwroot/**/*.ts', { base: 'wwwroot' })
34+
.pipe(sourcemaps.init())
35+
.pipe(ts(projectConfig))
36+
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: '/wwwroot' }))
37+
.pipe(gulp.dest('wwwroot'));
38+
});
39+
40+
gulp.task('clean', function (cb) {
41+
del('wwwroot/app/**/*.js');
42+
del('wwwroot/app/**/*.map');
43+
});
44+
45+
gulp.task('reload', ['build'], function () {
46+
browserSync.reload();
47+
});
48+
49+
gulp.task('serve', ['build'], function (done) {
50+
browserSync.init({
51+
// don't require online connectivity
52+
online: false,
53+
// don't open a browser
54+
open: false,
55+
port: 8080,
56+
server: {
57+
baseDir: ['wwwroot']
58+
}
59+
}, done);
60+
});
61+
62+
gulp.task('watch', ['serve'], function (cb) {
63+
gulp.watch('wwwroot/**/*.ts', ['build', 'reload']);
64+
});

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "1.0.0",
3+
"name": "angulartypescriptgraphsnippets",
4+
"private": true,
5+
"devDependencies": {
6+
"browser-sync": "^2.11.1",
7+
"del": "^2.2.0",
8+
"gulp": "^3.9.1",
9+
"gulp-bower": "0.0.13",
10+
"gulp-sourcemaps": "^1.6.0",
11+
"gulp-tsb": "^1.10.1",
12+
"gulp-typescript": "^2.11.0",
13+
"tsd": "^0.6.5",
14+
"typescript": "^1.7.5"
15+
}
16+
}

0 commit comments

Comments
 (0)