Skip to content

Commit

Permalink
New Verison 1.9.0
Browse files Browse the repository at this point in the history
- PR #77 Show errors when database connection test fails. Thx @techfreek
- E #72 French translation. Thx @LeBress
- B #66 assign temp.offset after connecting the printer
- B #79 selections-API return only the max numbers of tools
  • Loading branch information
OllisGit committed Oct 17, 2021
1 parent a976290 commit 5f8c903
Show file tree
Hide file tree
Showing 21 changed files with 1,541 additions and 296 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,22 @@ or manually using this URL:

`https://github.com/OllisGit/OctoPrint-FilamentManager/releases/latest/download/master.zip`

1. For PostgreSQL support you need to install an additional dependency:
1. For PostgreSQL support you need to install an additional dependency. Take a look into the [wiki](https://github.com/OllisGit/OctoPrint-FilamentManager/wiki) for more details.

`pip install psycopg2`


### Using PostgreSQL with Docker
You need to make sure that you setup a docker runtime on your system. After that you can "manage" a PostgreSQL with the following commands:

docker-compose up
_

docker-compose down --volumes
_

docker-compose run postgres bash

## Screenshots

![FilamentManager Sidebar](screenshots/filamentmanager_sidebar.png?raw=true)
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3'
services:
postgres:
image: "postgres" # use latest official postgres version
# env_file:
# - database.env # configure postgres
volumes:
- postgres-data:/var/lib/postgresql/data/ # persist data even if container shuts down
ports:
- 5432:5432
environment:
- POSTGRES_DB=spoolmanagerdb
- POSTGRES_USER=Olli
- POSTGRES_PASSWORD=illO

volumes:
postgres-data: # named volumes can be managed easier using docker-compose
19 changes: 13 additions & 6 deletions octoprint_filamentmanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,7 @@ def notify(pid, channel, payload):
self.update_pause_thresholds()

# set temperature offsets for saved selections
try:
all_selections = self.filamentManager.get_all_selections(self.client_id)
self.set_temp_offsets(all_selections)
except Exception as e:
self._logger.error("Failed to set temperature offsets: {message}".format(message=str(e)))
self._logger.exception("Failed to set temperature offsets: {message}".format(message=str(e)))
self.assign_temperature_offset()

def on_shutdown(self):
if self.filamentManager is not None:
Expand Down Expand Up @@ -257,6 +252,10 @@ def on_event(self, event, payload):
elif Events.PRINT_CANCELLED == event:
self.alreadyCanceled = True
self._printJobFinished()

elif Events.CONNECTED == event:
self.assign_temperature_offset()

pass

def _printJobStarted(self, payload):
Expand Down Expand Up @@ -310,6 +309,14 @@ def _printJobFinished(self):
# # update last print state
# self.lastPrintState = payload['state_id']

def assign_temperature_offset(self):
try:
all_selections = self.filamentManager.get_all_selections(self.client_id)
self.set_temp_offsets(all_selections)
except Exception as e:
self._logger.error("Failed to set temperature offsets: {message}".format(message=str(e)))
self._logger.exception("Failed to set temperature offsets: {message}".format(message=str(e)))

def update_filament_usage(self):
printer_profile = self._printer_profile_manager.get_current_or_default()
# extrusion = self.filamentOdometer.get_extrusion()
Expand Down
5 changes: 5 additions & 0 deletions octoprint_filamentmanager/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,12 @@ def delete_spool(self, identifier):
def get_selections_list(self):
try:
if (self.filamentManager != None):

printer_profile = self._printer_profile_manager.get_current_or_default()
printerProfileToolCount = printer_profile['extruder']['count']
all_selections = self.filamentManager.get_all_selections(self.client_id)
# return only the selection of the max tool count of the current printer profile
all_selections = all_selections[0:printerProfileToolCount]
else:
self._logger.warn("self.filamentManager is not initialized yet")
return
Expand Down
17 changes: 11 additions & 6 deletions octoprint_filamentmanager/static/js/filamentmanager.bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ FilamentManager.prototype.viewModels.config = function configurationViewModel()
var api = this.core.client;
var settingsViewModel = this.core.bridge.allViewModels.settingsViewModel;

self.testResult = ko.observable(null);
self.testConnectionResult = ko.observable(null);
self.testConnectionResultTextColor = ko.observable("color:blue");

var dialog = $('#settings_plugin_filamentmanager_configurationdialog');

Expand Down Expand Up @@ -280,23 +281,27 @@ FilamentManager.prototype.viewModels.config = function configurationViewModel()

var data = ko.mapping.toJS(self.config.database);

self.testResult('Waiting for response...');
self.testConnectionResult('Waiting for response...');
self.testConnectionResultTextColor('color:orange');

api.database.test(data).done(function () {
target.addClass('btn-success');
self.testResult('Success!');
self.testConnectionResult('Success!');
self.testConnectionResultTextColor('color:green');
}).fail(function (response) {
target.addClass('btn-danger');
console.log(JSON.stringify(response));
self.testResult(response.responseText);
self.testConnectionResult(response.responseText);
self.testConnectionResultTextColor("color:red");
}).always(function () {
$('i.fa-spinner', target).remove();
target.prop('disabled', false);
// clear the result message after a few seconds
window.setTimeout(function() {
self.testResult('');
self.testConnectionResult('');
self.testConnectionResultTextColor('');
target.removeClass('btn-success btn-danger');
}, 7 * 1000)
}, 10 * 1000)
});
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
<input type="checkbox" data-bind="checked: viewModels.config.config.database.useExternal">{{ _("Use external database") }}
</label>
<div class="help-block" >
<span style="color: red; ">If you want to use an external database, please take a look into my <a href="https://github.com/OllisGit/OctoPrint-FilamentManager/wiki/Setup-PostgreSQL-on-Raspbian-(Stretch)" target="newTab">wiki</a> how to install the drivers and setup the database.</span>
{# <span style="color: red; ">If you want to use an external database, please take a look into my <a href="https://github.com/OllisGit/OctoPrint-FilamentManager/wiki/Setup-PostgreSQL-on-Raspbian-(Stretch)" target="newTab">wiki</a> how to install the drivers and setup the database.</span>#}
<span style="color: red; ">{{ _('If you want to use an external database, please take a look into my <a href="https://github.com/OllisGit/OctoPrint-FilamentManager/wiki/Setup-PostgreSQL-on-Raspbian-(Stretch)" target="newTab">wiki</a> how to install the drivers and setup the database.') }}</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -110,7 +111,7 @@
<div class="control-group">
<div class="controls">
<button class="btn btn-primary pull-right" data-bind="click: viewModels.config.connectionTest">{{ _("Test connection") }}</button>
<span data-bind="text: viewModels.config.testResult"></span>
<span data-bind="text: viewModels.config.testConnectionResult, attr:{style: viewModels.config.testConnectionResultTextColor }"></span>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion octoprint_filamentmanager/templates/sidebar.jinja2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<label class="checkbox">
<input type="checkbox" data-bind="checked: $root.viewModels.spools.overUsedUsage" />
<span ></span> hide overused usage<br/>
<span ></span> {{ _('hide overused usage') }} <br/>
</label>

<!-- ko foreach: viewModels.selections.tools -->
Expand Down
Binary file not shown.
Loading

0 comments on commit 5f8c903

Please sign in to comment.