@ -224,7 +224,6 @@ async function init_notice(notice) {
await init _badge _mode ( ) ;
await init _share _option ( ) ;
async function fetchNicknames ( ) {
const response1 = await api . fetchApi ( ` /customnode/getmappings?mode=local ` ) ;
const mappings = await response1 . json ( ) ;
@ -235,7 +234,10 @@ async function fetchNicknames() {
for ( let i in mappings ) {
let item = mappings [ i ] ;
var nickname ;
if ( item [ 1 ] . title ) {
if ( item [ 1 ] . nickname ) {
nickname = item [ 1 ] . nickname ;
}
else if ( item [ 1 ] . title ) {
nickname = item [ 1 ] . title ;
}
else {
@ -256,6 +258,84 @@ async function fetchNicknames() {
const [ nicknames , nickname _patterns ] = await fetchNicknames ( ) ;
function getNickname ( node , nodename ) {
if ( node . nickname ) {
return node . nickname ;
}
else {
if ( nicknames [ nodename ] ) {
node . nickname = nicknames [ nodename ] ;
}
else {
for ( let i in nickname _patterns ) {
let item = nickname _patterns [ i ] ;
if ( nodename . match ( item [ 0 ] ) ) {
node . nickname = item [ 1 ] ;
}
}
}
return node . nickname ;
}
}
function drawBadge ( node , orig , ctx ) {
const r = orig ? . apply ? . ( node , arguments ) ;
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 ;
@ -302,9 +382,7 @@ async function fetchUpdates(update_check_checkbox) {
fetch _updates _button . style . backgroundColor = "gray" ;
try {
var mode = "url" ;
if ( manager _instance . local _mode _checkbox . checked )
mode = "local" ;
var mode = manager _instance . datasrc _combo . value ;
const response = await api . fetchApi ( ` /customnode/fetch_updates?mode= ${ mode } ` ) ;
@ -345,9 +423,7 @@ async function updateAll(update_check_checkbox, manager_dialog) {
update _all _button . style . backgroundColor = "gray" ;
try {
var mode = "url" ;
if ( manager _instance . local _mode _checkbox . checked )
mode = "local" ;
var mode = manager _instance . datasrc _combo . value ;
update _all _button . innerText = "Updating all..." ;
const response1 = await api . fetchApi ( '/comfyui_manager/update_comfyui' ) ;
@ -417,8 +493,6 @@ const isOutputNode = (node) => {
// -----------
class ManagerMenuDialog extends ComfyDialog {
local _mode _checkbox = null ;
createControlsMid ( ) {
let self = this ;
@ -505,18 +579,19 @@ class ManagerMenuDialog extends ComfyDialog {
createControlsLeft ( ) {
let self = this ;
this . local _mode _checkbox = $el ( "input" , { type : 'checkbox' , id : "use_local_db" } , [ ] )
const checkbox _text = $el ( "label" , { for : "use_local_db" } , [ " Use local DB" ] )
checkbox _text . style . color = "var(--fg-color)" ;
checkbox _text . style . cursor = "pointer" ;
checkbox _text . style . marginRight = "10px" ;
this . update _check _checkbox = $el ( "input" , { type : 'checkbox' , id : "skip_update_check" } , [ ] )
const uc _checkbox _text = $el ( "label" , { for : "skip_update_check" } , [ " Skip update check" ] )
uc _checkbox _text . style . color = "var(--fg-color)" ;
uc _checkbox _text . style . cursor = "pointer" ;
this . update _check _checkbox . checked = true ;
// db mode
this . datasrc _combo = document . createElement ( "select" ) ;
this . datasrc _combo . style . cursor = "pointer" ;
this . datasrc _combo . appendChild ( $el ( 'option' , { value : 'cache' , text : 'DB: Cache (1day)' } , [ ] ) ) ;
this . datasrc _combo . appendChild ( $el ( 'option' , { value : 'local' , text : 'DB: Local' } , [ ] ) ) ;
this . datasrc _combo . appendChild ( $el ( 'option' , { value : 'url' , text : 'DB: Remote' } , [ ] ) ) ;
// preview method
let preview _combo = document . createElement ( "select" ) ;
preview _combo . style . cursor = "pointer" ;
@ -612,8 +687,9 @@ class ManagerMenuDialog extends ComfyDialog {
} ) ;
return [
$el ( "div" , { } , [ this . local _mode _checkbox , checkbox _text , this . update _check _checkbox , uc _checkbox _text ] ) ,
$el ( "div" , { } , [ this . update _check _checkbox , uc _checkbox _text ] ) ,
$el ( "br" , { } , [ ] ) ,
this . datasrc _combo ,
preview _combo ,
badge _combo ,
channel _combo ,
@ -870,120 +946,21 @@ app.registerExtension({
} ,
async beforeRegisterNodeDef ( nodeType , nodeData , app ) {
const onDrawForeground = nodeType . prototype . onDrawForeground ;
nodeType . prototype . onDrawForeground = function ( ctx ) {
const r = onDrawForeground ? . apply ? . ( this , arguments ) ;
if ( ! this . flags . collapsed && badge _mode != 'none' && nodeType . title _mode != LiteGraph . NO _TITLE ) {
let text = "" ;
if ( badge _mode . startsWith ( 'id_nick' ) )
text = ` # ${ this . id } ` ;
if ( nicknames [ nodeData . name . trim ( ) ] ) {
let nick = nicknames [ nodeData . name . trim ( ) ] ;
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 ( this . size [ 0 ] - sz . width - 12 , - LiteGraph . NODE _TITLE _HEIGHT - 20 , sz . width + 12 , 20 , 5 ) ;
ctx . fill ( ) ;
ctx . fillStyle = fgColor ;
ctx . fillText ( text , this . size [ 0 ] - sz . width - 6 , - LiteGraph . NODE _TITLE _HEIGHT - 6 ) ;
ctx . restore ( ) ;
}
}
return r ;
} ;
this . _addExtraNodeContextMenu ( nodeType , app ) ;
} ,
async nodeCreated ( node , app ) {
if ( ! node . badge _enabled ) {
node . getNickname = function ( ) { return getNickname ( node , node . comfyClass . trim ( ) ) } ;
const orig = node . _ _proto _ _ . onDrawForeground ;
node . onDrawForeground = function ( ctx ) { drawBadge ( node , orig , ctx ) } ;
node . badge _enabled = true ;
}
} ,
async loadedGraphNode ( node , app ) {
if ( node . has _errors ) {
const onDrawForeground = node . onDrawForeground ;
node . onDrawForeground = function ( ctx ) {
const r = onDrawForeground ? . apply ? . ( this , arguments ) ;
if ( ! this . flags . collapsed && badge _mode != 'none' ) {
let text = "" ;
if ( badge _mode . startsWith ( 'id_nick' ) )
text = ` # ${ this . id } ` ;
if ( nicknames [ node . type . trim ( ) ] ) {
let nick = nicknames [ node . type . trim ( ) ] ;
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 ( this . size [ 0 ] - sz . width - 12 , - LiteGraph . NODE _TITLE _HEIGHT - 20 , sz . width + 12 , 20 , 5 ) ;
ctx . fill ( ) ;
ctx . fillStyle = fgColor ;
ctx . fillText ( text , this . size [ 0 ] - sz . width - 6 , - LiteGraph . NODE _TITLE _HEIGHT - 6 ) ;
ctx . restore ( ) ;
ctx . save ( ) ;
ctx . font = "bold 14px sans-serif" ;
const sz2 = ctx . measureText ( node . type ) ;
ctx . fillStyle = 'white' ;
ctx . fillText ( node . type , this . size [ 0 ] / 2 - sz2 . width / 2 , this . size [ 1 ] / 2 ) ;
ctx . restore ( ) ;
}
}
return r ;
} ;
if ( ! node . badge _enabled ) {
const orig = node . onDrawForeground ;
node . getNickname = function ( ) { return getNickname ( node , node . type . trim ( ) ) } ;
node . onDrawForeground = function ( ctx ) { drawBadge ( node , orig , ctx ) } ;
}
} ,