mirror of https://github.com/abpframework/abp.git
41 changed files with 407 additions and 265 deletions
@ -0,0 +1,16 @@ |
|||||
|
namespace Volo.Abp.Cli.ProjectBuilding.Templates.App |
||||
|
{ |
||||
|
public class AppProTemplate : AppTemplateBase |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// "app-pro".
|
||||
|
/// </summary>
|
||||
|
public const string TemplateName = "app-pro"; |
||||
|
|
||||
|
public AppProTemplate() |
||||
|
: base(TemplateName) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,123 +1,16 @@ |
|||||
using System.Collections.Generic; |
namespace Volo.Abp.Cli.ProjectBuilding.Templates.App |
||||
using Volo.Abp.Cli.ProjectBuilding.Building; |
|
||||
using Volo.Abp.Cli.ProjectBuilding.Building.Steps; |
|
||||
|
|
||||
namespace Volo.Abp.Cli.ProjectBuilding.Templates.App |
|
||||
{ |
{ |
||||
public class AppTemplate : TemplateInfo |
public class AppTemplate : AppTemplateBase |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// "app".
|
/// "app".
|
||||
/// </summary>
|
/// </summary>
|
||||
public const string TemplateName = "app"; |
public const string TemplateName = "app"; |
||||
|
|
||||
public AppTemplate() |
public AppTemplate() |
||||
: base(TemplateName, DatabaseProvider.EntityFrameworkCore, UiFramework.Mvc) |
: base(TemplateName) |
||||
{ |
|
||||
DocumentUrl = "https://docs.abp.io/en/abp/latest/Startup-Templates/Application"; |
|
||||
} |
|
||||
|
|
||||
public override IEnumerable<ProjectBuildPipelineStep> GetCustomSteps(ProjectBuildContext context) |
|
||||
{ |
|
||||
var steps = new List<ProjectBuildPipelineStep>(); |
|
||||
|
|
||||
SwitchDatabaseProvider(context, steps); |
|
||||
DeleteUnrelatedProjects(context, steps); |
|
||||
RandomizeSslPorts(context, steps); |
|
||||
CleanupFolderHierarchy(context, steps); |
|
||||
|
|
||||
return steps; |
|
||||
} |
|
||||
|
|
||||
private static void SwitchDatabaseProvider(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) |
|
||||
{ |
{ |
||||
if (context.BuildArgs.DatabaseProvider == DatabaseProvider.MongoDb) |
|
||||
{ |
|
||||
steps.Add(new AppTemplateSwitchEntityFrameworkCoreToMongoDbStep()); |
|
||||
} |
|
||||
|
|
||||
if (context.BuildArgs.DatabaseProvider != DatabaseProvider.EntityFrameworkCore) |
|
||||
{ |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore")); |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations")); |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests")); |
|
||||
} |
|
||||
|
|
||||
if (context.BuildArgs.DatabaseProvider != DatabaseProvider.MongoDb) |
|
||||
{ |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB")); |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests")); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
private void DeleteUnrelatedProjects(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) |
|
||||
{ |
|
||||
if (context.BuildArgs.UiFramework == UiFramework.Mvc) |
|
||||
{ |
|
||||
if (context.BuildArgs.ExtraProperties.ContainsKey("tiered")) |
|
||||
{ |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web")); |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests")); |
|
||||
steps.Add(new AppTemplateProjectRenameStep("MyCompanyName.MyProjectName.Web.Host", "MyCompanyName.MyProjectName.Web")); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); |
|
||||
steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44303")); |
|
||||
} |
|
||||
|
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); |
|
||||
} |
|
||||
|
|
||||
if (context.BuildArgs.UiFramework != UiFramework.Mvc) |
|
||||
{ |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web")); |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests")); |
|
||||
|
|
||||
if (context.BuildArgs.ExtraProperties.ContainsKey("separate-identity-server")) |
|
||||
{ |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); |
|
||||
steps.Add(new AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep()); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); |
|
||||
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); |
|
||||
steps.Add(new AppTemplateProjectRenameStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds", "MyCompanyName.MyProjectName.HttpApi.Host")); |
|
||||
steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44305")); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (context.BuildArgs.UiFramework != UiFramework.Angular) |
|
||||
{ |
|
||||
steps.Add(new RemoveFolderStep("/angular")); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
private static void RandomizeSslPorts(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) |
|
||||
{ |
|
||||
steps.Add(new TemplateRandomSslPortStep( |
|
||||
new List<string> |
|
||||
{ |
|
||||
"https://localhost:44300", |
|
||||
"https://localhost:44301", |
|
||||
"https://localhost:44302", |
|
||||
"https://localhost:44303", |
|
||||
"https://localhost:44305" |
|
||||
} |
|
||||
) |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
private void CleanupFolderHierarchy(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) |
|
||||
{ |
|
||||
if (context.BuildArgs.UiFramework == UiFramework.Mvc) |
|
||||
{ |
|
||||
steps.Add(new MoveFolderStep("/aspnet-core/", "/")); |
|
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,124 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.Cli.ProjectBuilding.Building; |
||||
|
using Volo.Abp.Cli.ProjectBuilding.Building.Steps; |
||||
|
|
||||
|
namespace Volo.Abp.Cli.ProjectBuilding.Templates.App |
||||
|
{ |
||||
|
public abstract class AppTemplateBase : TemplateInfo |
||||
|
{ |
||||
|
protected AppTemplateBase(string templateName) |
||||
|
: base(templateName, DatabaseProvider.EntityFrameworkCore, UiFramework.Mvc) |
||||
|
{ |
||||
|
DocumentUrl = "https://docs.abp.io/en/abp/latest/Startup-Templates/Application"; |
||||
|
} |
||||
|
|
||||
|
public static bool IsAppTemplate(string templateName) |
||||
|
{ |
||||
|
return templateName == AppTemplate.TemplateName || |
||||
|
templateName == AppProTemplate.TemplateName; |
||||
|
} |
||||
|
|
||||
|
public override IEnumerable<ProjectBuildPipelineStep> GetCustomSteps(ProjectBuildContext context) |
||||
|
{ |
||||
|
var steps = new List<ProjectBuildPipelineStep>(); |
||||
|
|
||||
|
SwitchDatabaseProvider(context, steps); |
||||
|
DeleteUnrelatedProjects(context, steps); |
||||
|
RandomizeSslPorts(context, steps); |
||||
|
CleanupFolderHierarchy(context, steps); |
||||
|
|
||||
|
return steps; |
||||
|
} |
||||
|
|
||||
|
private static void SwitchDatabaseProvider(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) |
||||
|
{ |
||||
|
if (context.BuildArgs.DatabaseProvider == DatabaseProvider.MongoDb) |
||||
|
{ |
||||
|
steps.Add(new AppTemplateSwitchEntityFrameworkCoreToMongoDbStep()); |
||||
|
} |
||||
|
|
||||
|
if (context.BuildArgs.DatabaseProvider != DatabaseProvider.EntityFrameworkCore) |
||||
|
{ |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore")); |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations")); |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests")); |
||||
|
} |
||||
|
|
||||
|
if (context.BuildArgs.DatabaseProvider != DatabaseProvider.MongoDb) |
||||
|
{ |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB")); |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests")); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void DeleteUnrelatedProjects(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) |
||||
|
{ |
||||
|
if (context.BuildArgs.UiFramework == UiFramework.Mvc) |
||||
|
{ |
||||
|
if (context.BuildArgs.ExtraProperties.ContainsKey("tiered")) |
||||
|
{ |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web")); |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests")); |
||||
|
steps.Add(new AppTemplateProjectRenameStep("MyCompanyName.MyProjectName.Web.Host", "MyCompanyName.MyProjectName.Web")); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); |
||||
|
steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44303")); |
||||
|
} |
||||
|
|
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); |
||||
|
} |
||||
|
|
||||
|
if (context.BuildArgs.UiFramework != UiFramework.Mvc) |
||||
|
{ |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web")); |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests")); |
||||
|
|
||||
|
if (context.BuildArgs.ExtraProperties.ContainsKey("separate-identity-server")) |
||||
|
{ |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); |
||||
|
steps.Add(new AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep()); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); |
||||
|
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); |
||||
|
steps.Add(new AppTemplateProjectRenameStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds", "MyCompanyName.MyProjectName.HttpApi.Host")); |
||||
|
steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44305")); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (context.BuildArgs.UiFramework != UiFramework.Angular) |
||||
|
{ |
||||
|
steps.Add(new RemoveFolderStep("/angular")); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static void RandomizeSslPorts(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) |
||||
|
{ |
||||
|
steps.Add(new TemplateRandomSslPortStep( |
||||
|
new List<string> |
||||
|
{ |
||||
|
"https://localhost:44300", |
||||
|
"https://localhost:44301", |
||||
|
"https://localhost:44302", |
||||
|
"https://localhost:44303", |
||||
|
"https://localhost:44305" |
||||
|
} |
||||
|
) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
private void CleanupFolderHierarchy(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) |
||||
|
{ |
||||
|
if (context.BuildArgs.UiFramework == UiFramework.Mvc) |
||||
|
{ |
||||
|
steps.Add(new MoveFolderStep("/aspnet-core/", "/")); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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 {} |
||||
|
|||||
@ -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> |
||||
|
|||||
@ -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)); |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -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); |
||||
|
} |
||||
|
} |
||||
@ -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`) |
|
||||
} |
|
||||
} |
|
||||
@ -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,4 +1,3 @@ |
|||||
export class BooksGet { |
export class BooksGet { |
||||
static readonly type = '[Books] Get'; |
static readonly type = '[Books] Get'; |
||||
constructor(public readonly payload?: any) { } |
|
||||
} |
} |
||||
|
|||||
@ -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, |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -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, |
||||
}); |
}); |
||||
}) |
}), |
||||
); |
); |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -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,7 +1,23 @@ |
|||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
||||
<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=59923913AE66194DB837F628B1FC08BE/@KeyIndexDefined">True</s:Boolean> |
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/CSharpCompletingCharacters/UpgradedFromVSSettings/@EntryValue">True</s:Boolean> |
||||
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=59923913AE66194DB837F628B1FC08BE/AbsolutePath/@EntryValue">D:\github\abp\common.DotSettings</s:String> |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceDoWhileStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=59923913AE66194DB837F628B1FC08BE/RelativePath/@EntryValue">..\..\..\common.DotSettings</s:String> |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceFixedStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
<s:Boolean x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File59923913AE66194DB837F628B1FC08BE/@KeyIndexDefined">True</s:Boolean> |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceForeachStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File59923913AE66194DB837F628B1FC08BE/RelativePriority/@EntryValue">1</s:Double> |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceForStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceIfStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceLockStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceUsingStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceWhileStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOR/@EntryValue">Required</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">Required</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String> |
||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_REDUNDANT/@EntryValue">False</s:Boolean> |
||||
|
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Implementations/@KeyIndexDefined">True</s:Boolean> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Async/@EntryIndexedValue">False</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Mutable/@EntryIndexedValue">False</s:String> |
||||
|
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Overrides/@KeyIndexDefined">True</s:Boolean> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=Async/@EntryIndexedValue">False</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=Mutable/@EntryIndexedValue">False</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQL/@EntryIndexedValue">SQL</s:String> |
||||
</wpf:ResourceDictionary> |
</wpf:ResourceDictionary> |
||||
@ -1,7 +1,23 @@ |
|||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
||||
<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=A9046795AF04F2428C81EEAFEDBD18EE/@KeyIndexDefined">True</s:Boolean> |
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/CSharpCompletingCharacters/UpgradedFromVSSettings/@EntryValue">True</s:Boolean> |
||||
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=A9046795AF04F2428C81EEAFEDBD18EE/AbsolutePath/@EntryValue">D:\github\abp\common.DotSettings</s:String> |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceDoWhileStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=A9046795AF04F2428C81EEAFEDBD18EE/RelativePath/@EntryValue">..\..\..\common.DotSettings</s:String> |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceFixedStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
<s:Boolean x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=FileA9046795AF04F2428C81EEAFEDBD18EE/@KeyIndexDefined">True</s:Boolean> |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceForeachStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=FileA9046795AF04F2428C81EEAFEDBD18EE/RelativePriority/@EntryValue">1</s:Double> |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceForStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceIfStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceLockStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceUsingStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceWhileStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOR/@EntryValue">Required</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">Required</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String> |
||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_REDUNDANT/@EntryValue">False</s:Boolean> |
||||
|
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Implementations/@KeyIndexDefined">True</s:Boolean> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Async/@EntryIndexedValue">False</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Mutable/@EntryIndexedValue">False</s:String> |
||||
|
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Overrides/@KeyIndexDefined">True</s:Boolean> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=Async/@EntryIndexedValue">False</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=Mutable/@EntryIndexedValue">False</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQL/@EntryIndexedValue">SQL</s:String> |
||||
</wpf:ResourceDictionary> |
</wpf:ResourceDictionary> |
||||
Loading…
Reference in new issue