Skip to content

Commit 0658abc

Browse files
remove unused store file
1 parent aecd360 commit 0658abc

38 files changed

+6835
-9252
lines changed

src/generators/AngularGenerator.js

+22-16
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export default class extends BaseGenerator {
1212
// COMMON COMPONENTS
1313
"app/components/common/delete/delete.component.html",
1414
"app/components/common/delete/delete.component.ts",
15-
"app/components/common/form/form.component.html",
16-
"app/components/common/form/form.component.ts",
1715
"app/components/common/header/header.component.html",
1816
"app/components/common/header/header.component.ts",
17+
"app/components/common/layout/layout.component.html",
18+
"app/components/common/layout/layout.component.ts",
1919
"app/components/common/sidebar/sidebar.component.html",
2020
"app/components/common/sidebar/sidebar.component.ts",
2121
"app/components/common/table/table.component.html",
@@ -26,6 +26,8 @@ export default class extends BaseGenerator {
2626
"app/components/foo/create/create.component.ts",
2727
"app/components/foo/edit/edit.component.html",
2828
"app/components/foo/edit/edit.component.ts",
29+
"app/components/foo/form/form.component.html",
30+
"app/components/foo/form/form.component.ts",
2931
"app/components/foo/list/list.component.html",
3032
"app/components/foo/list/list.component.ts",
3133
"app/components/foo/show/show.component.html",
@@ -45,11 +47,6 @@ export default class extends BaseGenerator {
4547

4648
//INTERFACE
4749
"app/interface/api.ts",
48-
"app/interface/foo.model.ts",
49-
"app/interface/hero.model.ts",
50-
"app/interface/list.model.ts",
51-
"app/interface/show.model.ts",
52-
"app/interface/update.model.ts",
5350

5451
// ROUTER
5552
"app/router/foo.ts",
@@ -89,7 +86,6 @@ export default class extends BaseGenerator {
8986
const titleUcFirst =
9087
resource.title.charAt(0).toUpperCase() + resource.title.slice(1);
9188
const fields = this.parseFields(resource);
92-
console.log(fields);
9389
const hasIsRelation = fields.some((field) => field.isRelation);
9490
const hasIsRelations = fields.some((field) => field.isRelations);
9591
const hasDateField = fields.some((field) => field.type === "dateTime");
@@ -108,19 +104,19 @@ export default class extends BaseGenerator {
108104
hasIsRelations,
109105
hasRelations: hasIsRelation || hasIsRelations,
110106
hasDateField,
107+
apiResource: this.apiResource(api),
111108
};
112-
console.log("api ==>", api);
113109

114110
//CREATE DIRECTORIES - These directories may already exist
115111
[
116112
`${dir}/assets`,
117113
`${dir}/utils`,
118114
`${dir}/app/components/${lc}/create`,
119115
`${dir}/app/components/${lc}/edit`,
116+
`${dir}/app/components/${lc}/form`,
120117
`${dir}/app/components/${lc}/list`,
121118
`${dir}/app/components/${lc}/show`,
122119
`${dir}/app/components/common/delete`,
123-
`${dir}/app/components/common/form`,
124120
`${dir}/app/components/common/header`,
125121
`${dir}/app/components/common/sidebar`,
126122
`${dir}/app/components/common/table`,
@@ -145,13 +141,14 @@ export default class extends BaseGenerator {
145141
"app/components/svg/menu/menu.component.ts",
146142
"app/components/common/delete/delete.component.html",
147143
"app/components/common/delete/delete.component.ts",
148-
"app/components/common/form/form.component.html",
149-
"app/components/common/form/form.component.ts",
150144
"app/components/common/header/header.component.html",
151145
"app/components/common/header/header.component.ts",
146+
"app/components/common/sidebar/sidebar.component.css",
152147
"app/components/common/sidebar/sidebar.component.html",
153148
"app/components/common/sidebar/sidebar.component.ts",
154-
149+
"app/components/common/table/table.component.html",
150+
"app/components/common/table/table.component.ts",
151+
"app/interface/api.ts",
155152
"app/app.component.html",
156153
"app/app.component.ts",
157154
"app/app.routes.ts",
@@ -165,10 +162,13 @@ export default class extends BaseGenerator {
165162
"app/components/%s/list/list.component.ts",
166163
"app/components/%s/create/create.component.html",
167164
"app/components/%s/create/create.component.ts",
168-
/*"app/components/%s/edit/edit.component.html",
165+
"app/components/%s/edit/edit.component.html",
169166
"app/components/%s/edit/edit.component.ts",
170-
"app/components/%s/show/show.component.svg",
171-
"app/components/%s/show/show.component.ts",*/
167+
"app/components/%s/form/form.component.html",
168+
"app/components/%s/form/form.component.ts",
169+
"app/components/%s/show/show.component.html",
170+
"app/components/%s/show/show.component.ts",
171+
"app/components/%s/show/show.component.html",
172172
].forEach((file) =>
173173
this.createFileFromPattern(file, dir, [lc, formFields], context)
174174
);
@@ -202,4 +202,10 @@ export default class extends BaseGenerator {
202202

203203
return Object.values(fields);
204204
}
205+
206+
apiResource(api) {
207+
return api.resources
208+
.filter((val) => !val.deprecated)
209+
.map((val) => val.title);
210+
}
205211
}

src/generators/BaseGenerator.js

-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ export default class {
5252
}
5353

5454
createFile(template, dest, context = {}, warn = true) {
55-
console.table(this.templates);
56-
console.log("template ==>", template);
57-
console.log("dest ==>", dest);
5855
if (undefined === this.templates[template]) {
5956
console.log(
6057
`The template ${template} does not exists in the registered templates.`

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222
program
2323
.version(packageJson.version)
2424
.description(
25-
"Generate apps built with Next, Nuxt, Quasar, React, React Native, Vue or Vuetify for any API documented using Hydra or OpenAPI"
25+
"Generate apps built with Next, Nuxt, Quasar, React, React Native, Vue, Vuetify or Angular for any API documented using Hydra or OpenAPI"
2626
)
2727
.usage("entrypoint outputDirectory")
2828
.option(
+1-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
<app-header></app-header>
2-
<div class="flex">
3-
<div class="w-1/6 h-100">
4-
<app-sidebar></app-sidebar>
5-
</div>
6-
<div class="w-5/6 ">
7-
<router-outlet></router-outlet>
8-
</div>
9-
</div>
1+
<router-outlet></router-outlet>

templates/angular/app/app.component.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import {Component} from '@angular/core';
22
import {RouterOutlet} from '@angular/router';
33
import {AsyncPipe} from "@angular/common";
44
import {HttpClientModule} from "@angular/common/http";
5-
import {SidebarComponent} from "./components/common/sidebar/sidebar.component";
6-
import {HeaderComponent} from "./components/common/header/header.component";
5+
import {LayoutComponent} from "@components/common/layout/layout.component";
76

87
@Component({
98
selector: 'app-root',
109
standalone: true,
11-
imports: [RouterOutlet, AsyncPipe, HttpClientModule, SidebarComponent, HeaderComponent],
10+
imports: [RouterOutlet, AsyncPipe, HttpClientModule,LayoutComponent],
1211
templateUrl: './app.component.html',
1312
styleUrl: './app.component.css'
1413
})

templates/angular/app/app.routes.ts

+26-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
import {Routes} from '@angular/router';
2-
import {ListComponent} from "./components/{{lc}}/list/list.component";
3-
import {ShowComponent} from "./components/{{lc}}/show/show.component";
4-
import {EditComponent} from "./components/{{lc}}/edit/edit.component";
5-
import {CreateComponent} from "./components/{{lc}}/create/create.component";
2+
import {ListComponent} from "@components/foo/list/list.component";
3+
import {ShowComponent} from "@components/foo/show/show.component";
4+
import {EditComponent} from "@components/foo/edit/edit.component";
5+
import {CreateComponent} from "@components/foo/create/create.component";
6+
import {LayoutComponent} from "@components/common/layout/layout.component";
67

78
export const routes: Routes = [
89
{
9-
path: '{{lc}}',
10-
component: ListComponent
11-
},
12-
{
13-
path: '{{lc}}/add',
14-
component: CreateComponent
15-
},
16-
{
17-
path: '{{lc}}/:id',
18-
component: ShowComponent,
19-
},
20-
{
21-
path: '{{lc}}/:id/edit',
22-
component: EditComponent
23-
},
10+
path: '',
11+
component: LayoutComponent,
12+
children: [
13+
{
14+
path: '{{lc}}',
15+
component: ListComponent
16+
},
17+
{
18+
path: '{{lc}}/add',
19+
component: CreateComponent
20+
},
21+
{
22+
path: '{{lc}}/:id',
23+
component: ShowComponent,
24+
},
25+
{
26+
path: '{{lc}}/:id/edit',
27+
component: EditComponent
28+
},
29+
]
30+
}
2431
];
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<button
22
(click)="deleteAction()"
33
[className]="!disabled ?
4-
'py-2 px-4 bg-red-600 text-white text-sm rounded shadow-md hover:bg-red-700' :
5-
'py-2 px-4 bg-red-600 text-white text-sm rounded shadow-md opacity-25'"
4+
'py-2 px-6 bg-red-600 text-white text-sm rounded shadow-md hover:bg-red-700' :
5+
'py-2 px-6 bg-red-600 text-white text-sm rounded shadow-md opacity-25'"
66
[disabled]="disabled">
77
Delete
88
</button>

templates/angular/app/components/common/delete/delete.component.ts

-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import {Component, EventEmitter, Input, Output} from '@angular/core';
2-
import {ApiService} from "../../../service/api.service";
3-
import {Location} from "@angular/common";
42

53
@Component({
64
selector: 'app-delete',
@@ -11,11 +9,6 @@ import {Location} from "@angular/common";
119
export class DeleteComponent {
1210
@Input() disabled!: boolean
1311
@Output() delete: EventEmitter<Function> = new EventEmitter<Function>()
14-
constructor(
15-
private heroService: ApiService,
16-
private location: Location
17-
) {
18-
}
1912

2013
deleteAction () {
2114
return this.delete.emit()

templates/angular/app/components/common/form/form.component.html

-18
This file was deleted.

templates/angular/app/components/common/form/form.component.ts

-33
This file was deleted.

templates/angular/app/components/common/header/header.component.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
}
99

1010
.menu {
11-
padding: 8px;
11+
padding: 8px;
1212
cursor: pointer;
1313
}

templates/angular/app/components/common/header/header.component.spec.ts

-23
This file was deleted.

templates/angular/app/components/common/header/header.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from '@angular/core';
2-
import {MenuComponent} from "../../svg/menu/menu.component";
2+
import {MenuComponent} from "@components/svg/menu/menu.component";
33

44
@Component({
55
selector: 'app-header',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<app-header></app-header>
2+
<div class="flex">
3+
<div class="w-1/6 h-100">
4+
<app-sidebar></app-sidebar>
5+
</div>
6+
<div class="w-5/6 ">
7+
<router-outlet></router-outlet>
8+
</div>
9+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {Component} from '@angular/core';
2+
import {RouterOutlet} from "@angular/router";
3+
import {HeaderComponent} from "@components/common/header/header.component";
4+
import {SidebarComponent} from "@components/common/sidebar/sidebar.component";
5+
6+
@Component({
7+
selector: 'app-layout',
8+
standalone: true,
9+
imports: [
10+
HeaderComponent,
11+
RouterOutlet,
12+
SidebarComponent
13+
],
14+
templateUrl: './layout.component.html',
15+
})
16+
export class LayoutComponent {
17+
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
<div class="sidebar px-3 py-6">
22
<ul>
3+
{{#each apiResource}}
34
<li class="py-2 hover:bg-neutral-100">
4-
<a routerLink="/heroes" [routerLinkActive]="['active']">
5+
<a routerLink="/{{lowercase this}}" [routerLinkActive]="['active']">
56
<div class="flex just-center items-center px-4 text-lg">
6-
<app-list-svg/>
7-
<span class="ml-4">Heroes</span>
8-
</div>
9-
</a>
10-
</li>
11-
<li class="py-2 hover:bg-neutral-100">
12-
<a routerLink="/heroes2" [routerLinkActive]="['active']">
13-
<div class="flex just-center items-center px-4 text-lg">
14-
<app-list-svg/>
15-
<span class="ml-4">Heroes</span>
7+
<app-list-svg></app-list-svg>
8+
<span class="ml-4">{{this}}</span>
169
</div>
1710
</a>
1811
</li>
12+
{{/each}}
1913
</ul>
2014
</div>

templates/angular/app/components/common/sidebar/sidebar.component.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Component } from '@angular/core';
2-
import {ListComponent} from "../../foo/list/list.component";
3-
import {ListSvgComponent} from "../../svg/list-svg/list-svg.component";
42
import {RouterLink, RouterLinkActive} from "@angular/router";
3+
import {ListSvgComponent} from "@components/svg/list-svg/list-svg.component";
54

65
@Component({
76
selector: 'app-sidebar',

0 commit comments

Comments
 (0)