Répercussion changement de noms entre classe et interface RemoteSource/RemoteSources.
This commit is contained in:
parent
879ef17fe2
commit
75c9179902
@ -6,7 +6,6 @@ const initialise = async () =>
|
|||||||
{
|
{
|
||||||
// Création d'un convertisseur parsant des données transmises en HTML
|
// Création d'un convertisseur parsant des données transmises en HTML
|
||||||
let converter=new FreeDatas2HTML("HTML");
|
let converter=new FreeDatas2HTML("HTML");
|
||||||
// converter.parser.setRemoteSource({ url: "http://localhost:8080/datas/posts.json", withCredentials:true, headers: [{ key:"Authorization", value:"Token YWxhZGRpbjpvcGVuc2VzYW1l" }] });
|
|
||||||
converter.datasViewElt={ id:"datas" };
|
converter.datasViewElt={ id:"datas" };
|
||||||
await converter.run();
|
await converter.run();
|
||||||
// Adaptation du rendu suivant la taille de l'écran
|
// Adaptation du rendu suivant la taille de l'écran
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const { compare }=require('natural-orderby');
|
const { compare }=require('natural-orderby');
|
||||||
const errors=require("./errors.js");
|
const errors=require("./errors.js");
|
||||||
|
|
||||||
import { Counter, Datas, DatasRenders, DOMElement, Paginations, Parsers, ParseErrors, RemoteSource, Selectors, SortingFields, SortingFunctions } from "./freeDatas2HTMLInterfaces";
|
import { Counter, Datas, DatasRenders, DOMElement, Paginations, Parsers, ParseErrors, RemoteSources, Selectors, SortingFields, SortingFunctions } from "./freeDatas2HTMLInterfaces";
|
||||||
import { Pagination} from "./freeDatas2HTMLPagination";
|
import { Pagination} from "./freeDatas2HTMLPagination";
|
||||||
import { ParserForCSV} from "./freeDatas2HTMLParserForCSV";
|
import { ParserForCSV} from "./freeDatas2HTMLParserForCSV";
|
||||||
import { ParserForHTML} from "./freeDatas2HTMLParserForHTML";
|
import { ParserForHTML} from "./freeDatas2HTMLParserForHTML";
|
||||||
@ -20,12 +20,7 @@ export class FreeDatas2HTML
|
|||||||
public datasHTML: string = "";
|
public datasHTML: string = "";
|
||||||
// Le parseur :
|
// Le parseur :
|
||||||
public parser: Parsers; // public pour permettre de charger un parseur tiers après instanciation
|
public parser: Parsers; // public pour permettre de charger un parseur tiers après instanciation
|
||||||
|
// Type de données à traiter
|
||||||
// Données distantes :
|
|
||||||
//private _datasRemoteSource: RemoteSource|undefined=undefined;
|
|
||||||
// Ou locales :
|
|
||||||
//private _datas2Parse:string|undefined=undefined;
|
|
||||||
// Dans tous les cas, besoin d'un type :
|
|
||||||
public datasType: "CSV"|"HTML"|"JSON"|undefined;
|
public datasType: "CSV"|"HTML"|"JSON"|undefined;
|
||||||
|
|
||||||
// Le nom des champs trouvés dans les données :
|
// Le nom des champs trouvés dans les données :
|
||||||
@ -53,7 +48,7 @@ export class FreeDatas2HTML
|
|||||||
// J'initialiser avec des valeurs par défaut pouvant être surchargées par les setters
|
// J'initialiser avec des valeurs par défaut pouvant être surchargées par les setters
|
||||||
// Attention, si je transmets datasRemoteSource ici, il ne passera pas par un new RemoteSources()
|
// Attention, si je transmets datasRemoteSource ici, il ne passera pas par un new RemoteSources()
|
||||||
// Il doit donc déjà avoir été testé
|
// Il doit donc déjà avoir été testé
|
||||||
constructor(datasType:"CSV"|"HTML"|"JSON", datas2Parse="", datasRemoteSource?:RemoteSource)
|
constructor(datasType:"CSV"|"HTML"|"JSON", datas2Parse="", datasRemoteSource?:RemoteSources)
|
||||||
{
|
{
|
||||||
this.datasRender=new Render(this);
|
this.datasRender=new Render(this);
|
||||||
switch (datasType)
|
switch (datasType)
|
||||||
|
@ -65,7 +65,7 @@ export interface ParseResults
|
|||||||
}
|
}
|
||||||
export interface Parsers
|
export interface Parsers
|
||||||
{
|
{
|
||||||
datasRemoteSource: RemoteSource;
|
datasRemoteSource: RemoteSources;
|
||||||
setRemoteSource(settings : RemoteSourceSettings): void;
|
setRemoteSource(settings : RemoteSourceSettings): void;
|
||||||
datas2Parse?: string;
|
datas2Parse?: string;
|
||||||
document2Parse?: HTMLDocument;
|
document2Parse?: HTMLDocument;
|
||||||
@ -78,7 +78,7 @@ export interface RemoteSourceSettings
|
|||||||
headers?: { key:string, value:string }[];
|
headers?: { key:string, value:string }[];
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
}
|
}
|
||||||
export interface RemoteSource extends RemoteSourceSettings
|
export interface RemoteSources extends RemoteSourceSettings
|
||||||
{
|
{
|
||||||
getFetchSettings() : {};
|
getFetchSettings() : {};
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
const Papa = require("papaparse");
|
const Papa=require("papaparse");
|
||||||
const errors = require("./errors.js");
|
const errors= require("./errors.js");
|
||||||
import { RemoteSources } from "./freeDatas2HTMLRemoteSources";
|
import { RemoteSource } from "./freeDatas2HTMLRemoteSource";
|
||||||
|
|
||||||
import { ParseResults, Parsers, RemoteSource, RemoteSourceSettings } from "./freeDatas2HTMLInterfaces";
|
import { ParseResults, Parsers, RemoteSources, RemoteSourceSettings } from "./freeDatas2HTMLInterfaces";
|
||||||
interface PapaParseOptions
|
|
||||||
|
// Options de Papa Parse
|
||||||
|
// cf. https://www.papaparse.com/docs#config
|
||||||
|
interface PublicPapaParseOptions
|
||||||
{
|
{
|
||||||
delimiter: string;
|
delimiter: string;
|
||||||
newline: string;
|
newline: string;
|
||||||
@ -11,28 +14,25 @@ interface PapaParseOptions
|
|||||||
escapeChar: string;
|
escapeChar: string;
|
||||||
transformHeader?(field: string, index: number): string;
|
transformHeader?(field: string, index: number): string;
|
||||||
preview: number;
|
preview: number;
|
||||||
comments: false|string,
|
comments: false|string;
|
||||||
fastMode: boolean|undefined;
|
fastMode: boolean|undefined;
|
||||||
transform?(value: string): string;
|
transform?(value: string): string;
|
||||||
}
|
}
|
||||||
interface PrivatePapaParseOptions
|
interface PrivatePapaParseOptions
|
||||||
{
|
{
|
||||||
header: boolean; // nécessaire pour obtenir le nom des champs
|
header: boolean;
|
||||||
download: boolean;
|
download: boolean;
|
||||||
downloadRequestHeaders: undefined| { [index: string]:string|boolean|number } ;
|
downloadRequestHeaders: undefined| { [index: string]:string };
|
||||||
skipEmptyLines: string;
|
skipEmptyLines: string;
|
||||||
withCredentials: boolean|undefined;
|
withCredentials: boolean|undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ParserForCSV implements Parsers
|
export class ParserForCSV implements Parsers
|
||||||
{
|
{
|
||||||
private _datasRemoteSource: RemoteSource;
|
private _datasRemoteSource: RemoteSources;
|
||||||
private _datas2Parse:string="";
|
private _datas2Parse:string="";
|
||||||
private _parseResults:ParseResults|undefined=undefined;
|
private _parseResults:ParseResults|undefined=undefined;
|
||||||
|
public options: PublicPapaParseOptions =
|
||||||
// Ouverture de certaines options de Papa Parse :
|
|
||||||
// cf. https://www.papaparse.com/docs#config
|
|
||||||
public options: PapaParseOptions =
|
|
||||||
{
|
{
|
||||||
delimiter: "",
|
delimiter: "",
|
||||||
newline: "",
|
newline: "",
|
||||||
@ -55,20 +55,20 @@ export class ParserForCSV implements Parsers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// L'instance d'une autre classe que RemoteSource peut être passée au constructeur
|
// L'instance d'une autre classe que RemoteSource peut être passée au constructeur
|
||||||
constructor(datasRemoteSource?: RemoteSource)
|
constructor(datasRemoteSource?: RemoteSources)
|
||||||
{
|
{
|
||||||
if(datasRemoteSource !== undefined)
|
if(datasRemoteSource !== undefined)
|
||||||
this._datasRemoteSource=datasRemoteSource;
|
this._datasRemoteSource=datasRemoteSource;
|
||||||
else
|
else
|
||||||
this._datasRemoteSource=new RemoteSources({ url:"" });
|
this._datasRemoteSource=new RemoteSource({ url:"" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public setRemoteSource(source: RemoteSourceSettings)
|
public setRemoteSource(source: RemoteSourceSettings)
|
||||||
{
|
{
|
||||||
this._datasRemoteSource=new RemoteSources(source);
|
this._datasRemoteSource=new RemoteSource(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
get datasRemoteSource() : RemoteSource
|
get datasRemoteSource() : RemoteSources
|
||||||
{
|
{
|
||||||
return this._datasRemoteSource;
|
return this._datasRemoteSource;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
const errors=require("./errors.js");
|
const errors=require("./errors.js");
|
||||||
import { ParseErrors, ParseResults, Parsers, RemoteSource, RemoteSourceSettings } from "./freeDatas2HTMLInterfaces";
|
import { ParseErrors, ParseResults, Parsers, RemoteSources, RemoteSourceSettings } from "./freeDatas2HTMLInterfaces";
|
||||||
import { RemoteSources } from "./freeDatas2HTMLRemoteSources";
|
import { RemoteSource } from "./freeDatas2HTMLRemoteSource";
|
||||||
|
|
||||||
export class ParserForHTML implements Parsers
|
export class ParserForHTML implements Parsers
|
||||||
{
|
{
|
||||||
private _datasRemoteSource: RemoteSource;
|
private _datasRemoteSource: RemoteSources;
|
||||||
private _document2Parse: HTMLDocument=document;
|
private _document2Parse: HTMLDocument=document;
|
||||||
private _parseResults: ParseResults|undefined=undefined;
|
private _parseResults: ParseResults|undefined=undefined;
|
||||||
private _fieldsSelector: string="table > thead > tr > th";
|
private _fieldsSelector: string="table > thead > tr > th";
|
||||||
@ -12,20 +12,20 @@ export class ParserForHTML implements Parsers
|
|||||||
private _datasSelector: string="tr > td";
|
private _datasSelector: string="tr > td";
|
||||||
|
|
||||||
// L'instance d'une autre classe que RemoteSource peut être passée au constructeur
|
// L'instance d'une autre classe que RemoteSource peut être passée au constructeur
|
||||||
constructor(datasRemoteSource?: RemoteSource)
|
constructor(datasRemoteSource?: RemoteSources)
|
||||||
{
|
{
|
||||||
if(datasRemoteSource !== undefined)
|
if(datasRemoteSource !== undefined)
|
||||||
this._datasRemoteSource=datasRemoteSource;
|
this._datasRemoteSource=datasRemoteSource;
|
||||||
else
|
else
|
||||||
this._datasRemoteSource=new RemoteSources({ url:"" });
|
this._datasRemoteSource=new RemoteSource({ url:"" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public setRemoteSource(source: RemoteSourceSettings)
|
public setRemoteSource(source: RemoteSourceSettings)
|
||||||
{
|
{
|
||||||
this._datasRemoteSource=new RemoteSources(source);
|
this._datasRemoteSource=new RemoteSource(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
get datasRemoteSource() : RemoteSource
|
get datasRemoteSource() : RemoteSources
|
||||||
{
|
{
|
||||||
return this._datasRemoteSource;
|
return this._datasRemoteSource;
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
const errors = require("./errors.js");
|
const errors = require("./errors.js");
|
||||||
import { RemoteSources } from "./freeDatas2HTMLRemoteSources";
|
import { RemoteSource } from "./freeDatas2HTMLRemoteSource";
|
||||||
|
|
||||||
import { ParseErrors, ParseResults, Parsers, RemoteSource, RemoteSourceSettings } from "./freeDatas2HTMLInterfaces";
|
import { ParseErrors, ParseResults, Parsers, RemoteSources, RemoteSourceSettings } from "./freeDatas2HTMLInterfaces";
|
||||||
|
|
||||||
export class ParserForJSON implements Parsers
|
export class ParserForJSON implements Parsers
|
||||||
{
|
{
|
||||||
private _datasRemoteSource: RemoteSource;
|
private _datasRemoteSource: RemoteSources;
|
||||||
private _datas2Parse: string="";
|
private _datas2Parse: string="";
|
||||||
private _parseResults: ParseResults|undefined=undefined;
|
private _parseResults: ParseResults|undefined=undefined;
|
||||||
|
|
||||||
// L'instance d'une autre classe que RemoteSource peut être passée au constructeur
|
// L'instance d'une autre classe que RemoteSource peut être passée au constructeur
|
||||||
constructor(datasRemoteSource?: RemoteSource)
|
constructor(datasRemoteSource?: RemoteSources)
|
||||||
{
|
{
|
||||||
if(datasRemoteSource !== undefined)
|
if(datasRemoteSource !== undefined)
|
||||||
this._datasRemoteSource=datasRemoteSource;
|
this._datasRemoteSource=datasRemoteSource;
|
||||||
else
|
else
|
||||||
this._datasRemoteSource=new RemoteSources({ url:"" });
|
this._datasRemoteSource=new RemoteSource({ url:"" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public setRemoteSource(source: RemoteSourceSettings)
|
public setRemoteSource(source: RemoteSourceSettings)
|
||||||
{
|
{
|
||||||
this._datasRemoteSource=new RemoteSources(source);
|
this._datasRemoteSource=new RemoteSource(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
get datasRemoteSource() : RemoteSource
|
get datasRemoteSource() : RemoteSources
|
||||||
{
|
{
|
||||||
return this._datasRemoteSource;
|
return this._datasRemoteSource;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const Papa = require("papaparse");
|
const Papa = require("papaparse");
|
||||||
import { RemoteSource, RemoteSourceSettings } from "../src/freeDatas2HTMLInterfaces";
|
import { RemoteSourceSettings } from "../src/freeDatas2HTMLInterfaces";
|
||||||
import { ParserForCSV as Parser } from "../src/freeDatas2HTMLParserForCSV";
|
import { ParserForCSV as Parser } from "../src/freeDatas2HTMLParserForCSV";
|
||||||
const errors=require("../src/errors.js");
|
const errors=require("../src/errors.js");
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { RemoteSource } from "../src/freeDatas2HTMLInterfaces";
|
|
||||||
import { ParserForHTML as Parser } from "../src/freeDatas2HTMLParserForHTML";
|
import { ParserForHTML as Parser } from "../src/freeDatas2HTMLParserForHTML";
|
||||||
const errors=require("../src/errors.js");
|
const errors=require("../src/errors.js");
|
||||||
const fixtures=require("./fixtures.js");
|
const fixtures=require("./fixtures.js");
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { RemoteSource } from "../src/freeDatas2HTMLInterfaces";
|
|
||||||
import { ParserForJSON as Parser } from "../src/freeDatas2HTMLParserForJSON";
|
import { ParserForJSON as Parser } from "../src/freeDatas2HTMLParserForJSON";
|
||||||
const errors=require("../src/errors.js");
|
const errors=require("../src/errors.js");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user