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

Support panel's repeat, transparent, span and description by default #145

Closed

Conversation

bazilio91
Copy link
Contributor

#136 related

Copy link
Owner

@jakubplichta jakubplichta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bazilio91 thanks for your pull request! I'd like to ask for 2 updates to make the code more universal and clean.


def copy_basic_fields(self, source, dest):
for field in {'description', 'transparent', 'repeat'}:
Copy link
Owner

@jakubplichta jakubplichta Apr 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already support for smth similar in JsonGenerator through _copy_fields attribute - it's already defined in e.g. Graph class. I think it should be pretty simple to define commons fields in PanelsItemBase and just extend it in all subclasses.

_copy_fields = {'stack', 'fill', 'aliasColors', 'leftYAxisLabel', 'bars', 'lines', 'linewidth', 'y_formats',
'x-axis', 'y-axis', 'points', 'pointradius', 'percentage', 'steppedLine', 'repeat',
'minSpan', 'datasource'}

def gen_json_from_data(self, data, context):
panel_json = super(Graph, self).gen_json_from_data(data, context)
self.copy_basic_fields(data, panel_json)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please instead of defining new method I think it would be better to rely on inheritance and just define method gen_json_from_data in PanelsItemBase and handle common properties there.

@jakubplichta jakubplichta added this to the 0.5.1a1 milestone Apr 9, 2019
@bazilio91
Copy link
Contributor Author

ok. give me some time, looks like _copy_fields flow needs some kind of refactoring anyway, to make alerts for Graph work.

@jakubplichta
Copy link
Owner

@jakubplichta
Copy link
Owner

@bazilio91 do you think you'll find some time to finish this or should I give it a try?

@jakubplichta jakubplichta modified the milestones: 0.5.1a1, 0.6.1a1 Nov 6, 2019
@bazilio91 bazilio91 closed this Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants