Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to batch request with mutliple configs #72

Open
MbBrainz opened this issue Nov 6, 2024 · 2 comments
Open

add option to batch request with mutliple configs #72

MbBrainz opened this issue Nov 6, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@MbBrainz
Copy link

MbBrainz commented Nov 6, 2024

Often for branding, you want qr codes in different set of colors. By allowing multiple configs in the json, one can automatically export the same qr codes for different color sets. This is super useful.

To make this feature work properly with all the existing features, we need some changes to the config.

  • it needs to support single AND multiple props entries
  • it needs to support single AND multiple data entries (in order to be compatible with the current batch feature)}

In order to support this i propose the following changes to the props. This is up for debate of course and id love to dicuss it in the comments 👍:

export interface Props {
    // data:                 string; /// Remove this entry
    image:                string;
    width:                number;
    height:               number;
    margin:               number;
    dotsOptions:          Options;
    cornersSquareOptions: Options;
    cornersDotOptions:    Options;
    imageOptions:         ImageOptions;
    qrOptions:            QrOptions;
   // NEW PARAMETERS
  prefix: string; 
 suffix: string;
 date_prefix: bool;
 date_suffix: bool;


}

The new parameters are related to issues #71 #70 and you could do this in a separate pr of course

and then the config json will look as follows:

{
// this will allow for both single and batches
"qr_code_data": ["url1", "url2","..."],

"props": [
// first config
{
 "image": "imageurl_or_data",
 "...": "other props"
},
// second config
{
"...":"...",
}
// etc

]
}
@MbBrainz
Copy link
Author

MbBrainz commented Nov 6, 2024

BTW, if we finalize this spec, im happy to implement it myself

@lyqht lyqht added the enhancement New feature or request label Nov 8, 2024
@lyqht
Copy link
Owner

lyqht commented Nov 8, 2024

hello @MbBrainz, appreciate that you opened these issues for discussion!

Initially i was a little confused when i saw this issue with the following schema,

// NEW PARAMETERS
prefix: string;
suffix: string;
date_prefix: bool;
date_suffix: bool;

then i realized these parameters are meant specifically for filenames based on the issues you have referenced.

In that case, i think it's better to name them

filenamePrefix: string;
filenameSuffix: string;

I don't think there's a need for date_prefix, date_suffix (which btw should be camelcase for JS projects). These can be set within filenamePrefix / filenameSuffix accordingly by the frontend.


Next, I don't quite understand the rationale of why we should separate out the data field into an array qr_code_data, and have the rest of the configs be placed within an array props.

I prefer if we kept the current config json format so that we will not break backward compability for current users who already saved their JSON config, and wants to import their JSON config.

JSON can be both the usual {} object or an array []. So then we will accept both {data, ...props} config or the new array format of
[{data1, ...props1}, {data2,...props2}].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants