Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
host key to hex
Browse files Browse the repository at this point in the history
  • Loading branch information
sanasol committed Jun 7, 2018
1 parent 4e0683c commit 13ded82
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 74 deletions.
4 changes: 2 additions & 2 deletions public/mix-manifest.json
@@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.2b7837ba460d8459cddf.js",
"/css/app.css": "/css/app.aa239bbccbbaf3187d3a.css"
"/js/app.js": "/js/app.28b50a6922c2ab5d252d.js",
"/css/app.css": "/css/app.45ac622dd4ec25ad972b.css"
}
114 changes: 42 additions & 72 deletions resources/assets/js/modules/host_view.vue
Expand Up @@ -236,90 +236,57 @@ export default {
this.error = false;
this.loading = true;
axios.get('/api/host/'+this.$route.params.id)
.then((response) => {
this.hostData = response.data;
this.loading = false;
let recommended = axios.get('/api/settings/recommended');
recommended.then((settingsResponse) => {
console.log('recommendedSettings', settingsResponse.data);
axios.get('/api/host/'+this.$route.params.id)
.then((response) => {
let recommendedSettings = settingsResponse.data;
this.hostData = response.data;
for(var i in this.hostData){
if(i === "history") continue;
var formatter = false;
if(i === 'score') {
formatter = function(str, entry){
var scores = JSON.parse(entry.score);
var resp = "";
for(var z in scores){
resp += "<p>"+z+": "+toFixed(scores[z])+"</p>"
}
return resp;
};
}
if(i === 'contractprice' || i === 'maxcollateral') {
formatter = function(str, entry, key){
let recommendation = '';
let recommended = recommendedSettings[key];
if(entry.rank > 50) {
recommendation = ' <sup>You can reach top 50 with '+(Math.round(parseInt(recommended.min)/1e24)) + ' SC</sup>';
}
for(var i in this.hostData){
if(i === "history") continue;
return (Math.round(parseInt(str)/1e24)) + ' SC'+recommendation;
};
}
var formatter = false;
if(i === 'maxdownloadbatchsize' || i === 'maxrevisebatchsize' || i === 'remainingstorage' || i === 'sectorsize' || i === 'totalstorage') {
formatter = function(str, entry){
return humanFileSize(parseInt(str), true);
};
}
if(i === 'storageprice' || i === 'collateral') {
formatter = function(str, entry, key){
let recommendation = '';
let recommended = recommendedSettings[key];
if(entry.rank > 50 && recommended.median != str) {
recommendation = ' <sup>You can reach top 50 with '+(Math.round(parseInt(recommended.median)/1e12*4320)) + ' SC</sup>';
}
if(i == 'score') {
formatter = function(str, entry){
var scores = JSON.parse(entry.score);
var resp = "";
for(var z in scores){
resp += "<p>"+z+": "+toFixed(scores[z])+"</p>"
}
return resp;
};
}
return (Math.round(parseInt(str)/1e12*4320)) + ' SC'+recommendation
};
}
if(i == 'contractprice' || i == 'maxcollateral') {
formatter = function(str, entry){
return (Math.round(parseInt(str)/1e24)) + ' SC';
};
}
if(i === 'downloadbandwidthprice' || i === 'uploadbandwidthprice') {
formatter = function(str, entry, key){
let recommendation = '';
let recommended = recommendedSettings[key];
if(entry.rank > 50 && recommended.median != str) {
recommendation = ' <sup>You can reach top 50 with '+(Math.round(parseInt(recommended.median)/1e12)) + ' SC</sup>';
}
return (Math.round(parseInt(str)/1e12)) + ' SC'+recommendation
};
}
if(i == 'storageprice' || i == 'collateral') {
formatter = function(str, entry){
return (Math.round(parseInt(str)/1e12*4320)) + ' SC'
};
}
this.$set(this.allFields, i, {
type: 'text',
name: i,
key: i,
formatter: formatter
});
if(i == 'downloadbandwidthprice' || i == 'uploadbandwidthprice') {
formatter = function(str, entry){
return (Math.round(parseInt(str)/1e12)) + ' SC'
};
}
this.loading = false;
this.$set(this.allFields, i, {
type: 'text',
name: i,
key: i,
formatter: formatter
});
}
})
.catch((error) => {
this.error = error.response.data;
this.loading = false;
});
});
axios.get('/api/sia/release').then((response) => {
this.releaseData = response.data;
Expand Down Expand Up @@ -374,7 +341,10 @@ export default {
key: {
type: 'text',
name: 'Key',
key: 'key'
key: 'key',
formatter: function(str, entry){
return entry.algorithm+':'+base64toHEX(str);
}
},
host: {
type: 'text',
Expand Down
10 changes: 10 additions & 0 deletions resources/assets/js/utils.js
Expand Up @@ -62,3 +62,13 @@ window.toFixed = function(x) {
}
return x;
};

window.base64toHEX = function(base64) {
var raw = atob(base64);
var HEX = '';
for (var i = 0; i < raw.length; i++ ) {
var _hex = raw.charCodeAt(i).toString(16)
HEX += (_hex.length==2?_hex:'0'+_hex);
}
return HEX;
};

0 comments on commit 13ded82

Please sign in to comment.