Added loading bar

Fixed product, account and employee details for add new.
This commit is contained in:
tanshu 2018-06-10 13:58:01 +05:30
parent 659de0ae52
commit 8996516978
10 changed files with 75 additions and 25 deletions

View File

@ -1,8 +1,8 @@
from decimal import Decimal
from datetime import date, datetime, timedelta, time
from io import BytesIO
import uuid
import re
import uuid
from datetime import date, datetime, timedelta, time
from decimal import Decimal
from io import BytesIO
import pkg_resources
from pyramid.httpexceptions import HTTPForbidden, HTTPFound
@ -20,14 +20,16 @@ def home(request):
file = pkg_resources.resource_filename(package, resource)
return FileResponse(file, request=request)
@view_config(context=HTTPForbidden)
def forbidden(request):
if 'X-Requested-With' in request.headers and request.headers['X-Requested-With'] == 'XMLHttpRequest':
def forbidden_json(request):
if request.accept.quality('application/json') == 1:
response = Response("Forbidden")
response.status_int = 401
return response
else:
return HTTPFound(location=request.route_url('login', _query={'returnUrl': request.path_qs}))
ret = HTTPFound(location=request.route_url('login', _query={'returnUrl': request.path_qs}))
return ret
@view_config(route_name='db_image')

View File

@ -204,7 +204,7 @@ def show_term(request):
def product_info(id, dbsession):
if id is None:
product = {'code': '(Auto)', 'isActive': True, 'isPurchased': True, 'isSold': False}
product = {'code': '(Auto)', 'productGroup': {}, 'isActive': True, 'isPurchased': True, 'isSold': False}
else:
product = dbsession.query(Product).filter(Product.id == id).first()
product = {'id': product.id, 'code': product.code, 'name': product.name, 'units': product.units,

View File

@ -24,6 +24,8 @@
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"@ngx-loading-bar/http-client": "^2.1.0",
"@ngx-loading-bar/router": "^2.1.0",
"core-js": "^2.5.4",
"moment": "^2.22.1",
"rxjs": "^6.2.0",

View File

@ -56,7 +56,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
this.item = item;
this.form.setValue({
code: this.item.code || '(Auto)',
name: this.item.name,
name: this.item.name || '',
type: this.item.type,
isActive: this.item.isActive,
isReconcilable: this.item.isReconcilable,

View File

@ -1,3 +1,4 @@
<ngx-loading-bar></ngx-loading-bar>
<app-nav-bar></app-nav-bar>
<div fxLayout="row" fxLayoutAlign="center none" class="mat-app-background basic-container">
<router-outlet></router-outlet>

View File

@ -3,10 +3,16 @@ import {CommonModule} from '@angular/common';
import {NavBarComponent} from './nav-bar/nav-bar.component';
import {MatButtonModule, MatIconModule, MatMenuModule, MatToolbarModule} from '@angular/material';
import {RouterModule} from '@angular/router';
import {HTTP_INTERCEPTORS} from '@angular/common/http';
import {HttpAuthInterceptor} from './http-auth-interceptor';
import {LoadingBarHttpClientModule} from '@ngx-loading-bar/http-client';
import {LoadingBarRouterModule} from '@ngx-loading-bar/router';
@NgModule({
imports: [
CommonModule,
LoadingBarHttpClientModule,
LoadingBarRouterModule,
MatButtonModule,
MatIconModule,
MatMenuModule,
@ -14,11 +20,18 @@ import {RouterModule} from '@angular/router';
RouterModule
],
declarations: [
NavBarComponent
NavBarComponent,
],
exports: [
NavBarComponent
]
NavBarComponent,
LoadingBarHttpClientModule,
LoadingBarRouterModule
],
providers: [[{
provide: HTTP_INTERCEPTORS,
useClass: HttpAuthInterceptor,
multi: true
}]]
})
export class CoreModule {
}

View File

@ -0,0 +1,31 @@
import {Injectable} from '@angular/core';
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';
import {Observable, ObservableInput, of as observableOf} from 'rxjs';
import {catchError} from 'rxjs/operators';
import {ToasterService} from './toaster.service';
import {Router} from '@angular/router';
import {ConfirmDialogComponent} from '../shared/confirm-dialog/confirm-dialog.component';
import {MatDialog} from '@angular/material';
@Injectable()
export class HttpAuthInterceptor implements HttpInterceptor {
constructor(private router: Router, private dialog: MatDialog, private toaster: ToasterService) {
}
intercept(req: HttpRequest<any>, next: HttpHandler):
Observable<HttpEvent<any>> {
return next.handle(req)
.pipe(
catchError((err: any, caught: Observable<any>): ObservableInput<{}> => {
if (err.status === 401) {
this.router.navigate(['login']);
this.toaster.show('Danger', 'User has been logged out');
}
return observableOf(caught);
}
)
);
}
}

View File

@ -64,9 +64,9 @@ export class EmployeeDetailComponent implements OnInit, AfterViewInit {
designation: this.item.designation || '',
salary: this.item.salary || '',
points: this.item.points || '',
isActive: this.item.isActive || true,
isActive: this.item.isActive,
costCentre: this.item.costCentre.id,
joiningDate: moment(this.item.joiningDate, 'DD-MMM-YYYY').toDate(),
joiningDate: this.item.joiningDate ? moment(this.item.joiningDate, 'DD-MMM-YYYY').toDate() : '',
leavingDate: this.item.isActive ? null : moment(this.item.leavingDate, 'DD-MMM-YYYY').toDate()
});
}

View File

@ -57,19 +57,20 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
showItem(item: Product) {
this.item = item;
console.log(item);
this.form.setValue({
code: this.item.code || '(Auto)',
name: this.item.name,
units: this.item.units,
fraction: this.item.fraction,
fractionUnits: this.item.fractionUnits,
productYield: this.item.productYield,
price: this.item.price,
salePrice: this.item.salePrice,
name: this.item.name || '',
units: this.item.units || '',
fraction: this.item.fraction || '',
fractionUnits: this.item.fractionUnits || '',
productYield: this.item.productYield || '',
price: this.item.price || '',
salePrice: this.item.salePrice || '',
isPurchased: this.item.isPurchased,
isSold: this.item.isSold,
isActive: this.item.isActive,
productGroup: this.item.productGroup.id
productGroup: this.item.productGroup.id ? this.item.productGroup.id : ''
});
}

View File

@ -44,7 +44,7 @@ export class TokenizerService {
const isSort = (key === '' && value.length > 1 && '+-'.indexOf(value.charAt(0)) !== -1);
return sorter !== null ? (isSort && value.substr(1) in sorter) : isSort;
}
// getFilters(input: string[]) {
// input.
// }
getFilters(input: string[]) {
// input.
}
}