-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60856c0
commit 14b1c41
Showing
20 changed files
with
472 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Resolve } from '@angular/router'; | ||
import { Injectable } from '@angular/core'; | ||
import { HomeState } from './state/home.state'; | ||
|
||
@Injectable() | ||
export class HomeResolver implements Resolve<any> { | ||
constructor( | ||
private homeState: HomeState | ||
) { } | ||
|
||
public resolve() { | ||
return this.homeState.getContent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
import { HomeComponent } from './home.component'; | ||
import { HomeResolver } from './home-resolver'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
component: HomeComponent, | ||
path: '' | ||
path: '', | ||
resolve: { | ||
content: HomeResolver | ||
} | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
providers: [HomeResolver], | ||
exports: [RouterModule] | ||
}) | ||
export class HomeRoutingModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpUrlService } from '@ng-lab/http/url'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { map } from 'rxjs/operators'; | ||
import { HomeModel } from './state/home-model'; | ||
|
||
@Injectable() | ||
export class HomeService { | ||
constructor( | ||
private readonly urlService: HttpUrlService, | ||
private readonly httpService: HttpClient | ||
) { } | ||
|
||
public fetchAll() { | ||
const url = this.urlService.get('HOME.FETCH'); | ||
|
||
return this.httpService.get<{data: HomeModel}>(url).pipe( | ||
map(response => response.data) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface HomeModel { | ||
title: string; | ||
description: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { action, NgxsDataRepository, StateRepository } from '@ngxs-labs/data'; | ||
import { Injectable } from '@angular/core'; | ||
import { HomeModel } from './home-model'; | ||
import { State } from '@ngxs/store'; | ||
import { HomeService } from '../home-service'; | ||
import { tap } from 'rxjs/operators'; | ||
|
||
@StateRepository() | ||
@State({ | ||
name: 'home', | ||
defaults: {} | ||
}) | ||
@Injectable() | ||
export class HomeState extends NgxsDataRepository<HomeModel> { | ||
constructor( | ||
private readonly homeService: HomeService | ||
) { | ||
super(); | ||
} | ||
|
||
@action() | ||
public getContent() { | ||
return this.homeService.fetchAll().pipe( | ||
tap(content => this.ctx.setState(state => ({...state, ...content}))) | ||
); | ||
} | ||
} |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"data": { | ||
"title": "Welcome to @ng-lab packages.", | ||
"description": "@ng-lab packages are functional libraries to help you on logic, decision tasks, tools, structures, browser features. This packages can go from directives, services and components (very few), that will have an opinated API to you to use to maintain repeated task, wrapper browser features and others things where you can use in more friendly, innovated and angular way. You will find from configuration, url resolver, screen responsive, jwt and other things as describe in this website, demonstrating the usage of those packages." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"id": 1, | ||
"title": "Configurator", | ||
"slug": "configurator", | ||
"logo": "./assets/cg-logo.svg", | ||
"description": "Configurator is an angular service where you can set/get all options or configs as a root (singleton) for all your app.", | ||
"namespace": "@ng-lab/configurator", | ||
"badge": "https://img.shields.io/npm/v/@ng-lab/configurator.svg?style=social", | ||
"href": "" | ||
}, | ||
{ | ||
"id": 2, | ||
"title": "Support", | ||
"slug": "support", | ||
"logo": "./assets/support-logo.svg", | ||
"description": "Support is a collection of common functions to help you and continues grow, also it is used on other ng-lab packages as a dependency.", | ||
"namespace": "@ng-lab/support", | ||
"badge": "https://img.shields.io/npm/v/@ng-lab/support.svg?style=social", | ||
"href": "" | ||
}, | ||
{ | ||
"id": 3, | ||
"title": "JWT", | ||
"slug": "jwt", | ||
"logo": "./assets/jwt-logo.svg", | ||
"description": "JWT is an angular service to help you on decode valid token and also checking expiration to provide renovation mecanism.", | ||
"namespace": "@ng-lab/jwt", | ||
"badge": "https://img.shields.io/npm/v/@ng-lab/jwt.svg?style=social", | ||
"href": "" | ||
}, | ||
{ | ||
"id": 4, | ||
"title": "Responsive", | ||
"slug": "responsive", | ||
"logo": "./assets/responsive-logo.svg", | ||
"description": "Responsive is an angular directive to define media breakpoints, listen for changes and trigger event when resize happens on the page.", | ||
"namespace": "@ng-lab/responsive", | ||
"badge": "https://img.shields.io/npm/v/@ng-lab/responsive.svg?style=social", | ||
"href": "" | ||
}, | ||
{ | ||
"id": 5, | ||
"title": "Hub", | ||
"slug": "hub", | ||
"logo": "./assets/hu-logo.svg", | ||
"description": "Hub is an angular service pub/sub where you can register channels and dispatch/listen custom events.", | ||
"namespace": "@ng-lab/hub", | ||
"badge": "https://img.shields.io/npm/v/@ng-lab/hub.svg?style=social", | ||
"href": "" | ||
}, | ||
{ | ||
"id": 6, | ||
"title": "Http-Script", | ||
"slug": "http-script", | ||
"logo": "./assets/hs-logo.svg", | ||
"description": "Http-Script is an angular service to register and load external javascript libraries.", | ||
"namespace": "@ng-lab/http-script", | ||
"badge": "https://img.shields.io/npm/v/@ng-lab/http-script.svg?style=social", | ||
"href": "" | ||
}, | ||
{ | ||
"id": 7, | ||
"title": "Http-Url", | ||
"slug": "http-url", | ||
"logo": "./assets/hu-logo.svg", | ||
"description": "Http-Url is an angular service to define urls and resolve them with or without parameters.", | ||
"namespace": "@ng-lab/http-url", | ||
"badge": "https://img.shields.io/npm/v/@ng-lab/http-url.svg?style=social", | ||
"href": "" | ||
}, | ||
{ | ||
"id": 8, | ||
"title": "Layout", | ||
"slug": "layout", | ||
"logo": "./assets/hu-logo.svg", | ||
"description": "Component to create flex container elements. Usefull for layout areas and many stuff (boxes, containers etc...)", | ||
"namespace": "@ng-lab/layout", | ||
"badge": "https://img.shields.io/npm/v/@ng-lab/layout.svg?style=social", | ||
"href": "" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.