()
| 198 | // =========================================================================================== |
| 199 | |
| 200 | initGrid() { |
| 201 | const container = this.element.querySelector(".cmm-manager-grid"); |
| 202 | const grid = new TG.Grid(container); |
| 203 | this.grid = grid; |
| 204 | |
| 205 | grid.bind('onUpdated', (e, d) => { |
| 206 | |
| 207 | this.showStatus(`${grid.viewRows.length.toLocaleString()} external models`); |
| 208 | |
| 209 | }); |
| 210 | |
| 211 | grid.bind('onSelectChanged', (e, changes) => { |
| 212 | this.renderSelected(); |
| 213 | }); |
| 214 | |
| 215 | grid.bind("onColumnWidthChanged", (e, columnItem) => { |
| 216 | storeColumnWidth(gridId, columnItem) |
| 217 | }); |
| 218 | |
| 219 | grid.bind('onClick', (e, d) => { |
| 220 | const { rowItem } = d; |
| 221 | const target = d.e.target; |
| 222 | const mode = target.getAttribute("mode"); |
| 223 | if (mode === "install") { |
| 224 | this.installModels([rowItem], target); |
| 225 | } |
| 226 | |
| 227 | }); |
| 228 | |
| 229 | grid.setOption({ |
| 230 | theme: 'dark', |
| 231 | |
| 232 | selectVisible: true, |
| 233 | selectMultiple: true, |
| 234 | selectAllVisible: true, |
| 235 | |
| 236 | textSelectable: true, |
| 237 | scrollbarRound: true, |
| 238 | |
| 239 | frozenColumn: 1, |
| 240 | rowNotFound: "No Results", |
| 241 | |
| 242 | rowHeight: 40, |
| 243 | bindWindowResize: true, |
| 244 | bindContainerResize: true, |
| 245 | |
| 246 | cellResizeObserver: (rowItem, columnItem) => { |
| 247 | const autoHeightColumns = ['name', 'description']; |
| 248 | return autoHeightColumns.includes(columnItem.id) |
| 249 | }, |
| 250 | |
| 251 | // updateGrid handler for filter and keywords |
| 252 | rowFilter: (rowItem) => { |
| 253 | |
| 254 | const searchableColumns = ["name", "type", "base", "description", "filename", "save_path"]; |
| 255 | const models_extensions = ['.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft']; |
| 256 | |
| 257 | let shouldShown = grid.highlightKeywordsFilter(rowItem, searchableColumns, this.keywords); |
no test coverage detected