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

front end and backend added for the feature #1243 #1244

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

unical1988
Copy link

I added tsx and go codes for backend and frontend to support SSL for PostgreSQL.

@unical1988
Copy link
Author

I now made the select and checkbox two seperated form groups and remove handleChange()

@unical1988
Copy link
Author

Your comments suggest fixing the frontend part of the new feature, are there problems with the backend commited code?

@unical1988
Copy link
Author

Is the connection string building for the DB correct (in internal/install/install_req.go)?. I assume the pem and crt files should be found in the folder data/cache/certs/

@shuashuai
Copy link
Member

I now made the select and checkbox two seperated form groups and remove handleChange()

An important point is that you have locally verified the code you submitted now? Can the front-end project run correctly?
If you haven't read the development guide, please go to the official website to read the development guide first.

image

I checked it and it still didn't handle the translation completely. In addition, if your editor uses vscode, it is recommended to install the eslint plugin.

SSL Mode On element, why not apply to react-bootstrap components? And why doesn't the checkbox value apply to the value you passed in, but continue to use the value on the current page?

I'm not sure if you end up submitting and saving the value of SSL Mode checkbox to the database. If it's just a logic of whether select is displayed, then it doesn't need to be saved in formData, it just needs to be processed within the current component.

image

The following is content without translation
image

image

@shuashuai
Copy link
Member

Your comments suggest fixing the frontend part of the new feature, are there problems with the backend commited code?

I currently only review the front-end code, and the back-end code needs to wait for @LinkinStars to review it.

@unical1988
Copy link
Author

I am in the process of testing right now, I will check your comments and make the changes in the next commits

@unical1988
Copy link
Author

I made few other frontend fixes (except relating to handle the translations)

@shuashuai
Copy link
Member

shuashuai commented Feb 8, 2025

I made few other frontend fixes (except relating to handle the translations)

  1. there are still ts errors reported in development mode

image

  1. the translation file should be in the i18n directory. What do you ask about creating and submitting the language file in the cmd directory

There are some tutorials on Answer development on the official blog that may be helpful for you to be familiar with projects and development. You can read it.

@LinkinStars
Copy link
Member

LinkinStars commented Feb 8, 2025

Is the connection string building for the DB correct (in internal/install/install_req.go)?. I assume the pem and crt files should be found in the folder data/cache/certs/

@unical1988 All the files required for SSL, such as .pem and .crt, have an input field where users can directly enter the directory path. Users can place the files in the specified directory themselves.

@unical1988
Copy link
Author

All the files required for SSL, such as .pem and .crt, have an input field where users can directly enter the directory path. Users can place the files in the specified directory themselves.

does it mean I have to create input text elements (3) in the UI while SSL is enabled to enable the user to specify the paths ? or is it an upload feature?

@LinkinStars
Copy link
Member

All the files required for SSL, such as .pem and .crt, have an input field where users can directly enter the directory path. Users can place the files in the specified directory themselves.

does it mean I have to create input text elements (3) in the UI while SSL is enabled to enable the user to specify the paths ? or is it an upload feature?

@unical1988 Make it simple. Only need three input text fields.

@unical1988
Copy link
Author

@LinkinStars I used this command to upgrade answer version:
answer.exe upgrade -f v1.4.2 -C ./tmp/answer-data/
Which returned this output:


[migrate] user set upgrade to version: v1.4.2
[migrate] current db version is 24, try to migrate version 25, latest version is 25
[migrate] try to migrate Answer version v1.4.2, description: add the number of question links
[migrate] migrate to db version 25 success
try to save cache file to tmp\answer-data\cache\cache.db
upgrade done

Then to test it again
answer.exe run but the error above persisted.

Here's the database question table schema:

question_table

@LinkinStars
Copy link
Member

@unical1988 Get it. From your screenshot, no fields are missing from the database, so I tested it again locally. I don't encounter the issue. I use the v1.4.2 version and re-install using PostgreSQL. I have not found any error log.

image

  1. Make sure you connect the right database in your screenshot.
  2. Try to verify the error is caused by using SSL.
  3. Use a new database and re-install it to check it.

@unical1988
Copy link
Author

unical1988 commented Feb 14, 2025

@LinkinStars @shuashuai now testing for the postgres to check everythings alright, but encountered the error

Form submission canceled because the form is not connected
this appears and blocks going to the third step, when SSL is unchecked (never checked before).
I have to trigger onChange for the form to pass

Any idea what would be causing this error on the installation second step interface?

@shuashuai
Copy link
Member

