import React from "react" import {TbResize} from 'react-icons/tb' import {BiCube, BiRefresh} from 'react-icons/bi' import {BsTrash} from 'react-icons/bs' import {CgLayoutGridSmall} from 'react-icons/cg' import '../../css/counter.css' export default class CustomNodeIframe extends React.Component { constructor({id , data}){ super() this.myRef = React.createRef() this.state = { id : id, reachable : this.isFetchable(data.host), selected : true, data : data, width : 540, height : 600, size : false, iframe : 0 } } handelSelected = () => { this.setState({id : this.state.id, reachable : this.state.reachable, selected : !this.state.selected, data : this.state.data, width : this.state.width, height : this.state.height, size : this.state.size, iframe : this.state.iframe}) } handelSizeState = () => { this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : this.state.width, height : this.state.height, size : !this.state.size, iframe : this.state.iframe}) } isFetchable = async (host) => { fetch(host, {mode: 'no-cors'}).then((re) => { return true }).catch((err)=>{ alert(`🤪 Something went wrong the url that that was put in is not reachable...\n\n${err}`) return false }) return false } onNodeClick = (id) => { this.state.data.delete(id) } onRefresh(){ if(!this.isFetchable) this.onNodeClick(this.state.data.label) else{ this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : this.state.width, height : this.state.height, size : this.state.size, iframe : this.state.iframe + 1}) } } handelOnChange(evt, type){ this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : type === "width" ? parseInt(evt.target.value) : this.state.width, height : type === "height" ? parseInt(evt.target.value) : this.state.height, size : this.state.size, iframe : this.state.iframe}) type === "width" ? this.myRef.current.style.width = `${parseInt(evt.target.value)}px` : this.myRef.current.style.height = `${parseInt(evt.target.value)}px` } handelSize(evt, increment, change){ if (evt === "increment") { this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : change === "width" ? this.state.width + increment : this.state.width, height : change === "height" ? this.state.height + increment : this.state.height, size : this.state.size, iframe : this.state.iframe}) change === "width" ? this.myRef.current.style.width = `${this.state.width + increment}px` : this.myRef.current.style.height = `${this.state.height + increment}px` } } Counter(focus, size){ return (