From 179d67dcc982b1a319679fc453e5360ffd758dff Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 27 Dec 2017 12:41:55 -0500 Subject: [PATCH] LP#626157 ang2 misc tidying Signed-off-by: Bill Erickson --- Open-ILS/eg2-src/src/app/core/idl.ts | 12 +++--------- Open-ILS/eg2-src/src/app/core/net.ts | 28 +++++++++++++++++----------- Open-ILS/eg2-src/src/app/core/pcrud.ts | 2 +- Open-ILS/eg2-src/src/app/core/store.ts | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Open-ILS/eg2-src/src/app/core/idl.ts b/Open-ILS/eg2-src/src/app/core/idl.ts index 8f46933954..fdbd1113cc 100644 --- a/Open-ILS/eg2-src/src/app/core/idl.ts +++ b/Open-ILS/eg2-src/src/app/core/idl.ts @@ -1,21 +1,15 @@ -import { Injectable } from '@angular/core'; +import {Injectable} from '@angular/core'; // Added globally by /IDL2js declare var _preload_fieldmapper_IDL: Object; /** - * NOTE: To achieve full type strictness and avoid compile warnings, - * we would likely have to pre-compile the IDL down to a .ts file with all - * of the IDL class and field definitions. - */ - -/** * Every IDL object class implements this interface. */ export interface EgIdlObject { a: any[]; - classname: String; - _isfieldmapper: Boolean; + classname: string; + _isfieldmapper: boolean; // Dynamically appended functions from the IDL. [fields: string]: any; } diff --git a/Open-ILS/eg2-src/src/app/core/net.ts b/Open-ILS/eg2-src/src/app/core/net.ts index 502ffbf0de..f6ec6b258b 100644 --- a/Open-ILS/eg2-src/src/app/core/net.ts +++ b/Open-ILS/eg2-src/src/app/core/net.ts @@ -2,7 +2,7 @@ * * constructor(private net : EgNetService) { * ... - * egNet.request(service, method, param1 [, param2, ...]) + * this.net.request(service, method, param1 [, param2, ...]) * .subscribe( * (res) => console.log('received one resopnse: ' + res), * (err) => console.error('recived request error: ' + err), @@ -10,9 +10,14 @@ * ) * ); * ... + * + * // Example translating a net request into a promise. + * this.net.request(service, method, param1) + * .toPromise().then(result => console.log(result)); + * * } * - * Each response is relayed via Observable onNext(). The interface is + * Each response is relayed via Observable.next(). The interface is * the same for streaming and atomic requests. */ import {Injectable, EventEmitter} from '@angular/core'; @@ -24,11 +29,11 @@ import {EgEventService, EgEvent} from './event'; declare var OpenSRF, OSRF_TRANSPORT_TYPE_WS; export class EgNetRequest { - service : String; - method : String; + service : string; + method : string; params : any[]; observer : Observer; - superseded : Boolean = false; + superseded : boolean = false; // If set, this will be used instead of a one-off OpenSRF.ClientSession. session? : any; // True if we're using a single-use local session @@ -39,7 +44,7 @@ export class EgNetRequest { // event will be available here. evt: EgEvent; - constructor(service: String, method: String, params: any[], session?: any) { + constructor(service: string, method: string, params: any[], session?: any) { this.service = service; this.method = method; this.params = params; @@ -80,17 +85,18 @@ export class EgNetService { } // Standard request call -- Variadic params version - request(service: String, method: String, ...params: any[]): Observable { + request(service: string, method: string, ...params: any[]): Observable { return this.requestWithParamList(service, method, params); } // Array params version - requestWithParamList(service: String, - method: String, params: any[]): Observable { + requestWithParamList(service: string, + method: string, params: any[]): Observable { return this.requestCompiled( new EgNetRequest(service, method, params)); } + // Request with pre-compiled EgNetRequest requestCompiled(request: EgNetRequest): Observable { return Observable.create( observer => { @@ -100,13 +106,13 @@ export class EgNetService { ); } - // Version with pre-compiled EgNetRequest object + // Send the compiled request to the server via WebSockets sendCompiledRequest(request: EgNetRequest): void { OpenSRF.Session.transport = OSRF_TRANSPORT_TYPE_WS; console.debug(`EgNet: request ${request.method}`); request.session.request({ - async : true, + async : true, // WS only operates in async mode method : request.method, params : request.params, oncomplete : () => { diff --git a/Open-ILS/eg2-src/src/app/core/pcrud.ts b/Open-ILS/eg2-src/src/app/core/pcrud.ts index 643a515915..e8a3ec5cf6 100644 --- a/Open-ILS/eg2-src/src/app/core/pcrud.ts +++ b/Open-ILS/eg2-src/src/app/core/pcrud.ts @@ -4,7 +4,7 @@ import {EgIdlService, EgIdlObject} from './idl'; import {EgNetService, EgNetRequest} from './net'; import {EgAuthService} from './auth'; -// Used for debugging. +// Externally defined. Used here for debugging. declare var js2JSON: (jsThing:any) => string; declare var OpenSRF: any; // creating sessions diff --git a/Open-ILS/eg2-src/src/app/core/store.ts b/Open-ILS/eg2-src/src/app/core/store.ts index fcb83c6675..2b3522b8cd 100644 --- a/Open-ILS/eg2-src/src/app/core/store.ts +++ b/Open-ILS/eg2-src/src/app/core/store.ts @@ -1,9 +1,9 @@ /** * Store and retrieve data from various sources. */ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs/Rx'; -import { CookieService } from 'ngx-cookie'; +import {Injectable} from '@angular/core'; +import {Observable} from 'rxjs/Rx'; +import {CookieService} from 'ngx-cookie'; @Injectable() export class EgStoreService { -- 2.11.0