|
1 | | -(function ($) { |
| 1 | +(function ($) { |
2 | 2 | $.widget('pic.configChemistry', { |
3 | 3 | options: {}, |
4 | 4 | _create: function () { |
|
33 | 33 | }); |
34 | 34 | $.getApiService('/config/options/chemControllers', null, 'Loading Options...', function (opts, status, xhr) { |
35 | 35 | chemOpts = opts; |
| 36 | + var standaloneSupported = typeof opts.intellichemStandaloneSupported !== 'undefined' |
| 37 | + ? makeBool(opts.intellichemStandaloneSupported) |
| 38 | + : (($('body').attr('data-controllertype') || '').toLowerCase() === 'nixie'); |
| 39 | + var standaloneEnabledMessage = 'Standalone mode keeps IntelliChem communication active even when the pool body is off. Use for Intellichem-only systems.'; |
| 40 | + var standaloneUnsupportedMessage = 'Standalone mode is only available when Nixie directly controls IntelliChem.'; |
36 | 41 | for (var i = 0; i < opts.controllers.length; i++) { |
37 | 42 | $('<div></div>').appendTo(pnl).pnlChemControllerConfig(opts)[0].dataBind(opts.controllers[i]); |
38 | 43 | } |
|
190 | 195 | case 'intellichem': |
191 | 196 | cc.name = 'IntelliChem'; |
192 | 197 | cc.address = 144; |
| 198 | + cc.intellichemStandalone = standaloneSupported && !!data.intellichemStandalone; |
193 | 199 | cc.ph = { setpoint: 7.4, dosingMethod: 0, flowReadingsOnly: true, tolerance: { enabled: true, low: 7.2, high: 7.6 }, phSupply: 1, acidType: 5, tank: { alarmEmptyEnabled: true, alarmEmptyLevel: 20 } }; |
194 | 200 | cc.orp = { setpoint: 750, dosingMethod: 0, flowReadingsOnly: true, tolerance: { enabled: true, low: 650, high: 800 }, phLockout: 7.8, tank: { alarmEmptyEnabled: true, alarmEmptyLevel: 20 } }; |
195 | 201 | break; |
|
213 | 219 | } |
214 | 220 | $('<div></div>').css({ textAlign: 'center' }).appendTo(divSelection).append('<i class="fas fa-flask" style="font-size:30pt;"></i>'); |
215 | 221 | $('<div></div>').css({ textAlign: 'center' }).appendTo(divSelection).text('Chem Controller'); |
216 | | - $('<div></div>').appendTo(divSelection).pickList({ |
| 222 | + var chemTypePick = $('<div></div>').appendTo(divSelection).pickList({ |
217 | 223 | required: true, |
218 | 224 | style: { textAlign: 'left' }, |
219 | 225 | bindColumn: 0, displayColumn: 2, labelText: 'Chem Controller Type<br/>', binding: 'type', |
|
224 | 230 | e.stopPropagation(); |
225 | 231 | }).on('mousedown', function (e) { |
226 | 232 | e.stopImmediatePropagation(); |
227 | | - |
228 | 233 | }); |
229 | | - |
| 234 | + var standaloneOpt = $('<div></div>').appendTo(divSelection).checkbox({ |
| 235 | + labelText: 'Intellichem Standalone', |
| 236 | + binding: 'intellichemStandalone' |
| 237 | + }).css({ marginTop: '.25rem', textAlign: 'left' }) |
| 238 | + .on('mousedown', function (e) { e.stopImmediatePropagation(); }) |
| 239 | + .on('click', function (e) { e.stopPropagation(); }) |
| 240 | + .hide(); |
| 241 | + var standaloneInfo = $('<span></span>').appendTo(divSelection) |
| 242 | + .css({ marginLeft: '.35rem', cursor: 'help', display: 'none' }) |
| 243 | + .append('<i class="fas fa-info-circle"></i>'); |
| 244 | + var updateStandaloneOption = function (selectedType) { |
| 245 | + var isIntellichem = typeof selectedType !== 'undefined' && selectedType !== null && selectedType.name === 'intellichem'; |
| 246 | + if (!isIntellichem || !standaloneSupported) { |
| 247 | + standaloneOpt.hide(); |
| 248 | + standaloneInfo.hide(); |
| 249 | + if (standaloneOpt[0] && typeof standaloneOpt[0].val === 'function') standaloneOpt[0].val(false); |
| 250 | + return; |
| 251 | + } |
| 252 | + standaloneOpt.show(); |
| 253 | + standaloneInfo.show(); |
| 254 | + if (standaloneOpt[0] && typeof standaloneOpt[0].disabled === 'function') standaloneOpt[0].disabled(false); |
| 255 | + }; |
| 256 | + chemTypePick.on('selchanged', function (evt) { updateStandaloneOption(evt.newItem); }); |
230 | 257 | divSelection = $('<div></div>').addClass('picButton').addClass('chemController-type').addClass('chemDoser').addClass('btn').css({ width: '157px', height: '97px', verticalAlign: 'middle' }) |
231 | 258 | .appendTo(line) |
232 | 259 | .on('mouseover', function (e) { $(e.currentTarget).addClass('button-hover'); }) |
|
1158 | 1185 | columns: [{ binding: 'val', hidden: true, text: 'Address' }, { binding: 'desc', text: 'Address' }], |
1159 | 1186 | items: addresses, inputAttrs: { style: { width: '3rem' } }, labelAttrs: { style: { marginLeft: '.25rem' } } |
1160 | 1187 | }); |
| 1188 | + $('<div></div>').appendTo(line).checkbox({ |
| 1189 | + labelText: 'Intellichem Standalone', |
| 1190 | + binding: binding + 'intellichemStandalone' |
| 1191 | + }).addClass('pnl-intellichem-standalone') |
| 1192 | + .hide(); |
| 1193 | + var standaloneTipMessage = 'Standalone mode keeps IntelliChem communication active even when the pool body is off. Use for Intellichem-only systems.'; |
| 1194 | + var standaloneInfo = $('<span></span>').appendTo(line) |
| 1195 | + .addClass('pnl-intellichem-standalone') |
| 1196 | + .css({ marginLeft: '.25rem', cursor: 'help', display: 'none' }) |
| 1197 | + .attr('tabindex', 0) |
| 1198 | + .attr('data-tip-message', standaloneTipMessage); |
| 1199 | + $('<i class="fas fa-info-circle"></i>').appendTo(standaloneInfo); |
| 1200 | + var showStandaloneTip = function () { |
| 1201 | + $.pic.fieldTip.clearTips(line); |
| 1202 | + var tipMessage = standaloneInfo.attr('data-tip-message') || standaloneTipMessage; |
| 1203 | + var tipContent = $('<div></div>').css({ |
| 1204 | + maxWidth: '22rem', |
| 1205 | + whiteSpace: 'normal', |
| 1206 | + lineHeight: '1.25rem' |
| 1207 | + }).text(tipMessage); |
| 1208 | + $.pic.fieldTip.showTip(line, { |
| 1209 | + field: standaloneInfo, |
| 1210 | + message: tipContent, |
| 1211 | + closeAfter: 5000, |
| 1212 | + placement: { my: 'right top', at: 'right bottom+8' } |
| 1213 | + }); |
| 1214 | + setTimeout(function () { |
| 1215 | + line.find('div.picFieldTip:last') |
| 1216 | + .addClass('intellichem-standalone-tip') |
| 1217 | + .removeClass('left right') |
| 1218 | + .addClass('bottom'); |
| 1219 | + }, 0); |
| 1220 | + }; |
| 1221 | + standaloneInfo |
| 1222 | + .on('mouseenter focusin click', function (evt) { |
| 1223 | + evt.stopPropagation(); |
| 1224 | + showStandaloneTip(); |
| 1225 | + }); |
1161 | 1226 | $('<hr></hr>').appendTo(pnl); |
1162 | 1227 | $('<div></div>').appendTo(pnl).addClass('pnl-chemcontroller-type'); |
1163 | 1228 |
|
|
1208 | 1273 | var cols = acc[0].columns(); |
1209 | 1274 | cols[0].elText().text(obj.name); |
1210 | 1275 | var type = o.types.find(elem => elem.val === obj.type); |
| 1276 | + var standaloneSupported = typeof o.intellichemStandaloneSupported !== 'undefined' |
| 1277 | + ? makeBool(o.intellichemStandaloneSupported) |
| 1278 | + : (($('body').attr('data-controllertype') || '').toLowerCase() === 'nixie'); |
| 1279 | + var standaloneEnabledMessage = 'Standalone mode keeps IntelliChem communication active even when the pool body is off. Use for Intellichem-only systems.'; |
| 1280 | + var standaloneUnsupportedMessage = 'Standalone mode is only available when Nixie directly controls IntelliChem.'; |
1211 | 1281 | cols[1].elText().text(typeof type !== 'undefined' ? type.desc : 'Controller'); |
1212 | 1282 |
|
1213 | 1283 | var ctype = el.attr('data-controllertype'); |
|
1258 | 1328 | if (typeof obj.orp === 'undefined') obj.orp = { |
1259 | 1329 | mixingTime: 60, maxDosingTime: 20, pump: {}, probe: {}, tank: {} |
1260 | 1330 | }; |
| 1331 | + if (typeof obj.intellichemStandalone === 'undefined') obj.intellichemStandalone = false; |
1261 | 1332 | self.splitSeconds('mixingTime', obj.ph, obj.ph.mixingTime); |
1262 | 1333 | self.splitSeconds('mixingTime', obj.orp, obj.orp.mixingTime); |
1263 | 1334 | self.splitSeconds('maxDosingTime', obj.ph, obj.ph.maxDosingTime); |
1264 | 1335 | self.splitSeconds('maxDosingTime', obj.orp, obj.orp.maxDosingTime); |
| 1336 | + el.find('div.picCheckbox[data-bind="intellichemStandalone"]').each(function () { |
| 1337 | + if (type.name === 'intellichem') { |
| 1338 | + $(this).show(); |
| 1339 | + if (typeof this.disabled === 'function') this.disabled(!standaloneSupported); |
| 1340 | + if (!standaloneSupported && typeof this.val === 'function') this.val(false); |
| 1341 | + } |
| 1342 | + else $(this).hide(); |
| 1343 | + }); |
| 1344 | + el.find('span.pnl-intellichem-standalone').each(function () { |
| 1345 | + if (type.name === 'intellichem') { |
| 1346 | + $(this).show(); |
| 1347 | + var tip = standaloneSupported ? standaloneEnabledMessage : standaloneUnsupportedMessage; |
| 1348 | + $(this).attr('data-tip-message', tip); |
| 1349 | + } |
| 1350 | + else $(this).hide(); |
| 1351 | + }); |
1265 | 1352 | if (type.hasAddress) { |
1266 | 1353 | el.find('*[data-bind="address"]').each(function () { |
1267 | 1354 | $(this).show(); |
|
0 commit comments