This commit is contained in:
EtSL33py
2024-09-19 11:47:34 +03:00
parent 6f61688bd8
commit ab5532c8e6
3 changed files with 40 additions and 14 deletions

View File

@@ -200,6 +200,7 @@ def ui_rules():
Rule("sidebar-control-always-compact", False, bool), Rule("sidebar-control-always-compact", False, bool),
Rule("sidebar-default-width", 0.5, float, 0.0, 1.0), Rule("sidebar-default-width", 0.5, float, 0.0, 1.0),
Rule("sidebar-default-height", 0.5, float, 0.0, 1.0), Rule("sidebar-default-height", 0.5, float, 0.0, 1.0),
Rule("sidebar-default-state", "left", str),
Rule("text-input-always-hide-search-button", False, bool), Rule("text-input-always-hide-search-button", False, bool),
Rule("text-input-always-hide-clear-button", False, bool), Rule("text-input-always-hide-clear-button", False, bool),

View File

@@ -10,7 +10,7 @@
position: fixed; position: fixed;
overflow: hidden; overflow: hidden;
width: 100%; width: 100%;
z-index: 2000; z-index: 1100;
/*override comfy-modal settings*/ /*override comfy-modal settings*/
border-radius: 0; border-radius: 0;
@@ -87,6 +87,7 @@
overflow: hidden; overflow: hidden;
color: var(--input-text); color: var(--input-text);
display: flex; display: flex;
gap: 2px;
flex-direction: row-reverse; flex-direction: row-reverse;
flex-wrap: wrap; flex-wrap: wrap;
} }
@@ -148,7 +149,7 @@
width: 100%; width: 100%;
} }
.model-manager button { .model-manager button, .model-manager .model-manager-head .topbar-right select {
margin: 0; margin: 0;
border: 2px solid var(--border-color); border: 2px solid var(--border-color);
} }
@@ -168,6 +169,11 @@
cursor: not-allowed; cursor: not-allowed;
} }
.model-manager select:hover{
filter: brightness(1.2);
cursor: pointer;
}
.model-manager button.block { .model-manager button.block {
width: 100%; width: 100%;
} }
@@ -248,7 +254,7 @@
.model-manager .model-tab-group { .model-manager .model-tab-group {
display: flex; display: flex;
gap: 4px; gap: 4px;
height: 40px; height: 44px;
} }
.model-manager .model-tab-group .tab-button { .model-manager .model-tab-group .tab-button {
@@ -264,6 +270,7 @@
.model-manager .model-tab-group .tab-button.active { .model-manager .model-tab-group .tab-button.active {
background-color: var(--bg-color); background-color: var(--bg-color);
margin-bottom: -2px;
cursor: default; cursor: default;
position: relative; position: relative;
z-index: 1; z-index: 1;
@@ -451,7 +458,7 @@
} }
.model-manager .comfy-grid .model-label { .model-manager .comfy-grid .model-label {
background-color: rgb(from var(--content-hover-bg) r g b / 0.5); background-color: rgb(from var(--content-hover-bg) r g b / 0.6);
width: 100%; width: 100%;
height: 2.2rem; height: 2.2rem;
position: absolute; position: absolute;
@@ -589,7 +596,8 @@
position: relative; position: relative;
top: 0; top: 0;
bottom: 0; bottom: 0;
font-size: 24px; font-size: 20px;
text-align-last: center;
-o-appearance: none; -o-appearance: none;
-ms-appearance: none; -ms-appearance: none;
-webkit-appearance: none; -webkit-appearance: none;
@@ -690,7 +698,7 @@
.model-manager .model-manager-settings input[type="number"], .model-manager .model-manager-settings input[type="number"],
.model-manager .tag-generator-settings input[type="number"]{ .model-manager .tag-generator-settings input[type="number"]{
width: 50px; width: 60px;
} }
.model-manager .search-settings-text { .model-manager .search-settings-text {

View File

@@ -2095,10 +2095,7 @@ class ModelGrid {
systemSeparator, systemSeparator,
); );
let actionButtons = []; let actionButtons = [];
if ( if (showCopyButton) {
showAddButton &&
!(modelType === 'embeddings' && !navigator.clipboard)
) {
actionButtons.push( actionButtons.push(
new ComfyButton({ new ComfyButton({
icon: 'content-copy', icon: 'content-copy',
@@ -2114,7 +2111,7 @@ class ModelGrid {
}).element, }).element,
); );
} }
if (showCopyButton) { if (showAddButton && !(modelType === 'embeddings' && !navigator.clipboard)) {
actionButtons.push( actionButtons.push(
new ComfyButton({ new ComfyButton({
icon: 'plus-box-outline', icon: 'plus-box-outline',
@@ -4394,6 +4391,9 @@ class SettingsView {
/** @return {() => Promise<void>} */ /** @return {() => Promise<void>} */
#updateModels = () => {}; #updateModels = () => {};
/** @return {() => void} */
#updateSidebarSettings = () => {};
/** /**
* @param {Object} settingsData * @param {Object} settingsData
* @param {boolean} updateModels * @param {boolean} updateModels
@@ -4427,6 +4427,8 @@ class SettingsView {
} }
} }
this.#updateSidebarSettings(settings);
if (updateModels) { if (updateModels) {
await this.#updateModels(); // Is this slow? await this.#updateModels(); // Is this slow?
} }
@@ -4491,9 +4493,11 @@ class SettingsView {
/** /**
* @param {() => Promise<void>} updateModels * @param {() => Promise<void>} updateModels
* @param {() => void} updateSidebarButtons * @param {() => void} updateSidebarButtons
* @param {(settings: Object) => void} updateSidebarSettings
*/ */
constructor(updateModels, updateSidebarButtons) { constructor(updateModels, updateSidebarButtons, updateSidebarSettings) {
this.#updateModels = updateModels; this.#updateModels = updateModels;
this.#updateSidebarSettings = updateSidebarSettings;
const settings = this.elements.settings; const settings = this.elements.settings;
const sidebarControl = $checkbox({ const sidebarControl = $checkbox({
@@ -4569,6 +4573,7 @@ class SettingsView {
{ {
style: { color: 'var(--fg-color)' }, style: { color: 'var(--fg-color)' },
href: 'https://github.com/hayden-fr/ComfyUI-Model-Manager/issues/', href: 'https://github.com/hayden-fr/ComfyUI-Model-Manager/issues/',
target: '_blank',
}, },
['File bugs and issues here.'], ['File bugs and issues here.'],
), ),
@@ -4604,6 +4609,11 @@ class SettingsView {
'vae_approx', 'vae_approx',
], ],
}), }),
$select({
$: (el) => (settings['sidebar-default-state'] = el),
textContent: 'Default model manager position',
options: ['left', 'right', 'top', 'bottom', 'none'],
}),
$checkbox({ $checkbox({
$: (el) => (settings['model-real-time-search'] = el), $: (el) => (settings['model-real-time-search'] = el),
textContent: 'Real-time search', textContent: 'Real-time search',
@@ -4833,6 +4843,7 @@ function GenerateSidebarToggleRadioAndSelect(labels, activationCallbacks = []) {
'select', 'select',
{ {
name: 'sidebar-select', name: 'sidebar-select',
classList: 'icon-button',
onchange: (event) => { onchange: (event) => {
const select = event.target; const select = event.target;
const children = select.children; const children = select.children;
@@ -4970,6 +4981,7 @@ class ModelManager extends ComfyDialog {
this.#settingsView = new SettingsView(this.#refreshModels, () => this.#settingsView = new SettingsView(this.#refreshModels, () =>
this.#updateSidebarButtons(), this.#updateSidebarButtons(),
this.#updateSidebarSettings,
); );
this.#modelInfo = new ModelInfo( this.#modelInfo = new ModelInfo(
@@ -5350,9 +5362,13 @@ class ModelManager extends ComfyDialog {
async #init() { async #init() {
await this.#settingsView.reload(false); await this.#settingsView.reload(false);
await this.#refreshModels(); await this.#refreshModels();
}
const settings = this.#settingsView.elements.settings; /**
* @param {settings: Object}
* @return {void}
*/
#updateSidebarSettings = (settings) => {
{ {
// initialize buttons' visibility state // initialize buttons' visibility state
const hideSearchButtons = const hideSearchButtons =
@@ -5374,6 +5390,7 @@ class ModelManager extends ComfyDialog {
const xDecimal = settings['sidebar-default-width'].value; const xDecimal = settings['sidebar-default-width'].value;
const yDecimal = settings['sidebar-default-height'].value; const yDecimal = settings['sidebar-default-height'].value;
this.element.dataset['sidebarState'] = settings['sidebar-default-state'].value;
this.element.dataset['sidebarLeftWidthDecimal'] = xDecimal; this.element.dataset['sidebarLeftWidthDecimal'] = xDecimal;
this.element.dataset['sidebarRightWidthDecimal'] = xDecimal; this.element.dataset['sidebarRightWidthDecimal'] = xDecimal;
this.element.dataset['sidebarTopHeightDecimal'] = yDecimal; this.element.dataset['sidebarTopHeightDecimal'] = yDecimal;