Skip to content

Commit

Permalink
made some changes based off the pr
Browse files Browse the repository at this point in the history
  • Loading branch information
Rylan-Meilutis committed Feb 26, 2024
1 parent acbbcff commit 299471e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 116 deletions.
4 changes: 3 additions & 1 deletion octoprint_nfv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ def on_event(self, event, payload):
# Get full path to local file
path = self._file_manager.path_on_disk(FileDestinations.LOCAL, path)
selected_file = path
self.check_print(selected_file)

with self._printer.job_on_hold():
self.check_print(selected_file)

##~~ TemplatePlugin mixin

Expand Down
2 changes: 1 addition & 1 deletion octoprint_nfv/static/js/Nozzle_Filament_Validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ $(function () {
title: 'Nozzle Filament Validator',
text: data.msg,
type: theme,
hide: data.type === 'info' || data.type === 'tmp_error' || data.type === 'tmp_danger' || data.type === 'success' ,
hide: data.type === 'info' || data.type === 'tmp_error' || data.type === 'tmp_danger' || data.type === 'success',
buttons: {closer: true, sticker: false}
});
}
Expand Down
81 changes: 14 additions & 67 deletions octoprint_nfv/static/js/build_plate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ $(function () {
if (this.checked) {
const selectedBuildPlateId = $("#build-plate-list").val();
// Fetch the current build plate data
$.ajax({
url: API_BASEURL + "plugin/" + PLUGIN_ID,
type: "POST",
contentType: "application/json; charset=UTF-8",
dataType: "json",
data: JSON.stringify({
"command": "get_build_plate",
"buildPlateId": selectedBuildPlateId
}),
success: function (response) {
OctoPrint.simpleApiCommand(PLUGIN_ID, "get_build_plate", {"buildPlateId": selectedBuildPlateId})
.done(function (response) {
let filaments = [];
if (response.filaments) {
filaments = response.filaments.split(",");
Expand All @@ -32,11 +24,7 @@ $(function () {
} else {
console.error("Compatible filaments is invalid:", filaments);
}
},
error: function (xhr, status, error) {
console.error("Error fetching build plate data:", error);
}
});
});
} else {
// Clear the input fields and uncheck all checkboxes
$("#build-plate-input").val("");
Expand All @@ -55,22 +43,11 @@ $(function () {

// Function to remove a build_plate
function removeBuildPlate(buildPlateID) {
$.ajax({
url: API_BASEURL + "plugin/" + PLUGIN_ID,
type: "POST",
contentType: "application/json; charset=UTF-8",
dataType: "json",
data: JSON.stringify({
"command": "remove_build_plate",
"buildPlateId": buildPlateID
}),
success: function (response) {

OctoPrint.simpleApiCommand(PLUGIN_ID, "remove_build_plate", {"buildPlateId": buildPlateID})
.done(function (response) {
displayData();
},
error: function (xhr, status, error) {
console.error("Error removing build plate:", error);
}
});
});
}

// Event handler for adding a build_plate
Expand All @@ -84,58 +61,28 @@ $(function () {
});
compatibleFilaments = compatibleFilaments.replace(/,\s*$/, "");


// Remove trailing comma
let id = $("#build-plate-list").val();
const isEditChecked = $("#edit-build-plate-checkbox").prop("checked");


// Update id based on the value of the edit checkbox
if (!isEditChecked) {
id = "null";
}

$.ajax({
url: API_BASEURL + "plugin/" + PLUGIN_ID,
type: "POST",
contentType: "application/json; charset=UTF-8",
dataType: "json",
data: JSON.stringify({
"command": "add_build_plate",
"name": buildPlateName,
"compatibleFilaments": compatibleFilaments,
"id": id
}),
success: function (response) {
displayData();
},
error: function (xhr, status, error) {
console.error("Error adding build plate: " + buildPlateName, error);
}
OctoPrint.simpleApiCommand(PLUGIN_ID, "add_build_plate", {
"name": buildPlateName,
"compatibleFilaments": compatibleFilaments,
"id": id
}).done(function (response) {
displayData();
});
});

// Event handler for selecting the current sized build_plate
$("#select-build-plate-button").click(function () {
const selectedBuildPlateId = $("#build-plate-list").val();
$.ajax({
url: API_BASEURL + "plugin/" + PLUGIN_ID,
type: "POST",
contentType: "application/json; charset=UTF-8",
dataType: "json",
data: JSON.stringify({
"command": "select_build_plate",
"buildPlateId": selectedBuildPlateId
}),

success: function (response) {
displayData()
// Optionally, perform any UI update after selecting the nozzle
},
error: function (xhr, status, error) {
console.error("Error selecting build plate: " + selectedBuildPlateId, error);
}
});
OctoPrint.simpleApiCommand(PLUGIN_ID, "select_build_plate", {"buildPlateId": selectedBuildPlateId})
});

// Event handler for removing a build_plate
Expand Down
53 changes: 6 additions & 47 deletions octoprint_nfv/static/js/nozzles.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,24 @@ $(function () {

// Function to remove a nozzle
function removeNozzle(nozzleId) {
$.ajax({
url: API_BASEURL + "plugin/" + PLUGIN_ID,
type: "POST",
contentType: "application/json; charset=UTF-8",
dataType: "json",
data: JSON.stringify({
"command": "removeNozzle",
"nozzleId": nozzleId
}),
success: function (response) {
displayData();
},
error: function (xhr, status, error) {
console.error("Error removing nozzle:", error);
}
OctoPrint.simpleApiCommand(PLUGIN_ID, "removeNozzle", {"nozzleId": nozzleId}).done(function (response) {
displayData();
});
}

// Event handler for adding a nozzle
$("#add-nozzle-button").click(function () {
const nozzleSize = $("#nozzle-size-input").val();
$.ajax({
url: API_BASEURL + "plugin/" + PLUGIN_ID,
type: "POST",
contentType: "application/json; charset=UTF-8",
dataType: "json",
data: JSON.stringify({
"command": "addNozzle",
"size": nozzleSize
}),
success: function (response) {
displayData();
},
error: function (xhr, status, error) {
console.error("Error adding nozzle: " + nozzleSize, error);
}
OctoPrint.simpleApiCommand(PLUGIN_ID, "addNozzle", {"size": nozzleSize}).done(function (response) {
displayData();
});
});

// Event handler for selecting the current sized nozzle
$("#select-nozzle-button").click(function () {
const selectedNozzleId = $("#nozzles-list").val();
$.ajax({
url: API_BASEURL + "plugin/" + PLUGIN_ID,
type: "POST",
contentType: "application/json; charset=UTF-8",
dataType: "json",
data: JSON.stringify({
"command": "selectNozzle",
"nozzleId": selectedNozzleId
}),

success: function (response) {
displayData()
// Optionally, perform any UI update after selecting the nozzle
},
error: function (xhr, status, error) {
console.error("Error selecting nozzle: " + selectedNozzleId, error);
}
OctoPrint.simpleApiCommand(PLUGIN_ID, "selectNozzle", {"nozzleId": selectedNozzleId}).done(function (response) {
displayData();
});
});

Expand Down

0 comments on commit 299471e

Please sign in to comment.