Skip to content

Commit c00fedb

Browse files
committed
Initial commit
0 parents  commit c00fedb

20 files changed

+597
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# angular-ngrx-data-custom-api-urls
2+
3+
[Edit on StackBlitz ⚡️](https://stackblitz.com/edit/angular-ngrx-data-custom-api-urls)

angular.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"demo": {
7+
"root": "",
8+
"sourceRoot": "src",
9+
"projectType": "application",
10+
"prefix": "app",
11+
"schematics": {},
12+
"architect": {
13+
"build": {
14+
"builder": "@angular-devkit/build-angular:browser",
15+
"options": {
16+
"outputPath": "dist/demo",
17+
"index": "src/index.html",
18+
"main": "src/main.ts",
19+
"polyfills": "src/polyfills.ts",
20+
"tsConfig": "src/tsconfig.app.json",
21+
"assets": [
22+
"src/favicon.ico",
23+
"src/assets"
24+
],
25+
"styles": [
26+
"src/styles.css"
27+
],
28+
"scripts": []
29+
},
30+
"configurations": {
31+
"production": {
32+
"fileReplacements": [
33+
{
34+
"replace": "src/environments/environment.ts",
35+
"with": "src/environments/environment.prod.ts"
36+
}
37+
],
38+
"optimization": true,
39+
"outputHashing": "all",
40+
"sourceMap": false,
41+
"extractCss": true,
42+
"namedChunks": false,
43+
"aot": true,
44+
"extractLicenses": true,
45+
"vendorChunk": false,
46+
"buildOptimizer": true
47+
}
48+
}
49+
},
50+
"serve": {
51+
"builder": "@angular-devkit/build-angular:dev-server",
52+
"options": {
53+
"browserTarget": "demo:build"
54+
},
55+
"configurations": {
56+
"production": {
57+
"browserTarget": "demo:build:production"
58+
}
59+
}
60+
},
61+
"extract-i18n": {
62+
"builder": "@angular-devkit/build-angular:extract-i18n",
63+
"options": {
64+
"browserTarget": "demo:build"
65+
}
66+
},
67+
"test": {
68+
"builder": "@angular-devkit/build-angular:karma",
69+
"options": {
70+
"main": "src/test.ts",
71+
"polyfills": "src/polyfills.ts",
72+
"tsConfig": "src/tsconfig.spec.json",
73+
"karmaConfig": "src/karma.conf.js",
74+
"styles": [
75+
"styles.css"
76+
],
77+
"scripts": [],
78+
"assets": [
79+
"src/favicon.ico",
80+
"src/assets"
81+
]
82+
}
83+
},
84+
"lint": {
85+
"builder": "@angular-devkit/build-angular:tslint",
86+
"options": {
87+
"tsConfig": [
88+
"src/tsconfig.app.json",
89+
"src/tsconfig.spec.json"
90+
],
91+
"exclude": [
92+
"**/node_modules/**"
93+
]
94+
}
95+
}
96+
}
97+
}
98+
},
99+
"defaultProject": "demo"
100+
}

package.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "angular",
3+
"version": "0.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"@angular/animations": "^10.0.0",
7+
"@angular/cdk": "10.2.4",
8+
"@angular/common": "^10.0.0",
9+
"@angular/compiler": "^10.0.0",
10+
"@angular/core": "^10.0.0",
11+
"@angular/forms": "^10.0.0",
12+
"@angular/material": "^10.2.4",
13+
"@angular/platform-browser": "^10.0.0",
14+
"@angular/platform-browser-dynamic": "^10.0.0",
15+
"@angular/router": "^10.0.0",
16+
"@ngrx/data": "^10.0.1",
17+
"@ngrx/effects": "10.0.1",
18+
"@ngrx/entity": "10.0.1",
19+
"@ngrx/store": "^10.0.1",
20+
"core-js": "^3.6.5",
21+
"rxjs": "^6.5.5",
22+
"tslib": "^2.0.0",
23+
"zone.js": "^0.10.3"
24+
},
25+
"scripts": {
26+
"ng": "ng",
27+
"start": "ng serve",
28+
"build": "ng build",
29+
"test": "ng test",
30+
"lint": "ng lint",
31+
"e2e": "ng e2e"
32+
},
33+
"devDependencies": {
34+
"@angular-devkit/build-angular": "~0.10.0",
35+
"@angular/cli": "~7.0.2",
36+
"@angular/compiler-cli": "~7.0.0",
37+
"@angular/language-service": "~7.0.0",
38+
"@types/node": "~8.9.4",
39+
"@types/jasmine": "~2.8.8",
40+
"@types/jasminewd2": "~2.0.3",
41+
"codelyzer": "~4.5.0",
42+
"jasmine-core": "~2.99.1",
43+
"jasmine-spec-reporter": "~4.2.1",
44+
"karma": "~3.0.0",
45+
"karma-chrome-launcher": "~2.2.0",
46+
"karma-coverage-istanbul-reporter": "~2.0.1",
47+
"karma-jasmine": "~1.1.2",
48+
"karma-jasmine-html-reporter": "^0.2.2",
49+
"protractor": "~5.4.0",
50+
"ts-node": "~7.0.0",
51+
"tslint": "~5.11.0",
52+
"typescript": "~3.1.1"
53+
}
54+
}

