showMachines()

in source/web-ui/src/views/overview/Overview.tsx [315:357]


    showMachines() {
        if (!this.state.machines || this.state.machines.length === 0) {
            return (<LargeNotification key="no-machines-notification" displayText={`${I18n.get('notification.noMachines')}`}></LargeNotification>);
        }

        const selectedLocation = this.state.locations.find(loc => loc.isSelected);
        if (!selectedLocation) {
            return (<LargeNotification key="error-notification" displayText={`${I18n.get('notification.error')}`}></LargeNotification>);
        }

        const machinesInLines: { [key: string]: IMachineReferenceDataItem[] } = {};
        const unassignedMachines: IMachineReferenceDataItem[] = [];

        this.state.machines
            .filter(machine => {
                if ((selectedLocation.id === this.UNASSIGNED_MACHINES_LOCATION_ID && !machine.locationId) ||
                    (machine.locationId === selectedLocation.id)) {
                    return true;
                }

                return false;
            })
            .forEach(machine => {
                if (machine.lineId) {
                    if (!machinesInLines[machine.lineId]) {
                        machinesInLines[machine.lineId] = [];
                    }

                    machinesInLines[machine.lineId].push(machine);
                } else {
                    unassignedMachines.push(machine);
                }
            });

        return (
            <>
                {this.showLineHeader(Object.keys(machinesInLines).length > 0)}
                {Object.keys(machinesInLines).map(
                    (lineId) => (
                        <Row className="machine-container-row" key={`machine-container-row-${lineId}`}>
                            <LineRow key={`machine-container-line-${selectedLocation.id}`} locationId={selectedLocation.id} line={this.state.lines.find(line => line.id === lineId)} machines={machinesInLines[lineId]}></LineRow>
                        </Row>
                    ))}