Initial commit
This commit is contained in:
Родитель
5a4da9ed9e
Коммит
d2a252b014
|
@ -0,0 +1,15 @@
|
|||
# http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = false
|
|
@ -1,288 +1,3 @@
|
|||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
**/Properties/launchSettings.json
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Typescript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
/node_modules/
|
||||
/dist/
|
||||
/npm-debug.log
|
||||
|
|
22
README.md
22
README.md
|
@ -1,14 +1,14 @@
|
|||
## angular2-seed
|
||||
|
||||
# Contributing
|
||||
A simple starter project demonstrating the basic concepts of Angular 2.
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
||||
the rights to use your contribution. For details, visit https://cla.microsoft.com.
|
||||
|
||||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
||||
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
||||
provided by the bot. You will only need to do this once across all repos using our CLA.
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
||||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
### Usage
|
||||
- Clone or fork this repository
|
||||
- Make sure you have [node.js](https://nodejs.org/) installed version 5+
|
||||
- Make sure you have NPM installed version 3+
|
||||
- `WINDOWS ONLY` run `npm install -g webpack webpack-dev-server typescript` to install global dependencies
|
||||
- run `npm install` to install dependencies
|
||||
- run `npm start` to fire up dev server
|
||||
- open browser to [`http://localhost:3000`](http://localhost:3000)
|
||||
- if you want to use other port, open `package.json` file, then change port in `--port 3000` script
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
"name": "angular2-seed",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple starter Angular2 project",
|
||||
"scripts": {
|
||||
"build": "rimraf dist && webpack --progress",
|
||||
"watch": "npm run build -- --watch",
|
||||
"server": "webpack-dev-server --inline --progress --port 3000 --content-base src",
|
||||
"start": "npm run server"
|
||||
},
|
||||
"contributors": [
|
||||
"Rob Wormald <robwormald@gmail.com>",
|
||||
"PatrickJS <github@gdi2290.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@angular/common": "~4.0.1",
|
||||
"@angular/compiler": "~4.0.1",
|
||||
"@angular/compiler-cli": "~4.0.1",
|
||||
"@angular/core": "~4.0.1",
|
||||
"@angular/forms": "~4.0.1",
|
||||
"@angular/http": "~4.0.1",
|
||||
"@angular/platform-browser": "~4.0.1",
|
||||
"@angular/platform-browser-dynamic": "~4.0.1",
|
||||
"@angular/platform-server": "~4.0.1",
|
||||
"@angular/router": "~4.0.1",
|
||||
"@angular/upgrade": "~4.0.1",
|
||||
"angular-in-memory-web-api": "^0.3.1",
|
||||
"core-js": "^2.4.1",
|
||||
"ie-shim": "^0.1.0",
|
||||
"reflect-metadata": "^0.1.9",
|
||||
"rxjs": "5.0.1",
|
||||
"zone.js": "^0.8.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/language-service": "~4.4.3",
|
||||
"@types/node": "^7.0.12",
|
||||
"angular2-router-loader": "^0.3.4",
|
||||
"angular2-template-loader": "^0.6.0",
|
||||
"awesome-typescript-loader": "^3.1.2",
|
||||
"css-loader": "^0.26.0",
|
||||
"html-webpack-plugin": "^2.28.0",
|
||||
"raw-loader": "^0.5.1",
|
||||
"rimraf": "^2.5.4",
|
||||
"to-string-loader": "^1.1.4",
|
||||
"typescript": "~2.2.0",
|
||||
"webpack": "^2.4.1",
|
||||
"webpack-dev-server": "2.4.2",
|
||||
"webpack-merge": "^4.1.0"
|
||||
},
|
||||
"keywords": [
|
||||
"Angular2",
|
||||
"angular2-seed",
|
||||
"official angular 2 seed",
|
||||
"official angular2 seed"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/angular/angular2-seed.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/angular/angular2-seed/issues"
|
||||
},
|
||||
"homepage": "https://github.com/angular/angular2-seed#readme"
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
<h3>About Component</h3>
|
||||
<p>This is the about component!</p>
|
|
@ -0,0 +1,9 @@
|
|||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'about',
|
||||
styleUrls: ['./about.component.css'],
|
||||
templateUrl: './about.component.html'
|
||||
})
|
||||
export class AboutComponent {
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<h3>
|
||||
Angular 2 Seed
|
||||
</h3>
|
||||
<nav>
|
||||
<a [routerLink]="['/']" title={{pro1.toLowCase}}>
|
||||
Home
|
||||
</a>
|
||||
|
|
||||
<a [routerLink]="['/about']">
|
||||
About
|
||||
</a>
|
||||
|
|
||||
<a [routerLink]="['/github', 'angular']">
|
||||
Github Repos
|
||||
</a>
|
||||
|
|
||||
<a [routerLink]="['/contact']">
|
||||
Contact Us
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
|
||||
|
||||
<footer>
|
||||
© 2017
|
||||
</footer>
|
|
@ -0,0 +1,20 @@
|
|||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app',
|
||||
template: '<span>{{prop1.tolower}}</spa>',
|
||||
})
|
||||
export class InlineComponent {
|
||||
prop1 = 'hello';
|
||||
prop2 = 'world';
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app',
|
||||
templateUrl: './app.component.ngml',
|
||||
})
|
||||
export class AppComponent {
|
||||
prop1 = 'hello';
|
||||
prop2 = 'world';
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import { NgModule } from '@angular/core'
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { rootRouterConfig } from './app.routes';
|
||||
import { AppComponent } from './app.component';
|
||||
import { GithubService } from './github/shared/github.service';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { HttpModule } from '@angular/http';
|
||||
|
||||
import { AboutComponent } from './about/about.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { RepoBrowserComponent } from './github/repo-browser/repo-browser.component';
|
||||
import { RepoListComponent } from './github/repo-list/repo-list.component';
|
||||
import { RepoDetailComponent } from './github/repo-detail/repo-detail.component';
|
||||
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
|
||||
import { ContactComponent } from './contact/contact.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
AboutComponent,
|
||||
RepoBrowserComponent,
|
||||
RepoListComponent,
|
||||
RepoDetailComponent,
|
||||
HomeComponent,
|
||||
ContactComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
HttpModule,
|
||||
RouterModule.forRoot(rootRouterConfig, { useHash: true })
|
||||
],
|
||||
providers: [
|
||||
GithubService
|
||||
],
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
export class AppModule {
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import { Routes } from '@angular/router';
|
||||
|
||||
import { AboutComponent } from './about/about.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { RepoBrowserComponent } from './github/repo-browser/repo-browser.component';
|
||||
import { RepoListComponent } from './github/repo-list/repo-list.component';
|
||||
import { RepoDetailComponent } from './github/repo-detail/repo-detail.component';
|
||||
import { ContactComponent } from './contact/contact.component';
|
||||
|
||||
export const rootRouterConfig: Routes = [
|
||||
{ path: '', redirectTo: 'home', pathMatch: 'full' },
|
||||
{ path: 'home', component: HomeComponent },
|
||||
{ path: 'about', component: AboutComponent },
|
||||
{ path: 'github', component: RepoBrowserComponent,
|
||||
children: [
|
||||
{ path: '', component: RepoListComponent },
|
||||
{ path: ':org', component: RepoListComponent,
|
||||
children: [
|
||||
{ path: '', component: RepoDetailComponent },
|
||||
{ path: ':repo', component: RepoDetailComponent }
|
||||
]
|
||||
}]
|
||||
},
|
||||
{ path: 'contact', component: ContactComponent }
|
||||
];
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
.form-content {
|
||||
width: 90%;
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.form-content .sd-form-control {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
}
|
||||
.form-content textarea.sd-form-control {
|
||||
max-width: 100%;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<h2>Contact Reactive Form</h2>
|
||||
|
||||
<form (ngSubmit)="submitForm()" [formGroup]="contactForm" novalidate>
|
||||
<div class="form-content">
|
||||
<label>
|
||||
Name:
|
||||
<input type="text" formControlName="name" class="sd-form-control" placeholder="Enter your name.">
|
||||
</label>
|
||||
<label>
|
||||
Email:
|
||||
<input type="email" formControlName="email" class="sd-form-control" placeholder="Enter your email.">
|
||||
</label>
|
||||
<label>
|
||||
Content:
|
||||
<textarea formControlName="content" class="sd-form-control" placeholder="Content here."></textarea>
|
||||
</label>
|
||||
<div class="form-submit">
|
||||
<button type="submit">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="form-value">
|
||||
Form value:
|
||||
<pre>
|
||||
{{contactForm.value | json}}
|
||||
</pre>
|
||||
<p>
|
||||
Status: {{contactForm.status}}
|
||||
</p>
|
||||
<p>
|
||||
Valid: {{contactForm.valid}}
|
||||
</p>
|
||||
<p>Submit then open console to see full form.</p>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import CustomValidators from '../forms/CustomValidators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-contact',
|
||||
templateUrl: './contact.component.html',
|
||||
styleUrls: ['./contact-component.css']
|
||||
})
|
||||
export class ContactComponent implements OnInit {
|
||||
contactForm: FormGroup;
|
||||
constructor(private formBuilder: FormBuilder) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.contactForm = this.formBuilder.group({
|
||||
name: ['', Validators.required],
|
||||
email: ['', [Validators.required, CustomValidators.validateEmail]],
|
||||
content: ['', [Validators.required, Validators.minLength(10)]]
|
||||
});
|
||||
}
|
||||
submitForm(): void {
|
||||
console.log(this.contactForm);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
import {FormControl} from '@angular/forms';
|
||||
|
||||
export default class CustomValidators {
|
||||
/**
|
||||
* sample from http://blog.thoughtram.io/angular/2016/03/14/custom-validators-in-angular-2.html
|
||||
*/
|
||||
static validateEmail(c: FormControl) {
|
||||
let EMAIL_REGEXP = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/;
|
||||
|
||||
return EMAIL_REGEXP.test(c.value) ? null : {
|
||||
validateEmail: {
|
||||
valid: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<h3>GitHub Browser</h3>
|
||||
|
||||
<input type="text" #repoName placeholder="Search Github Orgs">
|
||||
<button (click)="searchForOrg(repoName.value)">Search Orgs</button>
|
||||
|
||||
<router-outlet></router-outlet>
|
|
@ -0,0 +1,23 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { GithubService } from '../shared/github.service';
|
||||
|
||||
@Component({
|
||||
selector: 'repo-browser',
|
||||
templateUrl: './repo-browser.component.html',
|
||||
styleUrls: ['./repo-browser.component.css']
|
||||
})
|
||||
export class RepoBrowserComponent {
|
||||
|
||||
constructor(private router: Router, private github: GithubService) {
|
||||
}
|
||||
|
||||
searchForOrg(orgName: string) {
|
||||
this.github.getOrg(orgName)
|
||||
.subscribe(({name}) => {
|
||||
console.log(name);
|
||||
this.router.navigate(['/github', orgName]);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<h2>{{ repoDetails.full_name }}</h2>
|
||||
|
||||
<pre>this.repoDetails = {{ repoDetails | json }}</pre>
|
|
@ -0,0 +1,31 @@
|
|||
import {Component, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {GithubService} from '../shared/github.service';
|
||||
|
||||
@Component({
|
||||
selector: 'repo-detail',
|
||||
styleUrls: ['./repo-detail.component.css'],
|
||||
templateUrl: './repo-detail.component.html'
|
||||
})
|
||||
export class RepoDetailComponent implements OnInit {
|
||||
private org:string;
|
||||
private repo:string;
|
||||
public repoDetails:any = {};
|
||||
|
||||
constructor(public github:GithubService, private route:ActivatedRoute) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe(params => {
|
||||
this.org = this.route.snapshot.parent.params['org'];
|
||||
this.repo = params['repo'] || '';
|
||||
|
||||
if (this.repo) {
|
||||
this.github.getRepoForOrg(this.org, this.repo)
|
||||
.subscribe(repoDetails => {
|
||||
this.repoDetails = repoDetails;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<h3>Repo list</h3>
|
||||
<ul>
|
||||
<li *ngFor="let repo of repos | async">
|
||||
<a [routerLink]="['/github', repo.owner.login, repo.name]">
|
||||
{{ repo.name }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<router-outlet></router-outlet>
|
|
@ -0,0 +1,26 @@
|
|||
import {Component, OnInit} from '@angular/core';
|
||||
import {GithubService} from '../shared/github.service';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'repo-list',
|
||||
styleUrls: ['./repo-list.component.css'],
|
||||
templateUrl: './repo-list.component.html',
|
||||
})
|
||||
export class RepoListComponent implements OnInit {
|
||||
org: string;
|
||||
repos: Observable<any>;
|
||||
|
||||
constructor(public github: GithubService, private route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe(params => {
|
||||
this.org = params['org'];
|
||||
if (this.org) {
|
||||
this.repos = this.github.getReposForOrg(this.org);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Http, URLSearchParams } from '@angular/http';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
@Injectable()
|
||||
export class GithubService {
|
||||
constructor(private http: Http) {}
|
||||
|
||||
getOrg(org: string) {
|
||||
return this.makeRequest(`orgs/${org}`);
|
||||
}
|
||||
|
||||
getReposForOrg(org: string) {
|
||||
return this.makeRequest(`orgs/${org}/repos`);
|
||||
}
|
||||
|
||||
getRepoForOrg(org: string, repo: string) {
|
||||
return this.makeRequest(`repos/${org}/${repo}`);
|
||||
}
|
||||
|
||||
private makeRequest(path: string) {
|
||||
let params = new URLSearchParams();
|
||||
params.set('per_page', '100');
|
||||
|
||||
let url = `https://api.github.com/${ path }`;
|
||||
return this.http.get(url, {search: params})
|
||||
.map((res) => res.json());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
<h3>Home Component</h3>
|
||||
<p>Welcome to Angular Seed</p>
|
|
@ -0,0 +1,9 @@
|
|||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'home',
|
||||
styleUrls: ['./home.component.css'],
|
||||
templateUrl: './home.component.html'
|
||||
})
|
||||
export class HomeComponent {
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Custom Type Definitions
|
||||
* When including 3rd party modules you also need to include the type definition for the module
|
||||
* if they don't provide one within the module. You can try to install it with typings
|
||||
|
||||
typings install node --save
|
||||
|
||||
* If you can't find the type definition in the registry we can make an ambient definition in
|
||||
* this file for now. For example
|
||||
|
||||
declare module "my-module" {
|
||||
export function doesSomething(value: string): string;
|
||||
}
|
||||
|
||||
*
|
||||
* If you're prototying and you will fix the types later you can also declare it as type any
|
||||
*
|
||||
|
||||
declare var assert: any;
|
||||
|
||||
*
|
||||
* If you're importing a module that uses Node.js modules which are CommonJS you need to import as
|
||||
*
|
||||
|
||||
import * as _ from 'lodash'
|
||||
|
||||
* You can include your type definitions in this file until you create one for the typings registry
|
||||
* see https://github.com/typings/registry
|
||||
*
|
||||
*/
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 5.3 KiB |
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=UTF-8>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Angular2 Seed</title>
|
||||
<base href="/">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<app>
|
||||
Loading...
|
||||
</app>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,22 @@
|
|||
import './polyfills.browser';
|
||||
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { AppModule } from './app/app.module';
|
||||
|
||||
export const platformRef = platformBrowserDynamic();
|
||||
|
||||
export function main() {
|
||||
return platformRef.bootstrapModule(AppModule)
|
||||
.catch(err => console.error(err));
|
||||
}
|
||||
|
||||
// support async tag or hmr
|
||||
switch (document.readyState) {
|
||||
case 'interactive':
|
||||
case 'complete':
|
||||
main();
|
||||
break;
|
||||
case 'loading':
|
||||
default:
|
||||
document.addEventListener('DOMContentLoaded', () => main());
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// Polyfills
|
||||
|
||||
import 'ie-shim'; // Internet Explorer 9 support
|
||||
|
||||
// import 'core-js/es6';
|
||||
// Added parts of es6 which are necessary for your project or your browser support requirements.
|
||||
import 'core-js/es6/symbol';
|
||||
import 'core-js/es6/object';
|
||||
import 'core-js/es6/function';
|
||||
import 'core-js/es6/parse-int';
|
||||
import 'core-js/es6/parse-float';
|
||||
import 'core-js/es6/number';
|
||||
import 'core-js/es6/math';
|
||||
import 'core-js/es6/string';
|
||||
import 'core-js/es6/date';
|
||||
import 'core-js/es6/array';
|
||||
import 'core-js/es6/regexp';
|
||||
import 'core-js/es6/map';
|
||||
import 'core-js/es6/set';
|
||||
import 'core-js/es6/weak-map';
|
||||
import 'core-js/es6/weak-set';
|
||||
import 'core-js/es6/typed';
|
||||
import 'core-js/es6/reflect';
|
||||
// see issue https://github.com/AngularClass/angular2-webpack-starter/issues/709
|
||||
// import 'core-js/es6/promise';
|
||||
|
||||
import 'core-js/es7/reflect';
|
||||
import 'zone.js/dist/zone';
|
||||
import 'zone.js/dist/long-stack-trace-zone';
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"sourceMap": true,
|
||||
"sourceRoot": "src",
|
||||
"noEmitHelpers": true,
|
||||
"target": "es5",
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"lib": ["es6", "dom"]
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*.module.ts",
|
||||
"./src/*.d.ts"
|
||||
],
|
||||
"angularCompilerOptions": {
|
||||
"debug": false
|
||||
},
|
||||
"compileOnSave": false,
|
||||
"buildOnSave": false,
|
||||
"atom": { "rewriteTsconfig": false }
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"plugins": [
|
||||
{ "name": "@angular/language-service" }
|
||||
],
|
||||
"lib": ["es6", "dom"]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],
|
||||
"awesomeTypescriptLoaderOptions": {
|
||||
"useWebpackText": true
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"debug": false
|
||||
},
|
||||
"compileOnSave": false,
|
||||
"buildOnSave": false,
|
||||
"atom": { "rewriteTsconfig": false }
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
var webpack = require('webpack');
|
||||
var path = require('path');
|
||||
var webpackMerge = require('webpack-merge');
|
||||
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
// Webpack Config
|
||||
var webpackConfig = {
|
||||
entry: {
|
||||
'main': './src/main.browser.ts',
|
||||
},
|
||||
|
||||
output: {
|
||||
publicPath: '',
|
||||
path: path.resolve(__dirname, './dist'),
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new webpack.ContextReplacementPlugin(
|
||||
// The (\\|\/) piece accounts for path separators in *nix and Windows
|
||||
/angular(\\|\/)core(\\|\/)@angular/,
|
||||
path.resolve(__dirname, '../src'),
|
||||
{
|
||||
// your Angular Async Route paths relative to this root directory
|
||||
}
|
||||
),
|
||||
|
||||
new HtmlWebpackPlugin({
|
||||
template: 'src/index.html'
|
||||
}),
|
||||
|
||||
],
|
||||
|
||||
module: {
|
||||
loaders: [
|
||||
// .ts files for TypeScript
|
||||
{
|
||||
test: /\.ts$/,
|
||||
loaders: [
|
||||
'awesome-typescript-loader',
|
||||
'angular2-template-loader',
|
||||
'angular2-router-loader'
|
||||
]
|
||||
},
|
||||
{ test: /\.css$/, loaders: ['to-string-loader', 'css-loader'] },
|
||||
{ test: /\.html$/, loader: 'raw-loader' }
|
||||
]
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Our Webpack Defaults
|
||||
var defaultConfig = {
|
||||
devtool: 'source-map',
|
||||
|
||||
output: {
|
||||
filename: '[name].bundle.js',
|
||||
sourceMapFilename: '[name].map',
|
||||
chunkFilename: '[id].chunk.js'
|
||||
},
|
||||
|
||||
resolve: {
|
||||
extensions: [ '.ts', '.js' ],
|
||||
modules: [ path.resolve(__dirname, 'node_modules') ]
|
||||
},
|
||||
|
||||
devServer: {
|
||||
historyApiFallback: true,
|
||||
watchOptions: { aggregateTimeout: 300, poll: 1000 },
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
||||
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
|
||||
}
|
||||
},
|
||||
|
||||
node: {
|
||||
global: true,
|
||||
crypto: 'empty',
|
||||
__dirname: true,
|
||||
__filename: true,
|
||||
process: true,
|
||||
Buffer: false,
|
||||
clearImmediate: false,
|
||||
setImmediate: false
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports = webpackMerge(defaultConfig, webpackConfig);
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче