Browse Source

Merge branch 'dev' of https://github.com/abpframework/abp into dev

pull/1600/head
Halil İbrahim Kalkan 7 years ago
parent
commit
7a3fc1b18c
  1. 28
      samples/BookStore-Angular-MongoDb/angular/package.json
  2. 21
      samples/BookStore-Angular-MongoDb/angular/src/app/app-routing.module.ts
  3. 4
      samples/BookStore-Angular-MongoDb/angular/src/app/app.component.ts
  4. 2
      samples/BookStore-Angular-MongoDb/angular/src/app/app.module.ts
  5. 13
      samples/BookStore-Angular-MongoDb/angular/src/app/books/books-routing.module.ts
  6. 32
      samples/BookStore-Angular-MongoDb/angular/src/app/books/books.component.html
  7. 26
      samples/BookStore-Angular-MongoDb/angular/src/app/books/books.component.ts
  8. 9
      samples/BookStore-Angular-MongoDb/angular/src/app/books/books.module.ts
  9. 0
      samples/BookStore-Angular-MongoDb/angular/src/app/books/services/books.service.spec.ts
  10. 20
      samples/BookStore-Angular-MongoDb/angular/src/app/books/services/books.service.ts
  11. 5
      samples/BookStore-Angular-MongoDb/angular/src/app/home/home.component.html
  12. 15
      samples/BookStore-Angular-MongoDb/angular/src/app/shared/services/books.service.ts
  13. 10
      samples/BookStore-Angular-MongoDb/angular/src/app/shared/shared.module.ts
  14. 1
      samples/BookStore-Angular-MongoDb/angular/src/app/store/actions/books.actions.ts
  15. 30
      samples/BookStore-Angular-MongoDb/angular/src/app/store/models/books.ts
  16. 28
      samples/BookStore-Angular-MongoDb/angular/src/app/store/states/books.state.ts
  17. 4
      templates/app/angular/package.json
  18. 1
      templates/app/angular/src/app/app-routing.module.ts
  19. 10
      templates/app/angular/src/app/shared/shared.module.ts

28
samples/BookStore-Angular-MongoDb/angular/package.json

