-
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.
initial version of the pxl.generator.angular
- Loading branch information
1 parent
64ae1ea
commit 55b103a
Showing
21 changed files
with
8,437 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,2 @@ | ||
coverage | ||
**/templates |
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 @@ | ||
* text=auto |
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,2 @@ | ||
node_modules | ||
coverage |
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,7 @@ | ||
language: node_js | ||
node_js: | ||
- v11 | ||
- v10 | ||
- v8 | ||
- v6 | ||
- v4 |
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,9 @@ | ||
{ | ||
"generator-node": { | ||
"promptValues": { | ||
"authorName": "pixeldublu", | ||
"authorEmail": "[email protected]", | ||
"authorUrl": "" | ||
} | ||
} | ||
} |
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 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 pixeldublu <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,2 +1 @@ | ||
# pxl.yo.generator.angular | ||
|
||
npm install and then npm link and then you can use yo generator-pxl-angular |
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,74 @@ | ||
"use strict"; | ||
const Generator = require("yeoman-generator"); | ||
const chalk = require("chalk"); | ||
const glob = require("glob"); | ||
const yosay = require("yosay"); | ||
|
||
module.exports = class extends Generator { | ||
async prompting() { | ||
let answers; | ||
|
||
// Have Yeoman greet the user. | ||
this.log( | ||
yosay( | ||
`Welcome to the lovely ${chalk.red( | ||
"generator-scaffool-angular" | ||
)} generator!` | ||
) | ||
); | ||
|
||
const prompts = [{ | ||
type: "input", | ||
name: "name", | ||
message: "pxl.angular module name ? Start with uppercase. Ex: Cars" | ||
}, | ||
{ | ||
type: "input", | ||
name: "model", | ||
message: "model name used in the module ? Start with uppercase. Ex: Car" | ||
} | ||
]; | ||
|
||
return this.prompt(prompts).then(props => { | ||
// To access props later use this.props.someAnswer; | ||
this.props = props; | ||
}); | ||
} | ||
|
||
writing() { | ||
// // this.props.name | ||
// this.fs.copy( | ||
// this.templatePath('dummyfile.txt'), | ||
// this.destinationPath('dummyfile.txt') | ||
// ); | ||
const parent = this; | ||
glob(this.templatePath() + "/**/*", function (err, files) { | ||
files.forEach(file => { | ||
const originalFileName = file.replace( | ||
parent.templatePath().replace(/\\/gi, "/") + "/", | ||
"" | ||
); | ||
const newFileName = originalFileName.replace( | ||
/template/gi, | ||
String(parent.props.name).toLowerCase() | ||
); | ||
if (/\./gi.test(originalFileName)) { | ||
parent.fs.copyTpl( | ||
parent.templatePath(originalFileName), | ||
parent.destinationPath('' + newFileName), { | ||
mainTitle: parent.props.name, | ||
secondaryTitle: String(parent.props.name).toLowerCase(), | ||
mainModel: parent.props.model, | ||
secondaryModel: String(parent.props.model).toLowerCase() | ||
} | ||
); | ||
} | ||
|
||
}); | ||
}); | ||
} | ||
|
||
install() { | ||
// this.installDependencies(); | ||
} | ||
}; |
39 changes: 39 additions & 0 deletions
39
generators/app/templates/template-list/template-list.component.html
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,39 @@ | ||
<mat-card> | ||
<mat-toolbar class="whitebg"> | ||
<span class="centersmall"> | ||
<button [routerLink]="['/<%= secondaryTitle %>/manage/']" mat-raised-button>{{'New <%= mainModel %>' | translate}}</button> | ||
</span> | ||
</mat-toolbar> | ||
|
||
|
||
<div [hidden]="isLoading"> | ||
<table mat-table [dataSource]="dataSource" style="width:100%;"> | ||
|
||
<!-- Id Column --> | ||
<ng-container matColumnDef="id"> | ||
<th mat-header-cell *matHeaderCellDef translate> {{'Id' | translate}} </th> | ||
<td mat-cell *matCellDef="let element"> {{element.id}} </td> | ||
</ng-container> | ||
|
||
<!-- Name Column --> | ||
<ng-container matColumnDef="name"> | ||
<th mat-header-cell *matHeaderCellDef translate> {{'Name' | translate}} </th> | ||
<td mat-cell *matCellDef="let element"> {{element.name}} </td> | ||
</ng-container> | ||
|
||
<!-- Actions Column --> | ||
<ng-container matColumnDef="actions"> | ||
<th mat-header-cell *matHeaderCellDef translate> {{'Actions' | translate}} </th> | ||
<td mat-cell *matCellDef="let element"> <button [routerLink]="['/<%= secondaryTitle %>/manage/' + element.id]" | ||
mat-raised-button color="accent" translate>{{'Edit' | translate}}</button> </td> | ||
</ng-container> | ||
|
||
|
||
|
||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
</table> | ||
|
||
<mat-paginator [pageSizeOptions]="[10, 20, 50]" showFirstLastButtons></mat-paginator> | ||
</div> | ||
</mat-card> |
25 changes: 25 additions & 0 deletions
25
generators/app/templates/template-list/template-list.component.spec.ts
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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { <%= mainTitle %>ListComponent } from '@app/<%= secondaryTitle %>/<%= secondaryTitle %>-list/<%= secondaryTitle %>-list.component'; | ||
|
||
describe('<%= mainTitle %>ListComponent', () => { | ||
let component: <%= mainTitle %>ListComponent; | ||
let fixture: ComponentFixture<<%= mainTitle %>ListComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ <%= mainTitle %>ListComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(<%= mainTitle %>ListComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
generators/app/templates/template-list/template-list.component.ts
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,30 @@ | ||
import { Component, OnInit, ViewChild } from '@angular/core'; | ||
import { MatPaginator, MatTableDataSource } from '@angular/material'; | ||
import { <%= mainTitle %>Service } from '@app/core/services/<%= secondaryTitle %>.service'; | ||
import { <%= mainModel %> } from '@app/core/models/<%= secondaryModel %>'; | ||
import { finalize } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'app-<%= secondaryTitle %>-list', | ||
templateUrl: './<%= secondaryTitle %>-list.component.html' | ||
}) | ||
export class <%= mainTitle %>ListComponent implements OnInit { | ||
|
||
isLoading: boolean; | ||
displayedColumns: string[] = ['id', 'name', 'actions']; | ||
dataSource = new MatTableDataSource(); | ||
|
||
@ViewChild(MatPaginator) paginator: MatPaginator; | ||
|
||
constructor(private <%= secondaryTitle %>Service: <%= mainTitle %>Service) {} | ||
|
||
ngOnInit() { | ||
this.dataSource.paginator = this.paginator; | ||
|
||
this.isLoading = true; | ||
this.<%= secondaryTitle %>Service.api<%= mainTitle %>Get() | ||
.pipe(finalize(() => { this.isLoading = false; })) | ||
.subscribe((value: <%= mainModel %>) => { | ||
this.dataSource.data = <Object[]> value; }); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
generators/app/templates/template-manage/template-manage-component.spec.ts
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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { <%= mainTitle %>ManageComponent } from './<%= secondaryTitle %>-manage.component'; | ||
|
||
describe('<%= mainTitle %>ManageComponent', () => { | ||
let component: <%= mainTitle %>ManageComponent; | ||
let fixture: ComponentFixture<<%= mainTitle %>ManageComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ <%= mainTitle %>ManageComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(<%= mainTitle %>ManageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
51 changes: 51 additions & 0 deletions
51
generators/app/templates/template-manage/template-manage.component.html
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,51 @@ | ||
<form #form="ngForm" class="app-form"> | ||
<mat-card> | ||
<mat-card-title> | ||
{{'Details' | translate}} | ||
</mat-card-title> | ||
<mat-form-field class="input-full-width"> | ||
<input placeholder="{{'Name' | translate}}" matInput [ngModel]="<%= secondaryModel %>?.name" [value]="<%= secondaryModel %>?.name" | ||
(ngModelChange)="<%= secondaryModel %>.name = $event" name="name" id="name" class="form-control" required> | ||
</mat-form-field> | ||
|
||
</mat-card> | ||
|
||
<mat-card *ngIf="<%= secondaryModel %>.image || !isNew"> | ||
<mat-card-title> | ||
{{'Image' | translate}} | ||
</mat-card-title> | ||
<div class="imagebox" *ngIf="<%= secondaryModel %>.image"> | ||
|
||
<mat-card class="imagecard <%= secondaryModel %>image"> | ||
<img mat-card-image [src]="environment.serverHost + '/uploads/<%= secondaryTitle %>/' + <%= secondaryModel %>.image" class="imagecard"> | ||
</mat-card> | ||
|
||
</div> | ||
|
||
<div class="fileupload" *ngIf="!isNew"> | ||
<material-file-upload (complete)="onFileComplete($event)" (uploading)="onUploadStarted($event)" (error)="onUploadError($event)" | ||
[target]="'/api/<%= secondaryTitle %>/image/' + id" [multiple]="false" [disable]="isLoading" [text]="'Upload Image' | translate"></material-file-upload> | ||
</div> | ||
|
||
|
||
</mat-card> | ||
|
||
<mat-card> | ||
<mat-toolbar class="whitebg"> | ||
|
||
<span class="center"> | ||
<button type="submit" mat-raised-button color="accent" (click)="save<%= mainModel %>(form.valid)" [disabled]="form.invalid || isLoading">{{(isNew | ||
? 'Create' : 'Update') | translate}}</button> | ||
|
||
<button *ngIf="!isNew" type="submit" mat-raised-button color="warn" (click)="delete<%= mainModel %>()" [disabled]="isLoading">{{'Delete' | ||
| translate}}</button> | ||
</span> | ||
</mat-toolbar> | ||
</mat-card> | ||
</form> | ||
|
||
|
||
<mat-toolbar color="primary"> | ||
<span class="center"><button [disabled]="isLoading" [routerLink]="['/<%= secondaryTitle %>/']" mat-raised-button translate> | ||
{{'Back to <%= mainTitle %>' | translate}}</button> </span> | ||
</mat-toolbar> |
Oops, something went wrong.