Skip to content

Commit

Permalink
Merge pull request #53 from progress/develop
Browse files Browse the repository at this point in the history
Merge from Develop branch to Master branch
  • Loading branch information
edselg authored Dec 19, 2018
2 parents 94d96c2 + d2e4058 commit 4d996ca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
30 changes: 10 additions & 20 deletions customers/customer-list/customer-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,7 @@ export class CustomerListComponent implements OnInit {
private _routerExtensions: RouterExtensions,
private _changeDetectionRef: ChangeDetectorRef,
private _progressService: ProgressService
) {
this._progressService.isLoggedin$.subscribe((isLoggedIn) => {
if (!isLoggedIn) {
this._routerExtensions.navigate(["/login"], {
clearHistory: true,
transition: {
name: "fade"
}
});
}
});
}
) { }

/* ***********************************************************
* Use the "ngOnInit" handler to get the data and assign it to the
Expand Down Expand Up @@ -154,8 +143,8 @@ export class CustomerListComponent implements OnInit {
message: "\"" + customerName + "\" will be deleted forever.",
okButtonText: "Delete",
title: "Delete"

};

confirm(options)
.then((result: boolean) => {
// result can be true/false
Expand Down Expand Up @@ -255,9 +244,9 @@ export class CustomerListComponent implements OnInit {
if (this.timer) {
clearTimeout(this.timer);
}
if (args.object.loadOnDemandMode === ListViewLoadOnDemandMode[ListViewLoadOnDemandMode.None]) {
if (args.object.loadOnDemandMode === ListViewLoadOnDemandMode.None) {
this._skipRec = 0; // Because listView.loadOnDemandMode navigates to its function and makes read call
listView.loadOnDemandMode = ListViewLoadOnDemandMode[ListViewLoadOnDemandMode.Auto];
listView.loadOnDemandMode = ListViewLoadOnDemandMode.Auto;
}

this.timer = setTimeout(() => {
Expand Down Expand Up @@ -306,17 +295,18 @@ export class CustomerListComponent implements OnInit {
this._skipRec = params.skip;

this._recCount = this._customers.length;
const listView: RadListView = args.object;

// If max record count is available/specified in the settings or if the number of records
// loaded in client reaches to max count then send an alert
if (params.maxRecCount && (((this.scrollCount) * (params.pageSize) === params.maxRecCount)
&& (this._recCount) === (params.maxRecCount))) {
&& (this._recCount) === (params.maxRecCount))) {
this._isLoading = false;
args.object.notifyLoadOnDemandFinished();
args.object.notifyLoadOnDemandFinished();
alert("Reached max size. Increase limit.");
listView.loadOnDemandMode = ListViewLoadOnDemandMode.None;
} else {

const listView: RadListView = args.object;

this._customerService.load(params)
.finally(() => {
this._isLoading = false;
Expand All @@ -328,7 +318,7 @@ export class CustomerListComponent implements OnInit {

// Setting the loadOnDemandMode to None if the last resultset from server is empty
if (this._customerService.dataSource._isLastResultSetEmpty) {
listView.loadOnDemandMode = ListViewLoadOnDemandMode[ListViewLoadOnDemandMode.None];
listView.loadOnDemandMode = ListViewLoadOnDemandMode.None;
this._isLoading = false;
}

Expand Down
24 changes: 12 additions & 12 deletions customers/shared/customer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export class CustomerService {
private jsdoSettings: JsdoSettings = new JsdoSettings();

constructor(private _ngZone: NgZone,
private _progressService: ProgressService) {
// Basically, if a logout event is triggered by our progress service,
// we clear out the data source. Because we're good people
this._progressService.isLoggedin$.subscribe((isLoggedIn) => {
if (!isLoggedIn) {
this.dataSource = undefined;
}
});
}
private _progressService: ProgressService
) { }

// Clear out the datasource when we logout because we're good people
// Place any other cleanup code for logging out here
logout() {
this.dataSource = undefined;
this._progressService.logout();
}

getCustomerById(id: string): Customer {
if (!id) {
Expand Down Expand Up @@ -72,7 +72,7 @@ export class CustomerService {
resolve(myData.data);
}, (error) => {
if (error.toString() === "Error: Error: HTTP Status 401 Unauthorized") {
this._progressService.logout();
this.logout();
reject(new Error("Your session is no longer valid. Please log in to continue."));
} else {
reject(new Error("Error reading records: " + error.message));
Expand All @@ -88,7 +88,7 @@ export class CustomerService {
resolve(myData.data);
}, (error) => {
if (error.toString() === "Error: Error: HTTP Status 401 Unauthorized") {
this._progressService.logout();
this.logout();
reject(new Error("Your session is no longer valid. Please log in to continue."));

} else {
Expand Down Expand Up @@ -145,7 +145,7 @@ export class CustomerService {
resolve();
}, (error) => {
if (error.toString() === "Error: Error: HTTP Status 401 Unauthorized") {
this._progressService.logout();
this.logout();
reject(new Error("Your session is no longer valid. Please log in to continue."));
} else {
reject(error);
Expand Down
12 changes: 12 additions & 0 deletions shared/progress.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { progress } from "@progress/jsdo-core";
import { JsdoSettings } from "./jsdo.settings";

import { Component, Injectable } from "@angular/core";
import { RouterExtensions } from "nativescript-angular/router";
import { BehaviorSubject } from "rxjs/BehaviorSubject";

/* *************************************************************************************
Expand Down Expand Up @@ -30,6 +31,10 @@ export class ProgressService {

private jsdosession: progress.data.JSDOSession;

constructor(
private _routerExtensions: RouterExtensions,
) { }

isLoggedIn() {
if (this.jsdosession) {
return true;
Expand Down Expand Up @@ -61,6 +66,13 @@ export class ProgressService {
this.jsdosession = undefined;
this.isLoggedin$.next(false);

this._routerExtensions.navigate(["/login"], {
clearHistory: true,
transition: {
name: "fade"
}
});

return promise;
}

Expand Down

0 comments on commit 4d996ca

Please sign in to comment.