@ -1,5 +1,5 @@
{ {
"name": "my-project-name", "name": "BookStore",
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
@ -17,14 +17,14 @@
"@abp/ng.identity": "^0.8.0", "@abp/ng.identity": "^0.8.0",
"@abp/ng.tenant-management": "^0.8.0", "@abp/ng.tenant-management": "^0.8.0",
"@abp/ng.theme.basic": "^0.8.0", "@abp/ng.theme.basic": "^0.8.0",
"@angular/animations": "~8.1.2", "@angular/animations": "~8.2.0",
"@angular/common": "~8.1.2", "@angular/common": "~8.2.0",
"@angular/compiler": "~8.1.2", "@angular/compiler": "~8.2.0",
"@angular/core": "~8.1.2", "@angular/core": "~8.2.0",
"@angular/forms": "~8.1.2", "@angular/forms": "~8.2.0",
"@angular/platform-browser": "~8.1.2", "@angular/platform-browser": "~8.2.0",
"@angular/platform-browser-dynamic": "~8.1.2", "@angular/platform-browser-dynamic": "~8.2.0",
"@angular/router": "~8.1.2", "@angular/router": "~8.2.0",
"@angularclass/hmr": "^2.1.3", "@angularclass/hmr": "^2.1.3",
"@ngxs/devtools-plugin": "^3.5.0", "@ngxs/devtools-plugin": "^3.5.0",
"@ngxs/hmr-plugin": "^3.5.0", "@ngxs/hmr-plugin": "^3.5.0",
@ -33,10 +33,10 @@
"zone.js": "~0.9.1" "zone.js": "~0.9.1"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "~0.801.2", "@angular-devkit/build-angular": "~0.802.0",
"@angular/cli": "~8.1.2", "@angular/cli": "~8.2.0",
"@angular/compiler-cli": "~8.1.2", "@angular/compiler-cli": "~8.2.0",
"@angular/language-service": "~8.1.2", "@angular/language-service": "~8.2.0",
"@types/jasmine": "~3.3.8", "@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4", "@types/node": "~8.9.4",
@ -48,7 +48,7 @@
"karma-coverage-istanbul-reporter": "~2.0.1", "karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1", "karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0", "karma-jasmine-html-reporter": "^1.4.0",
"ngxs-schematic": "^1.1.5", "ngxs-schematic": "^1.1.6",
"protractor": "~5.4.0", "protractor": "~5.4.0",
"ts-node": "~7.0.0", "ts-node": "~7.0.0",
"tslint": "~5.15.0", "tslint": "~5.15.0",

21
samples/BookStore-Angular-MongoDb/angular/src/app/app-routing.module.ts

@ -6,21 +6,15 @@ import { ABP } from '@abp/ng.core';
import { TENANT_MANAGEMENT_ROUTES } from '@abp/ng.tenant-management'; import { TENANT_MANAGEMENT_ROUTES } from '@abp/ng.tenant-management';
const routes: Routes = [ const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ {
path: 'home', path: '',
loadChildren: () => import('./home/home.module').then(m => m.HomeModule), loadChildren: () => import('./home/home.module').then(m => m.HomeModule),
data: { data: {
routes: { routes: {
name: 'Home', name: '::Menu:Home',
} as ABP.Route, } as ABP.Route,
}, },
}, },
{ path: 'books', loadChildren: () => import('./books/books.module').then(m => m.BooksModule), data: {
routes: {
name: 'Books',
} as ABP.Route,
}, },
{ {
path: 'account', path: 'account',
loadChildren: () => import('./lazy-libs/account-wrapper.module').then(m => m.AccountWrapperModule), loadChildren: () => import('./lazy-libs/account-wrapper.module').then(m => m.AccountWrapperModule),
@ -37,8 +31,15 @@ const routes: Routes = [
import('./lazy-libs/tenant-management-wrapper.module').then(m => m.TenantManagementWrapperModule), import('./lazy-libs/tenant-management-wrapper.module').then(m => m.TenantManagementWrapperModule),
data: { routes: TENANT_MANAGEMENT_ROUTES }, data: { routes: TENANT_MANAGEMENT_ROUTES },
}, },
{ path: '**', redirectTo: '/' }, {
path: 'books',
loadChildren: () => import('./books/books.module').then(m => m.BooksModule),
data: {
routes: {
name: 'Books',
} as ABP.Route,
},
},
]; ];
@NgModule({ @NgModule({

4
samples/BookStore-Angular-MongoDb/angular/src/app/app.component.ts

@ -7,6 +7,4 @@ import { Component } from '@angular/core';
<router-outlet></router-outlet> <router-outlet></router-outlet>
`, `,
}) })
export class AppComponent { export class AppComponent {}
title = 'myProjectName';
}

2
samples/BookStore-Angular-MongoDb/angular/src/app/app.module.ts

@ -12,14 +12,12 @@ import { AppComponent } from './app.component';
import { SharedModule } from './shared/shared.module'; import { SharedModule } from './shared/shared.module';
import { ThemeSharedModule } from '@abp/ng.theme.shared'; import { ThemeSharedModule } from '@abp/ng.theme.shared';
import { BooksState } from './store/states/books.state'; import { BooksState } from './store/states/books.state';
import { HttpClientModule } from '@angular/common/http';
@NgModule({ @NgModule({
declarations: [AppComponent], declarations: [AppComponent],
imports: [ imports: [
BrowserModule, BrowserModule,
BrowserAnimationsModule, BrowserAnimationsModule,
HttpClientModule,
AppRoutingModule, AppRoutingModule,
SharedModule, SharedModule,
ThemeSharedModule.forRoot(), ThemeSharedModule.forRoot(),

13
samples/BookStore-Angular-MongoDb/angular/src/app/books/books-routing.module.ts

@ -1,19 +1,14 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
import { BooksComponent } from './books.component';
import { LayoutApplicationComponent } from '@abp/ng.theme.basic'; import { LayoutApplicationComponent } from '@abp/ng.theme.basic';
import { BooksComponent } from './books.component';
const routes: Routes = [ const routes: Routes = [
{ { path: '', component: LayoutApplicationComponent, children: [{ path: '', component: BooksComponent }] },
path: '',
component: LayoutApplicationComponent,
children: [{ path: '', component: BooksComponent }],
},
]; ];
@NgModule({ @NgModule({
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
exports: [RouterModule] exports: [RouterModule],
}) })
export class BooksRoutingModule { } export class BooksRoutingModule {}

32
samples/BookStore-Angular-MongoDb/angular/src/app/books/books.component.html

@ -1 +1,31 @@
<p>books works!</p> <div id="wrapper" class="card">
<div class="card-header">
<div class="row">
<div class="col col-md-6">
<h5 class="card-title">
Books
</h5>
</div>
</div>
</div>
<div class="card-body">
<p-table [value]="books$ | async" [loading]="loading" [paginator]="true" [rows]="10">
<ng-template pTemplate="header">
<tr>
<th>Book name</th>
<th>Book type</th>
<th>Publish date</th>
<th>Price</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-data>
<tr>
<td>{{ data.name }}</td>
<td>{{ bookType[data.type] }}</td>
<td>{{ data.publishDate | date }}</td>
<td>{{ data.price }}</td>
</tr>
</ng-template>
</p-table>
</div>
</div>

26
samples/BookStore-Angular-MongoDb/angular/src/app/books/books.component.ts

@ -1,13 +1,27 @@
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from '@angular/core';
import { Store } from "@ngxs/store"; import { Store, Select } from '@ngxs/store';
import { BooksState } from '../store/states';
import { Observable } from 'rxjs';
import { Books } from '../store/models';
import { BooksGet } from '../store/actions';
@Component({ @Component({
selector: "app-books", selector: 'app-books',
templateUrl: "./books.component.html", templateUrl: './books.component.html',
styleUrls: ["./books.component.scss"] styleUrls: ['./books.component.scss'],
}) })
export class BooksComponent implements OnInit { export class BooksComponent implements OnInit {
@Select(BooksState.getBooks)
books$: Observable<Books.Item[]>;
bookType = Books.Type;
loading = false;
constructor(private store: Store) {} constructor(private store: Store) {}
ngOnInit() {} ngOnInit() {
this.loading = true;
this.store.dispatch(new BooksGet()).subscribe(() => (this.loading = false));
}
} }

9
samples/BookStore-Angular-MongoDb/angular/src/app/books/books.module.ts

@ -5,13 +5,8 @@ import { BooksRoutingModule } from './books-routing.module';
import { BooksComponent } from './books.component'; import { BooksComponent } from './books.component';
import { SharedModule } from '../shared/shared.module'; import { SharedModule } from '../shared/shared.module';
@NgModule({ @NgModule({
declarations: [BooksComponent], declarations: [BooksComponent],
imports: [ imports: [CommonModule, BooksRoutingModule, SharedModule],
CommonModule,
BooksRoutingModule,
SharedModule
]
}) })
export class BooksModule { } export class BooksModule {}

0
samples/BookStore-Angular-MongoDb/angular/src/app/shared/services/books.service.spec.ts → samples/BookStore-Angular-MongoDb/angular/src/app/books/services/books.service.spec.ts

20
samples/BookStore-Angular-MongoDb/angular/src/app/books/services/books.service.ts

@ -0,0 +1,20 @@
import { Injectable } from '@angular/core';
import { RestService, Rest } from '@abp/ng.core';
import { Books } from '../../store/models';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class BooksService {
constructor(private rest: RestService) {}
get(): Observable<Books.Response> {
const request: Rest.Request<null> = {
method: 'GET',
url: '/api/app/book',
};
return this.rest.request<null, Books.Response>(request);
}
}

5
samples/BookStore-Angular-MongoDb/angular/src/app/home/home.component.html

@ -1,9 +1,8 @@
<div class="card"> <div class="card">
<div class="card-header">Welcome</div> <div class="card-header">{{ '::Welcome' | abpLocalization }}</div>
<div class="card-body"> <div class="card-body">
<p> <p>
Welcome to the application. This is a startup project based on the ABP framework. For more information, visit {{ '::LongWelcomeMessage' | abpLocalization }}
abp.io.
</p> </p>
<p *ngIf="!hasLoggedIn"> <p *ngIf="!hasLoggedIn">
<a routerLink="/account/login" [state]="{ redirectUrl: '/home' }" class="btn btn-primary" role="button" <a routerLink="/account/login" [state]="{ redirectUrl: '/home' }" class="btn btn-primary" role="button"

15
samples/BookStore-Angular-MongoDb/angular/src/app/shared/services/books.service.ts

@ -1,15 +0,0 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class BooksService {
constructor(private http: HttpClient) { }
get() {
return this.http.get(`${environment.apis.default.url}/app/book`)
}
}

10
samples/BookStore-Angular-MongoDb/angular/src/app/shared/shared.module.ts

@ -1,12 +1,14 @@
import { NgModule } from '@angular/core';
import { ThemeSharedModule } from '@abp/ng.theme.shared';
import { CoreModule } from '@abp/ng.core'; import { CoreModule } from '@abp/ng.core';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { NgModule } from '@angular/core';
import { ThemeBasicModule } from '@abp/ng.theme.basic'; import { ThemeBasicModule } from '@abp/ng.theme.basic';
import { ThemeSharedModule } from '@abp/ng.theme.shared';
import { TableModule } from 'primeng/table';
@NgModule({ @NgModule({
declarations: [], declarations: [],
imports: [CoreModule, ThemeSharedModule, ThemeBasicModule], imports: [CoreModule, ThemeSharedModule, ThemeBasicModule, TableModule, NgbDropdownModule],
exports: [CoreModule, ThemeSharedModule, ThemeBasicModule], exports: [CoreModule, ThemeSharedModule, ThemeBasicModule, TableModule, NgbDropdownModule],
providers: [], providers: [],
}) })
export class SharedModule {} export class SharedModule {}

1
samples/BookStore-Angular-MongoDb/angular/src/app/store/actions/books.actions.ts

@ -1,4 +1,3 @@
export class BooksGet { export class BooksGet {
static readonly type = '[Books] Get'; static readonly type = '[Books] Get';
constructor(public readonly payload?: any) { }
} }

30
samples/BookStore-Angular-MongoDb/angular/src/app/store/models/books.ts

@ -1,5 +1,33 @@
import { ABP } from '@abp/ng.core';
export namespace Books { export namespace Books {
export interface State { export interface State {
data: any; data: Response;
}
export type Response = ABP.PagedResponse<Item>;
export interface Item {
name: string;
type: Type;
publishDate: string;
price: number;
lastModificationTime: string;
lastModifierId: string;
creationTime: string;
creatorId: string;
id: string;
}
export enum Type {
Undefined,
Adventure,
Biography,
Dystopia,
Fantastic,
Horror,
Science,
ScienceFiction,
Poetry,
} }
} }

28
samples/BookStore-Angular-MongoDb/angular/src/app/store/states/books.state.ts

@ -1,27 +1,29 @@
import { State, Action, StateContext } from "@ngxs/store"; import { State, Action, StateContext, Selector } from '@ngxs/store';
import { BooksGet } from "../actions/books.actions"; import { BooksGet } from '../actions/books.actions';
import { Books } from "../models/books"; import { Books } from '../models/books';
import { BooksService } from "src/app/shared/services/books.service"; import { BooksService } from '../../books/services/books.service';
import { tap } from "rxjs/operators"; import { tap } from 'rxjs/operators';
@State<Books.State>({ @State<Books.State>({
name: "BooksState", name: 'BooksState',
defaults: {} as Books.State defaults: { data: {} } as Books.State,
}) })
export class BooksState { export class BooksState {
@Selector()
static getBooks({ data }: Books.State) {
return data.items || [];
}
constructor(private booksService: BooksService) {} constructor(private booksService: BooksService) {}
@Action(BooksGet) @Action(BooksGet)
booksAction( getBooks({ patchState }: StateContext<Books.State>) {
{ getState, patchState }: StateContext<Books.State>,
{ payload }: BooksGet
) {
return this.booksService.get().pipe( return this.booksService.get().pipe(
tap(data => { tap(data => {
patchState({ patchState({
data data,
}); });
}) }),
); );
} }
} }

4
templates/app/angular/package.json

@ -1,5 +1,5 @@
{ {
"name": "my-project-name", "name": "MyProjectName",
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
@ -48,7 +48,7 @@
"karma-coverage-istanbul-reporter": "~2.0.1", "karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1", "karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0", "karma-jasmine-html-reporter": "^1.4.0",
"ngxs-schematic": "^1.1.5", "ngxs-schematic": "^1.1.6",
"protractor": "~5.4.0", "protractor": "~5.4.0",
"ts-node": "~7.0.0", "ts-node": "~7.0.0",
"tslint": "~5.15.0", "tslint": "~5.15.0",

1
templates/app/angular/src/app/app-routing.module.ts

@ -31,7 +31,6 @@ const routes: Routes = [
import('./lazy-libs/tenant-management-wrapper.module').then(m => m.TenantManagementWrapperModule), import('./lazy-libs/tenant-management-wrapper.module').then(m => m.TenantManagementWrapperModule),
data: { routes: TENANT_MANAGEMENT_ROUTES }, data: { routes: TENANT_MANAGEMENT_ROUTES },
}, },
{ path: '**', redirectTo: '/' },
]; ];
@NgModule({ @NgModule({

10
templates/app/angular/src/app/shared/shared.module.ts

@ -1,12 +1,14 @@
import { NgModule } from '@angular/core';
import { ThemeSharedModule } from '@abp/ng.theme.shared';
import { CoreModule } from '@abp/ng.core'; import { CoreModule } from '@abp/ng.core';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { NgModule } from '@angular/core';
import { ThemeBasicModule } from '@abp/ng.theme.basic'; import { ThemeBasicModule } from '@abp/ng.theme.basic';
import { ThemeSharedModule } from '@abp/ng.theme.shared';
import { TableModule } from 'primeng/table';
@NgModule({ @NgModule({
declarations: [], declarations: [],
imports: [CoreModule, ThemeSharedModule, ThemeBasicModule], imports: [CoreModule, ThemeSharedModule, ThemeBasicModule, TableModule, NgbDropdownModule],
exports: [CoreModule, ThemeSharedModule, ThemeBasicModule], exports: [CoreModule, ThemeSharedModule, ThemeBasicModule, TableModule, NgbDropdownModule],
providers: [], providers: [],
}) })
export class SharedModule {} export class SharedModule {}

Loading…
Cancel
Save