Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove node badge feature as it is implemented in core #1051

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,7 @@ This repository provides Colab notebooks that allow you to install and use Comfy
* Channel settings have a broad impact, affecting not only the node list but also all functions like "Update all."
* Conflicted Nodes with a yellow background show a list of nodes conflicting with other extensions in the respective extension. This issue needs to be addressed by the developer, and users should be aware that due to these conflicts, some nodes may not function correctly and may need to be installed accordingly.

4. If you set the `Badge:` item in the menu as `Badge: Nickname`, `Badge: Nickname (hide built-in)`, `Badge: #ID Nickname`, `Badge: #ID Nickname (hide built-in)` the information badge will be displayed on the node.
* When selecting (hide built-in), it hides the 🦊 icon, which signifies built-in nodes.
* Nodes without any indication on the badge are custom nodes that Manager cannot recognize.
* `Badge: Nickname` displays the nickname of custom nodes, while `Badge: #ID Nickname` also includes the internal ID of the node.

![model-install-dialog](misc/nickname.jpg)
4. Node badge is moved to ComfyUI core since frontend v1.2.49. Now you should configure badge options in the settings dialog. ![image](https://github.com/user-attachments/assets/59db03f6-87f1-44ee-a1c1-ad4ad114319e)


5. Share
Expand Down Expand Up @@ -220,14 +215,10 @@ NODE_CLASS_MAPPINGS.update({
```

* When you write a docstring in the header of the .py file for the Node as follows, it will be used for managing the database in the Manager.
* Currently, only the `nickname` is being used, but other parts will also be utilized in the future.
* The `nickname` will be the name displayed on the badge of the node.
* If there is no `nickname`, it will be truncated to 20 characters from the arbitrarily written title and used.
```
"""
@author: Dr.Lt.Data
@title: Impact Pack
@nickname: Impact Pack
@description: This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler.
"""
```
Expand Down
3 changes: 0 additions & 3 deletions glob/manager_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def write_config():
config = configparser.ConfigParser()
config['default'] = {
'preview_method': manager_funcs.get_current_preview_method(),
'badge_mode': get_config()['badge_mode'],
'git_exe': get_config()['git_exe'],
'channel_url': get_config()['channel_url'],
'share_option': get_config()['share_option'],
Expand Down Expand Up @@ -241,7 +240,6 @@ def read_config():

return {
'preview_method': default_conf['preview_method'] if 'preview_method' in default_conf else manager_funcs.get_current_preview_method(),
'badge_mode': default_conf['badge_mode'] if 'badge_mode' in default_conf else 'none',
'git_exe': default_conf['git_exe'] if 'git_exe' in default_conf else '',
'channel_url': default_conf['channel_url'] if 'channel_url' in default_conf else 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main',
'share_option': default_conf['share_option'] if 'share_option' in default_conf else 'all',
Expand All @@ -259,7 +257,6 @@ def read_config():
except Exception:
return {
'preview_method': manager_funcs.get_current_preview_method(),
'badge_mode': 'none',
'git_exe': '',
'channel_url': 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main',
'share_option': 'all',
Expand Down
15 changes: 0 additions & 15 deletions glob/manager_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ def set_preview_method(method):
set_preview_method(core.get_config()['preview_method'])


def set_badge_mode(mode):
core.get_config()['badge_mode'] = mode


def set_default_ui_mode(mode):
core.get_config()['default_ui'] = mode

Expand Down Expand Up @@ -1085,17 +1081,6 @@ async def preview_method(request):
return web.Response(status=200)


@PromptServer.instance.routes.get("/manager/badge_mode")
async def badge_mode(request):
if "value" in request.rel_url.query:
set_badge_mode(request.rel_url.query['value'])
core.write_config()
else:
return web.Response(text=core.get_config()['badge_mode'], status=200)

return web.Response(status=200)


@PromptServer.instance.routes.get("/manager/default_ui")
async def default_ui_mode(request):
if "value" in request.rel_url.query:
Expand Down
111 changes: 0 additions & 111 deletions js/comfyui-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ document.head.appendChild(docStyle);
var update_comfyui_button = null;
var fetch_updates_button = null;
var update_all_button = null;
var badge_mode = "none";
let share_option = 'all';

// copied style from https://github.com/pythongosssss/ComfyUI-Custom-Scripts
Expand Down Expand Up @@ -378,13 +377,6 @@ const style = `
`;



async function init_badge_mode() {
api.fetchApi('/manager/badge_mode')
.then(response => response.text())
.then(data => { badge_mode = data; })
}

async function init_share_option() {
api.fetchApi('/manager/share_option')
.then(response => response.text())
Expand All @@ -401,7 +393,6 @@ async function init_notice(notice) {
})
}

await init_badge_mode();
await init_share_option();

async function fetchNicknames() {
Expand Down Expand Up @@ -468,65 +459,6 @@ function getNickname(node, nodename) {
}
}

function drawBadge(node, orig, restArgs) {
let ctx = restArgs[0];
const r = orig?.apply?.(node, restArgs);

if (!node.flags.collapsed && badge_mode != 'none' && node.constructor.title_mode != LiteGraph.NO_TITLE) {
let text = "";
if (badge_mode.startsWith('id_nick'))
text = `#${node.id} `;

let nick = node.getNickname();
if (nick) {
if (nick == 'ComfyUI') {
if(badge_mode.endsWith('hide')) {
nick = "";
}
else {
nick = "🦊"
}
}

if (nick.length > 25) {
text += nick.substring(0, 23) + "..";
}
else {
text += nick;
}
}

if (text != "") {
let fgColor = "white";
let bgColor = "#0F1F0F";
let visible = true;

ctx.save();
ctx.font = "12px sans-serif";
const sz = ctx.measureText(text);
ctx.fillStyle = bgColor;
ctx.beginPath();
ctx.roundRect(node.size[0] - sz.width - 12, -LiteGraph.NODE_TITLE_HEIGHT - 20, sz.width + 12, 20, 5);
ctx.fill();

ctx.fillStyle = fgColor;
ctx.fillText(text, node.size[0] - sz.width - 6, -LiteGraph.NODE_TITLE_HEIGHT - 6);
ctx.restore();

if (node.has_errors) {
ctx.save();
ctx.font = "bold 14px sans-serif";
const sz2 = ctx.measureText(node.type);
ctx.fillStyle = 'white';
ctx.fillText(node.type, node.size[0] / 2 - sz2.width / 2, node.size[1] / 2);
ctx.restore();
}
}
}
return r;
}


async function updateComfyUI() {
let prev_text = update_comfyui_button.innerText;
update_comfyui_button.innerText = "Updating ComfyUI...";
Expand Down Expand Up @@ -841,26 +773,6 @@ class ManagerMenuDialog extends ComfyDialog {
api.fetchApi(`/manager/preview_method?value=${event.target.value}`);
});

// nickname
let badge_combo = document.createElement("select");
badge_combo.setAttribute("title", "Configure the content to be displayed on the badge at the top right corner of the node. The ID is the identifier of the node. If 'hide built-in' is selected, both unknown nodes and built-in nodes will be omitted, making them indistinguishable");
badge_combo.className = "cm-menu-combo";
badge_combo.appendChild($el('option', { value: 'none', text: 'Badge: None' }, []));
badge_combo.appendChild($el('option', { value: 'nick', text: 'Badge: Nickname' }, []));
badge_combo.appendChild($el('option', { value: 'nick_hide', text: 'Badge: Nickname (hide built-in)' }, []));
badge_combo.appendChild($el('option', { value: 'id_nick', text: 'Badge: #ID Nickname' }, []));
badge_combo.appendChild($el('option', { value: 'id_nick_hide', text: 'Badge: #ID Nickname (hide built-in)' }, []));

api.fetchApi('/manager/badge_mode')
.then(response => response.text())
.then(data => { badge_combo.value = data; badge_mode = data; });

badge_combo.addEventListener('change', function (event) {
api.fetchApi(`/manager/badge_mode?value=${event.target.value}`);
badge_mode = event.target.value;
app.graph.setDirtyCanvas(true);
});

// channel
let channel_combo = document.createElement("select");
channel_combo.setAttribute("title", "Configure the channel for retrieving data from the Custom Node list (including missing nodes) or the Model list. Note that the badge utilizes local information.");
Expand Down Expand Up @@ -986,7 +898,6 @@ class ManagerMenuDialog extends ComfyDialog {
this.datasrc_combo,
channel_combo,
preview_combo,
badge_combo,
default_ui_combo,
share_combo,
component_policy_combo,
Expand Down Expand Up @@ -1410,28 +1321,6 @@ app.registerExtension({
this._addExtraNodeContextMenu(nodeType, app);
},

async nodeCreated(node, app) {
if(!node.badge_enabled) {
node.getNickname = function () { return getNickname(node, node.comfyClass.trim()) };
let orig = node.onDrawForeground;
if(!orig)
orig = node.__proto__.onDrawForeground;

node.onDrawForeground = function (ctx) {
drawBadge(node, orig, arguments)
};
node.badge_enabled = true;
}
},

async loadedGraphNode(node, app) {
if(!node.badge_enabled) {
const orig = node.onDrawForeground;
node.getNickname = function () { return getNickname(node, node.type.trim()) };
node.onDrawForeground = function (ctx) { drawBadge(node, orig, arguments) };
}
},

_addExtraNodeContextMenu(node, app) {
const origGetExtraMenuOptions = node.prototype.getExtraMenuOptions;
node.prototype.cm_menu_added = true;
Expand Down