src/app/app.component.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
p {
2+
font-family: Lato;
3+
}

src/app/app.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<hello name="{{ name }}"></hello>
2+
<p>
3+
<app-skills></app-skills>
4+
</p>

src/app/app.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'my-app',
5+
templateUrl: './app.component.html',
6+
styleUrls: [ './app.component.css' ]
7+
})
8+
export class AppComponent {
9+
name = 'SC 2020 Angular 10';
10+
}

src/app/app.module.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { NgModule } from "@angular/core";
2+
import { BrowserModule } from "@angular/platform-browser";
3+
import { FormsModule } from "@angular/forms";
4+
5+
import { EntityDataModule, DefaultDataServiceConfig } from '@ngrx/data';
6+
import { entityMetadata } from './entity-metadata';
7+
import { EffectsModule } from '@ngrx/effects';
8+
9+
import { HttpClientModule } from '@angular/common/http';
10+
11+
import { AppComponent } from "./app.component";
12+
import { HelloComponent } from "./hello.component";
13+
14+
import { MatTreeModule} from "@angular/material/tree";
15+
16+
import { MatButtonModule } from "@angular/material/button";
17+
import { MatIconModule } from "@angular/material/icon";
18+
19+
import { StoreModule } from "@ngrx/store";
20+
import { SkillsComponent } from "./skills/skills.component";
21+
import { SkillsService } from './skills/skills.service';
22+
23+
const defaultDataServiceConfig: DefaultDataServiceConfig = {
24+
root: 'https://sc2019.skillclusters.com/sc/',
25+
timeout: 3000
26+
}
27+
28+
export const entityConfig = {
29+
entityMetadata
30+
};
31+
32+
@NgModule({
33+
imports:
34+
[
35+
BrowserModule, FormsModule, HttpClientModule, MatButtonModule, MatIconModule, MatTreeModule,
36+
EffectsModule.forRoot([]),
37+
EntityDataModule.forRoot(entityConfig),
38+
StoreModule.forRoot({}),
39+
],
40+
declarations: [AppComponent, HelloComponent, SkillsComponent],
41+
bootstrap: [AppComponent],
42+
providers: [
43+
{provide: DefaultDataServiceConfig, useValue: defaultDataServiceConfig},
44+
SkillsService
45+
]
46+
})
47+
export class AppModule {}

src/app/entity-metadata.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { EntityMetadataMap } from '@ngrx/data';
2+
export const entityMetadata: EntityMetadataMap = {
3+
//StructSkill: {}
4+
//SkillNode: {}
5+
StructSkill: {}
6+
}

src/app/hello.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component, Input } from '@angular/core';
2+
3+
@Component({
4+
selector: 'hello',
5+
template: `<h1>Hello {{name}}!</h1>`,
6+
styles: [`h1 { font-family: Lato; }`]
7+
})
8+
export class HelloComponent {
9+
@Input() name: string;
10+
}

