(options)
| 653 | } |
| 654 | |
| 655 | function DeviceStatusCell(options) { |
| 656 | var stateClasses = { |
| 657 | using: 'state-using btn-primary' |
| 658 | , busy: 'state-busy btn-warning' |
| 659 | , available: 'state-available btn-primary-outline' |
| 660 | , ready: 'state-ready btn-primary-outline' |
| 661 | , present: 'state-present btn-primary-outline' |
| 662 | , preparing: 'state-preparing btn-primary-outline btn-success-outline' |
| 663 | , unauthorized: 'state-unauthorized btn-danger-outline' |
| 664 | , offline: 'state-offline btn-warning-outline' |
| 665 | , automation: 'state-automation btn-info' |
| 666 | } |
| 667 | |
| 668 | return _.defaults(options, { |
| 669 | title: options.title |
| 670 | , defaultOrder: 'asc' |
| 671 | , build: function() { |
| 672 | var td = document.createElement('td') |
| 673 | var a = document.createElement('a') |
| 674 | a.appendChild(document.createTextNode('')) |
| 675 | td.appendChild(a) |
| 676 | return td |
| 677 | } |
| 678 | , update: function(td, device) { |
| 679 | var a = td.firstChild |
| 680 | var t = a.firstChild |
| 681 | |
| 682 | a.className = 'btn btn-xs device-status ' + |
| 683 | (stateClasses[device.state] || 'btn-default-outline') |
| 684 | |
| 685 | if (device.usable && !device.using) { |
| 686 | a.href = '#!/control/' + device.serial |
| 687 | } |
| 688 | else { |
| 689 | a.removeAttribute('href') |
| 690 | } |
| 691 | |
| 692 | t.nodeValue = options.value(device) |
| 693 | |
| 694 | return td |
| 695 | } |
| 696 | , compare: (function() { |
| 697 | var order = { |
| 698 | using: 10 |
| 699 | , automation: 15 |
| 700 | , available: 20 |
| 701 | , busy: 30 |
| 702 | , ready: 40 |
| 703 | , preparing: 50 |
| 704 | , unauthorized: 60 |
| 705 | , offline: 70 |
| 706 | , present: 80 |
| 707 | , absent: 90 |
| 708 | } |
| 709 | return function(deviceA, deviceB) { |
| 710 | return order[deviceA.state] - order[deviceB.state] |
| 711 | } |
| 712 | })() |
no outgoing calls
no test coverage detected