@LinkinStars @shuashuai now testing for the postgres to check everythings alright, but encountered the error

Form submission canceled because the form is not connected this appears and blocks going to the third step, when SSL is unchecked (never checked before). I have to trigger onChange for the form to pass

Any idea what would be causing this error on the installation second step interface?

It has nothing to do with the error you're talking about, it's because the form validation logic within your page isn't working.You can check this method checkValidated

In addition to some of the changes mentioned above which you have already completed please click on Resolve conversation

Please restore the eslint and preittier configurations in your project first.

@unical1988
Copy link
Author

unical1988 commented Feb 19, 2025

@shuashuai eslint and preittier are causing the ui not to build correctly.
what is wrong with the logic of checkValidated? after the next commits, the form submits but the then the application doesn't execute after installation but returns 50x error.

@shuashuai
Copy link
Member

shuashuai commented Feb 20, 2025

@shuashuai eslint and preittier are causing the ui not to build correctly. what is wrong with the logic of checkValidated? after the next commits, the form submits but the then the application doesn't execute after installation but returns 50x error.

  1. The code must be formatted to match the current project style. There are eslint and prettier errors that you should fix first.
  2. You added your own checksum logic that doesn't pass in the checkValidated method, so hit the log yourself to find out what's wrong!
  3. Check out the documentation and blogs on the official website to see how to develop and debug the project.

@unical1988
Copy link
Author

@shuashuai where to find the logs?

@shuashuai
Copy link
Member

shuashuai commented Feb 20, 2025

@shuashuai where to find the logs?

You add the logs you need in development mode, and then view them in the browser console, or debug them in your editor, whichever you prefer.

https://answer.apache.org/docs/development

@unical1988
Copy link
Author

@shuashuai i was referring to server logs, where to find them?

@unical1988
Copy link
Author

unical1988 commented Feb 20, 2025

@LinkinStars The previous reported error is still being raised (linked_count not found), here's the error log (from the editor) and it is not caused by using SSL (I have also create another DB using a different version of postgres and yet the same error was displaying)

*errors.Error {Code: 500, Reason: "base.database_error", Message: "", Err: error(*modernc.org/sqlite.Error) *{msg: "SQL logic error: no such column: linked_count (1)", code: 1}, Stack: "C:/Users/SelimSoufargi/Desktop/Answer/answer/internal/repo/question/question_repo.go:419 github.com/apache/answer/internal/repo/question.(*questionRepo).GetQuestionPage\nC:/Users/SelimSoufargi/Desktop/Answer/answer/internal/service/content/question_service.go:1420 github.com/apache/answer/internal/service/content.(*QuestionService).GetQuestionPage\nC:/Users/SelimSoufargi/Desktop/Answer/answer/internal/controller/question_controller.go:335 github.com/apache/answer/internal/controller.(*QuestionController).Ques...+1471 more"}

@unical1988
Copy link
Author

unical1988 commented Feb 24, 2025

@LinkinStars I found the previous error cause: I was running Answer without specifying the config, so when I added it: go run main.go run -C ./data the error disappeared.
Now I will have to test the certificates for the ssl modes. To note that the require mode of ssl already needs the postgresql.conf to be changed to

ssl = on

UPDATE: The tests seem to be working fine (at least for verify-ca mode)!

@unical1988
Copy link
Author

@shuashuai how to format the front-end according to the project styling? is there a prettier command to execute to do so?

@unical1988
Copy link
Author

unical1988 commented Feb 25, 2025

@LinkinStars @shuashuai i have tested the new feature and it works with the certificates. to note that in the field Database host (Installation) I had to specify hostname as an IP (e.g., 127.0.0.1) and then port number (e.g., 127.0.0.1:5432) for the database to connect using SSL.
here's the resulting config:

debug: false
server:
  http:
    addr: 0.0.0.0:80
data:
  database:
    driver: postgres
    connection: host=127.0.0.1 port=5432 user=postgres password=root dbname=test_answer sslmode=verify-ca sslrootcert=C:/Users/SelimSoufargi/Desktop/new_ssl_certifs/server.crt  sslcert=C:/Users/SelimSoufargi/Desktop/new_ssl_certifs/client.crt sslkey=C:/Users/SelimSoufargi/Desktop/new_ssl_certifs/client.key
  cache:
    file_path: data\cache\cache.db
i18n:
  bundle_dir: data\i18n
service_config:
  upload_path: data\uploads
swaggerui:
  show: true
  protocol: http
  host: 127.0.0.1
  address: :80
ui:
  base_url: ""

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

Successfully merging this pull request may close these issues.

3 participants