Spaces:
Running
Running
File size: 4,786 Bytes
4902e39 1cb152d 4902e39 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
var dagcomponentfuncs = window.dashAgGridComponentFunctions = window.dashAgGridComponentFunctions || {};
dagcomponentfuncs.ModelLink = function(props) {
if (!props.data.Model_Link) {
return props.value; // Just return text if no link
}
return React.createElement(
'a',
{
href: props.data.Model_Link,
target: '_blank',
style: {
color: '#007bff',
textDecoration: 'none'
}
},
props.value
);
};
dagcomponentfuncs.PinRenderer = function(props) {
return React.createElement(
'div',
{
onClick: function() {
const api = props.api;
const modelId = props.data.Model_Display;
const isPinned = props.data.pinned || false;
if (isPinned) {
// Unpin
const currentPinned = api.getGridOption('pinnedTopRowData') || [];
const newPinnedRows = currentPinned.filter(row => row.Model_Display !== modelId);
api.setGridOption('pinnedTopRowData', newPinnedRows);
} else {
// Pin
const currentPinned = api.getGridOption('pinnedTopRowData') || [];
const pinnedRow = {...props.data, pinned: true};
api.setGridOption('pinnedTopRowData', [...currentPinned, pinnedRow]);
}
},
style: {
cursor: 'pointer',
textAlign: 'center',
fontSize: '16px'
}
},
props.data.pinned ? 'π' : 'β'
);
};
dagcomponentfuncs.TypeRenderer = function(props) {
const typeMap = {
'Base': ['Base', '#ddd']
};
// Determine type from raw flags
let type = 'Unknown';
if (props.data['Base']) {
type = 'Base';
}
const [letter, color] = typeMap[type] || ['', '#999'];
return React.createElement('div', {
style: {
display: 'flex',
alignItems: 'center',
height: '100%'
}
},
React.createElement('div', {
style: {
color: color,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontWeight: 'bold',
fontSize: '14px',
lineHeight: '1',
textAlign: 'center'
}
}, letter)
);
};
dagcomponentfuncs.BehaviorRenderer = function(props) {
const typeMap = {
'10': ['10', '#6bde57'],
'9': ['9', '#88bd11'],
'8': ['8', '#b0d38d'],
'7': ['7', '#c3c669'],
'6': ['6', '#dabe78'],
'5': ['5', '#cb7951']
};
let type = props.data['Behavior'];
const [behavior, color] = typeMap[type] || ['?', '#999'];
return React.createElement('div', {
style: {
display: 'flex',
alignItems: 'center',
height: '100%'
}
},
React.createElement('div', {
style: {
color: color,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontWeight: 'bold',
fontSize: '14px',
lineHeight: '1',
textAlign: 'center'
}
}, behavior)
);
};
dagcomponentfuncs.ScoreRenderer = function(props) {
const typeMap = {
'10': ['#6bde57'],
'9': ['#88bd11'],
'8': ['#b0d38d'],
'7': ['#c3c669'],
'6': ['#dabe78'],
'5': ['#cb7951']
};
let type = 'Unknown';
if (props.data['Score'] >= 90) {
type = '10';
} else if (props.data['Score'] >= 80) {
type = '9';
} else if (props.data['Score'] >= 70) {
type = '8';
} else if (props.data['Score'] >= 60) {
type = '7';
} else if (props.data['Score'] >= 50) {
type = '6';
} else if (props.data['Score'] >= 40) {
type = '5';
}
const [score, color] = [props.data['Score'], typeMap[type]] || [props.data['Score'], '#999'];
return React.createElement('div', {
style: {
display: 'flex',
alignItems: 'center',
height: '100%'
}
},
React.createElement('div', {
style: {
color: color,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontWeight: 'bold',
fontSize: '14px',
lineHeight: '1',
textAlign: 'center'
}
}, score)
);
}; |