public async Task <bool> RemoveNodes(List <string> nodes) { return(await Task.Run(() => { foreach (var id in nodes) { Nodes.Node oldNode = engine.GetNode(id); if (oldNode == null) { engine.LogEngineError($"Can`t remove node [{id}]. Does not exist."); return false; } if (oldNode.GetNodeOptions().ProtectedAccess) { if (!User.HasClaim(x => x.Type == UserClaims.EditorProtectedAccess)) { engine.LogEngineError( $"Can`t remove node [{oldNode.Category}/{oldNode.Type}]. No permissions for protected access."); continue; } } engine.RemoveNode(oldNode); } return true; })); }
public async Task <bool> RemoveNode(LiteGraph.Node node) { return(await Task.Run(() => { if (engine == null) { return false; } Nodes.Node oldNode = engine.GetNode(node.id); if (oldNode == null) { engine.LogEngineError($"Can`t remove node [{node.id}]. Does not exist."); return false; } if (oldNode.GetNodeOptions().ProtectedAccess) { if (!User.HasClaim(x => x.Type == UserClaims.EditorProtectedAccess)) { engine.LogEngineError( $"Can`t remove node [{oldNode.Category}/{oldNode.Type}]. No permissions for protected access."); return false; } } engine.RemoveNode(oldNode); return true; })); }
public async Task <bool> CloneNode(string id) { return(await Task.Run(() => { if (engine == null) { return false; } Nodes.Node node = engine.GetNode(id); if (node == null) { engine.LogEngineError($"Can`t clone node [{id}]. Does not exist."); return false; } if (node.GetNodeOptions().ProtectedAccess) { if (!User.HasClaim(x => x.Type == UserClaims.EditorProtectedAccess)) { engine.LogEngineError( $"Can`t clone node [{node.Category}/{node.Type}]. No permissions for protected access."); return false; } } engine.CloneNode(id); return true; })); }
public async Task <bool> CreateLink(LiteGraph.Link link) { return(await Task.Run(() => { if (engine == null) { return false; } Nodes.Node outNode = SystemController.nodesEngine.GetNode(link.origin_id); Nodes.Node inNode = SystemController.nodesEngine.GetNode(link.target_id); if (outNode == null || inNode == null) { engine.LogEngineError( $"Can`t create link from [{link.origin_id}] to [{link.target_id}]. Does not exist."); return false; } if (outNode.GetNodeOptions().ProtectedAccess || inNode.GetNodeOptions().ProtectedAccess) { if (!User.HasClaim(x => x.Type == UserClaims.EditorProtectedAccess)) { engine.LogEngineError( $"Can`t create link from [{link.origin_id}] to [{link.target_id}]. No permissions for protected access."); return false; } } engine.AddLink(outNode.Outputs[link.origin_slot], inNode.Inputs[link.target_slot]); return true; })); }
public async Task <bool> AddNode(LiteGraph.Node node) { return(await Task.Run(() => { if (engine == null) { return false; } string type = node.properties["ObjectType"]; string assemblyName = node.properties["Assembly"]; Nodes.Node newNode = CreateNode(type, assemblyName); if (newNode == null) { engine.LogEngineError($"Can`t create node [{node.properties["ObjectType"]}]. Type does not exist."); return false; } if (newNode.GetNodeOptions().ProtectedAccess) { if (!User.HasClaim(x => x.Type == UserClaims.EditorProtectedAccess)) { engine.LogEngineError( $"Can`t create node [{node.properties["ObjectType"]}]. No permissions for protected access."); return false; } } newNode.Position = new Position { X = node.pos[0], Y = node.pos[1] }; if (node.size.Length == 2) { newNode.Size = new Size { Width = node.size[0], Height = node.size[1] } } ; //newNode.Id = node.id; newNode.PanelId = node.panel_id ?? MAIN_PANEL_ID; engine.AddNode(newNode); return true; })); }
public bool SetNodeSettings(string id, Dictionary <string, string> data) { Nodes.Node node = engine.GetNode(id); if (node == null) { engine.LogEngineError($"Can`t set settings for node [{id}]. Does not exist."); return(false); } if (node.GetNodeOptions().ProtectedAccess) { if (!User.HasClaim(x => x.Type == UserClaims.EditorProtectedAccess)) { engine.LogEngineError( $"Can`t set settings for node [{node.Category}/{node.Type}]. No permissions for protected access."); return(false); } } return(node.SetSettings(data)); }