Update assets/dashAgGridComponentFunctions.js
Browse files
assets/dashAgGridComponentFunctions.js
CHANGED
|
@@ -2,6 +2,10 @@ var dagcomponentfuncs = window.dashAgGridComponentFunctions = window.dashAgGridC
|
|
| 2 |
// Store original data globally
|
| 3 |
window.gridOriginalData = null;
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
dagcomponentfuncs.ModelLink = function(props) {
|
| 6 |
if (!props.data.Model_Link) {
|
| 7 |
return props.value; // Just return text if no link
|
|
@@ -20,41 +24,30 @@ dagcomponentfuncs.ModelLink = function(props) {
|
|
| 20 |
);
|
| 21 |
};
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
const allRows = [];
|
| 27 |
-
props.api.forEachNode(node => {
|
| 28 |
-
allRows.push({...node.data});
|
| 29 |
-
});
|
| 30 |
-
window.gridOriginalData = allRows;
|
| 31 |
-
}
|
| 32 |
|
|
|
|
| 33 |
return React.createElement(
|
| 34 |
'div',
|
| 35 |
{
|
| 36 |
onClick: function() {
|
| 37 |
const api = props.api;
|
| 38 |
-
const
|
| 39 |
-
|
| 40 |
-
// Create a copy of the original data and update pin state for clicked row only
|
| 41 |
-
const allRows = window.gridOriginalData.map(row => ({
|
| 42 |
-
...row,
|
| 43 |
-
// Preserve existing pin states and only update the clicked row
|
| 44 |
-
pinned: row.Model_Display === props.data.Model_Display ? newValue :
|
| 45 |
-
(row.pinned || false)
|
| 46 |
-
}));
|
| 47 |
-
|
| 48 |
-
// Update window.gridOriginalData to maintain pin states
|
| 49 |
-
window.gridOriginalData = allRows;
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
},
|
| 59 |
style: {
|
| 60 |
cursor: 'pointer',
|
|
@@ -62,6 +55,54 @@ dagcomponentfuncs.PinRenderer = function(props) {
|
|
| 62 |
fontSize: '16px'
|
| 63 |
}
|
| 64 |
},
|
| 65 |
-
props.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
);
|
| 67 |
};
|
|
|
|
| 2 |
// Store original data globally
|
| 3 |
window.gridOriginalData = null;
|
| 4 |
|
| 5 |
+
// Global store for pinned model IDs
|
| 6 |
+
window.pinnedModelIds = new Set(JSON.parse(localStorage.getItem('pinnedModelIds') || '[]'));
|
| 7 |
+
|
| 8 |
+
|
| 9 |
dagcomponentfuncs.ModelLink = function(props) {
|
| 10 |
if (!props.data.Model_Link) {
|
| 11 |
return props.value; // Just return text if no link
|
|
|
|
| 24 |
);
|
| 25 |
};
|
| 26 |
|
| 27 |
+
if (!localStorage.getItem('pinnedModelIds')) {
|
| 28 |
+
localStorage.setItem('pinnedModelIds', '[]');
|
| 29 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
dagcomponentfuncs.PinRenderer = function(props) {
|
| 32 |
return React.createElement(
|
| 33 |
'div',
|
| 34 |
{
|
| 35 |
onClick: function() {
|
| 36 |
const api = props.api;
|
| 37 |
+
const modelId = props.data.Model_Display;
|
| 38 |
+
const isPinned = props.data.pinned || false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
if (isPinned) {
|
| 41 |
+
// Unpin
|
| 42 |
+
const currentPinned = api.getGridOption('pinnedTopRowData') || [];
|
| 43 |
+
const newPinnedRows = currentPinned.filter(row => row.Model_Display !== modelId);
|
| 44 |
+
api.setGridOption('pinnedTopRowData', newPinnedRows);
|
| 45 |
+
} else {
|
| 46 |
+
// Pin
|
| 47 |
+
const currentPinned = api.getGridOption('pinnedTopRowData') || [];
|
| 48 |
+
const pinnedRow = {...props.data, pinned: true};
|
| 49 |
+
api.setGridOption('pinnedTopRowData', [...currentPinned, pinnedRow]);
|
| 50 |
+
}
|
| 51 |
},
|
| 52 |
style: {
|
| 53 |
cursor: 'pointer',
|
|
|
|
| 55 |
fontSize: '16px'
|
| 56 |
}
|
| 57 |
},
|
| 58 |
+
props.data.pinned ? 'π' : 'β'
|
| 59 |
+
);
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
dagcomponentfuncs.TypeRenderer = function(props) {
|
| 63 |
+
const typeMap = {
|
| 64 |
+
'Base': ['B', '#71de5f'],
|
| 65 |
+
'Finetune': ['F', '#f6b10b'],
|
| 66 |
+
'Merge': ['M', '#f08aff'],
|
| 67 |
+
'Proprietary': ['P', '#19cdce']
|
| 68 |
+
};
|
| 69 |
+
|
| 70 |
+
// Determine type from raw flags
|
| 71 |
+
let type = 'Unknown';
|
| 72 |
+
if (props.data['Total Parameters'] === null) {
|
| 73 |
+
type = 'Proprietary';
|
| 74 |
+
} else if (props.data['Is Foundation'] && !props.data['Is Merged']) {
|
| 75 |
+
type = 'Base';
|
| 76 |
+
} else if (props.data['Is Merged']) {
|
| 77 |
+
type = 'Merge';
|
| 78 |
+
} else if (props.data['Is Finetuned'] && !props.data['Is Merged']) {
|
| 79 |
+
type = 'Finetune';
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
const [letter, color] = typeMap[type] || ['?', '#999'];
|
| 83 |
+
|
| 84 |
+
return React.createElement('div', {
|
| 85 |
+
style: {
|
| 86 |
+
display: 'flex',
|
| 87 |
+
alignItems: 'center',
|
| 88 |
+
height: '100%',
|
| 89 |
+
position: 'absolute',
|
| 90 |
+
top: 0,
|
| 91 |
+
bottom: 0,
|
| 92 |
+
left: '12px'
|
| 93 |
+
}
|
| 94 |
+
},
|
| 95 |
+
React.createElement('div', {
|
| 96 |
+
style: {
|
| 97 |
+
color: color,
|
| 98 |
+
display: 'flex',
|
| 99 |
+
alignItems: 'center',
|
| 100 |
+
justifyContent: 'center',
|
| 101 |
+
fontWeight: 'bold',
|
| 102 |
+
fontSize: '14px',
|
| 103 |
+
lineHeight: '1',
|
| 104 |
+
textAlign: 'center'
|
| 105 |
+
}
|
| 106 |
+
}, letter)
|
| 107 |
);
|
| 108 |
};
|