Like to add custom metadata to file and show it is the GUI

Hi,

I plan to add additional data to the file that beside the filament length also information about the spool is shown like (material: PLA, name: Blabla,...)

I checked the API and found set_additional_metadata in the filemanager API (octoprint.filemanager — OctoPrint master documentation). But to avoid creating everything I am sure that there is another plugin adding metainformation to the uploaded file. Does anybody know if there is some out?

Cheers,
Nils

Not sure if it has all the details, but PrintJobHistory in combination with SpoolManager may get you where you want to be? But to answer your question, my thumbnail plugins use this option to add thumbnail url to the metadata and changes the web UI to allow showing the thumbnail in the file list.

Perfect...will take a look.

@fieldOfView added variables to Cura for me to add material name,... in Gcode. I plan to enhance my plugin that it also adds this to the Gcode metadata which can be read from SpoolManager, ... in the future or simply shows for which material the Gcode was generated. That was a feature I missed...

I did some investigation and I have to overwrite the filesViewModel Method getAdditionalData.
https://docs.octoprint.org/en/master/plugins/viewmodels.html#registering-custom-viewmodels

I handled to overwrite the function generated the HTML code but I cannot merge the content. If I tried I does not see the string returned I see an "object Object" Text. I am totally not familiar with JS so what is going wrong? How can I convert the object (if everything is right) to a string that I can add some lines? I am sure this must be very easy. :slight_smile:

You shouldn't have to do that, you should be able to inject your own text bits to the view model and just make sure that their binding is to the original scope. Here's an example for the inline thumbnail.

Moin,

ich hab mich jetzt etwas damit befasst und folgender Code funktioniert. Ich hab mir nur überlegt ob es nicht eine elegantere Methode gibt und mich etwas mit JQuery beschäftigt (bin da totaler Neuling).

Folgendes basiert auf dem RegEx und funktioniert:

    self.onBeforeBinding = function() {
      // inject filelist thumpnail into template
      let regex = /<div class="additionalInfo hide"/mi;

      $("#files_template_machinecode").text(function () {
        var return_value = $(this).text();
        return_value = return_value.replace(regex, '<div>blabla</div> <div class="additionalInfo hide"');
        return return_value
      });
    }

Ich hab mich aber gefragt ob es nicht schöner ist es vor jeder DOM Element einzufügen. Das Beispiel hab ich mal mit "size" probiert, aber es funktioniert nicht.

    self.onBeforeBinding = function() {
      // inject filelist thumpnail into template
      //size_elem = $("#files_template_machinecode").find(".size");


      $( "<p>Bla</p>" ).insertBefore( ".size" );
      /*
      $("#files_template_machinecode").text(function () {
        var return_value = $(this).text();
        return_value = return_value.replace(regex, '<div>blabla</div> <div class="additionalInfo hide"');
        return return_value
      });*/
    }
  
  }

Ergebnis der RegEx Variante, laufen tut es also generell mal :slight_smile: :