@@ -15,7 +15,10 @@ class MetadataDialog extends ComfyDialog {
15
15
$el (
16
16
"div" ,
17
17
Object . keys ( metadata ) . map ( ( k ) =>
18
- $el ( "div" , [ $el ( "label" , { textContent : k } ) , $el ( "span" , { textContent : metadata [ k ] } ) ] )
18
+ $el ( "div" , [
19
+ $el ( "label" , { textContent : k } ) ,
20
+ $el ( "span" , { textContent : typeof metadata [ k ] === "object" ? JSON . stringify ( metadata [ k ] ) : metadata [ k ] } ) ,
21
+ ] )
19
22
)
20
23
)
21
24
) ;
@@ -146,13 +149,10 @@ export class ModelInfoDialog extends ComfyDialog {
146
149
if ( textarea ) {
147
150
this . customNotes = textarea . value ;
148
151
149
- const resp = await api . fetchApi (
150
- "/pysssss/metadata/notes/" + encodeURIComponent ( `${ this . type } /${ this . name } ` ) ,
151
- {
152
- method : "POST" ,
153
- body : this . customNotes ,
154
- }
155
- ) ;
152
+ const resp = await api . fetchApi ( "/pysssss/metadata/notes/" + encodeURIComponent ( `${ this . type } /${ this . name } ` ) , {
153
+ method : "POST" ,
154
+ body : this . customNotes ,
155
+ } ) ;
156
156
157
157
if ( resp . status !== 200 ) {
158
158
console . error ( resp ) ;
@@ -255,11 +255,24 @@ export class ModelInfoDialog extends ComfyDialog {
255
255
} )
256
256
) ;
257
257
258
- const preview = info . images . find ( ( i ) => i . type === "image" ) ;
259
- if ( preview ) {
260
- this . img . src = preview . url ;
258
+ const allPreviews = info . images ?. filter ( ( i ) => i . type === "image" ) ;
259
+ const previews = allPreviews ?. filter ( ( i ) => i . nsfwLevel <= ModelInfoDialog . nsfwLevel ) ;
260
+ if ( previews ?. length ) {
261
+ let previewIndex = 0 ;
262
+ let preview ;
263
+ const updatePreview = ( ) => {
264
+ preview = previews [ previewIndex ] ;
265
+ this . img . src = preview . url ;
266
+ } ;
267
+
268
+ updatePreview ( ) ;
261
269
this . img . style . display = "" ;
262
270
271
+ this . img . title = `${ previews . length } previews.` ;
272
+ if ( allPreviews . length !== previews . length ) {
273
+ this . img . title += ` ${ allPreviews . length - previews . length } images hidden due to NSFW level.` ;
274
+ }
275
+
263
276
this . imgSave = $el ( "button" , {
264
277
textContent : "Use as preview" ,
265
278
parent : this . imgWrapper ,
@@ -299,6 +312,41 @@ export class ModelInfoDialog extends ComfyDialog {
299
312
app . refreshComboInNodes ( ) ;
300
313
} ,
301
314
} ) ;
315
+
316
+ $el ( "button" , {
317
+ textContent : "Show metadata" ,
318
+ parent : this . imgWrapper ,
319
+ onclick : async ( ) => {
320
+ if ( preview . meta && Object . keys ( preview . meta ) . length ) {
321
+ new MetadataDialog ( ) . show ( preview . meta ) ;
322
+ } else {
323
+ alert ( "No image metadata found" ) ;
324
+ }
325
+ } ,
326
+ } ) ;
327
+
328
+ const addNavButton = ( icon , direction ) => {
329
+ $el ( "button.pysssss-preview-nav" , {
330
+ textContent : icon ,
331
+ parent : this . imgWrapper ,
332
+ onclick : async ( ) => {
333
+ previewIndex += direction ;
334
+ if ( previewIndex < 0 ) {
335
+ previewIndex = previews . length - 1 ;
336
+ } else if ( previewIndex >= previews . length ) {
337
+ previewIndex = 0 ;
338
+ }
339
+ updatePreview ( ) ;
340
+ } ,
341
+ } ) ;
342
+ } ;
343
+
344
+ if ( previews . length > 1 ) {
345
+ addNavButton ( "‹" , - 1 ) ;
346
+ addNavButton ( "›" , 1 ) ;
347
+ }
348
+ } else if ( info . images ?. length ) {
349
+ $el ( "span" , { style : { opacity : 0.6 } , textContent : "⚠️ All images hidden due to NSFW level setting." , parent : this . imgWrapper } ) ;
302
350
}
303
351
304
352
return info ;
0 commit comments