snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.05k stars 3.18k forks source link

Adding a custom field to my labels(?) #9298

Closed haupt-pascal closed 3 years ago

haupt-pascal commented 3 years ago

Server (please complete the following information):

It's a mix between feature request and a general question: I've created a custom field with a number (for our internal documentation [...]) - now I want to print labels, the problem is: I need the custom field I've created in the label. Is there a way to add the custom field into the label(s)?

image

This is the number/field I need in the following label (position isn't relevant yet, I guess)

2021-03-15 18_19_05-Window

I saw multiple feature-requests like mine, but no solution - maybe can you help me!

boring10 commented 3 years ago

I believe that, at this time, the only way to do that is to roll your own solution by using the API key. We created our own with Node.js on a Linux machine using some modules for the QR code and barcode. At this time our solution is a quick and dirty one that only prints one label at a time for our specific label maker.

The "*GF/OF" is based off of our own custom field.

asset-tags

haupt-pascal commented 3 years ago

Can you explain how exactly u've did this? Is there "no" other way to create a customized field? :(

boring10 commented 3 years ago

I've been wanting to re-write our current label generator so if I get some time this week I will work on that and share it. I can't share it now since it is messy with our own data manually mixed in.

We just used Node.js to retrieve the data (npm package axios) and then generate the QR code (npm package qr-image) and barcode (npm package barcode) into images that are sent to the browser. The barcode package does require the installation of GraphicsMagick in order to work. You cannot just simply use a barcode font since it will not be coded properly, unless I was looking at the wrong fonts.

We are using a DYMO LabelWriter 450 using labels that are 2.25 inches in width and 1.25 inches in height but that is something that can be adjusted based on the label size that you end up using.

snipe commented 3 years ago

We already use axios for the Ziggy package from TightenCo

haupt-pascal commented 3 years ago

Simple customizations aren't that hard, I think. The biggest problem is a custom field I need on my label :)

But it'd be great to see how you've solved the "problem customization"!

haupt-pascal commented 3 years ago

I mean ... a custom field I'm using at all assets, but it's a "personal ID" for our devices, so the number is different at every device xD

boring10 commented 3 years ago

Here is a repo with simple labels being generated https://gitlab.com/boring10/snipe-it-custom-labels. For this to run though, you will need to have that GraphicsMagick package installed. It doesn't really affect us since we just use an in-house Ubuntu server to host this.

To change the custom field that is being pulled you would just need to know the name of the field and change that in the src/routes/hardware.js file. For the case of the MAC address, in this case, the call is to data.custom_fields['MAC Address'].value.

The apiEndpoint, in this case is hardware, points to the file src/views/hardware.hbs.

res.render(apiEndpoint, {
  LABEL_HEADING: process.env.LABEL_HEADING,
  tag: id,
  macAddress: data.custom_fields['MAC Address'].value,
  qrcode: `assets/images/qr/${qrCodeName}`,
  barcode: `assets/images/barcode/${barcodeName}`,
})

If you're not sure what yours may be called exactly but you can do a console.log(data) right before the res.render in the hardware route and when you make a label for the hardware the data that is returned from Snipe-IT will be displayed in your terminal.

We have a few different hardware labels that we have depending on the device. For instance, we do a front label and back label for our laptops/Chromebooks. The front label has the person that it is checked out to on it but the barcode and QR code both point to the asset. The back label for us has the asset tag and serial number on it.

GitLab
Lee Boring / snipe-it-custom-labels
Custom labels for Dymo LabelWriter 400 with a 2-1/4 inch width and 1-1/4 inch height.
Longbh2023 commented 1 year ago

please, Help me ! How to add People (user) in Asset Labels