src/app/skills/models/skill-node.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {BehaviorSubject} from 'rxjs';
2+
3+
export class SkillNode {
4+
/** Will be used in the future */
5+
static DefaultFontSize = '12px';
6+
static DefaultHeight: string = "80px";
7+
static CategoryWeightThreshold = 0.5;
8+
9+
item: string;
10+
fontSize: string;
11+
percentOfTime: number;
12+
children: SkillNode[];
13+
public expandCollapseIcon: string = 'arrow_drop_down_circle';
14+
15+
public nodeAlwaysVisible: boolean = false;
16+
private _nodeVisible: boolean = false;
17+
18+
constructor(itemObj: any, fontSize: any, percentOfTime: any, childrenArr?: any[]) {
19+
this.item = itemObj;
20+
this.fontSize = fontSize;
21+
this. percentOfTime = percentOfTime;
22+
this.children = childrenArr ? SkillNode.CreateChildrenArray(childrenArr): null;
23+
}
24+
25+
static CreateChildrenArray(childrenArr?: any[]) {
26+
let snChildren = new Array<SkillNode>();
27+
childrenArr.map(child => {
28+
let sn = new SkillNode(child.item, child.fontSize, child.percentOfTime, child.successors);
29+
snChildren.push(sn);
30+
});
31+
return snChildren;
32+
}
33+
}
34+
35+
export class SkillFlatNode {
36+
constructor(public expandable: boolean, public name: string, public fontSize: string, public percentOfTime: number, public level: number) {}
37+
}

src/app/skills/models/struct-skill.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {BehaviorSubject} from 'rxjs';
2+
3+
export class StructSkill {
4+
/** Will be used in the future */
5+
static DefaultFontSize = '12px';
6+
static DefaultHeight: string = "80px";
7+
static CategoryWeightThreshold = 0.5;
8+
9+
item: string;
10+
fontSize: string;
11+
percentOfTime: number;
12+
children: StructSkill[];
13+
public expandCollapseIcon: string = 'arrow_drop_down_circle';
14+
15+
public nodeAlwaysVisible: boolean = false;
16+
private _nodeVisible: boolean = false;
17+
18+
constructor(itemObj: any, fontSize: any, percentOfTime: any, childrenArr?: any[]) {
19+
this.item = itemObj;
20+
this.fontSize = fontSize;
21+
this. percentOfTime = percentOfTime;
22+
this.children = childrenArr ? StructSkill.CreateChildrenArray(childrenArr): null;
23+
}
24+
25+
static CreateChildrenArray(childrenArr?: any[]) {
26+
let snChildren = new Array<StructSkill>();
27+
childrenArr.map(child => {
28+
let sn = new StructSkill(child.item, child.fontSize, child.percentOfTime, child.successors);
29+
snChildren.push(sn);
30+
});
31+
return snChildren;
32+
}
33+
}
34+
35+
export class SkillFlatNode {
36+
constructor(public expandable: boolean, public name: string, public fontSize: string, public percentOfTime: number, public level: number) {}
37+
}

src/app/skills/skills.component.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.node-inline {
2+
float: left;
3+
clear: none;
4+
}
5+
6+
.node-inline:not(:first-of-type) {
7+
padding-left: 5px !important;
8+
}
9+
10+
.node-normal {
11+
float: none;
12+
clear: left;
13+
}
14+
15+
.button-with-margin {
16+
margin-right: 10px;
17+
margin-bottom: 3px;
18+
margin-top: 3px;
19+
}

src/app/skills/skills.component.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
2+
<mat-tree-node
3+
*matTreeNodeDef="let node"
4+
matTreeNodeToggle
5+
matTreeNodePadding
6+
[class.node-inline]="!node.expandable"
7+
>
8+
<li class="mat-tree-node">
9+
<button mat-icon-button disabled></button>
10+
<button
11+
mat-stroked-button
12+
class="button-with-margin"
13+
color="primary"
14+
[ngStyle]="{ 'font-size.px': node.fontSize}"
15+
>
16+
{{node.name}}<br />{{node.percentOfTime}}
17+
</button>
18+
</li>
19+
</mat-tree-node>
20+
21+
<mat-tree-node
22+
*matTreeNodeDef="let node;when: hasChild"
23+
matTreeNodePadding
24+
[class.node-normal]="node.expandable"
25+
>
26+
<button
27+
mat-icon-button
28+
matTreeNodeToggle
29+
[attr.aria-label]="'toggle ' + node.name"
30+
>
31+
<mat-icon class="mat-icon-rtl-mirror" color="accent">
32+
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
33+
</mat-icon>
34+
</button>
35+
{{node.name}}
36+
</mat-tree-node>
37+
</mat-tree>

0 commit comments

Comments
 (0)