Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download excel #1

Open
wants to merge 7 commits into
base: product-crud
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25,896 changes: 17,000 additions & 8,896 deletions angular/package-lock.json

Large diffs are not rendered by default.

62 changes: 44 additions & 18 deletions angular/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,50 @@ import { UsersComponent } from './users/users.component';
import { TenantsComponent } from './tenants/tenants.component';
import { RolesComponent } from 'app/roles/roles.component';
import { ChangePasswordComponent } from './users/change-password/change-password.component';
import { ProductsComponent } from './products/products.component';

@NgModule({
imports: [
RouterModule.forChild([
{
path: '',
component: AppComponent,
children: [
{ path: 'home', component: HomeComponent, canActivate: [AppRouteGuard] },
{ path: 'users', component: UsersComponent, data: { permission: 'Pages.Users' }, canActivate: [AppRouteGuard] },
{ path: 'roles', component: RolesComponent, data: { permission: 'Pages.Roles' }, canActivate: [AppRouteGuard] },
{ path: 'tenants', component: TenantsComponent, data: { permission: 'Pages.Tenants' }, canActivate: [AppRouteGuard] },
{ path: 'about', component: AboutComponent },
{ path: 'update-password', component: ChangePasswordComponent }
]
}
])
],
exports: [RouterModule]
imports: [
RouterModule.forChild([
{
path: '',
component: AppComponent,
children: [
{
path: 'home',
component: HomeComponent,
canActivate: [AppRouteGuard]
},
{
path: 'users',
component: UsersComponent,
data: { permission: 'Pages.Users' },
canActivate: [AppRouteGuard]
},
{
path: 'roles',
component: RolesComponent,
data: { permission: 'Pages.Roles' },
canActivate: [AppRouteGuard]
},
{
path: 'products',
component: ProductsComponent,
data: { permission: 'Pages.Products' },
canActivate: [AppRouteGuard]
},
{
path: 'tenants',
component: TenantsComponent,
data: { permission: 'Pages.Tenants' },
canActivate: [AppRouteGuard]
},
{ path: 'about', component: AboutComponent },
{ path: 'update-password', component: ChangePasswordComponent }
]
}
])
],
exports: [RouterModule]
})
export class AppRoutingModule { }
export class AppRoutingModule {}
14 changes: 12 additions & 2 deletions angular/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import { CreateUserDialogComponent } from '@app/users/create-user/create-user-di
import { EditUserDialogComponent } from '@app/users/edit-user/edit-user-dialog.component';
import { ChangePasswordComponent } from './users/change-password/change-password.component';
import { ResetPasswordDialogComponent } from './users/reset-password/reset-password.component';
import { CreateProductDialogComponent } from './products/create-product/create-product-dialog.component';
import { EditProductDialogComponent } from './products/edit-product/edit-product-dialog.component';
import { ProductsComponent } from './products/products.component';

@NgModule({
declarations: [
Expand All @@ -62,7 +65,11 @@ import { ResetPasswordDialogComponent } from './users/reset-password/reset-passw
CreateUserDialogComponent,
EditUserDialogComponent,
ChangePasswordComponent,
ResetPasswordDialogComponent
ResetPasswordDialogComponent,
// products
ProductsComponent,
CreateProductDialogComponent,
EditProductDialogComponent,
],
imports: [
CommonModule,
Expand All @@ -88,7 +95,10 @@ import { ResetPasswordDialogComponent } from './users/reset-password/reset-passw
// users
CreateUserDialogComponent,
EditUserDialogComponent,
ResetPasswordDialogComponent
ResetPasswordDialogComponent,
// products
CreateProductDialogComponent,
EditProductDialogComponent,
]
})
export class AppModule {}
1 change: 1 addition & 0 deletions angular/src/app/layout/sidebar-nav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class SideBarNavComponent extends AppComponentBase {
new MenuItem(this.l('HomePage'), '', 'home', '/app/home'),

new MenuItem(this.l('Tenants'), 'Pages.Tenants', 'business', '/app/tenants'),
new MenuItem(this.l('Products'), 'Pages.Users', 'local_grocery_store', '/app/products'),
new MenuItem(this.l('Users'), 'Pages.Users', 'people', '/app/users'),
new MenuItem(this.l('Roles'), 'Pages.Roles', 'local_offer', '/app/roles'),
new MenuItem(this.l('About'), '', 'info', '/app/about'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<form autocomplete="off" #createProductForm="ngForm" (ngSubmit)="save()">
<h1 mat-dialog-title>Create New Product</h1>
<mat-dialog-content>
<div class="row-fluid">
<div class="col-md-12">
<mat-form-field>
<input matInput name="Name" [placeholder]="'Name' | localize" [(ngModel)]="product.name" required
maxlength="128" />
</mat-form-field>
</div>
</div>
</mat-dialog-content>
<div mat-dialog-actions align="end">
<button mat-button type="button" [disabled]="saving" (click)="close(false)">
{{ "Cancel" | localize }}
</button>
<button mat-flat-button type="submit" flex="15" color="primary"
[disabled]="!createProductForm.form.valid || saving">
{{ "Save" | localize }}
</button>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Component, Injector, OnInit } from '@angular/core';
import { MatDialogRef } from '@angular/material';
import { finalize } from 'rxjs/operators';
import { AppComponentBase } from '@shared/app-component-base';
import {
ProductDto,
ProductsServiceProxy
} from '@shared/service-proxies/service-proxies';

@Component({
templateUrl: 'create-product-dialog.component.html',
styles: [
`
mat-form-field {
width: 100%;
}
mat-checkbox {
padding-bottom: 5px;
}
`
]
})
export class CreateProductDialogComponent extends AppComponentBase
implements OnInit {
saving = false;
product: ProductDto = new ProductDto();

constructor(
injector: Injector,
public _productService: ProductsServiceProxy,
private _dialogRef: MatDialogRef<CreateProductDialogComponent>
) {
super(injector);
}

ngOnInit(): void {
}

save(): void {
this.saving = true;

this._productService
.create(this.product)
.pipe(
finalize(() => {
this.saving = false;
})
)
.subscribe(() => {
this.notify.info(this.l('SavedSuccessfully'));
this.close(true);
});
}

close(result: any): void {
this._dialogRef.close(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<form autocomplete="off" #editProductForm="ngForm" (ngSubmit)="save()">
<h1 mat-dialog-title>{{ "EditProduct" | localize }}</h1>
<mat-dialog-content>
<div class="row-fluid">
<div class="col-md-12">
<mat-form-field>
<input matInput name="Name" [placeholder]="'Name' | localize" [(ngModel)]="product.name" required
maxlength="128" />
</mat-form-field>
</div>
</div>
</mat-dialog-content>
<div mat-dialog-actions align="end">
<button mat-button type="button" [disabled]="saving" (click)="close(false)">
{{ "Cancel" | localize }}
</button>
<button mat-flat-button type="submit" flex="15" color="primary" [disabled]="!editProductForm.form.valid || saving">
{{ "Save" | localize }}
</button>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Component, Injector, OnInit, Inject, Optional } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { finalize } from 'rxjs/operators';
import { AppComponentBase } from '@shared/app-component-base';
import {
ProductsServiceProxy,
ProductDto
} from '@shared/service-proxies/service-proxies';

@Component({
templateUrl: 'edit-product-dialog.component.html',
styles: [
`
mat-form-field {
width: 100%;
}
mat-checkbox {
padding-bottom: 5px;
}
`
]
})
export class EditProductDialogComponent extends AppComponentBase
implements OnInit {
saving = false;
product: ProductDto = new ProductDto();

constructor(
injector: Injector,
public _productService: ProductsServiceProxy,
private _dialogRef: MatDialogRef<EditProductDialogComponent>,
@Optional() @Inject(MAT_DIALOG_DATA) private _id: number
) {
super(injector);
}

ngOnInit(): void {
this._productService.get(this._id).subscribe((result: ProductDto) => {
this.product = result;
});
}

save(): void {
this.saving = true;

this._productService
.update(this.product)
.pipe(
finalize(() => {
this.saving = false;
})
)
.subscribe(() => {
this.notify.info(this.l('SavedSuccessfully'));
this.close(true);
});
}

close(result: any): void {
this._dialogRef.close(result);
}
}
91 changes: 91 additions & 0 deletions angular/src/app/products/products.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<div class="row clearfix" [@routerTransition]>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="card main-content">
<div class="header">
<h2>{{ "Products" | localize }}</h2>
<ul class="header-dropdown m-r--5">
<li>
<button
mat-icon-button
[matMenuTriggerFor]="headerMenu"
class="header-dropdown-mat-icon-button"
>
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #headerMenu="matMenu">
<button mat-menu-item (click)="refresh()">
<mat-icon>refresh</mat-icon>
<span>{{ "Refresh" | localize }}</span>
</button>
</mat-menu>
</li>
</ul>
</div>
<div class="body table-responsive">
<table class="table table-hover table-striped" [busy]="isTableLoading">
<thead>
<tr>
<th>{{ "Name" | localize }}</th>
<th>{{ "Quantity" | localize }}</th>
<th>{{ "Actions" | localize }}</th>
</tr>
</thead>
<tbody>
<tr
*ngFor="
let product of (products
| paginate
: {
id: 'server',
itemsPerPage: pageSize,
currentPage: pageNumber,
totalItems: totalItems
})
"
>
<td>{{ product.name }}</td>
<td>{{ product.quantity }}</td>
<td>
<button class="action-button" mat-icon-button [matMenuTriggerFor]="actionsMenu">
<mat-icon>menu</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="editProduct(product)">
<mat-icon>edit</mat-icon>
<span>{{ "Edit" | localize }}</span>
</button>
<button mat-menu-item (click)="delete(product)">
<mat-icon>delete</mat-icon>
<span>{{ "Delete" | localize }}</span>
</button>
<button mat-menu-item (click)="download()">
<mat-icon>download</mat-icon>
<span>Download</span>
</button>
</mat-menu>
</td>
</tr>
</tbody>
</table>
<div
class="abp-pagination-controls-wrapper"
*ngIf="totalItems > pageSize"
>
<abp-pagination-controls
(pageChange)="getDataPage($event)"
id="server"
>
</abp-pagination-controls>
</div>
<button
mat-mini-fab
color="primary"
class="pull-right"
(click)="createProduct()"
>
<mat-icon>add</mat-icon>
</button>
</div>
</div>
</div>
</div>
Loading