From b5e99b01160f21bacebab9dfe999aadc0935e8fd Mon Sep 17 00:00:00 2001 From: liosha84 <138026690+liosha84@users.noreply.github.com> Date: Thu, 14 Aug 2025 18:50:16 +0300 Subject: [PATCH] remake init data json dump --- backups/flyway_schema_history.ndjson | 10 + backups/roles.ndjson | 3 + backups/tutorials.ndjson | 4 + backups/user_roles.ndjson | 5 + backups/users.ndjson | 4 + .../breadcrumbs.component.html | 2 +- .../breadcrumbs.component.scss | 2 + .../breadcrumbs.component.ts | 8 +- .../inner-layout.component.html | 17 + .../inner-layout.component.scss | 36 ++ .../inner-layout.component.spec.ts} | 12 +- .../inner-layout.component.ts | 39 ++ .../vertical-nav.component.html | 25 + .../vertical-nav.component.scss | 68 +++ .../vertical-nav.component.spec.ts | 23 + .../vertical-nav.component.ts | 111 +++++ jambotron-ui/src/app/models/table.spec.ts | 7 + jambotron-ui/src/app/models/table.ts | 4 + .../admin-module/admin-module.service.ts | 28 +- .../admin.component/admin.component.html | 25 +- .../admin.component/admin.component.scss | 40 +- .../admin.component/admin.component.ts | 72 +-- .../app/modules/admin-module/admin.routing.ts | 19 +- .../json-dump.component.html | 59 +++ .../json-dump.component.scss | 27 ++ .../json-dump.component.spec.ts | 23 + .../json-dump.component.ts | 135 ++++++ .../data-base.component.html | 7 + .../data-base.component.scss | 0 .../data-base.component.spec.ts | 23 + .../data-base.component.ts | 25 + .../admin-module/json-dump.service.spec.ts | 16 + .../modules/admin-module/json-dump.service.ts | 449 +++++++++++++++++ .../settings.component.html | 2 + .../settings.component/settings.component.ts | 4 +- .../side-bar-admin.component.html | 35 -- .../side-bar-admin.component.scss | 14 - .../side-bar-admin.component.ts | 20 - .../users.component/users.component.ts | 12 +- .../main.component/main.component.html | 105 ++-- .../main.component/main.component.scss | 1 + .../app/modules/main-module/main.routing.ts | 5 +- .../moderator.component.html | 7 +- .../moderator.component.scss | 13 - .../moderator.component.ts | 9 +- .../moderator-module/moderator.routing.ts | 12 +- .../user.component/user.component.html | 10 +- .../user.component/user.component.ts | 35 +- .../app/modules/user-module/user.routing.ts | 18 +- .../src/app/services/spinner.service.ts | 4 +- jambotron-ui/src/app/services/user.service.ts | 4 +- jambotron-ui/src/index.html | 4 +- jambotron-ui/src/index_dev.html | 2 + jambotron-ui/src/styles.scss | 6 +- .../jambotron/DTOs/RoleDto.java | 48 ++ .../jambotron/DTOs/TutorialDto.java | 145 ++++++ .../jambotron/DTOs/UserDto.java | 102 ++++ .../jambotron/JambotronApplication.java | 13 + .../controllers/JsonDumpController.java | 347 +++++++++++++ .../fileUpload/FilesStorageServiceImpl.java | 1 + .../initData/InitDataConfiguration.java | 21 + .../jambotron/initData/InitDataService.java | 148 ++++++ .../jambotron/jsonDump/JsonDumpService.java | 456 ++++++++++++++++++ .../JsonDumpServiceConfiguration.java | 34 ++ .../jambotronGroup/jambotron/model/Role.java | 6 +- .../jambotron/model/Tutorial.java | 14 +- .../jambotronGroup/jambotron/model/User.java | 2 +- .../jambotron/repository/RoleRepository.java | 3 + .../jambotron/security/WebSecurityConfig.java | 7 +- src/main/resources/application-dev.properties | 12 + .../db/migration/V10__refresh_token.sql | 12 - src/main/resources/db/migration/V1__Init.sql | 84 +++- src/main/resources/db/migration/V2__init.sql | 14 - src/main/resources/db/migration/V3__init.sql | 25 - .../resources/db/migration/V4__Init_data.sql | 20 - src/main/resources/db/migration/V5__Fixes.sql | 2 - .../db/migration/V6__fix_tutorial_id.sql | 6 - .../V7__add_column_userid_to_tutorials.sql | 27 -- .../db/migration/V8__tutorial_remake.sql | 19 - .../db/migration/V9__title_image.sql | 9 - src/main/resources/import/roles.json | 10 + src/main/resources/import/users.json | 34 ++ 82 files changed, 2814 insertions(+), 457 deletions(-) create mode 100644 backups/flyway_schema_history.ndjson create mode 100644 backups/roles.ndjson create mode 100644 backups/tutorials.ndjson create mode 100644 backups/user_roles.ndjson create mode 100644 backups/users.ndjson create mode 100644 jambotron-ui/src/app/components/inner-layout.component/inner-layout.component.html create mode 100644 jambotron-ui/src/app/components/inner-layout.component/inner-layout.component.scss rename jambotron-ui/src/app/{modules/admin-module/side-bar-admin.component/side-bar-admin.component.spec.ts => components/inner-layout.component/inner-layout.component.spec.ts} (51%) create mode 100644 jambotron-ui/src/app/components/inner-layout.component/inner-layout.component.ts create mode 100644 jambotron-ui/src/app/components/vertical-nav.component/vertical-nav.component.html create mode 100644 jambotron-ui/src/app/components/vertical-nav.component/vertical-nav.component.scss create mode 100644 jambotron-ui/src/app/components/vertical-nav.component/vertical-nav.component.spec.ts create mode 100644 jambotron-ui/src/app/components/vertical-nav.component/vertical-nav.component.ts create mode 100644 jambotron-ui/src/app/models/table.spec.ts create mode 100644 jambotron-ui/src/app/models/table.ts create mode 100644 jambotron-ui/src/app/modules/admin-module/components/json-dump.component/json-dump.component.html create mode 100644 jambotron-ui/src/app/modules/admin-module/components/json-dump.component/json-dump.component.scss create mode 100644 jambotron-ui/src/app/modules/admin-module/components/json-dump.component/json-dump.component.spec.ts create mode 100644 jambotron-ui/src/app/modules/admin-module/components/json-dump.component/json-dump.component.ts create mode 100644 jambotron-ui/src/app/modules/admin-module/data-base.component/data-base.component.html create mode 100644 jambotron-ui/src/app/modules/admin-module/data-base.component/data-base.component.scss create mode 100644 jambotron-ui/src/app/modules/admin-module/data-base.component/data-base.component.spec.ts create mode 100644 jambotron-ui/src/app/modules/admin-module/data-base.component/data-base.component.ts create mode 100644 jambotron-ui/src/app/modules/admin-module/json-dump.service.spec.ts create mode 100644 jambotron-ui/src/app/modules/admin-module/json-dump.service.ts delete mode 100644 jambotron-ui/src/app/modules/admin-module/side-bar-admin.component/side-bar-admin.component.html delete mode 100644 jambotron-ui/src/app/modules/admin-module/side-bar-admin.component/side-bar-admin.component.scss delete mode 100644 jambotron-ui/src/app/modules/admin-module/side-bar-admin.component/side-bar-admin.component.ts create mode 100644 src/main/java/com/jambotronGroup/jambotron/DTOs/RoleDto.java create mode 100644 src/main/java/com/jambotronGroup/jambotron/DTOs/TutorialDto.java create mode 100644 src/main/java/com/jambotronGroup/jambotron/DTOs/UserDto.java create mode 100644 src/main/java/com/jambotronGroup/jambotron/controllers/JsonDumpController.java create mode 100644 src/main/java/com/jambotronGroup/jambotron/initData/InitDataConfiguration.java create mode 100644 src/main/java/com/jambotronGroup/jambotron/initData/InitDataService.java create mode 100644 src/main/java/com/jambotronGroup/jambotron/jsonDump/JsonDumpService.java create mode 100644 src/main/java/com/jambotronGroup/jambotron/jsonDump/JsonDumpServiceConfiguration.java delete mode 100644 src/main/resources/db/migration/V10__refresh_token.sql delete mode 100644 src/main/resources/db/migration/V2__init.sql delete mode 100644 src/main/resources/db/migration/V3__init.sql delete mode 100644 src/main/resources/db/migration/V4__Init_data.sql delete mode 100644 src/main/resources/db/migration/V5__Fixes.sql delete mode 100644 src/main/resources/db/migration/V6__fix_tutorial_id.sql delete mode 100644 src/main/resources/db/migration/V7__add_column_userid_to_tutorials.sql delete mode 100644 src/main/resources/db/migration/V8__tutorial_remake.sql delete mode 100644 src/main/resources/db/migration/V9__title_image.sql create mode 100644 src/main/resources/import/roles.json create mode 100644 src/main/resources/import/users.json diff --git a/backups/flyway_schema_history.ndjson b/backups/flyway_schema_history.ndjson new file mode 100644 index 0000000..5caf3c8 --- /dev/null +++ b/backups/flyway_schema_history.ndjson @@ -0,0 +1,10 @@ +{"type": "SQL", "script": "V1__Init.sql", "success": true, "version": "1", "checksum": 1015436223, "description": "Init", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.278963", "execution_time": 23, "installed_rank": 1} +{"type": "SQL", "script": "V2__init.sql", "success": true, "version": "2", "checksum": 1439164107, "description": "init", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.364728", "execution_time": 21, "installed_rank": 2} +{"type": "SQL", "script": "V3__init.sql", "success": true, "version": "3", "checksum": 1126077872, "description": "init", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.430577", "execution_time": 16, "installed_rank": 3} +{"type": "SQL", "script": "V4__Init_data.sql", "success": true, "version": "4", "checksum": 1082838296, "description": "Init data", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.480949", "execution_time": 22, "installed_rank": 4} +{"type": "SQL", "script": "V5__Fixes.sql", "success": true, "version": "5", "checksum": 1011882594, "description": "Fixes", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.54043", "execution_time": 10, "installed_rank": 5} +{"type": "SQL", "script": "V6__fix_tutorial_id.sql", "success": true, "version": "6", "checksum": 2025331495, "description": "fix tutorial id", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.577613", "execution_time": 16, "installed_rank": 6} +{"type": "SQL", "script": "V7__add_column_userid_to_tutorials.sql", "success": true, "version": "7", "checksum": -1581139665, "description": "add column userid to tutorials", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.624337", "execution_time": 11, "installed_rank": 7} +{"type": "SQL", "script": "V8__tutorial_remake.sql", "success": true, "version": "8", "checksum": 2000720842, "description": "tutorial remake", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.657116", "execution_time": 11, "installed_rank": 8} +{"type": "SQL", "script": "V9__title_image.sql", "success": true, "version": "9", "checksum": 499316035, "description": "title image", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.689202", "execution_time": 13, "installed_rank": 9} +{"type": "SQL", "script": "V10__refresh_token.sql", "success": true, "version": "10", "checksum": -284916251, "description": "refresh token", "installed_by": "admin", "installed_on": "2025-08-11T18:05:52.724264", "execution_time": 9, "installed_rank": 10} diff --git a/backups/roles.ndjson b/backups/roles.ndjson new file mode 100644 index 0000000..02dd18d --- /dev/null +++ b/backups/roles.ndjson @@ -0,0 +1,3 @@ +{"id": 1, "name": "ROLE_USER"} +{"id": 2, "name": "ROLE_MODERATOR"} +{"id": 3, "name": "ROLE_ADMIN"} diff --git a/backups/tutorials.ndjson b/backups/tutorials.ndjson new file mode 100644 index 0000000..5a6d213 --- /dev/null +++ b/backups/tutorials.ndjson @@ -0,0 +1,4 @@ +{"id": 1, "body": "## Markdown __rulez__!\n---\n\n### Syntax highlight\n```typescript\nconst language = 'typescript';\n```\n\n### Lists\n1. Ordered list\n2. Another bullet point\n - Unordered list\n - Another unordered bullet\n\n### Blockquote\n> Blockquote to the max", "title": "Test 1", "userid": 1, "created": "2025-08-11T18:07:54.037686+03:00", "modified": "2025-08-11T18:07:54.037686+03:00", "published": true, "titleimage": "http://localhost:8082/files/Tutorial_user-image-1-07a460cf07aa41d1b7f2f9d2b9789c0b.png", "description": null, "tobepublished": true} +{"id": 3, "body": "## Markdown __rulez__!\n---\n\n### Syntax highlight\n```typescript\nconst language = 'typescript';\n```\n\n### Lists\n1. Ordered list\n2. Another bullet point\n - Unordered list\n - Another unordered bullet\n\n### Blockquote\n> Blockquote to the max", "title": "Test 2", "userid": 1, "created": "2025-08-11T18:08:33.839282+03:00", "modified": "2025-08-11T18:08:33.839403+03:00", "published": true, "titleimage": "http://localhost:8082/files/Tutorial_user-image-1-c4281de414ae44ba8e39e03f06c8f803.png", "description": null, "tobepublished": true} +{"id": 4, "body": "## Markdown __rulez__!\n---\n\n### Syntax highlight\n```typescript\nconst language = 'typescript';\n```\n\n### Lists\n1. Ordered list\n2. Another bullet point\n - Unordered list\n - Another unordered bullet\n\n### Blockquote\n> Blockquote to the max", "title": "Test 3", "userid": 1, "created": "2025-08-11T18:08:59.02719+03:00", "modified": "2025-08-11T18:08:59.02719+03:00", "published": true, "titleimage": "http://localhost:8082/files/Tutorial_user-image-1-0a55158e36d34fe8842ceac520bd6032.png", "description": null, "tobepublished": true} +{"id": 6, "body": "# How to run the application\n\nTo run the application, follow these steps:\n\n1. **Build the Project**:\n - Ensure you have Java 24, Gradle, and Node.js installed.\n - Run the following command to build the project:\n ```bash\n ./gradlew build\n ```\n\n 2. **Prepare Frontend Resources**:\n - Build the Angular frontend by navigating to the `jambotron-ui` directory and running\n ```bash\n cd jambotron-ui\n ```\n - next:\n ```bash\n npm install\n ```\n - next:\n ```bash\n npm run build\n ```\n - This will generate the frontend files in the `jambotron-ui/dist/jambotron-ui/browser` directory.\n\n\n3. **Copy Frontend Resources**:\n - Use the Gradle task to copy the frontend resources to the `jumbotron/src/main/resources/public` directory:\n ```bash\n cd ..\n ```\n - next:\n ```bash\n ./gradlew copyResources\n ```\n then\n4. **Create postgres server and database**:\n - Create a PostgreSQL database \n - named `jambotronDB` with the \n - user `admin` and \n - password `postgrespw`.\n \n - You can use a PostgreSQL client or run the following command in your terminal:\n ```sql\n CREATE DATABASE jambotronDB;\n CREATE USER admin WITH PASSWORD 'postgrespw';\n GRANT ALL PRIVILEGES ON DATABASE jambotronDB TO admin;\n ```\n - If you are using Docker, you can run PostgreSQL using the following command:\n - port 5433 is used.\n ```bash\n docker run --name postgresDB -p 5433:5432 -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=postgrespw -e POSTGRES_DB=jambotronDB -d postgres\n ```\n - if you are wont to use pgadmin\n ```bash\n docker run --name pgadmin -e \"PGADMIN_DEFAULT_EMAIL=name@example.com\" -e \"PGADMIN_DEFAULT_PASSWORD=admin\" -p 5050:80 -d dpage/pgadmin4\n ```\n then\n - create a network for the containers to communicate:\n ```bash\n docker network create --driver bridge pgnetwork\n ```\n - Show list of networks:\n ```bash\n docker network ls\n ```\n - Connect pgadmin to the network:\n ```bash\n docker network connect pgnetwork pgadmin\n ```\n - Connect postgresDB to the network (postgresDB must by running):\n ```bash\n docker network connect pgnetwork postgresDB\n ```\n - Inspect the network to ensure both containers are connected:\n ```bash\n docker network inspect pgnetwork\n ```\n \n\n\n5. **Run the Application**:\n - Start the Spring Boot application:\n ```bash\n ./gradlew bootRun\n ```\n\n6. **Access the Application**:\n - Open your browser and navigate to `http://localhost:8080`.\n\nMake sure all dependencies and configurations are correctly set up before running these steps.\n\n\n\n\n# How to run the application in Docker\n\nTo run the application in Docker, follow these steps:\n\n- build jar file\n```bash\n./gradlew bootJar\n ```\n- Run docker compose to start the application and PostgreSQL:\n```bash\ndocker-compose -f src/Docker/docker-compose.yml up -d \n```\n- For connection from pgadmin use \nhostename: **host.docker.internal**\n\n# How to run the application in Docker with HTTPS support\n\nTo run the application in Docker with HTTPS support, follow these steps:\n\n1. **Cerbot**\n \n - Run this command below to get certificate and store it to volume certs.\n\n - Expanded(readable) command example:\n\n docker run -d \\\n --name certbot \\\n -v certs:/etc/letsencrypt \\\n -v certs-data:/var/lib/letsencrypt \\\n -p 80:80 \\\n -p 443:443 \\\n certbot/certbot \\\n certonly --standalone --preferred-challenges http --email youremail@gmail.com -d yourdomain.com --agree-tos\n\n - Command to run certbot with specific domain and email:\n ```bash\n docker run -d --name certbot -v certs:/etc/letsencrypt -v certs-data:/var/lib/letsencrypt -p 8081:80 -p 8443:443 certbot/certbot certonly --standalone --preferred-challenges http --email liosha84@gmail.com -d jambotron.run.place --agree-tos\n ```\n - Tip: You can generate certificate to local machine used next command:\n ```bash\n docker run -it --rm -p 8081:80 --name certbot -v \"C:\\certbot\\etc\\letsencrypt:/etc/letsencrypt\" -v \"C:\\certbot\\var\\lib\\letsencrypt:/var/lib/letsencrypt\" certbot/certbot certonly --standalone -d jambotron.run.place \n ```\n certificate files will be stored in `C:\\certbot\\etc\\letsencrypt` and `C:\\certbot\\var\\lib\\letsencrypt` directories.\n\n - If you have same trouble before running certbot, run this project\n `Helper_projects/spring-boot-https-main` insted of jambotron project.\n \n\n - TODO: Add cron job to renew certificate automatically.\n\n### Reference Documentation\nFor further reference, please consider the following sections:\n\n* [Official Gradle documentation](https://docs.gradle.org)\n* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/3.5.0/gradle-plugin)\n* [Create an OCI image](https://docs.spring.io/spring-boot/3.5.0/gradle-plugin/packaging-oci-image.html)\n\n### Additional Links\nThese additional references should also help you:\n\n* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle)\n\n\n\nFor docker-compose db connect with pgAdmin used\nhost.docker.internal", "title": "Test 4", "userid": 1, "created": "2025-08-11T18:10:12.111675+03:00", "modified": "2025-08-11T18:10:12.111675+03:00", "published": true, "titleimage": "http://localhost:8082/files/Tutorial_9a17dfe0-9d45-4e4f-bddc-d514b5774529.png", "description": null, "tobepublished": true} diff --git a/backups/user_roles.ndjson b/backups/user_roles.ndjson new file mode 100644 index 0000000..13e4b82 --- /dev/null +++ b/backups/user_roles.ndjson @@ -0,0 +1,5 @@ +{"role_id": 1, "user_id": 3} +{"role_id": 2, "user_id": 2} +{"role_id": 3, "user_id": 1} +{"role_id": 1, "user_id": 1} +{"role_id": 2, "user_id": 1} diff --git a/backups/users.ndjson b/backups/users.ndjson new file mode 100644 index 0000000..876ad35 --- /dev/null +++ b/backups/users.ndjson @@ -0,0 +1,4 @@ +{"id": 1, "email": "liosha84@gmail.com", "password": "$2a$10$qyoKXYSukha6XCjorTzoweF4Os1pwmwyzbaSsb3RCVB0LK6WLQKPC", "username": "Admin"} +{"id": 2, "email": "Moderator@gmail.com", "password": "$2a$10$zLo5th8Xbfq.MM7y/dCRQu3Ud7HHyAwm.7.yS08ytJtkHMKrbOJlu", "username": "Moderator"} +{"id": 3, "email": "user@gmail.com", "password": "$2a$10$2EcwYffteBF3GhVaf5qPB.I7XiHepDEauU5D4fx9fpBXMTZI/QnnC", "username": "User"} +{"id": 4, "email": "user1@gmail.com", "password": "$2a$10$/lditoDdNNkwjr.jL0KUveGGSzF1ZA6Nhj4lC/w8CkuOGWTj8pOY6", "username": "user1"} diff --git a/jambotron-ui/src/app/components/breadcrumbs.component/breadcrumbs.component.html b/jambotron-ui/src/app/components/breadcrumbs.component/breadcrumbs.component.html index 6753bf6..7f153ac 100644 --- a/jambotron-ui/src/app/components/breadcrumbs.component/breadcrumbs.component.html +++ b/jambotron-ui/src/app/components/breadcrumbs.component/breadcrumbs.component.html @@ -1,4 +1,4 @@ - +