From ae72bfcbcafcc2c04f4f608a043d651685f32ba9 Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Sun, 6 Jun 2021 16:41:58 +0200 Subject: [PATCH] Work in progress --- src-rx/package.json | 9 +- src-rx/public/index.html | 2 +- src-rx/src/assets/devices/Irrigation.svg | 22 -- src-rx/src/assets/devices/Printer.svg | 10 + src-rx/src/assets/devices/SmokeDetector.svg | 13 + .../assets/devices/Temperature Sensors.svg | 37 ++- src-rx/src/assets/devices/list.json | 286 +++++++++--------- src-rx/src/assets/rooms/Chamber.svg | 22 +- src-rx/src/assets/rooms/list.json | 18 +- src-rx/src/components/Connection.js | 2 +- src-rx/src/components/Drawer.js | 32 +- src-rx/src/components/Enums/EnumBlock.js | 8 +- src-rx/src/components/Enums/EnumEditDialog.js | 29 +- .../ColorPicker/components/ColorPicker.js | 115 ------- .../ColorPicker/components/PickerDialog.js | 26 -- .../IOFields/ColorPicker/index.d.ts | 19 -- .../components/IOFields/ColorPicker/index.js | 2 - .../IOFields/ColorPicker/transformers.js | 11 - src-rx/src/components/IOFields/Fields.js | 153 +--------- src-rx/src/components/Workers/LogsWorker.js | 14 +- 20 files changed, 250 insertions(+), 580 deletions(-) delete mode 100644 src-rx/src/assets/devices/Irrigation.svg create mode 100644 src-rx/src/assets/devices/Printer.svg create mode 100644 src-rx/src/assets/devices/SmokeDetector.svg delete mode 100644 src-rx/src/components/IOFields/ColorPicker/components/ColorPicker.js delete mode 100644 src-rx/src/components/IOFields/ColorPicker/components/PickerDialog.js delete mode 100644 src-rx/src/components/IOFields/ColorPicker/index.d.ts delete mode 100644 src-rx/src/components/IOFields/ColorPicker/index.js delete mode 100644 src-rx/src/components/IOFields/ColorPicker/transformers.js diff --git a/src-rx/package.json b/src-rx/package.json index 9cf0642d4..dff801a9b 100644 --- a/src-rx/package.json +++ b/src-rx/package.json @@ -10,7 +10,7 @@ "@date-io/core": "^1.3.13", "@date-io/date-fns": "^1.3.13", "@fnando/sparkline": "^0.3.10", - "@iobroker/adapter-react": "^1.6.24", + "@iobroker/adapter-react": "^1.6.25", "@material-ui/core": "^4.11.4", "@material-ui/data-grid": "^4.0.0-alpha.30", "@material-ui/icons": "^4.11.2", @@ -27,7 +27,7 @@ "echarts": "^4.9.0", "echarts-for-react": "^2.0.16", "leaflet": "^1.7.1", - "leaflet-geosearch": "^3.3.2", + "leaflet-geosearch": "^3.2.2", "lodash": "^4.17.21", "material-ui-chip-input": "^2.0.0-beta.2", "ol": "^6.5.0", @@ -46,7 +46,8 @@ "react-dropzone": "^11.3.2", "react-icons": "^4.2.0", "react-inlinesvg": "^2.3.0", - "react-leaflet": "^3.2.0", + "react-leaflet": "3.1.0", + "@react-leaflet/core": "1.0.2", "react-markdown": "^6.0.2", "react-scripts": "^4.0.3", "react-showdown": "^2.3.0", @@ -75,4 +76,4 @@ "last 1 safari version" ] } -} \ No newline at end of file +} diff --git a/src-rx/public/index.html b/src-rx/public/index.html index b8571e571..447253e41 100644 --- a/src-rx/public/index.html +++ b/src-rx/public/index.html @@ -28,7 +28,7 @@ }; setTimeout(() => { - script.src = window.location.port === '3000' ? window.location.protocol + '//' + window.location.hostname + ':8081/lib/js/socket.io.js' : '%PUBLIC_URL%/lib/js/socket.io.js'; + script.src = window.location.port === '3000' ? window.location.protocol + '//iob-server:8081/lib/js/socket.io.js' : '%PUBLIC_URL%/lib/js/socket.io.js'; }, 1000); document.head.appendChild(script); diff --git a/src-rx/src/assets/devices/Irrigation.svg b/src-rx/src/assets/devices/Irrigation.svg deleted file mode 100644 index 03db9a066..000000000 --- a/src-rx/src/assets/devices/Irrigation.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src-rx/src/assets/devices/Printer.svg b/src-rx/src/assets/devices/Printer.svg new file mode 100644 index 000000000..ffef4e660 --- /dev/null +++ b/src-rx/src/assets/devices/Printer.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src-rx/src/assets/devices/SmokeDetector.svg b/src-rx/src/assets/devices/SmokeDetector.svg new file mode 100644 index 000000000..a69db012a --- /dev/null +++ b/src-rx/src/assets/devices/SmokeDetector.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src-rx/src/assets/devices/Temperature Sensors.svg b/src-rx/src/assets/devices/Temperature Sensors.svg index 93291a756..3a9f374b3 100644 --- a/src-rx/src/assets/devices/Temperature Sensors.svg +++ b/src-rx/src/assets/devices/Temperature Sensors.svg @@ -1,13 +1,28 @@ - + - - - - - - - - - + + + + + + + + + - \ No newline at end of file + diff --git a/src-rx/src/assets/devices/list.json b/src-rx/src/assets/devices/list.json index 5ac77132f..2dbfd2401 100644 --- a/src-rx/src/assets/devices/list.json +++ b/src-rx/src/assets/devices/list.json @@ -1,26 +1,26 @@ [ { - "_id": "hoods", + "_id": "hood", "name": { - "en": "Hoods", - "ru": "Вытяжки", - "de": "Abzugshauben", - "fr": "Capots", + "en": "Hood", + "ru": "Вытяжка", + "de": "Abzugshaube", + "fr": "Capot", "it": "Cappe", - "nl": "Hoods", + "nl": "Hood", "pl": "Okapy", - "pt": "Hoods", - "es": "Campanas", + "pt": "Hood", + "es": "Campana", "zh-cn": "抽油烟机" }, "icon": "Hoods.svg" }, { - "_id": "alarm_systems", + "_id": "alarm_system", "name": { - "en": "Alarm Systems", - "ru": "Системы Сигнализации", - "de": "Alarmanlagen", + "en": "Alarm System", + "ru": "Сигнализация", + "de": "Alarmanlage", "fr": "Systèmes D'Alarme", "it": "Sistemi Di Allarme", "nl": "Alarm Systems", @@ -35,7 +35,7 @@ "_id": "battery_status", "name": { "en": "Battery Status", - "ru": "Заряд Батареи", + "ru": "Заряд батареи", "de": "Batteriestatus", "fr": "État De La Batterie", "it": "Stato Della Batteria", @@ -48,10 +48,10 @@ "icon": "Battery Status.svg" }, { - "_id": "lightings", + "_id": "lighting", "name": { - "en": "Lightings", - "ru": "Светильники", + "en": "Lighting", + "ru": "Светильник", "de": "Beleuchtung", "fr": "Éclairages", "it": "Illuminazione", @@ -128,42 +128,42 @@ "icon": "Computer.svg" }, { - "_id": "ceiling_spotlights", + "_id": "ceiling_spotlight", "name": { - "en": "Ceiling Spotlights", - "ru": "Потолочные Прожекторы", - "de": "Deckenspots", - "fr": "Plafond Spotlights", + "en": "Ceiling Spotlight", + "ru": "Потолочный прожектор", + "de": "Deckenspot", + "fr": "Plafond Spotlight", "it": "Faretti A Soffitto", - "nl": "Plafond Spotlights", + "nl": "Plafond Spotlight", "pl": "Reflektory Sufitowe", - "pt": "Tecto Focos", + "pt": "Tecto Foco", "es": "Focos De Techo", "zh-cn": "天花射灯" }, "icon": "Ceiling Spotlights.svg" }, { - "_id": "handle", + "_id": "printer", "name": { - "en": "Handle", - "ru": "Ручка", - "de": "Drücker", - "fr": "Manipuler", - "it": "Maniglia", - "nl": "Handvat", - "pl": "Uchwyt", - "pt": "Lidar Com", - "es": "Resolver", - "zh-cn": "处理" + "en": "Printer", + "de": "Drucker", + "ru": "Принтер", + "pt": "Impressora", + "nl": "Printer", + "fr": "Imprimante", + "it": "Stampante", + "es": "Impresora", + "pl": "Drukarka", + "zh-cn": "打印机" }, - "icon": "Handle.svg" + "icon": "Printer.svg" }, { "_id": "power_consumption", "name": { "en": "Power Consumption", - "ru": "Потребляемая Мощность", + "ru": "Потребляемая мощность", "de": "Stromverbrauch", "fr": "Consommation D'Énergie", "it": "Consumo Di Energia", @@ -192,14 +192,14 @@ "icon": "Window.svg" }, { - "_id": "garage_doors", + "_id": "garage_door", "name": { - "en": "Garage Doors", + "en": "Garage Door", "ru": "Гаражные Ворота", - "de": "Garagentore", + "de": "Garagentor", "fr": "Portes De Garage", - "it": "Garage Doors", - "nl": "Garage Doors", + "it": "Garage Door", + "nl": "Garage Door", "pl": "Bramy Garażowe", "pt": "Portas De Garagem", "es": "Las Puertas De Garaje", @@ -224,11 +224,11 @@ "icon": "Hairdryer.svg" }, { - "_id": "hanging_lamps", + "_id": "hanging_lamp", "name": { - "en": "Hanging Lamps", - "ru": "Подвесные Светильники", - "de": "Hängelampen", + "en": "Hanging Lamp", + "ru": "Подвесной светильник", + "de": "Hängelampe", "fr": "Lampes Suspendues", "it": "Lampade A Sospensione", "nl": "Opknoping Lampen", @@ -242,9 +242,9 @@ { "_id": "doorstep", "name": { - "en": "Doorstep", - "ru": "Порог", - "de": "Haustüre", + "en": "Enterance", + "ru": "Входная дверь", + "de": "Haustür", "fr": "Seuil De Porte", "it": "Gradino Della Porta", "nl": "Drempel", @@ -259,7 +259,7 @@ "_id": "hot_water", "name": { "en": "Hot Water", - "ru": "Горячая Вода", + "ru": "Горячая вода", "de": "Heißwasser", "fr": "Eau Chaude", "it": "Acqua Calda", @@ -272,10 +272,10 @@ "icon": "Hot Water.svg" }, { - "_id": "heater", + "_id": "heating", "name": { - "en": "Heater", - "ru": "Подогреватель", + "en": "Heating", + "ru": "Отопление", "de": "Heizung", "fr": "Chauffe-Eau", "it": "Riscaldatore", @@ -307,7 +307,7 @@ "_id": "louvre", "name": { "en": "Louvre", - "ru": "Жалюзийное Отверстие", + "ru": "Жалюзи", "de": "Jalousie", "fr": "Persienne", "it": "Persiana Di Ventilazione", @@ -320,17 +320,17 @@ "icon": "Louvre.svg" }, { - "_id": "coffee_makers", + "_id": "coffee_maker", "name": { - "en": "Coffee Makers", - "ru": "Кофеварки", - "de": "Kaffemaschinen", - "fr": "Cafetières", + "en": "Coffee Maker", + "ru": "Кофеварка", + "de": "Kaffemaschine", + "fr": "Cafetière", "it": "Macchine Da Caffè", - "nl": "Koffie Makers", + "nl": "Koffie Maker", "pl": "Ekspresy Do Kawy", - "pt": "Cafeteiras", - "es": "Cafeteras", + "pt": "Cafeteira", + "es": "Cafetera", "zh-cn": "咖啡壶" }, "icon": "Coffee Makers.svg" @@ -339,7 +339,7 @@ "_id": "cold_water", "name": { "en": "Cold Water", - "ru": "Холодная Вода", + "ru": "Холодная вода", "de": "Kaltwasser", "fr": "Eau Froide", "it": "Acqua Fredda", @@ -371,7 +371,7 @@ "_id": "speaker", "name": { "en": "Speaker", - "ru": "Оратор", + "ru": "Звуковая система", "de": "Lautsprecher", "fr": "Orateur", "it": "Altoparlante", @@ -387,7 +387,7 @@ "_id": "led_strip", "name": { "en": "Led Strip", - "ru": "Светодиодная Полоса", + "ru": "Светодиодная лента", "de": "LED Leiste", "fr": "Led Strip", "it": "Led Strip", @@ -419,7 +419,7 @@ "_id": "fan", "name": { "en": "Fan", - "ru": "Поклонник", + "ru": "Вентилятор", "de": "Lüfter", "fr": "Ventilateur", "it": "Fan", @@ -480,11 +480,11 @@ "icon": "Chandelier.svg" }, { - "_id": "awnings", + "_id": "awning", "name": { - "en": "Awnings", - "ru": "Тенты", - "de": "Markisen", + "en": "Awning", + "ru": "Маркиза", + "de": "Markise", "fr": "Auvents", "it": "Tende", "nl": "Luifels", @@ -548,7 +548,7 @@ "name": { "en": "Pump", "ru": "Насос", - "de": "Pumpen", + "de": "Pumpe", "fr": "Pompe", "it": "Pompa", "nl": "Pomp", @@ -563,8 +563,8 @@ "_id": "outdoor_blinds", "name": { "en": "Outdoor Blinds", - "ru": "Открытый Жалюзи", - "de": "Raffstoren", + "ru": "Внещгте жалюзи", + "de": "Raffstore", "fr": "Volets", "it": "Tende Da Esterni", "nl": "Outdoor Blinds", @@ -579,7 +579,7 @@ "_id": "mowing_machine", "name": { "en": "Mowing Machine", - "ru": "Стрижка Машина", + "ru": "Газонокосилка", "de": "Rasenmäher", "fr": "Machine De Fauchage", "it": "Macchina Di Falciatura", @@ -595,7 +595,7 @@ "_id": "receiver", "name": { "en": "Receiver", - "ru": "Приемник", + "ru": "Приставка", "de": "Receiver", "fr": "Destinataire", "it": "Ricevitore", @@ -607,22 +607,6 @@ }, "icon": "Receiver.svg" }, - { - "_id": "computer", - "name": { - "en": "Computer", - "ru": "Компьютер", - "de": "Rechner", - "fr": "L'Ordinateur", - "it": "Computer", - "nl": "Computer", - "pl": "Komputer", - "pt": "Computador", - "es": "Ordenador", - "zh-cn": "电脑" - }, - "icon": "Computer.svg" - }, { "_id": "shutters", "name": { @@ -639,6 +623,22 @@ }, "icon": "Shutters.svg" }, + { + "_id": "smoke_detector", + "name": { + "en": "Smoke detector", + "de": "Rauchmelder", + "ru": "Детектор дыма", + "pt": "Detector de fumaça", + "nl": "Rookdetector", + "fr": "Détecteur de fumée", + "it": "Rilevatore di fumo", + "es": "Detector de humo", + "pl": "Wykrywacz dymu", + "zh-cn": "烟雾探测器" + }, + "icon": "SmokeDetector.svg" + }, { "_id": "lock", "name": { @@ -672,11 +672,11 @@ "icon": "Security.svg" }, { - "_id": "dishwashers", + "_id": "dishwasher", "name": { - "en": "Dishwashers", - "ru": "Посудомоечные", - "de": "Spülmaschinen", + "en": "Dishwasher", + "ru": "Посудомоечная машина", + "de": "Spülmaschine", "fr": "Lave-Vaisselles", "it": "Lavastoviglie", "nl": "Vaatwassers", @@ -704,27 +704,27 @@ "icon": "Vacuum Cleaner.svg" }, { - "_id": "sockets", + "_id": "socket", "name": { - "en": "Sockets", - "ru": "Розетки", - "de": "Steckdosen", - "fr": "Prises", - "it": "Sockets", - "nl": "Sockets", + "en": "Socket", + "ru": "Розетка", + "de": "Steckdose", + "fr": "Prise", + "it": "Socket", + "nl": "Socket", "pl": "Gniazdka", - "pt": "Tomadas", - "es": "Zócalos", + "pt": "Tomada", + "es": "Zócalo", "zh-cn": "套接字" }, "icon": "Sockets.svg" }, { - "_id": "floor_lamps", + "_id": "floor_lamp", "name": { - "en": "Floor Lamps", - "ru": "Торшеры", - "de": "Stehlampen", + "en": "Floor Lamp", + "ru": "Торшер", + "de": "Stehlampe", "fr": "Lampes Pour Plancher", "it": "Lampade A Stelo", "nl": "Vloerlampen", @@ -739,7 +739,7 @@ "_id": "power_consumption", "name": { "en": "Power Consumption", - "ru": "Потребляемая Мощность", + "ru": "Потребляемая мощность", "de": "Stromverbrauch", "fr": "Consommation D'Énergie", "it": "Consumo Di Energia", @@ -752,14 +752,14 @@ "icon": "Power Consumption.svg" }, { - "_id": "temperature_sensors", + "_id": "temperature_sensor", "name": { - "en": "Temperature Sensors", - "ru": "Температурные Датчики", - "de": "Temperatur-Sensoren", - "fr": "Capteurs De Température", + "en": "Temperature Sensor", + "ru": "Температурный датчик", + "de": "Temperatur-Sensor", + "fr": "Capteur De Température", "it": "Sensori Di Temperatura", - "nl": "Temperatuursensoren", + "nl": "Temperatuursensor", "pl": "Czujniki Temperatury", "pt": "Sensores De Temperatura", "es": "Sensores De Temperatura", @@ -768,11 +768,11 @@ "icon": "Temperature Sensors.svg" }, { - "_id": "table_lamps", + "_id": "table_lamp", "name": { - "en": "Table Lamps", - "ru": "Настольные Лампы", - "de": "Tischlampen", + "en": "Table Lamp", + "ru": "Настольная лампа", + "de": "Tischlampe", "fr": "Lampe De Chevet", "it": "Lampade Da Tavolo", "nl": "Tafellampen", @@ -784,14 +784,14 @@ "icon": "Table Lamps.svg" }, { - "_id": "gates", + "_id": "gate", "name": { - "en": "Gates", + "en": "Gate", "ru": "Ворота", - "de": "Tore", - "fr": "Portes", - "it": "Gates", - "nl": "Gates", + "de": "Tor", + "fr": "Porte", + "it": "Gate", + "nl": "Gate", "pl": "Bramy", "pt": "Portões", "es": "Puertas", @@ -816,11 +816,11 @@ "icon": "Dryer.svg" }, { - "_id": "doors", + "_id": "door", "name": { - "en": "Doors", - "ru": "Двери", - "de": "Türen", + "en": "Door", + "ru": "Дверь", + "de": "Tür", "fr": "Des Portes", "it": "Porte", "nl": "Deuren", @@ -867,7 +867,7 @@ "_id": "amplifier", "name": { "en": "Amplifier", - "ru": "Усилитель Звука", + "ru": "Усилитель звука", "de": "Verstärker", "fr": "Amplificateur", "it": "Amplificatore", @@ -896,14 +896,14 @@ "icon": "Curtains.svg" }, { - "_id": "sconces", + "_id": "sconce", "name": { - "en": "Sconces", - "ru": "Sconces", - "de": "Wandlampen", - "fr": "Sconces", - "it": "Sconces", - "nl": "Sconces", + "en": "Sconce", + "ru": "Настенный светильник", + "de": "Wandlampe", + "fr": "Sconce", + "it": "Sconce", + "nl": "Sconce", "pl": "Kinkiety", "pt": "Arandelas", "es": "Los Apliques", @@ -912,11 +912,11 @@ "icon": "Sconces.svg" }, { - "_id": "washing_machines", + "_id": "washing_machine", "name": { - "en": "Washing Machines", - "ru": "Стиральные Машины", - "de": "Waschmaschinen", + "en": "Washing Machine", + "ru": "Стиральная машина", + "de": "Waschmaschine", "fr": "Machines À Laver", "it": "Lavatrici", "nl": "Wasmachines", @@ -931,7 +931,7 @@ "_id": "water", "name": { "en": "Water", - "ru": "Воды", + "ru": "Вода", "de": "Wasser", "fr": "L'Eau", "it": "Acqua", @@ -947,7 +947,7 @@ "_id": "water_heater", "name": { "en": "Water Heater", - "ru": "Нагреватель Воды", + "ru": "Нагреватель воды", "de": "Wasserkocher", "fr": "Chauffe-Eau", "it": "Scaldabagno", @@ -963,7 +963,7 @@ "_id": "water_consumption", "name": { "en": "Water Consumption", - "ru": "Потребление Воды", + "ru": "Потребление воды", "de": "Wasserverbrauch", "fr": "Consommation D'Eau", "it": "Consumo D'Acqua", diff --git a/src-rx/src/assets/rooms/Chamber.svg b/src-rx/src/assets/rooms/Chamber.svg index 218540462..c6a2077ac 100644 --- a/src-rx/src/assets/rooms/Chamber.svg +++ b/src-rx/src/assets/rooms/Chamber.svg @@ -1,17 +1,9 @@ - + - - - - - - - - - - - - - + + + + + - \ No newline at end of file + diff --git a/src-rx/src/assets/rooms/list.json b/src-rx/src/assets/rooms/list.json index 1c96423f6..82ba2604b 100644 --- a/src-rx/src/assets/rooms/list.json +++ b/src-rx/src/assets/rooms/list.json @@ -751,27 +751,11 @@ }, "icon": "Toilet.svg" }, - { - "_id": "stairway", - "name": { - "en": "Stairway", - "ru": "Лестница", - "de": "Treppe", - "fr": "Escalier", - "it": "Scala", - "nl": "Trap", - "pl": "Klatka Schodowa", - "pt": "Escada", - "es": "Escalera", - "zh-cn": "楼梯" - }, - "icon": "Stairway.svg" - }, { "_id": "stairwell", "name": { "en": "Stairwell", - "ru": "Лестничная Клетка", + "ru": "Лестничная клетка", "de": "Treppenhaus", "fr": "Cage D'Escalier", "it": "Tromba Delle Scale", diff --git a/src-rx/src/components/Connection.js b/src-rx/src/components/Connection.js index 06791adb3..54b524706 100644 --- a/src-rx/src/components/Connection.js +++ b/src-rx/src/components/Connection.js @@ -42,7 +42,7 @@ class Connection { this.autoSubscribeLog = this.props.autoSubscribeLog; this.props.protocol = this.props.protocol || window.location.protocol; - this.props.host = this.props.host || window.location.hostname; + this.props.host = this.props.host || (window.location.port === '3000' ? 'iob-server' : window.location.hostname); this.props.port = this.props.port || (window.location.port === '3000' ? 8081 : window.location.port); this.props.ioTimeout = Math.max(this.props.ioTimeout || 20000, 20000); this.props.cmdTimeout = Math.max(this.props.cmdTimeout || 5000, 5000); diff --git a/src-rx/src/components/Drawer.js b/src-rx/src/components/Drawer.js index 0d3b62f58..b05aaf550 100644 --- a/src-rx/src/components/Drawer.js +++ b/src-rx/src/components/Drawer.js @@ -122,6 +122,14 @@ const styles = theme => ({ alignSelf: 'center', marginLeft: 5 }, + editButton: { + position: 'sticky', + bottom: 0, + width: 'fit-content', + marginLeft: 'auto', + marginTop: 'auto', + transition: 'opacity 0.5s', + } }); export const STATES = { @@ -176,6 +184,8 @@ class Drawer extends Component { this.instances = null; + this.refEditButton = React.createRef(); + this.getTabs(); } @@ -603,13 +613,7 @@ class Drawer extends Component { /> } - {this.props.state === STATES.opened &&
+ {this.props.state === STATES.opened &&
this.setState({ editList: !this.state.editList })} @@ -623,6 +627,8 @@ class Drawer extends Component { anchor="left" open={this.props.state !== STATES.closed} classes={{ paper: classes.paper }} + onMouseEnter={() => this.refEditButton.current.style.opacity = 1} + onMouseLeave={() => this.refEditButton.current.style.opacity = 0} > @@ -637,13 +643,11 @@ class Drawer extends Component { /> } - {this.props.state === STATES.opened &&
+ {this.props.state === STATES.opened &&
this.setState({ editList: !this.state.editList })} diff --git a/src-rx/src/components/Enums/EnumBlock.js b/src-rx/src/components/Enums/EnumBlock.js index 8c3c2c153..c2b5f723a 100644 --- a/src-rx/src/components/Enums/EnumBlock.js +++ b/src-rx/src/components/Enums/EnumBlock.js @@ -422,7 +422,13 @@ const EnumBlockDrag = props => { }, end: (item, monitor) => { const dropResult = monitor.getDropResult(); - props.moveEnum(item.enumId, dropResult.enumId); + if (!dropResult) { + // root + const parts = item.enumId.split('.'); + props.moveEnum(item.enumId, parts[0] + '.' + parts[1]); + } else { + props.moveEnum(item.enumId, dropResult.enumId); + } }, collect: (monitor) => ({ isDragging: monitor.isDragging(), diff --git a/src-rx/src/components/Enums/EnumEditDialog.js b/src-rx/src/components/Enums/EnumEditDialog.js index 6b28f7530..fe3ac2a00 100644 --- a/src-rx/src/components/Enums/EnumEditDialog.js +++ b/src-rx/src/components/Enums/EnumEditDialog.js @@ -54,7 +54,7 @@ const styles = theme => ({ }, formControl : { display: 'flex', - padding: 24, + padding: '0 0 24px 0', flexGrow: 1000 }, }); @@ -79,33 +79,6 @@ function EnumEditDialog(props) { return idArray.join('.'); } - /*let ICONS; - if (props.enum._id.startsWith('enum.functions.')) { - ICONS = JSON.parse(JSON.stringify(devices)); - ICONS.forEach(item => { - if (!item.icon.startsWith('/')) { - try { - item.icon = require(`../../assets/devices/${item.icon}`).default; - } catch (e) { - console.warn('Cannot load ' + item.icon); - item.icon = null; - } - } - }); - } else if (props.enum._id.startsWith('enum.rooms.')) { - ICONS = JSON.parse(JSON.stringify(rooms)); - ICONS.forEach(item => { - if (!item.icon.startsWith('/')) { - try { - item.icon = require(`../../assets/rooms/${item.icon}`).default; - } catch (e) { - console.warn('Cannot load ' + item.icon); - item.icon = null; - } - } - }); - }*/ - return { - const fieldRef = useRef(); - return <> - setShowPicker(true)} - onChange={e => { - setValue(e.target.value) - onChange(e.target.value) - }} - InputProps={{style: {color: value === undefined ? internalValue : value}}} - {...TextFieldProps} - {...custom} - /> - setShowPicker(false)} - anchorEl={() => fieldRef.current} - anchorOrigin={{vertical: 'bottom', horizontal: 'left'}} - > - { - const newValue = converters[convert](c) - setValue(newValue) - onChange(newValue) - }} - className={pickerClassName} - /> - - }; - -ColorPicker.propTypes = { - value: PropTypes.string, - onChange: PropTypes.func, - convert: PropTypes.oneOf(Object.keys(converters)), - name: PropTypes.string, - id: PropTypes.string, - hintText: PropTypes.string, - placeholder: PropTypes.string, - label: PropTypes.string, - floatingLabelText: PropTypes.string, - TextFieldProps: PropTypes.shape(TextField.propTypes), - showPicker: PropTypes.bool, - setShowPicker: PropTypes.func, - internalValue: PropTypes.string, - setValue: PropTypes.func, - pickerClassName: PropTypes.any -}; - -ColorPicker.defaultProps = { - convert: DEFAULT_CONVERTER -}; - -const makeColorPicker = compose( - withState('showPicker', 'setShowPicker', false), - withState('internalValue', 'setValue', ({defaultValue}) => defaultValue) -); - -const MadenColorPicker = makeColorPicker(ColorPicker); - -export const ColorPickerField = ({input: {value, onChange, ...restInput}, meta: {touched, error}, ...restProps}) => - ; - -ColorPickerField.propTypes = { - input: PropTypes.object, - meta: PropTypes.object -}; - -export default MadenColorPicker; diff --git a/src-rx/src/components/IOFields/ColorPicker/components/PickerDialog.js b/src-rx/src/components/IOFields/ColorPicker/components/PickerDialog.js deleted file mode 100644 index aec8a1923..000000000 --- a/src-rx/src/components/IOFields/ColorPicker/components/PickerDialog.js +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import {ChromePicker} from 'react-color'; - -const PickerDialog = - ({ - value, - onClick, - onChange, - className - }) => - - - -PickerDialog.propTypes = { - value: PropTypes.string, - onChange: PropTypes.func, - onClick: PropTypes.func, - className: PropTypes.any -}; - -export default PickerDialog; diff --git a/src-rx/src/components/IOFields/ColorPicker/index.d.ts b/src-rx/src/components/IOFields/ColorPicker/index.d.ts deleted file mode 100644 index 08aaf7f29..000000000 --- a/src-rx/src/components/IOFields/ColorPicker/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { TextFieldProps } from '@material-ui/core/TextField'; -import { converters } from './transformers'; -import { FC } from 'react'; - -type props = { - defaultValue?: string; - onChange: (color: string) => void; - convert?: keyof converters; - hintText?: string; - floatingLabelText?: string; - showPicker?: boolean; - internalValue?: string; - setShowPicker?: (open: boolean) => void; - setValue?: (value: string) => void; -} & Omit; - -declare const ColorPicker: FC; - -export default ColorPicker; diff --git a/src-rx/src/components/IOFields/ColorPicker/index.js b/src-rx/src/components/IOFields/ColorPicker/index.js deleted file mode 100644 index cd2e7e470..000000000 --- a/src-rx/src/components/IOFields/ColorPicker/index.js +++ /dev/null @@ -1,2 +0,0 @@ -import ColorPicker from './components/ColorPicker' -export default ColorPicker; diff --git a/src-rx/src/components/IOFields/ColorPicker/transformers.js b/src-rx/src/components/IOFields/ColorPicker/transformers.js deleted file mode 100644 index cae307ca4..000000000 --- a/src-rx/src/components/IOFields/ColorPicker/transformers.js +++ /dev/null @@ -1,11 +0,0 @@ -export const DEFAULT_CONVERTER = 'rgba_hex'; -export const converters = { - rgba: c => `rgba(${c.rgb.r}, ${c.rgb.g}, ${c.rgb.b}, ${c.rgb.a})`, - rgb: c => `rgb(${c.rgb.r}, ${c.rgb.g}, ${c.rgb.b})`, - hex: c => c.hex, - - rgba_rgb: c => c.rgb.a === 1 ? converters.rgb(c) : converters.rgba(c), - rgba_hex: c => c.rgb.a === 1 ? converters.hex(c) : converters.rgba(c) -} - -export default converters; diff --git a/src-rx/src/components/IOFields/Fields.js b/src-rx/src/components/IOFields/Fields.js index cb1322136..ce7f6adb3 100644 --- a/src-rx/src/components/IOFields/Fields.js +++ b/src-rx/src/components/IOFields/Fields.js @@ -1,28 +1,17 @@ -import {useCallback} from 'react' -import {useDropzone} from 'react-dropzone'; import PropTypes from 'prop-types'; -import { makeStyles } from '@material-ui/core/styles'; import TextField from '@material-ui/core/TextField'; -import InputLabel from '@material-ui/core/InputLabel'; import FormControl from '@material-ui/core/FormControl'; -import IconButton from '@material-ui/core/IconButton'; -import ClearIcon from '@material-ui/icons/Clear'; -import IconSelector from '@iobroker/adapter-react/Components/IconSelector'; -import Icon from '@iobroker/adapter-react/Components/Icon'; - -import ColorPicker from './ColorPicker'; +import ColorPicker from '@iobroker/adapter-react/Components/ColorPicker'; export function IOTextField(props) { let IconCustom = props.icon; return
{IconCustom ? : null} - - { props.t(props.label)} - { let IconCustom = props.icon; - return
+ return
{IconCustom ? : null} props.onChange('')}> - - - : - undefined, - }} + style={{width: IconCustom ? 'calc(100% - 45px)' : '100%', display: 'inline-block', verticalAlign: 'top'}} + name={props.t(props.label)} onChange={props.onChange} - InputLabelProps={{shrink: true}} - value={props.value || ''} + openAbove={true} + color={props.value || ''} />
; }; @@ -73,117 +48,3 @@ IOColorPicker.propTypes = { formData: PropTypes.object, }; export {IOColorPicker}; - -let IOFileInput = function (props) { - let IconCustom = props.icon; - - const useStyles = makeStyles(theme => ({ - formContainer : { - display: 'flex', - justifyContent:'center', - alignItems:'center' - }, - formControl : { - display: 'flex', - padding: 24, - flexGrow: 1000 - }, - divContainer: { - width: 32 + 24, - height: 32, - whiteSpace: 'nowrap', - lineHeight: '32px', - marginRight: 8 - }, - dragField: { - textAlign: 'center', - display: 'inline-block', - height: 90, - width: 240, - border: '2px dashed #777', - borderRadius: 10, - marginTop: 12, - padding: 4 - }, - formIcon : { - margin: 10, - opacity: 0.6 - }, - })); - - const classes = useStyles(); - - const onDrop = useCallback(acceptedFiles => { - const reader = new FileReader(); - - reader.addEventListener('load', () => - props.onChange(reader.result), false); - - if (acceptedFiles[0]) { - reader.readAsDataURL(acceptedFiles[0]); - } - }, []); // eslint-disable-line react-hooks/exhaustive-deps - - const {getRootProps, getInputProps, isDragActive} = useDropzone({onDrop}); - - return
- {IconCustom ? : null} - - - { props.t(props.label)} - -
- {props.value ? -
- - props.onChange('')} - > - - -
- : - props.onChange(base64)} - t={props.t} - lang={props.lang} - /> - } - -
- - { - isDragActive ? -

{props.t('ra_Drop the files here ...')}

: -

{props.t(`ra_Drag 'n' drop some files here, or click to select files`)}

- } -
-
-
-
; -}; - -IOFileInput.propTypes = { - t: PropTypes.func.isRequired, - lang: PropTypes.string.isRequired, - previewClassName: PropTypes.string, - icon: PropTypes.object, - classes: PropTypes.object, - label: PropTypes.string, - name: PropTypes.string, - value: PropTypes.any, - onChange: PropTypes.func, - - icons: PropTypes.array, - onlyRooms: PropTypes.bool, - onlyDevices: PropTypes.bool, -}; - -export {IOFileInput}; \ No newline at end of file diff --git a/src-rx/src/components/Workers/LogsWorker.js b/src-rx/src/components/Workers/LogsWorker.js index 832ce8758..a527ea8d5 100644 --- a/src-rx/src/components/Workers/LogsWorker.js +++ b/src-rx/src/components/Workers/LogsWorker.js @@ -214,15 +214,21 @@ class LogsWorker { // if no time found if (length) { obj = this.logs[length - 1]; - if (typeof obj.message === 'object') { - obj.message = Utils.parseColorMessage(obj.message.original + line); - } else { - obj.message += line; + if (obj) { + if (typeof obj.message === 'object') { + obj.message = Utils.parseColorMessage(obj.message.original + line); + } else { + obj.message += line; + } } } } } + if (!obj) { + return; + } + if (typeof obj.message !== 'object') { obj.message = Utils.parseColorMessage(obj.message); }