export const appCard = (data) => { // dont look at anything in here. let app_name = data.name || data.title.toLowerCase(); let shortened_name = ""; let shortened_desc = data.description.slice(0, 60) + "..."; let modal = app_name.replaceAll(" ", "-"); let form_id = app_name.replaceAll("-", "_"); let note = data.note ? data.note.replaceAll(". ", ".\n") : "no notes available"; let description = data.description.replaceAll(". ", ".\n") || "no description available"; let command = data.command ? data.command : ""; let command_check = command ? "checked" : ""; let privileged = data.privileged || ""; let privileged_check = privileged ? "checked" : ""; let repository = data.repository || ""; let source = data.image || ""; let net_host, net_bridge, net_docker = ''; let net_name = 'AppBridge'; // if data.network is set to host, bridge, or docker set the radio button to checked if (data.network == 'host') { net_host = 'checked'; } else if (data.network) { net_bridge = 'checked'; net_name = data.network; } else { net_docker = 'checked'; } if (data.title.length > 28) { shortened_name = (data.title).slice(0, 25) + "..."; } else { shortened_name = data.title; } if (repository != "") { source = (`${repository.url}/raw/master/${repository.stackfile}`); } function CatagoryColor(category) { switch (category) { case 'Other': return 'Other '; case 'Productivity': return 'Productivity '; case 'Tools': return 'Tools '; case 'Dashboard': return 'Dashboard '; case 'Communication': return 'Communication '; case 'Media': return 'Media '; case 'CMS': return 'CMS '; case 'Monitoring': return 'Monitoring '; case 'LDAP': return 'LDAP '; case 'Arr': return 'Arr '; case 'Database': return 'Database '; case 'Paid': return 'Paid '; case 'Gaming': return 'Gaming '; case 'Finance': return 'Finance '; case 'Networking': return 'Networking '; case 'Authentication': return 'Authentication '; case 'Development': return 'Development '; case 'Media Server': return 'Media Server '; case 'Downloaders': return 'Downloaders '; default: return ''; // default to other if the category is not recognized } } // set data.catagories to 'other' if data.catagories is empty or undefined if (data.categories == null || data.categories == undefined || data.categories == '') { data.categories = ['Other']; } let categories = ''; for (let i = 0; i < data.categories.length; i++) { categories += CatagoryColor(data.categories[i]); } if (data.restart_policy == null) { data.restart_policy = 'unless-stopped'; } let ports_data = [], volumes_data = [], env_data = [], label_data = []; for (let i = 0; i < 12; i++) { // Get port details try { let ports = data.ports[i]; let port_check = ports ? "checked" : ""; let port_external = ports.split(":")[0] ? ports.split(":")[0] : ports.split("/")[0]; let port_internal = ports.split(":")[1] ? ports.split(":")[1].split("/")[0] : ports.split("/")[0]; let port_protocol = ports.split("/")[1] ? ports.split("/")[1] : ""; // remove /tcp or /udp from port_external if it exists if (port_external.includes("/")) { port_external = port_external.split("/")[0]; } ports_data.push({ check: port_check, external: port_external, internal: port_internal, protocol: port_protocol }); } catch { ports_data.push({ check: "", external: "", internal: "", protocol: "" }); } // Get volume details try { let volumes = data.volumes[i]; let volume_check = volumes ? "checked" : ""; let volume_bind = volumes.bind ? volumes.bind : ""; let volume_container = volumes.container ? volumes.container.split(":")[0] : ""; let volume_readwrite = "rw"; if (volumes.readonly == true) { volume_readwrite = "ro"; } volumes_data.push({ check: volume_check, bind: volume_bind, container: volume_container, readwrite: volume_readwrite }); } catch { volumes_data.push({ check: "", bind: "", container: "", readwrite: "" }); } // Get environment details try { let env = data.env[i]; let env_check = ""; let env_default = env.default ? env.default : ""; if (env.set) { env_default = env.set;} let env_description = env.description ? env.description : ""; let env_label = env.label ? env.label : ""; let env_name = env.name ? env.name : ""; env_data.push({ check: env_check, default: env_default, description: env_description, label: env_label, name: env_name }); } catch { env_data.push({ check: "", default: "", description: "", label: "", name: "" }); } // Get label details try { let label = data.labels[i]; let label_check = ""; let label_name = label.name ? label.name : ""; let label_value = label.value ? label.value : ""; label_data.push({ check: label_check, name: label_name, value: label_value }); } catch { label_data.push({ check: "", name: "", value: "" }); } } return `

${shortened_name}

${shortened_desc}
${categories}
`; }