Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
4b1a2d3b
Unverified
Commit
4b1a2d3b
authored
Oct 12, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure to add all variable nodes to dag before linking variables
parent
09c9c2a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
+34
-4
public/app/core/utils/dag.test.ts
+12
-0
public/app/core/utils/dag.ts
+18
-2
public/app/features/templating/variable_srv.ts
+4
-2
No files found.
public/app/core/utils/dag.test.ts
View file @
4b1a2d3b
...
@@ -104,5 +104,17 @@ describe('Directed acyclic graph', () => {
...
@@ -104,5 +104,17 @@ describe('Directed acyclic graph', () => {
const
actual
=
nodeH
.
getOptimizedInputEdges
();
const
actual
=
nodeH
.
getOptimizedInputEdges
();
expect
(
actual
).
toHaveLength
(
0
);
expect
(
actual
).
toHaveLength
(
0
);
});
});
it
(
'when linking non-existing input node with existing output node should throw error'
,
()
=>
{
expect
(()
=>
{
dag
.
link
(
'non-existing'
,
'A'
);
}).
toThrowError
(
"cannot link input node named non-existing since it doesn't exist in graph"
);
});
it
(
'when linking existing input node with non-existing output node should throw error'
,
()
=>
{
expect
(()
=>
{
dag
.
link
(
'A'
,
'non-existing'
);
}).
toThrowError
(
"cannot link output node named non-existing since it doesn't exist in graph"
);
});
});
});
});
});
public/app/core/utils/dag.ts
View file @
4b1a2d3b
...
@@ -15,6 +15,14 @@ export class Edge {
...
@@ -15,6 +15,14 @@ export class Edge {
}
}
link
(
inputNode
:
Node
,
outputNode
:
Node
)
{
link
(
inputNode
:
Node
,
outputNode
:
Node
)
{
if
(
!
inputNode
)
{
throw
Error
(
'inputNode is required'
);
}
if
(
!
outputNode
)
{
throw
Error
(
'outputNode is required'
);
}
this
.
unlink
();
this
.
unlink
();
this
.
inputNode
=
inputNode
;
this
.
inputNode
=
inputNode
;
this
.
outputNode
=
outputNode
;
this
.
outputNode
=
outputNode
;
...
@@ -152,7 +160,11 @@ export class Graph {
...
@@ -152,7 +160,11 @@ export class Graph {
for
(
let
n
=
0
;
n
<
inputArr
.
length
;
n
++
)
{
for
(
let
n
=
0
;
n
<
inputArr
.
length
;
n
++
)
{
const
i
=
inputArr
[
n
];
const
i
=
inputArr
[
n
];
if
(
typeof
i
===
'string'
)
{
if
(
typeof
i
===
'string'
)
{
inputNodes
.
push
(
this
.
getNode
(
i
));
const
n
=
this
.
getNode
(
i
);
if
(
!
n
)
{
throw
Error
(
`cannot link input node named
${
i
}
since it doesn't exist in graph`
);
}
inputNodes
.
push
(
n
);
}
else
{
}
else
{
inputNodes
.
push
(
i
);
inputNodes
.
push
(
i
);
}
}
...
@@ -161,7 +173,11 @@ export class Graph {
...
@@ -161,7 +173,11 @@ export class Graph {
for
(
let
n
=
0
;
n
<
outputArr
.
length
;
n
++
)
{
for
(
let
n
=
0
;
n
<
outputArr
.
length
;
n
++
)
{
const
i
=
outputArr
[
n
];
const
i
=
outputArr
[
n
];
if
(
typeof
i
===
'string'
)
{
if
(
typeof
i
===
'string'
)
{
outputNodes
.
push
(
this
.
getNode
(
i
));
const
n
=
this
.
getNode
(
i
);
if
(
!
n
)
{
throw
Error
(
`cannot link output node named
${
i
}
since it doesn't exist in graph`
);
}
outputNodes
.
push
(
n
);
}
else
{
}
else
{
outputNodes
.
push
(
i
);
outputNodes
.
push
(
i
);
}
}
...
...
public/app/features/templating/variable_srv.ts
View file @
4b1a2d3b
...
@@ -291,9 +291,11 @@ export class VariableSrv {
...
@@ -291,9 +291,11 @@ export class VariableSrv {
createGraph
()
{
createGraph
()
{
const
g
=
new
Graph
();
const
g
=
new
Graph
();
this
.
variables
.
forEach
(
v1
=>
{
this
.
variables
.
forEach
(
v
=>
{
g
.
createNode
(
v1
.
name
);
g
.
createNode
(
v
.
name
);
});
this
.
variables
.
forEach
(
v1
=>
{
this
.
variables
.
forEach
(
v2
=>
{
this
.
variables
.
forEach
(
v2
=>
{
if
(
v1
===
v2
)
{
if
(
v1
===
v2
)
{
return
;
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment