Request available slicers and slicing profiles from backend asynchronously when opening the slicing dialog

Should make sure that slicers and new profiles are detected correctly even without reload.

Could maybe help with #689
This commit is contained in:
Gina Häußge 2014-12-21 15:57:23 +01:00
parent 363b23d6e3
commit 103e0796b7

View file

@ -28,6 +28,7 @@ function SlicingViewModel(loginStateViewModel, printerProfilesViewModel) {
self.afterSlicing = ko.observable("none");
self.show = function(target, file) {
self.requestData();
self.target = target;
self.file = file;
self.title(_.sprintf(gettext("Slicing %(filename)s"), {filename: self.file}));
@ -48,13 +49,18 @@ function SlicingViewModel(loginStateViewModel, printerProfilesViewModel) {
&& self.profile() != undefined;
});
self.requestData = function() {
self.requestData = function(callback) {
$.ajax({
url: API_BASEURL + "slicing",
type: "GET",
dataType: "json",
success: self.fromResponse
})
success: function(data) {
self.fromResponse(data);
if (callback !== undefined) {
callback();
}
}
});
};
self.fromResponse = function(data) {