Coder Social home page Coder Social logo

feat: capability and tags support about zero-ui HOT 8 CLOSED

dec0dos avatar dec0dos commented on September 4, 2024 1
feat: capability and tags support

from zero-ui.

Comments (8)

timothyle97 avatar timothyle97 commented on September 4, 2024

I agree that it would be nice to be able to change the node tags in the UI. Currently if you have the tags defined under your flow rules as your screenshot shows, you can use an API call to the controller to set the tags.

This is an example of what I've used:
curl -X POST 127.0.0.1:9993/api/network/xxxxxxxxxxxxxxxx/member/xxxxxxxxxx -H "X-ZT1-AUTH:xxxxxxxxxxxxxxxxxxxxxxxx" -d '{ "tags": [[1000,7],[1001,0]]}'

The value after X-ZT1-AUTH is the API token of the ZT controller.

Reference for the controller API is here: https://my.zerotier.com/central-api.html#member-member-post

from zero-ui.

chenall avatar chenall commented on September 4, 2024

@timothyle97 Yes, and zero-ui Flow rule currently does not support cap and tag, it will be ignored, there may be small bugs.

@dec0dOS

e.g.

tag department
  id 1000 
  enum 100 sales
;

cap super
  id 1000
	accept;
;

image

from zero-ui.

timothyle97 avatar timothyle97 commented on September 4, 2024

@chenall If I'm not mistaken the tags are implemented by the ZT controller, not Zero-UI. I believe if the tags are set on the network and the members via the API, any flow rules referencing the tags should work even though the preview shows the tags are empty.

@dec0dOS I've found another project which acts as a command line interface to set the tags on the network and members for ZTNCUI: https://github.com/Fusion/ztncli

from zero-ui.

snachx avatar snachx commented on September 4, 2024

It's indeed a bug in zero-ui's flow rule editor which will ignore tags and caps, I've already fixed it but I haven't do a thoroughly test.

caps = [],
tags = [];
const res = compile(src, rules, caps, tags);
if (!res) {
setFlowData({
rules: [...rules],
capabilities: [...caps],
tags: [...tags],
});

tags and caps should be object instead of array, the rule compiler uses them as objects to store parse result with names as keys.

from zero-ui.

dec0dOS avatar dec0dOS commented on September 4, 2024

Hello, @snachx, thanks for sharing!

Please reach out to me if it works as expected for you.

from zero-ui.

snachx avatar snachx commented on September 4, 2024

@dec0dOS hello, you can check the detail of the rule compiler

tags[tagName] = {
id: id,
default: dfl,
enums: enums,
flags: flags,
};

caps[capName] = {
id: id,
default: dfl,
rules: capRules,
};

the compile method uses caps and tags different from rules
rules have no names, they will be parsed and pushed to the rules array
both of tags and caps have names, and their names will be keys in the result objects

if we pass arrays as tags and caps, the spread syntax ...tags ...caps can't handle the result returned by the compile method.

I tried to init tags and caps as empty object and change the setFlowData method, it works as expected.

from zero-ui.

snachx avatar snachx commented on September 4, 2024

Also, even if the bug is fixed, the ui interface to set member's group and capabilities still needs to be developed, I've checked MemberSettings.jsx, there's no such support yet. I intend to implement this feature, but don't have time to do it yet.

from zero-ui.

dec0dOS avatar dec0dOS commented on September 4, 2024

Pull request #41 has been merged to the main branch. This feature will be available with the new release.

Special gratitude goes to @snachx for finding the bug and developing the UI for tags and caps.

from zero-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.