Settings working now. Everything working now.
Time for docker and beta test
This commit is contained in:
@ -4,7 +4,6 @@ import { MatSort } from '@angular/material/sort';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
import { Account } from '../../core/account';
|
||||
import {Employee} from "../../employee/employee";
|
||||
|
||||
|
||||
export class AccountListDataSource extends DataSource<Account> {
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import {User} from '../core/user';
|
||||
import { User } from '../core/user';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
const loginUrl = '/token';
|
||||
const refreshUrl = '/refresh';
|
||||
const JWT_USER = 'JWT_USER';
|
||||
const ACCESS_TOKEN_REFRESH_MINUTES = 10; // refresh token 10 minutes before expiry
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class AuthService {
|
||||
@ -60,10 +60,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
needsRefreshing(): boolean {
|
||||
|
||||
// We use this line to debug token refreshing
|
||||
// console.log("\n", Date.now(), ": Date.now()\n", this.user.exp * 1000, ": user.exp\n",(this.user.exp - (ACCESS_TOKEN_REFRESH_MINUTES * 60)) * 1000, ": comp");
|
||||
return Date.now() > (this.user.exp - (ACCESS_TOKEN_REFRESH_MINUTES * 60)) * 1000;
|
||||
return Date.now() > (this.user.exp - (environment.ACCESS_TOKEN_REFRESH_MINUTES * 60)) * 1000;
|
||||
}
|
||||
|
||||
expired(): boolean {
|
||||
@ -76,10 +73,6 @@ export class AuthService {
|
||||
this.currentUserSubject.next(null);
|
||||
}
|
||||
|
||||
getJwtToken() {
|
||||
return JSON.parse(localStorage.getItem(JWT_USER)).access_token;
|
||||
}
|
||||
|
||||
refreshToken() {
|
||||
return this.http.post<any>(refreshUrl, {})
|
||||
.pipe(map(u => u.access_token))
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
import {DataSource} from '@angular/cdk/collections';
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {map, tap} from 'rxjs/operators';
|
||||
import {merge, Observable, of as observableOf} from 'rxjs';
|
||||
import {Product} from '../../core/product';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
import { Product } from '../../core/product';
|
||||
|
||||
|
||||
export class ProductListDataSource extends DataSource<Product> {
|
||||
private dataObservable: Observable<Product[]>;
|
||||
private filterValue: string;
|
||||
|
||||
constructor(private paginator: MatPaginator, private sort: MatSort, private filter: Observable<string>, public data: Product[]) {
|
||||
@ -18,9 +17,8 @@ export class ProductListDataSource extends DataSource<Product> {
|
||||
}
|
||||
|
||||
connect(): Observable<Product[]> {
|
||||
this.dataObservable = observableOf(this.data);
|
||||
const dataMutations = [
|
||||
this.dataObservable,
|
||||
observableOf(this.data),
|
||||
this.filter,
|
||||
this.paginator.page,
|
||||
this.sort.sortChange
|
||||
@ -28,9 +26,13 @@ export class ProductListDataSource extends DataSource<Product> {
|
||||
|
||||
return merge(...dataMutations).pipe(
|
||||
map((x: any) => {
|
||||
return this.getPagedData(this.getSortedData(this.getFilteredData([...this.data])));
|
||||
return this.getFilteredData([...this.data]);
|
||||
}),
|
||||
tap((x: Product[]) => this.paginator.length = x.length)
|
||||
).pipe(
|
||||
map((x: any) => {
|
||||
return this.getPagedData(this.getSortedData(x));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@ -66,6 +68,8 @@ export class ProductListDataSource extends DataSource<Product> {
|
||||
switch (this.sort.active) {
|
||||
case 'name':
|
||||
return compare(a.name, b.name, isAsc);
|
||||
case 'productGroup':
|
||||
return compare(a.productGroup, b.productGroup, isAsc);
|
||||
case 'id':
|
||||
return compare(+a.id, +b.id, isAsc);
|
||||
default:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
export const environment = {
|
||||
production: true
|
||||
production: true,
|
||||
ACCESS_TOKEN_REFRESH_MINUTES: 10 // refresh token 10 minutes before expiry
|
||||
};
|
||||
|
||||
@ -3,7 +3,8 @@
|
||||
// The list of file replacements can be found in `angular.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false
|
||||
production: false,
|
||||
ACCESS_TOKEN_REFRESH_MINUTES: 10 // refresh token 10 minutes before expiry
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user