apache / streampipes

Apache StreamPipes - A self-service (Industrial) IoT toolbox to enable non-technical users to connect, analyze and explore IoT data streams.
https://streampipes.apache.org
Apache License 2.0
566 stars 174 forks source link

Empty string as API token name #793

Closed dominikriemer closed 1 year ago

dominikriemer commented 1 year ago

Currently, StreamPipes allows to have an empty string as name when generating an API token in the UI. We should add a validator here.

Imported from Jira STREAMPIPES-645. Original Jira may contain additional context. Reported by: bossenti.

Mentoring

As this ticket is marked as good first issue: @bossenti is happy to provide help for getting started

aamirxshaikh commented 1 year ago

Hey, @bossenti I'm interested in contributing to this issue. How can I get started with it?

bossenti commented 1 year ago

great to hear! First of all you need to setup StreamPipes locally in that way that you can develop the UI. Have a look at this documentation.

The gif below demonstrates the described issue: missing-api-token-name

Empty names for API tokens should be avoided, therefore we need a validator here. The corresponding Angular component can be found here.

Hopefully, this provides you with enough information to start. Otherwise, just let me know.

aamirxshaikh commented 1 year ago

Hey @bossenti I'm following the documentation to setup streampipes locally and I'm unable to configure streampipes for ui development.

I have followed all the mentioned steps.

On running

./streampipes env --set ui

I get

[INFO] Set environment to 'ui'
cp: target 'source/streampipes/installer/cli/.spenv' is not a directory

When starting streampipes backend

./streampipes up -d

I get

[ERROR] Environment missing. See 'streampipes env --help'

dominikriemer commented 1 year ago

Hi @aamirxshaikh, which OS are using? There shouldn't be a cp error when setting the environment - the env --set command should only create a new file called .spenv which includes all services defined for the environment.

aamirxshaikh commented 1 year ago

Hey @dominikriemer I'm using windows 11 (bash shell),

dominikriemer commented 1 year ago

I think the CLI is a unix bash script and doesn't work with the Windows bash. Under Windows 11, you can use e.g. Git bash or WSL to run the CLI.

aamirxshaikh commented 1 year ago

By bash shell I meant Git bash. So, I'll try running with WSL.

dominikriemer commented 1 year ago

Ok, Git bash should also work without problems. If WSL doesn't work, we can further investigate why the script doesn't work in your environment!

aamirxshaikh commented 1 year ago

Hey @dominikriemer Unfortunately with GitBash, I'm facing the same issue as previously I have mentioned. Coming to WSL, It takes forever to open the project. The terminal is just blank and does not not load up.

image

Can you suggest anything else? Thanks.

bossenti commented 1 year ago

Hm thats really strange, both have always worked on my Windows 10 machine 🤔 Are you able to run usual terminal commands in both of them?

aamirxshaikh commented 1 year ago

Hm thats really strange, both have always worked on my Windows 10 machine 🤔

Are you able to run usual terminal commands in both of them?

Yes, I can run usual terminal commands

bossenti commented 1 year ago

Okay, then I think the easiest way is to follow this workaround:

  1. go to `/installer/cli/
  2. create a file named .spenv
  3. go to installer/cli/environments/ and copy the content of the file ui into .spenv

This finally does the same as the script that is not working on your machine. Let me know if that works for you.

aamirxshaikh commented 1 year ago

Hey, @bossenti Thanks for providing the guide. It seems that the issue was because of the whitespace in my parent directory. I'm now able to run it locally. I'm currently going through API docs.

Regarding email and password, where can I register the account?

image

bossenti commented 1 year ago

👍 The default user is the following:

You can change that once you are logged in if you want or create additional users.

aamirxshaikh commented 1 year ago

Hello @bossenti, I am trying to implement the validation for the input field as mentioned in the issue. I have tried it, but I'm having trouble getting it to work. I'm new to learning Angular. I've read the documentation and tried various approaches, but I'm still stuck. Can you please point me to any relevant resources or similar code in the codebase that I can refer to for guidance? Also, could you provide some more information about the validation conditions? For example, are there specific validation rules that need to be followed or specific error messages that should be displayed? I want to make sure I'm meeting all the requirements. I'd really appreciate it. Thank you in advance for your help!

bossenti commented 1 year ago

thanks for catching up on this @aamirxshaikh. Fom my perspective the token name should be longer than three characters and only consist of alphanumeric symbols including - and _.

@dominikriemer @tenthe can you provide Aamir with a sample of our codebase where we use a validator?

tenthe commented 1 year ago

Hi @aamirxshaikh, I couldn't find a validator in the code, but here is a tutorial on typed reactive forms [1]. It also includes a regex validator. Since you are new to Anular, I would recommend trying the tutorial first. It is quite short and provides a good introduction.

[1] https://www.syncfusion.com/blogs/post/strictly-typed-reactive-forms-in-angular.aspx

aamirxshaikh commented 1 year ago

Thanks @tenthe, I'll check it out.