|
|
@ -16,12 +16,25 @@ function displayQRPairing() { |
|
|
|
const activeTab = sessionStorage.getItem('activeTab'); |
|
|
|
processAction(activeTab).then( |
|
|
|
function (result) { |
|
|
|
if (!result) {return;} |
|
|
|
const url = window.location.protocol + '//' + window.location.host + conf['api']['baseUri']; |
|
|
|
result['pairing']['url'] = url; |
|
|
|
const textJson = JSON.stringify(result, null, 4); |
|
|
|
$("#qr-pairing").html('') // clear qrcode first
|
|
|
|
$('#qr-pairing').qrcode({width: 256, height: 256, text: textJson}); |
|
|
|
if (result) { |
|
|
|
if (result['api']) { |
|
|
|
const textJson = JSON.stringify(result['api'], null, 4); |
|
|
|
$("#qr-pairing").html('') // clear qrcode first
|
|
|
|
$('#qr-pairing').qrcode({width: 256, height: 256, text: textJson}); |
|
|
|
} |
|
|
|
if (result['explorer'] && result['explorer']['pairing']['url']) { |
|
|
|
const textJson = JSON.stringify(result['explorer'], null, 4); |
|
|
|
$("#qr-explorer-pairing").html('') // clear qrcode first
|
|
|
|
$('#qr-explorer-pairing').qrcode({width: 256, height: 256, text: textJson}); |
|
|
|
} else { |
|
|
|
$("#qr-label").removeClass('halfwidth'); |
|
|
|
$("#qr-label").addClass('fullwidth'); |
|
|
|
$("#qr-container").removeClass('halfwidth'); |
|
|
|
$("#qr-container").addClass('fullwidth'); |
|
|
|
$("#qr-explorer-label").hide(); |
|
|
|
$("#qr-explorer-container").hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
function (jqxhr) {} |
|
|
|
); |
|
|
@ -147,14 +160,34 @@ function preparePage() { |
|
|
|
* Process action (api calls) |
|
|
|
*/ |
|
|
|
function processAction(activeTab, args, args2, args3) { |
|
|
|
if (activeTab == '#link-pairing') |
|
|
|
return lib_api.getPairingInfo(); |
|
|
|
else if (activeTab == '#link-status-api') |
|
|
|
if (activeTab == '#link-pairing') { |
|
|
|
//return lib_api.getPairingInfo();
|
|
|
|
let result = { |
|
|
|
'api': null, |
|
|
|
'explorer': null |
|
|
|
}; |
|
|
|
return lib_api.getPairingInfo().then(apiInfo => { |
|
|
|
if (apiInfo) { |
|
|
|
apiInfo['pairing']['url'] = window.location.protocol + '//' + window.location.host + conf['api']['baseUri']; |
|
|
|
result['api'] = apiInfo; |
|
|
|
} |
|
|
|
}).then(() => { |
|
|
|
return lib_api.getExplorerPairingInfo(); |
|
|
|
}).then(explorerInfo => { |
|
|
|
if (explorerInfo) |
|
|
|
result['explorer'] = explorerInfo; |
|
|
|
return result |
|
|
|
}).catch(e => { |
|
|
|
console.log(e); |
|
|
|
return result; |
|
|
|
}); |
|
|
|
} else if (activeTab == '#link-status-api') { |
|
|
|
return lib_api.getApiStatus(); |
|
|
|
else if (activeTab == '#link-status-pushtx') |
|
|
|
} else if (activeTab == '#link-status-pushtx') { |
|
|
|
return lib_api.getPushtxStatus(); |
|
|
|
else if (activeTab == '#link-orchestrator') |
|
|
|
} else if (activeTab == '#link-orchestrator') { |
|
|
|
return lib_api.getOrchestratorStatus(); |
|
|
|
} |
|
|
|
|
|
|
|
if (args == '') { |
|
|
|
alert('Argument is mandatory'); |
|
|
|