fixed errors VC

This commit is contained in:
Daniel Barbero Martin 2020-01-27 13:16:01 +01:00
parent 8ee038667c
commit 570ebd9a0a
10 changed files with 45 additions and 238 deletions

View File

@ -1165,19 +1165,7 @@ function createOrUpdateVisualConsoleItem(
title = "Update item ";
}
title += nameType;
// var props = item.props || {};
/*
var elementsVc = visualConsole.elements
.filter(function(item) {
return item.props.id;
})
.map(function(item) {
return {
value: item.props.id,
text: VisualConsole.itemDescriptiveName(item)
};
});
*/
load_modal({
target: $("#modalVCItemForm"),
form: ["itemForm-label", "itemForm-general", "itemForm-specific"],
@ -1194,6 +1182,19 @@ function createOrUpdateVisualConsoleItem(
visualConsole.updateElement(data);
item.setMeta({ isUpdating: false });
} else {
document
.getElementById("visual-console-container")
.classList.remove("is-updating");
var div = document
.getElementById("visual-console-container")
.querySelector(".div-visual-console-spinner");
if (div !== null) {
var parent = div.parentElement;
if (parent !== null) {
parent.removeChild(div);
}
}
data["receivedAt"] = new Date();
var newItem = visualConsole.addElement(data);
newItem.setMeta({ editMode: true });
@ -1241,6 +1242,20 @@ function createOrUpdateVisualConsoleItem(
}
if (item.itemProps.id) {
item.setMeta({ isUpdating: true });
} else {
var divParent = document.createElement("div");
divParent.className = "div-visual-console-spinner";
var divSpinner = document.createElement("div");
divSpinner.className = "visual-console-spinner";
divParent.appendChild(divSpinner);
document
.getElementById("visual-console-container")
.classList.add("is-updating");
document
.getElementById("visual-console-container")
.appendChild(divParent);
}
}
},
@ -1250,225 +1265,6 @@ function createOrUpdateVisualConsoleItem(
tinyMCE.execCommand("mceRemoveControl", true, "textarea_label");
}
});
/*
var formContainer = {};
if (props.id) {
// Item selection.
visualConsole.selectItem(props.id, true);
formContainer = item.getFormContainer();
} else {
formContainer = VisualConsole.items[props.type].getFormContainer({
width: 0,
type: props.type
});
}
formContainer.onInputGroupDataRequested(function(e) {
var identifier = e.identifier;
var params = e.params;
var done = e.done;
switch (identifier) {
case "service-list":
asyncTaskManager
.add(identifier + "-" + params.id, function(doneAsyncTask) {
var abortable = serviceListVisualConsole(
baseUrl,
visualConsole.props.id,
params,
function(error, data) {
if (error || !data) {
console.log(
"[ERROR]",
"[VISUAL-CONSOLE-CLIENT]",
"[API]",
error ? error.message : "Invalid response"
);
done(error);
doneAsyncTask();
return;
}
if (typeof data === "string") {
try {
data = JSON.parse(data);
} catch (error) {
console.log(
"[ERROR]",
"[VISUAL-CONSOLE-CLIENT]",
"[API]",
error ? error.message : "Invalid response"
);
done(error);
doneAsyncTask();
return; // Stop task execution.
}
}
done(null, data);
doneAsyncTask();
}
);
return {
cancel: function() {
abortable.abort();
}
};
})
.init();
break;
default:
done(new Error("identifier not found"));
}
});
var formElement = formContainer.getFormElement();
var $formElement = jQuery(formElement);
formContainer.onSubmit(function(e) {
console.log(e);
// Send the update.
var id = props.id;
var data = e.data;
if (
props.type != 20 &&
props.type != 3 &&
props.type != 9 &&
props.type != 15 &&
props.type != 16
) {
// Content tiny.
var content = tinymce.get("tinyMCE_editor").getContent();
// Pass content to array data.
data.label = content;
}
var taskId = "visual-console-item-update-" + id;
if (props.id) {
// Show updating state.
item.setMeta({ isUpdating: true });
} else {
data.type = props.type;
}
// Persist the new data.
asyncTaskManager
.add(taskId, function(done) {
var abortable;
if (props.id) {
abortable = updateVisualConsoleItem(
baseUrl,
visualConsole.props.id,
id,
data,
function(error, data) {
// Hide updating state.
item.setMeta({ isUpdating: false });
// if (!error && !data) return;
if (error || !data) {
console.log(
"[ERROR]",
"[VISUAL-CONSOLE-CLIENT]",
"[API]",
error ? error.message : "Invalid response"
);
// TODO: Recover from error.
done();
return;
}
if (typeof data === "string") {
try {
data = JSON.parse(data);
} catch (error) {
console.log(
"[ERROR]",
"[VISUAL-CONSOLE-CLIENT]",
"[API]",
error ? error.message : "Invalid response"
);
// TODO: Recover from error.
done();
return; // Stop task execution.
}
}
visualConsole.updateElement(data);
done();
}
);
} else {
abortable = createVisualConsoleItem(
baseUrl,
visualConsole.props.id,
data,
function(error, data) {
if (error || !data) {
console.log(
"[ERROR]",
"[VISUAL-CONSOLE-CLIENT]",
"[API]",
error ? error.message : "Invalid response"
);
// TODO: Recover from error.
done();
return;
}
if (typeof data === "string") {
try {
data = JSON.parse(data);
} catch (error) {
console.log(
"[ERROR]",
"[VISUAL-CONSOLE-CLIENT]",
"[API]",
error ? error.message : "Invalid response"
);
// TODO: Recover from error.
done();
return; // Stop task execution.
}
}
data["receivedAt"] = new Date();
var newItem = visualConsole.addElement(data);
newItem.setMeta({ editMode: true });
done();
}
);
}
return {
cancel: function() {
abortable.abort();
}
};
})
.init();
console.log("Form submit", e.data);
$formElement.dialog("close");
});
*/
}
/**

View File

@ -538,11 +538,11 @@ final class BarsGraph extends Item
// Default values.
if (isset($values['width']) === false) {
$values['width'] = 250;
$values['width'] = 300;
}
if (isset($values['height']) === false) {
$values['height'] = 250;
$values['height'] = 180;
}
return $values;

View File

@ -69,6 +69,10 @@ final class Box extends Item
$border_width = parent::getBorderWidth($data);
if ($border_width !== null) {
if ($border_width < 1) {
$border_width = 1;
}
$return['border_width'] = $border_width;
}

View File

@ -278,11 +278,11 @@ final class DonutGraph extends Item
// Default values.
if (isset($values['width']) === false) {
$values['width'] = 100;
$values['width'] = 300;
}
if (isset($values['height']) === false) {
$values['height'] = 100;
$values['height'] = 300;
}
return $values;

View File

@ -264,6 +264,10 @@ final class Line extends Model
$borderWidth = static::getBorderWidth($data);
if ($borderWidth !== null) {
if ($borderWidth < 1) {
$borderWidth = 1;
}
$result['border_width'] = $borderWidth;
}

View File

@ -126,6 +126,7 @@
align-items: center;
opacity: 0.7;
background: rgb(212, 215, 218);
z-index: 2;
}
.show-elements {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -824,6 +824,7 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
this.elementRef.classList.remove("is-fetching");
}
}
if (!prevMeta || prevMeta.isUpdating !== this.meta.isUpdating) {
if (this.meta.isUpdating) {
this.elementRef.classList.add("is-updating");

View File

@ -90,6 +90,7 @@
align-items: center;
opacity: 0.7;
background: rgb(212, 215, 218);
z-index: 2;
}
.show-elements {