Skip to content

Commit

Permalink
Renamed files postConsumer restApiPost restGetFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikoteko committed Dec 18, 2023
1 parent 1599129 commit 9de661d
Show file tree
Hide file tree
Showing 16 changed files with 715 additions and 25 deletions.
9 changes: 6 additions & 3 deletions engine/services/technicalComponentDirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = {
cacheNosql: require('../workspaceComponentExecutor/cacheNosql.js'),
gouvFrInverseGeo: require('../workspaceComponentExecutor/gouvFrInverseGeo.js'),
restApiGet: require('../workspaceComponentExecutor/restApiGet.js'),
restApiPost: require('../workspaceComponentExecutor/restApiPost.js'),
restApiPost: require('../workspaceComponentExecutor/httpProvider.js'),
httpProvider: require('../workspaceComponentExecutor/httpProvider.js'),
// xmlToObject: require('./workspaceComponentExecutor/xmlToObject.js'),
framcalcGetCsv: require('../workspaceComponentExecutor/framcalcGetCsv.js'),
gouvFrGeoLocaliser: require('../workspaceComponentExecutor/gouvFrGeoLocaliser.js'),
Expand All @@ -22,7 +23,8 @@ module.exports = {
filter: require('../workspaceComponentExecutor/filter.js'),
upload: require('../workspaceComponentExecutor/upload.js'),
scrapper: require('../workspaceComponentExecutor/scrapper/scrapper.js'),
httpGet: require('../workspaceComponentExecutor/restGetFile.js'),
httpGet: require('../workspaceComponentExecutor/httpConsumerFile.js'),
httpConsumerFile: require('../workspaceComponentExecutor/httpConsumerFile.js'),
sqlConnector: require('../workspaceComponentExecutor/sqlConnecteur.js'),
mongoConnector: require('../workspaceComponentExecutor/MongoDB.js'),
influxdbConnector: require('../workspaceComponentExecutor/influxdb.js'),
Expand All @@ -33,7 +35,8 @@ module.exports = {
valueFromPath: require('../workspaceComponentExecutor/valueFromPath.js'),
unicity: require('../workspaceComponentExecutor/unicity.js'),
propertiesMatrix: require('../workspaceComponentExecutor/propertiesMatrix.js'),
postConsumer: require('../workspaceComponentExecutor/postConsumer.js'),
postConsumer: require('../workspaceComponentExecutor/httpConsumer.js'),
httpConsumer: require('../workspaceComponentExecutor/httpConsumer.js'),
keyToArray: require('../workspaceComponentExecutor/keyToArray.js'),
sftpConsumer: require('../workspaceComponentExecutor/sftpConsumer.js'),
flat: require('../workspaceComponentExecutor/flat.js'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const https = require('https');
const fileLib = require('../../core/lib/file_lib.js')

class PostConsumer {
class HttpConsumer {
constructor () {
this.fetch = require('node-fetch');
this.stringReplacer = require('../utils/stringReplacer.js');
Expand Down Expand Up @@ -298,4 +298,4 @@ class PostConsumer {
}
}

module.exports = new PostConsumer()
module.exports = new HttpConsumer()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
class HttpGet {
class HttpConsumerFile {
constructor () {
this.url = require('url')
this.http = require('http')
Expand Down Expand Up @@ -68,4 +68,4 @@ class HttpGet {
return this.makeRequest('GET', data.specificData.url, data.specificData.contentType,flowdata, pullParams)
}
}
module.exports = new HttpGet()
module.exports = new HttpConsumerFile()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
class RestApiPost {
class HttpProvider {
constructor () {
this.stepNode = false
this.workspace_component_lib = require('../../core/lib/workspace_component_lib')
Expand All @@ -22,4 +22,4 @@ class RestApiPost {
}
}

module.exports = new RestApiPost()
module.exports = new HttpProvider()
3 changes: 3 additions & 0 deletions main/client/static/application.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,17 @@
<script type="riot/tag" src="tag/editorComponents/cache/cache-nosql-editor.tag"></script>

<script type="riot/tag" src="tag/editorComponents/dataFlow/rest-api-get-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/dataFlow/http-provider-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/dataFlow/rest-get-json-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/dataFlow/framacalc-get-csv-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/dataFlow/google-get-json-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/dataFlow/rest-api-post-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/dataFlow/http-consumer-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/dataFlow/post-consumer-editor.tag"></script>

<script type="riot/tag" src="tag/editorComponents/files/upload-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/files/rest-get-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/files/http-consumer-file-editor.tag"></script>
<script type="riot/tag" src="tag/editorComponents/files/sftp-consumer-editor.tag"></script>

<script type="riot/tag" src="tag/editorComponents/geocodage/google-geolocaliser-editor.tag"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<http-consumer-editor>
<!-- bouton aide -->
<div class="contenaireH" style="margin-left:97%">
<a href="https://github.com/assemblee-virtuelle/Semantic-Bus/wiki/Composant:-HTTP-Consumer" target="_blank"><img src="./image/help.png" alt="Aide" width="25px" height="25px"></a>
</div>
<div class="contenaireV title-component">{data.type}</div>
<div>
<div class="bar"/>
</div>
<!-- Description du composant -->
<div class="title-description-component">{data.description}</div>
<!-- Champ du composant -->
<div>
<div class="bar"/>
</div>

<label class="labelFormStandard">URL externe où envoyer les données:</label>
<div class="cardInput">
<input class="inputComponents" placeholder="" type="text" name="urlInput" ref="urlInput" onChange={urlInputChanged} value={data.specificData.url}></input>
</div>
<div class="options">
<label class="labelFormStandard">corp de requête vide :</label>
<div class="cardInput">
<label class="switch">
<input type="checkbox" name="noBodyInput" ref="noBodyInput" checked={data.specificData.noBody} onchange={noBodyChange}/>
<span class="slider round"></span>
</label>
</div>
</div>
<label class="labelFormStandard" ref="typeLabel">Content-type:</label>
<div class="cardInput" ref="typeInput">
<input class="inputComponents" placeholder="application/json" type="text" name="contentTypeInput" ref="contentTypeInput" onChange={contentTypeInputChanged} value={data.specificData.contentType}></input>
</div>
<label class="labelFormStandard" ref="methodLabel">Methode:</label>
<div class="cardInput" ref="methodInput">
<select class="inputComponents" name="methodInput" ref="methodeInput" onchange={methodInputChanged}>
<option value="GET" selected={data.specificData.method==='GET' || data.specificData.method===undefined}>GET</option>
<option value="POST" selected={data.specificData.method==='POST'}>POST</option>
<option value="PATCH" selected={data.specificData.method==='PATCH'}>PATCH</option>
<option value="PUT" selected={data.specificData.method==='PUT'}>PUT</option>
<option value="DELETE" selected={data.specificData.method==='DELETE'}>DELETE</option>
</select>
</div>
<label class="labelFormStandard">Temps de réponse accordé (TimeOut):</label>
<div class="cardInput">
<input class="inputComponents" placeholder="20" type="text" name="timeoutInput" ref="timeoutInput" onChange={timeoutInputChanged} value={data.specificData.timeout}></input>
</div>
<label class="labelFormStandard">nombre de tentatives:</label>
<div class="cardInput">
<input class="inputComponents" placeholder="1" type="text" name="retryInput" ref="retryInput" onChange={retryInputChanged} value={data.specificData.retry}></input>
</div>


<label class="labelFormStandard">Content-type de réponse forcé:</label>
<div class="cardInput">
<input class="inputComponents" placeholder="" type="text" ref="overidedContentTypeInput" value={data.specificData.overidedContentType} onchange={overidedContentTypeInputChange}></input>
</div>

<label class="labelFormStandard">certificat pfx (doit être une propriété faisant reference à un fichier interne uploadé ex:_file)</label>
<div class="cardInput">
<input class="inputComponents" placeholder="" type="text" ref="certificatePropertyInput" value={data.specificData.certificateProperty} onchange={certificatePropertyInputChange}></input>
</div>
<label class="labelFormStandard">passphrase pfx</label>
<div class="cardInput">
<input class="inputComponents" placeholder="" type="text" ref="certificatePassphraseInput" value={data.specificData.certificatePassphrase} onchange={certificatePassphraseInputChange}></input>
</div>

<label class="labelFormStandard">Header</label>
<div class="cardInput">
<div onclick={addRowClick} class="btnFil commandButtonImage">
Ajouter
<img class="imgFil" src="./image/ajout_composant.svg" title="Importer un Workflow">
<input onchange={import} ref="import" type="file" style="display:none;"/>
</div>
</div>
<zentable ref="headerTable" title="header de la requete" allowdirectedit={true} disallowselect={true} disallownavigation={true}>
<yield to="row">
<input placeholder="Clé" type="text" style="flex-basis:50%; margin: 5px" value={key} data-field="key"/>
<input placeholder="Valeur" type="text" style="flex-basis:50%; margin: 5px" value={value} data-field="value"/>
</yield>
</zentable>

<script>
this.data = {};
urlInputChanged = e => {
this.data.specificData.url = e.currentTarget.value;
};

timeoutInputChanged = e => {
this.data.specificData.timeout = e.currentTarget.value;
};

retryInputChanged = e => {
this.data.specificData.retry = e.currentTarget.value;
};

methodInputChanged(e) {
this.data.specificData.method = e.currentTarget.value;
}

contentTypeInputChanged = e => {
this.data.specificData.contentType = e.currentTarget.value;
};

noBodyChange(event){
this.data.specificData.noBody = event.target.checked;
this.methodInputVisibility();
}

overidedContentTypeInputChange = function (e) {
this.data.specificData.overidedContentType = e.target.value;
}

certificatePropertyInputChange = function (e) {
this.data.specificData.certificateProperty = e.target.value;
}

certificatePassphraseInputChange = function (e) {
this.data.specificData.certificatePassphrase = e.target.value;
}

this.addRowClick = function (e) {
this.refs.headerTable.data.push({})
}

methodInputVisibility(specificData){
if(this.data.specificData.noBody!=true){
this.refs.typeInput.classList.remove("hide");
this.refs.typeLabel.classList.remove("hide");
}else{
this.refs.typeInput.classList.add("hide");
this.refs.typeLabel.classList.add("hide");
}
}

this.profilCertificatesChanged = function (certificates) {
this.refs.certificates.data = certificates;
this.update();
}.bind(this);


this.updateData = dataToUpdate => {
this.data = dataToUpdate;
this.refs.headerTable.data = this.data.specificData.headers || [];
this.methodInputVisibility();
this.update();
};
this.on('mount', function () {
this.refs.headerTable.on('dataChanged', data => {
this.data.specificData.headers = data;
});
this.refs.headerTable.on('delRow', row => {
this.refs.headerTable.data.splice(row.rowid, 1);
});
RiotControl.on('item_current_changed', this.updateData);
RiotControl.on('profil_certificates_changed', this.profilCertificatesChanged);
RiotControl.trigger('profil_get_certificates')
});
this.on('unmount', function () {
RiotControl.off('item_current_changed', this.updateData);
});
</script>
<style>
.hide {
display: none;
}
</style>
</http-consumer-editor>
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<http-provider-editor>
<!-- bouton aide -->
<div class="contenaireH" style="margin-left:97%">
<a href="https://github.com/assemblee-virtuelle/Semantic-Bus/wiki/Composant:-HTTP-Provider" target="_blank"><img src="./image/help.png" alt="Aide" width="25px" height="25px"></a>
</div>
<!-- Titre du composant -->
<div class="contenaireV title-component">{data.type}</div>
<div>
<div class="bar"/>
</div>
<!-- Description du composant -->
<div class="title-description-component">{data.description}</div>
<div>
<div class="bar"/>
</div>
<!-- Champ du composant -->
<label class="labelFormStandard">Clé de l'API:</label>
<div class="cardInput cardInputApiId">
<div class="idApi">{data._id}-</div>
<input class="inputComponents inputApiId" placeholder="" type="text" name="urlInput" ref="urlInput" onChange={urlInputChanged} value={data.specificData.urlName}></input>
</div>
<label class="labelFormStandard">URL de l'API:</label>
<div class="cardInput">
<a class="linkApi" ref="link" target="_blank" href={window.location.origin +'/data/api/'+data.specificData.url}>{window.location.origin +'/data/api/'+data.specificData.url}</a>
</div>
<label class="labelFormStandard">Content-type:</label>
<div class="cardInput">
<select class="inputComponents" name="contentTypeInput" ref="contentTypeInput" onchange={contentTypeInputChanged}>
<option value="application/json" selected={data.specificData.contentType==='application/json' || data.specificData.contentType===undefined}>application/json</option>
<option value="application/ld+json" selected={data.specificData.contentType==='application/ld+json'}>application/ld+json</option>
<option value="application/xml" selected={data.specificData.contentType==='application/xml'}>application/xml</option>
<option value="application/x-yaml" selected={data.specificData.contentType==='application/x-yaml'}>application/x-yaml</option>
<option value="application/vnd.ms-excel" selected={data.specificData.contentType==='application/vnd.ms-excel'}>application/vnd.ms-excel</option>
<option value="application/rdf+xml" selected={data.specificData.contentType==='application/rdf+xml'}>application/rdf+xml</option>
</select>
</div>
<label class="labelFormStandard">Composant qui contient le flux principal:</label>
<div class="cardInput">
<select class="inputComponents" name="responseComponentIdInput" ref="responseComponentIdInput" onchange={responseComponentIdInputChanged}>
<option value="undefined">non-défini</option>
<option each={option in components} value={option._id} selected={parent.data.specificData.responseComponentId ==option._id}>{option.type} : {option.name}</option>
</select>
</div>
<!--<label>Sortie en xls (Boolean)</label> <input type="text" name="xlsInput" ref="xlsInput"value={data.specificData.xls}></input>-->
<script>

this.data = {};
this.test = function () {
consol.log('test');
}

// Object.defineProperty(this, 'data', { set: function (data) { this.data=data; this.update(); }.bind(this), get: function () { return this.data; }, configurable: true });

urlInputChanged(e) {
console.log(e.currentTarget.value);
this.data.specificData.urlName = e.currentTarget.value;
this.data.specificData.url=this.data._id + '-'+this.data.specificData.urlName;
}

contentTypeInputChanged = e => {
this.data.specificData.contentType = e.currentTarget.value;
};


responseComponentIdInputChanged(e){
console.log(e.currentTarget.value);
this.data.specificData.responseComponentId = e.currentTarget.value;
}
contentTypeInputChanged(e) {
this.data.specificData.contentType = e.currentTarget.value;
}
this.updateData = function (dataToUpdate) {
this.data = dataToUpdate;
this.update();
}.bind(this);
$
this.updateWorkspace = (workspace) =>{
this.components = workspace.components;
}

this.on('mount', function () {
// this.refs.secondaryFlowIdInput.addEventListener('change', function (e) {
// this.data.specificData.secondaryFlowId = e.currentTarget.value;
// }.bind(this));

RiotControl.on('item_current_changed', this.updateData);
RiotControl.on('workspace_current_changed', this.updateWorkspace);
RiotControl.trigger('workspace_current_refresh');

});
this.on('unmount', function () {
RiotControl.off('item_current_changed', this.updateData);
RiotControl.off('item_current_changed', this.updateData);
RiotControl.off('workspace_current_changed', this.updateWorkspace);

});
</script>
<style>
/* a {
color: blue;
}
a:active {
color: blue;
}

a:visited {
color: blue;
}

a:hover {
color: blue;
} */

.cardInputApiId {
position: relative;
align-items: center;
justify-content: flex-start;
display: flex;
}
.inputApiId {
padding-left: 250px;
}
.idApi{
position: absolute;
padding-left: 1vw;
top: 1.4vh;
font-style: italic;
color: rgb(212,212,212);
}
.linkApi{
color:rgb(180,180,180);
}
</style>
</http-provider-editor>
Loading

0 comments on commit 9de661d

Please sign in to comment.