Commit 8a6f45a4 authored by MaxSol1's avatar MaxSol1
Browse files

templates feature enhancements part 2

parent 8efce170
......@@ -579,7 +579,7 @@ function VariablesModal({hide, dashboard, slug}) {
const addInputs = (e) => {
e.preventDefault();
if (inputs.length > 4) {
if (inputs.length > 50) {
alert("Max allowed variables reached");
return;
}
......@@ -611,7 +611,7 @@ function VariablesModal({hide, dashboard, slug}) {
}
return <div class="modal-wrap" onMouseDown={hide}>
<div class="modal-fixed" onMouseDown={e => e.stopPropagation()}>
<div class="modal-fixed template-modal" onMouseDown={e => e.stopPropagation()}>
<div class="row">
<div class="col-md-4">
<h3>Variables</h3>
......@@ -620,10 +620,10 @@ function VariablesModal({hide, dashboard, slug}) {
</div>
</div>
<form>
<div class="form-row">
<div class="form-row template-inputs">
{inputs.map((entry, i) => (
<div class="form-row" key={entry.id}>
<div class="col-md-5" key={i}>
<div class="col-md-4" key={i}>
<label for={`var${i}_key`}>Name</label>
<input
style="h-30p"
......
......@@ -431,30 +431,36 @@ export function alertSounds(checkState, options, dashboard) {
export function linkHelper(element, ele, dashboard){
let target = null;
let link = element.options.linkURL;
if (dashboard.tabLink) {
target = 'blank';
}
let encoded = encodeURIComponent(element.options.linkURL);
for (const [key, property] of Object.entries(dashboard.variables)) {
if (element.options.hasOwnProperty('linkURL') && element.options.linkURL.includes(`~${key}~`)) {
let reg = new RegExp('~(' + key + ')~', 'g');
link = link.replaceAll(reg, encodeURIComponent(property));
}
}
if (element.options.linkURL && element.type === 'static-text') {
if (element.options.linkURL.includes('http') ) {
ele = <a id="text-link" href={encoded} target={target}>{ele}</a>
ele = <a id="text-link" href={link} target={target}>{ele}</a>
} else {
ele = <a id="text-link" href={`https://${encoded}`} target={target}>{ele}</a>
ele = <a id="text-link" href={`https://${link}`} target={target}>{ele}</a>
}
} if (element.options.linkURL && element.type === 'dynamic-text') {
if (element.options.linkURL.includes('http') ) {
ele = <a id="text-link" href={encoded} target={target}>{ele}</a>
ele = <a id="text-link" href={link} target={target}>{ele}</a>
} else {
ele = <a id="text-link" href={`https://${encoded}`} target={target}>{ele}</a>
ele = <a id="text-link" href={`https://${link}`} target={target}>{ele}</a>
}
} else if (element.options.linkURL) {
if (element.options.linkURL.includes('http') ) {
ele = <a id="a-link" href={encoded} target={target}>{ele}</a>
ele = <a id="a-link" href={link} target={target}>{ele}</a>
} else {
ele = <a id="a-link" href={`https://${encoded}`} target={target}>{ele}</a>
ele = <a id="a-link" href={`https://${link}`} target={target}>{ele}</a>
}
}
......
......@@ -448,7 +448,7 @@ div.modal-wrap .modal-fixed {
padding: 20px;
left: calc(50% - 200px);
width: 400px;
top: 5vh;
top: 20vh;
color: var(--color-black);
border-radius: 4px;
animation-name: slide-up;
......@@ -468,6 +468,17 @@ div.modal-wrap .modal-fixed {
text-shadow: -1px -1px 0 rgb(0 0 0 / 30%);
}
div.modal-fixed.template-modal {
max-height: 500px;
width: 450px;
}
div.template-inputs {
max-height: 380px;
overflow-y: auto;
overflow-x: hidden;
}
.h-30p {
height: 30px !important;
}
......@@ -831,6 +842,10 @@ div.tag .close-icon {
height: 100%;
}
.template-modal {
/* height: 500px; */
}
.check > .card {
padding: 6px 10px;
color: white;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment