Skip to content

Commit

Permalink
show correct link color for db request when failing
Browse files Browse the repository at this point in the history
show correct color for multiple link when some request have client error
  • Loading branch information
YoussefDahi committed Dec 19, 2024
1 parent 0ee6bdb commit c705726
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/app/model/trace.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class LinkRequestNode implements Link<Label> {
switch(true){
case (this.nodeObject.status >= 200 && this.nodeObject.status < 300): return "SUCCES";
case (this.nodeObject.status >= 400 && this.nodeObject.status < 500): return "CLIENT_ERROR"
case (this.nodeObject.status >=500): return "SERVER_ERROR";
case (this.nodeObject.status >=500): return "ERROR";
case (this.nodeObject.status == 0): return "UNREACHABLE"
}
}
Expand Down Expand Up @@ -299,7 +299,7 @@ export class JdbcRequestNode implements Node<Label>, Link<Label> {
}

getLinkStyle(): string {
return this.nodeObject.status ? 'SUCCES' : 'FAILURE'
return this.nodeObject.status ? 'SUCCES' : 'ERROR'
}
}

Expand Down Expand Up @@ -332,7 +332,7 @@ export class FtpRequestNode implements Node<Label>, Link<Label> {
}

getLinkStyle(): string {
return this.nodeObject.status ? 'SUCCES' : 'FAILURE'
return this.nodeObject.status ? 'SUCCES' : 'ERROR'
}
}

Expand Down Expand Up @@ -365,7 +365,7 @@ export class MailRequestNode implements Node<Label>, Link<Label> {
}

getLinkStyle(): string {
return this.nodeObject.status ? 'SUCCES' : 'FAILURE'
return this.nodeObject.status ? 'SUCCES' : 'ERROR'
}
}

Expand Down Expand Up @@ -398,7 +398,7 @@ export class LdapRequestNode implements Node<Label>, Link<Label> {
}

getLinkStyle(): string {
return this.nodeObject.status ? 'SUCCES' : 'FAILURE'
return this.nodeObject.status ? 'SUCCES' : 'ERROR'
}
}

Expand Down Expand Up @@ -441,7 +441,7 @@ export class RestRequestNode implements Node<Label> {
switch(true){
case (this.nodeObject.status >= 200 && this.nodeObject.status < 300): return "SUCCES";
case (this.nodeObject.status > 400 && this.nodeObject.status < 500): return "CLIENT_ERROR"
case (this.nodeObject.status >=500): return "SERVER_ERROR";
case (this.nodeObject.status >=500): return "ERROR";
case (this.nodeObject.status == 0): return "UNREACHABLE"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/model/tree.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export const ServerConfig = {
export const LinkConfig = {
SUCCES: "strokeColor=green;",
CLIENT_ERROR: "strokeColor=#f9ad4e;",
SERVER_ERROR: "strokeColor=red;",
ERROR: "strokeColor=red;",
UNREACHABLE: "strokeColor=red;"
}

13 changes: 8 additions & 5 deletions src/app/views/tree/tree.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export class TreeView implements OnDestroy {
if (v[1].length > 1) {
b = this.draw(treeGraph, this.mergeRestRequests(v[0], v[1]), serverlbl, linklbl);
label = { linkLbl: linklbl, nodes: v[1] };
linkStyle = LinkConfig[this.checkSome<RestRequestNode>(v[1], v => { return v.nodeObject.status > 400 || v.nodeObject.status == 0 }) ? 'SERVER_ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
linkStyle = LinkConfig[this.checkSome<RestRequestNode>(v[1], v => { return v.nodeObject.status >= 500 || v.nodeObject.status == 0 }) ? 'ERROR' :
this.checkSome<RestRequestNode>(v[1], v => { return v.nodeObject.status >= 400 && v.nodeObject.status < 500 }) ? 'CLIENT_ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
}
else {
let restRequestNode = v[1][0];
Expand All @@ -169,7 +170,7 @@ export class TreeView implements OnDestroy {
b = treeGraph.insertServer(jdbcRequestNode.formatNode(serverlbl), "JDBC"); // demon server
if (v[1].length > 1) {
label = { linkLbl: linklbl, nodes: v[1] };
linkStyle = LinkConfig[this.checkSome<JdbcRequestNode>(v[1], v => { return !v.nodeObject.status }) ? 'SERVER_ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
linkStyle = LinkConfig[this.checkSome<JdbcRequestNode>(v[1], v => { return !v.nodeObject.status }) ? 'ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
} else {
label = jdbcRequestNode.formatLink(linklbl);
linkStyle = LinkConfig[jdbcRequestNode.getLinkStyle()];
Expand All @@ -186,7 +187,7 @@ export class TreeView implements OnDestroy {
b = treeGraph.insertServer(ftpRequestNode.formatNode(serverlbl), "FTP"); // demon server
if (v[1].length > 1) {
label = { linkLbl: linklbl, nodes: v[1] };
linkStyle = LinkConfig[this.checkSome<FtpRequestNode>(v[1], v => { return !v.nodeObject.status }) ? 'SERVER_ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
linkStyle = LinkConfig[this.checkSome<FtpRequestNode>(v[1], v => { return !v.nodeObject.status }) ? 'ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
} else {
label = ftpRequestNode.formatLink(linklbl);
linkStyle = LinkConfig[ftpRequestNode.getLinkStyle()];
Expand All @@ -203,7 +204,7 @@ export class TreeView implements OnDestroy {
b = treeGraph.insertServer(mailRequestNode.formatNode(serverlbl), "SMTP"); // demon server
if (v[1].length > 1) {
label = { linkLbl: linklbl, nodes: v[1] };
linkStyle = LinkConfig[this.checkSome<MailRequestNode>(v[1], v => { return !v.nodeObject.status }) ? 'SERVER_ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
linkStyle = LinkConfig[this.checkSome<MailRequestNode>(v[1], v => { return !v.nodeObject.status }) ? 'ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
} else {
label = mailRequestNode.formatLink(linklbl);
linkStyle = LinkConfig[mailRequestNode.getLinkStyle()];
Expand All @@ -220,7 +221,7 @@ export class TreeView implements OnDestroy {
b = treeGraph.insertServer(ldapRequestNode.formatNode(serverlbl), "LDAP"); // demon server
if (v[1].length > 1) {
label = { linkLbl: linklbl, nodes: v[1] };
linkStyle = LinkConfig[this.checkSome<MailRequestNode>(v[1], v => { return !v.nodeObject.status }) ? 'SERVER_ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
linkStyle = LinkConfig[this.checkSome<MailRequestNode>(v[1], v => { return !v.nodeObject.status }) ? 'ERROR' : 'SUCCES'] + "strokeWidth=1.5;"
} else {
label = ldapRequestNode.formatLink(linklbl);
linkStyle = LinkConfig[ldapRequestNode.getLinkStyle()];
Expand Down Expand Up @@ -249,6 +250,8 @@ export class TreeView implements OnDestroy {
checkSome<T>(arr: T[], fn: (o: T) => any) {
return arr.some(r => fn(r));
}

check

getIcon(obj: ServerRestSession | ServerMainSession) {
if ("type" in obj) {
Expand Down

0 comments on commit c705726

Please sign in to comment.