Feature: Download Products
Fix: Add user Fix: Added 5000 page size in products Fix: Local Time Pipe was showing the wrong time
This commit is contained in:
parent
f8162f364d
commit
cd20982753
@ -104,7 +104,7 @@ class UserView(object):
|
|||||||
|
|
||||||
def user_info(self, id):
|
def user_info(self, id):
|
||||||
if id is None:
|
if id is None:
|
||||||
account = {'name': '', 'lockedOut': False, 'groups': []}
|
account = {'name': '', 'lockedOut': False, 'lockedOut': False, 'groups': []}
|
||||||
for item in self.request.dbsession.query(Group).order_by(Group.name).all():
|
for item in self.request.dbsession.query(Group).order_by(Group.name).all():
|
||||||
account['groups'].append({'id': item.id, 'name': item.name, 'enabled': False})
|
account['groups'].append({'id': item.id, 'name': item.name, 'enabled': False})
|
||||||
return account
|
return account
|
||||||
|
@ -11,47 +11,47 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^6.0.3",
|
"@angular/animations": "^6.1.0",
|
||||||
"@angular/cdk": "^6.1.0",
|
"@angular/cdk": "^6.4.1",
|
||||||
"@angular/common": "^6.0.3",
|
"@angular/common": "^6.1.0",
|
||||||
"@angular/compiler": "^6.0.3",
|
"@angular/compiler": "^6.1.0",
|
||||||
"@angular/core": "^6.0.3",
|
"@angular/core": "^6.1.0",
|
||||||
"@angular/flex-layout": "^6.0.0-beta.15",
|
"@angular/flex-layout": "^6.0.0-beta.17",
|
||||||
"@angular/forms": "^6.0.3",
|
"@angular/forms": "^6.1.0",
|
||||||
"@angular/http": "^6.0.3",
|
"@angular/http": "^6.1.0",
|
||||||
"@angular/material": "^6.1.0",
|
"@angular/material": "^6.4.1",
|
||||||
"@angular/material-moment-adapter": "^6.1.0",
|
"@angular/material-moment-adapter": "^6.4.1",
|
||||||
"@angular/platform-browser": "^6.0.3",
|
"@angular/platform-browser": "^6.1.0",
|
||||||
"@angular/platform-browser-dynamic": "^6.0.3",
|
"@angular/platform-browser-dynamic": "^6.1.0",
|
||||||
"@angular/router": "^6.0.3",
|
"@angular/router": "^6.1.0",
|
||||||
"@ngx-loading-bar/http-client": "^2.1.0",
|
"@ngx-loading-bar/http-client": "^2.1.2",
|
||||||
"@ngx-loading-bar/router": "^2.1.0",
|
"@ngx-loading-bar/router": "^2.1.2",
|
||||||
"core-js": "^2.5.4",
|
"core-js": "^2.5.7",
|
||||||
"mathjs": "^5.0.0",
|
"mathjs": "^5.0.4",
|
||||||
"moment": "^2.22.1",
|
"moment": "^2.22.2",
|
||||||
"rxjs": "^6.2.0",
|
"rxjs": "^6.2.2",
|
||||||
"zone.js": "^0.8.26"
|
"zone.js": "^0.8.26"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "~0.6.0",
|
"@angular-devkit/build-angular": "^0.7.1",
|
||||||
"@angular/cli": "~6.0.0",
|
"@angular/cli": "^6.1.1",
|
||||||
"@angular/compiler-cli": "^6.0.3",
|
"@angular/compiler-cli": "^6.1.0",
|
||||||
"@angular/language-service": "^6.0.3",
|
"@angular/language-service": "^6.1.0",
|
||||||
"@types/jasmine": "~2.8.6",
|
"@types/jasmine": "^2.8.8",
|
||||||
"@types/jasminewd2": "~2.0.3",
|
"@types/jasminewd2": "^2.0.3",
|
||||||
"@types/node": "~8.9.4",
|
"@types/node": "^10.5.4",
|
||||||
"codelyzer": "~4.2.1",
|
"codelyzer": "^4.4.2",
|
||||||
"jasmine-core": "~2.99.1",
|
"jasmine-core": "^3.1.0",
|
||||||
"jasmine-spec-reporter": "~4.2.1",
|
"jasmine-spec-reporter": "^4.2.1",
|
||||||
"karma": "~1.7.1",
|
"karma": "^2.0.5",
|
||||||
"karma-chrome-launcher": "~2.2.0",
|
"karma-chrome-launcher": "^2.2.0",
|
||||||
"karma-coverage-istanbul-reporter": "~1.4.2",
|
"karma-coverage-istanbul-reporter": "^2.0.1",
|
||||||
"karma-jasmine": "~1.1.1",
|
"karma-jasmine": "^1.1.2",
|
||||||
"karma-jasmine-html-reporter": "^0.2.2",
|
"karma-jasmine-html-reporter": "^1.2.0",
|
||||||
"protractor": "~5.3.0",
|
"protractor": "^5.4.0",
|
||||||
"standard-version": "^4.4.0",
|
"standard-version": "^4.4.0",
|
||||||
"ts-node": "~5.0.1",
|
"ts-node": "^7.0.0",
|
||||||
"tslint": "~5.9.1",
|
"tslint": "^5.11.0",
|
||||||
"typescript": "~2.7.2"
|
"typescript": "^2.9.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-title-group>
|
<mat-card-title-group>
|
||||||
<mat-card-title>Products</mat-card-title>
|
<mat-card-title>Products</mat-card-title>
|
||||||
|
<button mat-button mat-icon-button *ngIf="dataSource.data.length" (click)="exportCsv()">
|
||||||
|
<mat-icon>save_alt</mat-icon>
|
||||||
|
</button>
|
||||||
<a mat-button [routerLink]="['/Product']">
|
<a mat-button [routerLink]="['/Product']">
|
||||||
<mat-icon>add_box</mat-icon>
|
<mat-icon>add_box</mat-icon>
|
||||||
Add
|
Add
|
||||||
@ -77,7 +80,7 @@
|
|||||||
[length]="dataSource.data.length"
|
[length]="dataSource.data.length"
|
||||||
[pageIndex]="0"
|
[pageIndex]="0"
|
||||||
[pageSize]="50"
|
[pageSize]="50"
|
||||||
[pageSizeOptions]="[25, 50, 100, 250]">
|
[pageSizeOptions]="[25, 50, 100, 250, 5000]">
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
@ -6,6 +6,7 @@ import {ActivatedRoute} from '@angular/router';
|
|||||||
import {debounceTime, distinctUntilChanged, startWith} from 'rxjs/operators';
|
import {debounceTime, distinctUntilChanged, startWith} from 'rxjs/operators';
|
||||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
|
import {ToCsvService} from "../../shared/to-csv.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-product-list',
|
selector: 'app-product-list',
|
||||||
@ -23,7 +24,7 @@ export class ProductListComponent implements OnInit, AfterViewInit {
|
|||||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||||
displayedColumns: string[];
|
displayedColumns: string[];
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute, private fb: FormBuilder) {
|
constructor(private route: ActivatedRoute, private fb: FormBuilder, private toCsv: ToCsvService) {
|
||||||
this.showExtended = false;
|
this.showExtended = false;
|
||||||
this.createForm();
|
this.createForm();
|
||||||
this.filter = this.listenToFilterChange();
|
this.filter = this.listenToFilterChange();
|
||||||
@ -73,4 +74,24 @@ export class ProductListComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportCsv() {
|
||||||
|
const headers = {
|
||||||
|
Code: 'code',
|
||||||
|
Name: 'name',
|
||||||
|
Units: 'units',
|
||||||
|
Fraction: 'fraction',
|
||||||
|
FractionUnits: 'fractionUnits',
|
||||||
|
CostPrice: 'costPrice',
|
||||||
|
Yield: 'yield',
|
||||||
|
ProductGroup: 'productGroup'
|
||||||
|
};
|
||||||
|
|
||||||
|
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {type: 'text/csv;charset=utf-8;'});
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = window.URL.createObjectURL(csvData);
|
||||||
|
link.setAttribute('download', 'products.csv');
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ export class LocalTimePipe implements PipeTransform {
|
|||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return moment(value, 'DD-MMM-YYYY HH:mm').subtract(new Date().getTimezoneOffset(), 'seconds').format('DD-MMM-YYYY HH:mm');
|
return moment(value, 'DD-MMM-YYYY HH:mm').subtract(new Date().getTimezoneOffset(), 'minutes').format('DD-MMM-YYYY HH:mm');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import {ToasterService} from '../../core/toaster.service';
|
|||||||
import {ConfirmDialogComponent} from '../../shared/confirm-dialog/confirm-dialog.component';
|
import {ConfirmDialogComponent} from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||||
import {MatDialog} from '@angular/material';
|
import {MatDialog} from '@angular/material';
|
||||||
import {FormArray, FormBuilder, FormGroup} from '@angular/forms';
|
import {FormArray, FormBuilder, FormGroup} from '@angular/forms';
|
||||||
|
import {Account} from "../../account/account";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-user-detail',
|
selector: 'app-user-detail',
|
||||||
@ -43,18 +44,25 @@ export class UserDetailComponent implements OnInit, AfterViewInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.data
|
this.route.data
|
||||||
.subscribe((data: { item: User }) => {
|
.subscribe((data: { item: User }) => {
|
||||||
this.item = data.item;
|
this.showItem(data.item);
|
||||||
this.form.get('name').setValue(this.item.name);
|
|
||||||
this.form.setControl('groups', this.fb.array(
|
|
||||||
this.item.groups.map(
|
|
||||||
x => this.fb.group({
|
|
||||||
group: x.enabled
|
|
||||||
})
|
|
||||||
)
|
|
||||||
));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showItem(item: User) {
|
||||||
|
this.item = item;
|
||||||
|
this.form.get('name').setValue(item.name);
|
||||||
|
this.form.get('password').setValue('');
|
||||||
|
this.form.get('lockedOut').setValue(item.lockedOut);
|
||||||
|
this.form.setControl('groups', this.fb.array(
|
||||||
|
item.groups.map(
|
||||||
|
x => this.fb.group({
|
||||||
|
group: x.enabled
|
||||||
|
})
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.nameElement.nativeElement.focus();
|
this.nameElement.nativeElement.focus();
|
||||||
@ -103,7 +111,7 @@ export class UserDetailComponent implements OnInit, AfterViewInit {
|
|||||||
getItem(): User {
|
getItem(): User {
|
||||||
const formModel = this.form.value;
|
const formModel = this.form.value;
|
||||||
this.item.name = formModel.name;
|
this.item.name = formModel.name;
|
||||||
this.item.password = formModel.password``;
|
this.item.password = formModel.password;
|
||||||
this.item.lockedOut = formModel.lockedOut;
|
this.item.lockedOut = formModel.lockedOut;
|
||||||
const array = this.form.get('groups') as FormArray;
|
const array = this.form.get('groups') as FormArray;
|
||||||
this.item.groups.forEach((item, index) => {
|
this.item.groups.forEach((item, index) => {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-title-group>
|
<mat-card-title-group>
|
||||||
<mat-card-title>Users</mat-card-title>
|
<mat-card-title>Users</mat-card-title>
|
||||||
|
<a mat-button [routerLink]="['/User']">
|
||||||
|
<mat-icon>add_box</mat-icon>
|
||||||
|
Add
|
||||||
|
</a>
|
||||||
</mat-card-title-group>
|
</mat-card-title-group>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
||||||
|
@ -3,5 +3,5 @@ waitress
|
|||||||
transaction
|
transaction
|
||||||
zope.sqlalchemy
|
zope.sqlalchemy
|
||||||
SQLAlchemy
|
SQLAlchemy
|
||||||
psycopg2
|
psycopg2-binary
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user