({
|
CallBackAction : function(component,action_name,para,callback) {
|
var action = component.get("c." + action_name.trimStart().replace("c.",""));
|
if(para){
|
action.setParams(para);
|
}
|
if(callback){
|
action.setCallback(this,function(data){
|
callback(data);
|
});
|
}
|
|
$A.enqueueAction(action);
|
},
|
ShowToast : function(paras){
|
var toastEvent = $A.get("e.force:showToast");
|
toastEvent.setParams(paras);
|
toastEvent.fire();
|
},
|
AwsPost : function(postURL, data ,callback,token){
|
let payloadForNewPI = '';
|
if(typeof(data) == 'string'){
|
payloadForNewPI = data;
|
}else{
|
payloadForNewPI = JSON.stringify(data);
|
}
|
|
fetch(postURL, {
|
method: 'POST',
|
body: payloadForNewPI,
|
headers: {
|
'Content-Type': 'application/json',
|
'pi-token': token
|
}
|
}).then((data) => {
|
console.log('data=' + JSON.stringify(data));
|
return data.json();
|
}).then((result) => {
|
//this.insertCalloutLog(this.insertModule,postURL,JSON.stringify(payloadForNewPI),JSON.stringify(result),this.successStatus);
|
if(callback) callback(result);
|
}).catch(error => {
|
console.log('error');
|
//this.insertCalloutLog(this.insertModule,postURL,JSON.stringify(payloadForNewPI),JSON.stringify(error),this.failStatus);
|
console.log(error);
|
});
|
},
|
AwsGet : function(url, data ,callback,token){
|
|
if(typeof(data) == 'string'){
|
url += data;
|
}else{
|
let i = 0;
|
for(let p in data){
|
url += (i++) ? '&' : '?';
|
url += p + '=' + data[p];
|
}
|
}
|
|
fetch(url, {
|
method: 'GET',
|
headers: {
|
'Content-Type': 'application/json',
|
'pi-token': token
|
}
|
}).then((data) => {
|
console.log('data=' + JSON.stringify(data));
|
return data.json();
|
}).then((result) => {
|
//this.insertCalloutLog(this.insertModule,postURL,JSON.stringify(payloadForNewPI),JSON.stringify(result),this.successStatus);
|
if(callback) callback(result);
|
}).catch(error => {
|
console.log('error');
|
//this.insertCalloutLog(this.insertModule,postURL,JSON.stringify(payloadForNewPI),JSON.stringify(error),this.failStatus);
|
console.log(error);
|
});
|
}
|
})
|