Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Turns off unnecessary lint rules and fixes remaining lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
phantomjinx committed May 26, 2018
1 parent 2d5d360 commit f7f9b9c
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 78 deletions.
22 changes: 14 additions & 8 deletions ngapp/src/app/core/api.service.ts
Expand Up @@ -63,7 +63,7 @@ export abstract class ApiService {
public isXML(xml: string): boolean {
try {
const parser = new X2JS();
const xmlDoc = parser.xml2js(xml); //is valid XML
const xmlDoc = parser.xml2js(xml); // is valid XML
return xmlDoc != null;
} catch (err) {
// was not XML
Expand All @@ -74,20 +74,24 @@ export abstract class ApiService {
public tryXMLParse(xml: string): any {
try {
const parser = new X2JS();
const xmlDoc = parser.xml2js(xml); //is valid XML
const xmlDoc = parser.xml2js(xml); // is valid XML
return xmlDoc;
} catch (err) {}
} catch (err) {
// Do nothing
}

return null;
}

public tryNumberParse(jsonString: string): number {
try {
var n = parseInt(jsonString);
const n = parseInt(jsonString, 10);
if (n && typeof n === "number") {
return n;
}
} catch (e) {}
} catch (e) {
// Do nothing
}

return null;
}
Expand All @@ -96,9 +100,9 @@ export abstract class ApiService {
* Try to parse the given string and if parseable
* then return the object
*/
public tryJsonParse (jsonString: string): any {
public tryJsonParse(jsonString: string): any {
try {
var o = JSON.parse(jsonString);
const o = JSON.parse(jsonString);

// Handle non-exception-throwing cases:
// Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking,
Expand All @@ -107,7 +111,9 @@ export abstract class ApiService {
if (o && typeof o === "object") {
return o;
}
} catch (e) {}
} catch (e) {
// Do nothing
}

return null;
}
Expand Down
2 changes: 0 additions & 2 deletions ngapp/src/app/dataservices/dataservices.component.ts
Expand Up @@ -824,6 +824,4 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
private setOdataServiceName(svcName): void {
this.odataSvcName = svcName;
}


}
11 changes: 9 additions & 2 deletions ngapp/src/app/dataservices/odata-control/odata-constants.ts
@@ -1,3 +1,10 @@
/* tslint:disable:max-line-length */

/*
* TODO
* This file should be ported to a proper i18n translation module
*/

/**
* @license
* Copyright 2017 JBoss Inc
Expand Down Expand Up @@ -58,7 +65,7 @@ export class OdataConstants {
public readonly searchErrorConsoleMsg = "Error: Failed to get value at link: ";
public readonly searchErrorMsg = "Error: failed to get any results: ";
public readonly whereErrorMsg = "The chosen column has a type which cannot be used in a where condition";
public readonly metadataFetchFailure = "Failed to get the odata metadata for the published artifact."
public readonly metadataFetchFailure = "Failed to get the odata metadata for the published artifact.";

public readonly help_endpointSubmit = "This URL is formed using the OData specification. It can be copied into a new browser window to return the results in xml format or append ?format=json to the URL for JSON. Click the Submit button to display the results in a formatted table.";
public readonly help_select = "Choose the view from which results should be sought. Select a limit to curtail the number of results returned ";
Expand All @@ -68,5 +75,5 @@ export class OdataConstants {
public readonly help_format = "Choose the format of the query results.";
public readonly help_resultsTable = "Use the column headers to sort the results or filter them by entering values. Results are paginated in blocks of 25 and can be scrolled through with the controls at the foot of the table.";
public readonly help_resultsRaw = "The raw data as returned from the odata teiid service in json format.";
public readonly help_sqlSearch = "Use the Teiid dialect of SQL to construct a query that interrogates the data service for data results. Use the record limit to limit the number of results returned. Set the starting record index to fetch a subset of results starting at the given row index.";
public readonly help_sqlSearch = "Use the Teiid dialect of SQL to construct a query that interrogates the data service for data results. Use the record limit to limit the number of results returned. Set the starting record index to fetch a subset of results starting at the given row index.";
}
23 changes: 10 additions & 13 deletions ngapp/src/app/dataservices/odata-control/odata-control.component.ts
Expand Up @@ -38,10 +38,9 @@ import { OdataWhere } from "@dataservices/odata-control/odata-where.model";
})
export class OdataControlComponent implements OnChanges {

@Input() dataserviceName: string;

@ViewChild('odataResultsEditor') resultsEditor: any;
@Input() private dataserviceName: string;

@ViewChild('odataResultsEditor') private resultsEditor: any;

private dataserviceService: DataserviceService;
private dataservice: Dataservice;
Expand Down Expand Up @@ -86,7 +85,7 @@ export class OdataControlComponent implements OnChanges {
//
// Format of the results
//
public resultsType: string = "JSON";
public resultsType = "JSON";

//
// Results to show from the odata query
Expand Down Expand Up @@ -121,7 +120,7 @@ export class OdataControlComponent implements OnChanges {
.subscribe(
(response) => {
if (! _.isEmpty(response) && this.dataserviceService.isXML(response.value)) {
let xmlObject = this.dataserviceService.tryXMLParse(response.value);
const xmlObject = this.dataserviceService.tryXMLParse(response.value);
this.odata.metadata = xmlObject;
this.odata.metadataFailure = false;
} else {
Expand Down Expand Up @@ -154,8 +153,8 @@ export class OdataControlComponent implements OnChanges {
return this.i18n.UrlNotAvailable;

const service = this.odata.entity;
if (_.isEmpty(service) || _.isEmpty(service.name))
return this.i18n.UrlNotAvailable;
if (_.isEmpty(service) || _.isEmpty(service.name))
return this.i18n.UrlNotAvailable;

let odataUrl = baseUrl + '/' + service.name;

Expand Down Expand Up @@ -313,12 +312,12 @@ export class OdataControlComponent implements OnChanges {
* * Remove the where condition since it may be invalid
* * Check the column is queryable and if not display an error
*/
public onWhereColumnSelected(where: OdataWhere) {
public onWhereColumnSelected(where: OdataWhere): void {
if (! _.isEmpty(where) && ! _.isEmpty(where.condition))
delete where.condition;

if (! _.isEmpty(where.column)) {
let index = _.indexOf(Odata.QUERYABLE_TYPES, where.column.type);
const index = _.indexOf(Odata.QUERYABLE_TYPES, where.column.type);
if (index < 0)
where.error = this.i18n.whereErrorMsg;
else
Expand Down Expand Up @@ -365,7 +364,7 @@ export class OdataControlComponent implements OnChanges {
* Provides the choices to select for a where clause
* depending on the type of column already selected
*/
public whereConditions(where: OdataWhere) {
public whereConditions(where: OdataWhere): Array<string> {
if (_.isEmpty(where) || _.isEmpty(where.column))
return [];

Expand All @@ -392,13 +391,11 @@ export class OdataControlComponent implements OnChanges {
* Submit the query for evaluation
*/
public submitQuery(): void {
let url = this.endPointUrl;

this.searchMsg = null;
this.searchMsgClasses = [];
this.searchInProgress = true;

this.dataserviceService.odataGet(url)
this.dataserviceService.odataGet(this.endPointUrl)
.subscribe(
(response) => {
this.results = null;
Expand Down
4 changes: 2 additions & 2 deletions ngapp/src/app/dataservices/odata-control/odata-where.model.ts
Expand Up @@ -26,8 +26,8 @@ import { OdataColumn } from "@dataservices/odata-control/odata-column.model";
export class OdataWhere {

private _column: OdataColumn;
private _condition: string = '';
private _value: string = '';
private _condition = '';
private _value = '';

public error: string = null;

Expand Down
47 changes: 25 additions & 22 deletions ngapp/src/app/dataservices/odata-control/odata.model.ts
Expand Up @@ -67,7 +67,7 @@ export class Odata {

private _metadata: any = null;

private _metadataFailure: boolean = false;
private _metadataFailure = false;

private _entities: Array<OdataEntity> = [];

Expand All @@ -92,7 +92,7 @@ export class Odata {
* @returns collection of conditions for int types
*/
public intConditions(): string[] {
const conditions:Array<string> = [ Odata.EQUALS, Odata.NOT_EQUALS, Odata.GREATER_THAN,
const conditions: Array<string> = [ Odata.EQUALS, Odata.NOT_EQUALS, Odata.GREATER_THAN,
Odata.GREATER_THAN_EQ_TO, Odata.LESS_THAN, Odata.LESS_THAN_EQ_TO,
Odata.IN ];
return conditions;
Expand All @@ -102,7 +102,7 @@ export class Odata {
* @returns collection of conditions for string types
*/
public stringConditions(): string[] {
const conditions:Array<string> = [ Odata.EQUALS, Odata.NOT_EQUALS, Odata.IN, Odata.EQUALS_CINS, Odata.NOT_EQUALS_CINS,
const conditions: Array<string> = [ Odata.EQUALS, Odata.NOT_EQUALS, Odata.IN, Odata.EQUALS_CINS, Odata.NOT_EQUALS_CINS,
Odata.STARTS_WITH, Odata.NO_STARTS_WITH, Odata.ENDS_WITH, Odata.NO_ENDS_WITH,
Odata.CONTAINS, Odata.LENGTH_EQ ];
return conditions;
Expand All @@ -112,15 +112,15 @@ export class Odata {
* @returns collection of conditions for date types
*/
public dateConditions(): string[] {
const conditions:Array<string> = [ Odata.EQUALS, Odata.BEFORE_DATE, Odata.AFTER_DATE, Odata.BEFORE_EQ, Odata.AFTER_EQ ];
const conditions: Array<string> = [ Odata.EQUALS, Odata.BEFORE_DATE, Odata.AFTER_DATE, Odata.BEFORE_EQ, Odata.AFTER_EQ ];
return conditions;
}

/**
* @returns collection of conditions for boolean types
*/
public booleanConditions(): string[] {
const conditions:Array<string> = [ Odata.EQUALS, Odata.NOT_EQUALS ];
const conditions: Array<string> = [ Odata.EQUALS, Odata.NOT_EQUALS ];
return conditions;
}

Expand All @@ -142,14 +142,14 @@ export class Odata {

const columns = entity.Property;
if (_.isArray(columns)) {
for (let column of columns) {
let odataColumn = new OdataColumn();
for (const column of columns) {
const odataColumn = new OdataColumn();
odataColumn.name = column._Name;
odataColumn.type = column._Type.replace('Edm.', '');
odataColumns.push(odataColumn);
}
} else if (_.isObject(columns)) {
let singleColumn = new OdataColumn();
const singleColumn = new OdataColumn();
singleColumn.name = columns._Name;
singleColumn.type = columns._Type.replace('Edm.', '');
odataColumns = [singleColumn];
Expand Down Expand Up @@ -181,14 +181,14 @@ export class Odata {

const entityTypes = metadata.Edmx.DataServices.Schema.EntityType;
if (_.isArray(entityTypes)) {
for (let entityType of entityTypes) {
let entity = new OdataEntity();
for (const entityType of entityTypes) {
const entity = new OdataEntity();
entity.name = entityType._Name;
entity.columns = this.extractColumns(entityType);
this._entities.push(entity);
}
} else if (_.isObject(entityTypes)) {
let singleEntity = new OdataEntity();
const singleEntity = new OdataEntity();
singleEntity.name = entityTypes._Name;
singleEntity.columns = this.extractColumns(entityTypes);
this._entities = [singleEntity];
Expand Down Expand Up @@ -262,7 +262,7 @@ export class Odata {
* Is this column with name selected
*/
public hasColumn(columnName: string): boolean {
for (let column of this.columns) {
for (const column of this.columns) {
if (_.isEqual(columnName, column.name))
return true;
}
Expand Down Expand Up @@ -347,7 +347,7 @@ export class Odata {
* Converts the where clauses into odata where clauses
*/
public convertWhere(): string {
if (this._wheres.length == 0)
if (this._wheres.length === 0)
return '';

const SPACE = ' ';
Expand All @@ -356,10 +356,10 @@ export class Odata {
const QUOTE = "'";
const COMMA = ',';

let prefix = '$filter=';
const prefix = '$filter=';
let clauses = '';

for (var i = 0; i < this._wheres.length; ++i) {
for (let i = 0; i < this._wheres.length; ++i) {
const where = this._wheres[i];
const column: OdataColumn = where.column;
const condition: string = where.condition;
Expand Down Expand Up @@ -391,13 +391,15 @@ export class Odata {
clause = 'tolower' + OBKT + column + CBKT +
SPACE + 'eq' + SPACE +
'tolower' + OBKT + QUOTE + value + QUOTE + CBKT;
} else if (condition === Odata.NOT_EQUALS_CINS) {
}
else if (condition === Odata.NOT_EQUALS_CINS) {
//
// tolower(Description) ne tolower('value')
//
clause = 'tolower' + OBKT + column + CBKT + SPACE + 'ne' + SPACE +
'tolower' + OBKT + QUOTE + value + QUOTE + CBKT;
} else if (condition === Odata.STARTS_WITH) {
}
else if (condition === Odata.STARTS_WITH) {
//
// startswith(Description, 'value')
//
Expand Down Expand Up @@ -432,7 +434,8 @@ export class Odata {
// length(Description) eq 5
//
clause = 'length' + OBKT + column.name + CBKT + SPACE + 'eq' + SPACE + value;
} else if (condition === Odata.IN) {
}
else if (condition === Odata.IN) {
//
// in separated by ;, eg. 1;2
// becomes
Expand Down Expand Up @@ -462,7 +465,7 @@ export class Odata {
* Converts the column array into odata select clause
*/
public convertColumns(): string {
if (this._columns.length == 0)
if (this._columns.length === 0)
return '';

//
Expand All @@ -483,10 +486,10 @@ export class Odata {
}

/**
* Converts the order by values into odata orderby clause
*/
* Converts the order by values into odata orderby clause
*/
public convertOrderBy(): string {
if (this._entity.columns.length == 0)
if (this._entity.columns.length === 0)
return '';

//
Expand Down
2 changes: 1 addition & 1 deletion ngapp/src/app/dataservices/shared/dataservice.model.ts
Expand Up @@ -269,7 +269,7 @@ export class Dataservice implements Identifiable< string > {
return null;
}

let route: VirtRoute = this.virtualization.getOdataRoute();
const route: VirtRoute = this.virtualization.getOdataRoute();
if (route == null) {
return null;
}
Expand Down
6 changes: 3 additions & 3 deletions ngapp/src/app/dataservices/shared/dataservice.service.ts
Expand Up @@ -495,9 +495,9 @@ export class DataserviceService extends ApiService {
.get(url, this.getAuthRequestOptions())
.map((response) => {
const data = response.text();
let jobj = this.tryJsonParse(data);
const jobj = this.tryJsonParse(data);
if (_.isObject(jobj)) {
let json = JSON.stringify(jobj, null, 4);
const json = JSON.stringify(jobj, null, 4);
return {
value: json
};
Expand All @@ -520,7 +520,7 @@ export class DataserviceService extends ApiService {
};
}

let n = this.tryNumberParse(data);
const n = this.tryNumberParse(data);
if (n) {
return {
count: n
Expand Down
2 changes: 1 addition & 1 deletion ngapp/src/app/dataservices/shared/virt-route.model.ts
Expand Up @@ -108,6 +108,6 @@ export class VirtRoute {
* Is this an odata route
*/
public isOdata(): boolean {
return this.getProtocol() == VirtRoute.ODATA_PROTOCOL;
return this.getProtocol() === VirtRoute.ODATA_PROTOCOL;
}
}

0 comments on commit f7f9b9c

Please sign in to comment.