mirror of
https://github.com/openziti/zrok.git
synced 2025-01-09 07:28:15 +01:00
infrastructure for detecting limited accounts (#320)
This commit is contained in:
parent
9591f5150e
commit
d0cedaf6e5
@ -84,8 +84,20 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
|
|||||||
}
|
}
|
||||||
envShrsList = append(envShrsList, envShrs)
|
envShrsList = append(envShrsList, envShrs)
|
||||||
}
|
}
|
||||||
|
var alj *store.AccountLimitJournal
|
||||||
|
aljEmpty, err := str.IsAccountLimitJournalEmpty(int(principal.ID), tx)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("error checking account limit journal for '%v': %v", principal.Email, err)
|
||||||
|
}
|
||||||
|
if !aljEmpty {
|
||||||
|
alj, err = str.FindLatestAccountLimitJournal(int(principal.ID), tx)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("error getting latest account limit journal entry for '%v': %v", principal.Email, err)
|
||||||
|
return metadata.NewOverviewInternalServerError()
|
||||||
|
}
|
||||||
|
}
|
||||||
return metadata.NewOverviewOK().WithPayload(&rest_model_zrok.Overview{
|
return metadata.NewOverviewOK().WithPayload(&rest_model_zrok.Overview{
|
||||||
AccountLimited: false,
|
AccountLimited: alj != nil && alj.Action == store.LimitAction,
|
||||||
Environments: envShrsList,
|
Environments: envShrsList,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ const Visualizer = (props) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("visualizer overview", props.overview);
|
console.log("visualizer overview", props.overview);
|
||||||
setNetworkGraph(mergeGraph(networkGraph, props.user, props.overview.environments));
|
setNetworkGraph(mergeGraph(networkGraph, props.user, props.overview.accountLimited, props.overview.environments));
|
||||||
|
|
||||||
if(isSelectionGone(networkGraph, props.selection)) {
|
if(isSelectionGone(networkGraph, props.selection)) {
|
||||||
// if the selection is no longer in the network graph...
|
// if the selection is no longer in the network graph...
|
||||||
|
@ -15,7 +15,7 @@ const nodesEqual = (a, b) => {
|
|||||||
return a.every((e, i) => e.id === b[i].id && e.limited === b[i].limited);
|
return a.every((e, i) => e.id === b[i].id && e.limited === b[i].limited);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mergeGraph = (oldGraph, user, newOverview) => {
|
export const mergeGraph = (oldGraph, user, accountLimited, newOverview) => {
|
||||||
let newGraph = {
|
let newGraph = {
|
||||||
nodes: [],
|
nodes: [],
|
||||||
links: []
|
links: []
|
||||||
@ -25,6 +25,7 @@ export const mergeGraph = (oldGraph, user, newOverview) => {
|
|||||||
id: user.token,
|
id: user.token,
|
||||||
label: user.email,
|
label: user.email,
|
||||||
type: "account",
|
type: "account",
|
||||||
|
limited: !!accountLimited,
|
||||||
val: 50
|
val: 50
|
||||||
}
|
}
|
||||||
newGraph.nodes.push(accountNode);
|
newGraph.nodes.push(accountNode);
|
||||||
@ -36,7 +37,7 @@ export const mergeGraph = (oldGraph, user, newOverview) => {
|
|||||||
label: env.environment.description,
|
label: env.environment.description,
|
||||||
type: "environment",
|
type: "environment",
|
||||||
val: 50,
|
val: 50,
|
||||||
limited: env.limited
|
limited: !!env.limited || accountNode.limited
|
||||||
};
|
};
|
||||||
newGraph.nodes.push(envNode);
|
newGraph.nodes.push(envNode);
|
||||||
newGraph.links.push({
|
newGraph.links.push({
|
||||||
@ -55,7 +56,7 @@ export const mergeGraph = (oldGraph, user, newOverview) => {
|
|||||||
envZId: env.environment.zId,
|
envZId: env.environment.zId,
|
||||||
label: shrLabel,
|
label: shrLabel,
|
||||||
type: "share",
|
type: "share",
|
||||||
limited: !!shr.limited,
|
limited: !!shr.limited || envNode.limited,
|
||||||
val: 50
|
val: 50
|
||||||
};
|
};
|
||||||
newGraph.nodes.push(shrNode);
|
newGraph.nodes.push(shrNode);
|
||||||
|
Loading…
Reference in New Issue
Block a user