Skip to content

Commit 9ffe3a9

Browse files
lonesomegeeklonesomegeek
and
lonesomegeek
authored
Work/duge/92 (#140)
* before merging with default vanilla project * working version bug outdated * working version with ng8, ag-grid and netcore3.1 * adding database location and themes to aggrid * tests with wsl2 * adding new docker commands for wsl * adding babel to let ng build complete, bug documented here: angular/angular-cli#17262 * working version with vscode debugger * adding objects and shares controller * adding contact controller * remove item controller, new tables * working objects FE and BE * adding generic crud historical, missing generic service layer * adding release notes and breaking changes * merge conflict Co-authored-by: lonesomegeek <[email protected]>
1 parent a4b2beb commit 9ffe3a9

File tree

66 files changed

+1344
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1344
-243
lines changed

LSG.GenericCrud.Samples/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,5 @@ _Pvt_Extensions
229229

230230
# FAKE - F# Make
231231
.fake/
232+
233+
Databases/docker_data/*
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
// Use IntelliSense to find out which attributes exist for C# debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (web)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/LSG.GenericCrud.Samples.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}",
16+
"stopAtEntry": false,
17+
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
18+
"serverReadyAction": {
19+
"action": "openExternally",
20+
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
21+
},
22+
"env": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
},
25+
"sourceFileMap": {
26+
"/Views": "${workspaceFolder}/Views"
27+
}
28+
},
29+
{
30+
"name": ".NET Core Attach",
31+
"type": "coreclr",
32+
"request": "attach",
33+
"processId": "${command:pickProcess}"
34+
}
35+
]
36+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/LSG.GenericCrud.Samples.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/LSG.GenericCrud.Samples.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"${workspaceFolder}/LSG.GenericCrud.Samples.csproj",
36+
"/property:GenerateFullPaths=true",
37+
"/consoleloggerparameters:NoSummary"
38+
],
39+
"problemMatcher": "$msCompile"
40+
}
41+
]
42+
}

LSG.GenericCrud.Samples/ClientApp/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LSG.GenericCrud.Samples/ClientApp/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"@angular/platform-server": "8.2.12",
2323
"@angular/router": "8.2.12",
2424
"@nguniversal/module-map-ngfactory-loader": "8.1.1",
25+
"ag-grid-angular": "^23.0.2",
26+
"ag-grid-community": "^23.0.2",
2527
"aspnet-prerendering": "^3.0.1",
2628
"bootstrap": "^4.3.1",
2729
"core-js": "^3.3.3",

LSG.GenericCrud.Samples/ClientApp/src/app/@crud/crud/crud.component.css

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>crud works!</p>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { CrudComponent } from './crud.component';
4+
5+
describe('CrudComponent', () => {
6+
let component: CrudComponent;
7+
let fixture: ComponentFixture<CrudComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ CrudComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(CrudComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-crud',
5+
templateUrl: './crud.component.html',
6+
styleUrls: ['./crud.component.css']
7+
})
8+
export class CrudComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}

LSG.GenericCrud.Samples/ClientApp/src/app/@crud/historical-crud/historical-crud/historical-crud.component.css

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<p>historical-crud works!</p>
2+
3+
<button [routerLink]="['/objects/create']">Create</button>
4+
5+
<ag-grid-angular style="width: 500px; height: 500px;"
6+
#agGrid
7+
class="ag-theme-balham"
8+
[rowData]="rows | async"
9+
[columnDefs]="columnDefs">
10+
</ag-grid-angular>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { HistoricalCrudComponent } from './historical-crud.component';
4+
5+
describe('HistoricalCrudComponent', () => {
6+
let component: HistoricalCrudComponent;
7+
let fixture: ComponentFixture<HistoricalCrudComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ HistoricalCrudComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(HistoricalCrudComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Component, OnInit, ViewChild } from '@angular/core';
2+
import { Observable } from 'rxjs';
3+
import { Router } from '@angular/router';
4+
import { ItemService } from 'src/app/items/item.service';
5+
import { AgGridAngular } from 'ag-grid-angular';
6+
7+
@Component({
8+
selector: 'app-historical-crud',
9+
templateUrl: './historical-crud.component.html',
10+
styleUrls: ['./historical-crud.component.css']
11+
})
12+
export class HistoricalCrudComponent implements OnInit {
13+
@ViewChild('agGrid', undefined) agGrid: AgGridAngular;
14+
15+
public rows: Observable<any[]>;
16+
public columnDefs: any[];
17+
18+
public baseRoute: string;
19+
20+
constructor(
21+
private router: Router,
22+
private service: ItemService
23+
) { }
24+
25+
ngOnInit() {
26+
this.rows = this.service.getAll();
27+
this.agGrid.rowDoubleClicked.subscribe(row => this.rowDoubleClicked(row));
28+
}
29+
30+
rowDoubleClicked(row: any) {
31+
this.router.navigate(['/objects/' + row.data.id]);
32+
}
33+
}

LSG.GenericCrud.Samples/ClientApp/src/app/@crud/historical-crud/historical-detail/historical-detail.component.css

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<p>historical-detail works!</p>
2+
3+
Mode: {{mode}}
4+
<h1>Items</h1>
5+
6+
<p>This component demonstrates fetching data from the server.</p>
7+
8+
<p *ngIf="!row"><em>Loading...</em></p>
9+
<button *ngIf="mode=='read'" (click)="editActivate()">Edit</button>
10+
11+
<button *ngIf="mode=='edit'" (click)="save()">Save</button>
12+
<button *ngIf="mode=='create'" (click)="create()">Create</button>
13+
<button *ngIf="mode=='edit'" (click)="editDeactivate()">Cancel</button>
14+
<button *ngIf="mode=='edit'" (click)="delete()">Delete</button>
15+
<table class='table table-striped' *ngIf="row">
16+
<thead>
17+
<tr>
18+
<th>Name</th>
19+
</tr>
20+
</thead>
21+
<tbody>
22+
<tr>
23+
<td *ngIf="mode=='read'">{{ row.name }}</td>
24+
<td *ngIf="mode!='read'"><input required [(ngModel)]="row.name" name="name"></td>
25+
</tr>
26+
</tbody>
27+
</table>
28+
<div *ngIf="mode=='read'">
29+
<h1>History</h1>
30+
<p *ngIf="!history"><em>Loading...</em></p>
31+
<ag-grid-angular style="width: 500px; height: 500px;"
32+
class="ag-theme-balham"
33+
[rowData]="history | async"
34+
[columnDefs]="historyColumnDefs">
35+
</ag-grid-angular>
36+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { HistoricalDetailComponent } from './historical-detail.component';
4+
5+
describe('HistoricalDetailComponent', () => {
6+
let component: HistoricalDetailComponent;
7+
let fixture: ComponentFixture<HistoricalDetailComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ HistoricalDetailComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(HistoricalDetailComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Observable } from 'rxjs';
3+
import { ItemService } from 'src/app/items/item.service';
4+
import { Router, ActivatedRoute } from '@angular/router';
5+
6+
@Component({
7+
selector: 'app-historical-detail',
8+
templateUrl: './historical-detail.component.html',
9+
styleUrls: ['./historical-detail.component.css']
10+
})
11+
export class HistoricalDetailComponent implements OnInit {
12+
row: any;
13+
selectedId: string;
14+
mode: string = "read";
15+
isEditing: boolean = false;
16+
history: Observable<History[]>;
17+
historyColumnDefs: any[] = [
18+
{ headerName: 'Action', field: 'action', sortable: true },
19+
{ headerName: 'By', field: 'createdBy', sortable: true },
20+
{ headerName: 'At', field: 'createdDate', sortable: true }];
21+
22+
constructor(
23+
private service: ItemService,
24+
private router: Router,
25+
route: ActivatedRoute
26+
) {
27+
this.selectedId = route.snapshot.params["id"];
28+
if (this.selectedId == "create") this.mode = "create";
29+
}
30+
31+
ngOnInit() {
32+
if (this.mode != "create") {
33+
this.service.getOne(this.selectedId).subscribe(e => { this.row = e; });
34+
this.service.makeRead(this.selectedId).subscribe();
35+
this.history = this.service.getOneHistory(this.selectedId);
36+
} else {
37+
this.row = {};
38+
}
39+
}
40+
41+
editActivate() {
42+
this.mode = "edit";
43+
}
44+
45+
editDeactivate() {
46+
this.mode = "read";
47+
}
48+
49+
create() {
50+
this.service.postOne(this.row).subscribe(result => {
51+
this.router.navigate(['/objects']);
52+
})
53+
}
54+
55+
delete() {
56+
this.service.deleteOne(this.selectedId).subscribe(result => {
57+
this.router.navigate(['/objects']);
58+
59+
});
60+
}
61+
62+
save() {
63+
this.service.putOne(this.selectedId, this.row).subscribe(result => {
64+
this.editDeactivate();
65+
});
66+
}
67+
}

0 commit comments

Comments
 (0)