Skip to content
Snippets Groups Projects
Commit 48a38769 authored by capossele's avatar capossele
Browse files

:construction: WIP

parent 4a4c5a22
Branches
No related tags found
No related merge requests found
......@@ -5,7 +5,6 @@ import (
analysisclient "github.com/iotaledger/goshimmer/plugins/analysis/client"
analysisdashboard "github.com/iotaledger/goshimmer/plugins/analysis/dashboard"
analysisserver "github.com/iotaledger/goshimmer/plugins/analysis/server"
analysiswebinterface "github.com/iotaledger/goshimmer/plugins/analysis/webinterface"
"github.com/iotaledger/goshimmer/plugins/remotelog"
"github.com/iotaledger/hive.go/node"
)
......@@ -14,7 +13,6 @@ var PLUGINS = node.Plugins(
remotelog.Plugin,
analysisserver.Plugin,
analysisclient.Plugin,
analysiswebinterface.Plugin,
fpctest.App,
analysisdashboard.Plugin,
)
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -10,15 +10,6 @@ export class Node {
opinion: number = 0;
}
export function LightenDarkenColor(col, amt) {
var num = parseInt(col, 16);
var r = (num >> 16) + amt;
var b = ((num >> 8) & 0x00FF) + amt;
var g = (num & 0x0000FF) + amt;
var newColor = g | (b << 8) | (r << 16);
return newColor.toString(16);
}
function SetColor(opinion) {
if (opinion == Opinion.Dislike) {
return "#BD0000"
......@@ -26,6 +17,23 @@ function SetColor(opinion) {
return "#00BD00"
}
function getEta(conflict) {
let total = conflict.nodes.length;
console.log("Total:", total)
if (total == 0) return;
let likes = 0;
conflict.nodes.forEach((node: Node, id: string, obj: Map<string, Node>) => {
if (node.opinion == Opinion.Like) likes++;
})
console.log("Likes:", likes/total)
return likes/total;
}
enum Opinion {
Like = 1,
Dislike
......@@ -46,8 +54,6 @@ export class FPCMessage {
}
class ConflictDetail {
@observable like: number;
@observable dislike: number;
@observable nodes: ObservableMap<string, Node>
}
......@@ -76,12 +82,11 @@ export class FPCStore {
for (const key of Object.keys(msg.conflictset)) {
for (const key2 of Object.keys(msg.conflictset[key].nodesview)){
let voteContext = msg.conflictset[key].nodesview[key2];
console.log(voteContext.nodeid, voteContext.rounds, voteContext.opinions, voteContext.like);
//console.log(voteContext.nodeid, voteContext.rounds, voteContext.opinions, voteContext.like);
this.addNewNode(key, voteContext.nodeid, voteContext.opinions[voteContext.opinions.length-1])
this.updateNodeValue(key, voteContext.nodeid, voteContext.opinions[voteContext.opinions.length-1])
}
console.log("for loop", this.conflicts.get(key).nodes);
}
}
......@@ -91,8 +96,6 @@ export class FPCStore {
node.id = nodeID;
node.opinion = opinion;
console.log("has", this.conflicts.has(conflictID))
if (!this.conflicts.has(conflictID)) {
let cd = new ConflictDetail();
cd.nodes = new ObservableMap<string, Node>();
......@@ -101,12 +104,8 @@ export class FPCStore {
let c = this.conflicts.get(conflictID)
console.log("c nodes", c.nodes);
c.nodes.set(nodeID, node);
this.conflicts.set(conflictID, c);
console.log("conflict nodes", this.conflicts.get(conflictID).nodes);
}
@action
......@@ -123,9 +122,6 @@ export class FPCStore {
if (!this.currentConflict) return;
let nodeSquares = [];
let c = this.conflicts.get(this.currentConflict);
console.log("current conflict", this.currentConflict, "current", c);
c.nodes.forEach((node: Node, id: string, obj: Map<string, Node>) => {
nodeSquares.push(
<Col xs={1} key={id} style={{
......@@ -145,13 +141,12 @@ export class FPCStore {
get conflictGrid(){
let conflictSquares = [];
this.conflicts.forEach((conflict: ConflictDetail, id: string, obj: Map<string, ConflictDetail>) => {
//getEta(conflict)
conflictSquares.push(
<Col xs={1} key={id} style={{
height: 50,
width: 50,
border: "1px solid #FFFFFF",
background: SetColor(conflict.like),
background: RGB_Log_Blend(getEta(conflict),"#BD0000", "#00BD00"),
}}>
{<Link to={`/fpc-example/conflict/${id}`}>
{id.substr(0, 5)}
......@@ -165,3 +160,9 @@ export class FPCStore {
}
export default FPCStore;
const RGB_Log_Blend=(p,c0,c1)=>{
var i=parseInt,r=Math.round,P=1-p,[a,b,c,d]=c0.split(","),[e,f,g,h]=c1.split(","),x=d||h;
//j=x?","+(!d?h:!h?d:r((parseFloat(d)*P+parseFloat(h)*p)*1000)/1000+")"):")";
return"rgb"+(x?"a(":"(")+r((P*i(a[3]=="a"?a.slice(5):a.slice(4))**2+p*i(e[3]=="a"?e.slice(5):e.slice(4))**2)**0.5)+","+r((P*i(b)**2+p*i(f)**2)**0.5)+","+r((P*i(c)**2+p*i(g)**2)**0.5)+d;
}
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -24,8 +24,8 @@ var ErrNotFound = errors.New("not found")
var ErrForbidden = errors.New("forbidden")
// holds dashboard assets
var appBox = packr.New("Dashboard_App", "./frontend/build")
var assetsBox = packr.New("Dashboard_Assets", "./frontend/src/assets")
var appBox = packr.New("Analysys_Dashboard_App", "./frontend/build")
var assetsBox = packr.New("Analysys_Dashboard_Assets", "./frontend/src/assets")
func indexRoute(e echo.Context) error {
if config.Node.GetBool(CfgDev) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment