From 1cb1ea2a2c0f6e7bb9dd191ea3097dbbe3e5cfbc Mon Sep 17 00:00:00 2001 From: AlexJoom Date: Fri, 10 Jun 2022 14:15:59 +0300 Subject: [PATCH] improvements on the readme and on labels/texts/links --- .env.example | 2 +- README.md | 244 +++++++++++++----- app/Http/Controllers/DashboardController.php | 14 +- .../2022_06_03_145949_add_column_to_user.php | 33 +++ docker-compose.yml | 2 +- resources/js/app.js | 4 +- resources/js/vue-components/CreateNetApp.vue | 58 +++-- .../vue-components/common/ModalComponent.vue | 2 +- .../common/PurchasedNetappModal.vue | 2 +- .../js/vue-components/common/SuccessModal.vue | 2 +- .../{price-table.vue => priceTable.vue} | 0 .../{edit-netapp.vue => editNetapp.vue} | 33 ++- resources/sass/dashboard.scss | 15 +- resources/sass/home.scss | 6 +- resources/sass/netapp-creators.scss | 26 +- resources/sass/netapp-single.scss | 2 +- .../views/admin/user-management.blade.php | 2 +- resources/views/common/footer.blade.php | 64 ++--- resources/views/common/navbar.blade.php | 10 +- resources/views/home.blade.php | 85 +++++- .../my-account-settings-dashboard.blade.php | 114 ++++---- resources/views/netapp-create.blade.php | 2 +- resources/views/netapp-creators.blade.php | 27 +- resources/views/netapp-single.blade.php | 144 ++++++----- resources/views/purchased-netapps.blade.php | 2 +- resources/views/welcome-dashboard.blade.php | 6 +- routes/web.php | 2 + 27 files changed, 574 insertions(+), 329 deletions(-) create mode 100644 database/migrations/2022_06_03_145949_add_column_to_user.php rename resources/js/vue-components/common/{price-table.vue => priceTable.vue} (100%) rename resources/js/vue-components/{edit-netapp.vue => editNetapp.vue} (98%) diff --git a/.env.example b/.env.example index d698bcf..a8ca8d6 100644 --- a/.env.example +++ b/.env.example @@ -65,6 +65,6 @@ CRYPTO_RECEIVER_ADDRESS= CRYPTO_WALLET_PRIVATE_KEY= CRYPTO_NETWORK=rinkeby CRYPTO_INFURA_PROJECT_ID= -FORUM_URL=http://evolved5g-marketplace-forum.evolved-5g.gr/ +FORUM_URL=https://forum.evolved-5g.eu/ CRYPTO_SENDER_BASE_URL=http://localhost:8000/ TM_FORUM_API_BASE_URL=http://localhost:8080/tmf-api/ diff --git a/README.md b/README.md index 4e6c5cc..c890ba7 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,84 @@ # Εvolved-5G Marketplace | Web Application -Laravel 8 Web Application for Evolved-5G Market +Laravel 8 Web Application for Evolved-5G Marketplace +## About this documentation guide + +This documentation contains all the relevant instructions and information, in order to set up the marketplace project. + +It contains 2 different initialization options, the first assuming a non-docker environment (classic), and the second +assuming a docker-enabled environment. [Project URL](https://evolved5g-marketplace.maggioli.gr) +## Pre-initialization steps -# Installation Instructions: +After cloning the project, create an .env file (should be a copy of .env.example), +containing the information about your database name and credentials: -## First time install (setup database and install dependencies) +```bash +cp .env.example .env +``` -1. Make sure `php 7.4` (or newer) and `NodeJS v14` (or newer) are installed. -2. Make sure php [related packages](https://stackoverflow.com/questions/40815984/how-to-install-all-required-php-extensions-for-laravel) are installed -4. Install laravel/back-end dependencies +Then, run the command to set the application unique key: + +```bash +php artisan key:generate ``` + +
+ +## Installation Option #1: Non-Docker environment + +### First time install (setup database and install dependencies) + +#### PHP and NodeJS versions + +0. Make sure `php 7.4` (or newer) and `NodeJS v14` (or newer) are installed: + +Node version that should be used: `14.18.1` +Npm version that should be used: `6.14.5` + +Make sure + php [related packages](https://stackoverflow.com/questions/40815984/how-to-install-all-required-php-extensions-for-laravel) + are installed +### Laravel initialization commands + +After the `.env` file is completed, we should run all the Laravel-related initialization commands. + +1. Let's begin by installing all the backend Composer dependencies: + +```bash composer install + composer dump-autoload ``` -4. After cloning the project, create an .env file (should be a copy of .env.example), - containing the information about your database name and credentials. - Then run ```php artisan migrate``` to create the DB schema and - ```php artisan db:seed``` in order to insert the starter data to the DB -5. Install front-end dependencies -``` -npm install -``` +2. Then, we can set up the DB schema and populating the DB: -Node version that should be used: `14.18.1` -Npm version that should be used: `6.14.5` +```bash +php artisan migrate +php artisan db:seed +``` -6. Create symbolic link for uploaded files. +3. Make the soft link from the `/public/storage` folder with the `/storage/app/public` director -``` +```bash php artisan storage:link ``` -to link the `/public/storage` folder with the `/storage/app/public` director +4. Install and compile all frontend npm dependencies: -7. Create folder /public/assets and allow the www-data user to create new folders there +```bash +npm install -## Apache configuration example: +npm run dev +``` + +5. Create folder /public/assets and allow the www-data user to create new folders there +### Apache configuration example: ``` % sudo touch /etc/apache2/sites-available/evolved5g-marketplace.conf @@ -62,15 +98,21 @@ to link the `/public/storage` folder with the `/storage/app/public` director ``` -Make the symbolic link: + +6. Make the symbolic link: + ``` % cd /etc/apache2/sites-enabled && sudo ln -s ../sites-available/evolved5g-marketplace.conf ``` -Enable mod_rewrite, mod_ssl and restart apache: + +7. Enable mod_rewrite, mod_ssl and restart apache: + ``` % sudo a2enmod rewrite && sudo a2enmod ssl && sudo service apache2 restart ``` -Fix permissions for storage directory: + +8. Fix permissions for storage directory: + ``` sudo chown -R user:www-data storage chmod 775 storage @@ -80,84 +122,160 @@ find . -type d -exec chmod 775 {} \; ``` Or run the `set-file-permissions.sh` script. + ```$xslt sudo ./set-file-permissions.sh www-data currentUser . ``` -Change hosts file so local-dev.evolved5g-marketplace points to localhost + +9. Change hosts file so local-dev.evolved5g-marketplace points to localhost + ```$xslt sudo nano /etc/hosts 127.0.0.1 local-dev.evolved5g-marketplace ``` -## How to debug -- Install and configure Xdebug on your machine -- At Chrome install [Xdebug helper](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?utm_source=chrome-app-launcher-info-dialog) -- At PhpStorm/IntelliJ click the "Start listening for PHP debug connections" +
-## About the Blockchain Integration +## Installation Option #2: Docker environment -The Evolved-5G Marketplace makes use of the Ethereum Blockchain, in order to create digital signatures when a Netapp is bought. +### Docker initialization -In order to do so, every time a purchase is made, the app communicates with an external Nodejs REST API, that makes the request to the Ethereum Blockchain. +As mentioned above, the Evolved5G Project uses a total of 3 applications (code repositories) that act as services, +communicating with each other. -This script can be found in this GitHub repository: [ETH Transaction Sender](https://github.com/EVOLVED-5G/marketplace-blockchain-integration). +This can (and is highly recommended to) be done via the existing Docker files that are available in each of the +repositories, and that can be invoked using `docker-compose`. -In order to install the script, clone the repository and then set up the NodeJS/Express app in order to run on the :8000 port of the host machine. -Then, edit the `CRYPTO_SENDER_BASE_URL` variable in the `.env` file, so that Laravel knows where to find the endpoint. An example can be found in the `.env.example` file. +In general, for each of the 3 repositories, it is needed to run `docker-compose up --build -d` in order to build the +relevant images and containers, and make them available +in the docker runtime. -**NOTE** +When using Docker though, communication between containers via `localhost` is not possible, though. +That is why in the `docker-compose.yml` file of the Laravel project (the project in which this Readme file is in), a +step exists in which a Docker network is created. -If the `CRYPTO_SENDER_BASE_URL` variable is left empty, then the app will regard the Blockchain integration as non-functional and will not make the API call. +Then, the other 2 repositories will use the same network and deploy their containers there. +So, when Laravel wants to communicate with the NodeJS Blockchain integration service, it will not +call `http://localhost:8000`, but it will need to call +`http://evolved5g_blockchain_sender:8000`, since the name of the Blockchain Integration app container on the Docker +network is `evolved5g_blockchain_sender`. +So, when running the 3 repositories via Docker, the `.env` file should be altered as such: -## About the TM Forum Integration +```bash +CRYPTO_SENDER_BASE_URL=http://evolved5g_blockchain_sender:8000/ +TM_FORUM_API_BASE_URL=http://evolved5g_pilot_tmf_api_container:8080/tmf-api/ +``` -The Evolved-5G Marketplace makes use of the TM Forum API, in order to create product offerings when a Netapp is created. +### Laravel initialization with Docker -In order to do so, every time a netapp is created **and is set to have a fixed price**, the app communicates with an external TM Forum REST API, that stores the relevant information for the product offering. +After running `docker-compose up --build -d` in the root Laravel directory, the app will be available +at [http://localhost:89](http://localhost:89). +In order to run all Laravel installation-specific commands (like `php artisan migrate` , `npm install`, etc) we can use +the utility Docker containers that are defined in `docker-compose.yml`. -The TM Forum implementation can be found in this GitHub repository: [TM Forum API](https://github.com/EVOLVED-5G/marketplace-tmf620-api). +***Note about the DB connection*** -In order to install the TM Forum Backend, clone the repository and then use the provider Docker files in order to make it available on the :8080 port of the host machine. -Then, edit the `TM_FORUM_API_BASE_URL` variable in the `.env` file, so that Laravel knows where to find the endpoint. An example can be found in the `.env.example` file. +You need first to specify a MySQL user and password of your choice in the `.env` file, and when the DB container is created, it will use these credentials from the .env file. -**NOTE** +So, if you haven't specified those in the `.env` file, please delete the db container, add the credentials in `.env`, and create the container again. -If the `TM_FORUM_API_BASE_URL` variable is left empty, then the app will regard the TM Forum API integration as non-functional and will not make the API call. +Please note that since the Docker compose service that refers to the DB is called `db`, the `DB_HOST` variable in `.env` should also have `db` as a value. +See an example of all the DB-related field of `.env` here: -## Docker initialization +```bash +DB_CONNECTION=mysql +DB_HOST=db +DB_PORT=3306 +DB_DATABASE=evolved5g_db +DB_USERNAME=admin +DB_PASSWORD=secret +``` -As mentioned above, the Evolved5G Project uses a total of 3 applications (code repositories) that act as services, communicating with each other. +### Laravel initialization commands -This can (and is highly recommended to) be done via the existing Docker files that are available in each of the repositories, and that can be invoked using `docker-compose`. +After the `.env` file is completed, we should run all the Laravel-related initialization commands. -In general, for each of the 3 repositories, it is needed to run `docker-compose up --build -d` in order to build the relevant images and containers, and make them available -in the docker runtime. +Let's begin by installing all the backend Composer dependencies: -When using Docker though, communication between containers via `localhost` is not possible, though. -That is why in the `docker-compose.yml` file of the Laravel project (the project in which this Readme file is in), a step exists in which a Docker network is created. +```bash +docker-compose run --rm composer install -Then, the other 2 repositories will use the same network and deploy their containers there. -So, when Laravel wants to communicate with the NodeJS Blockchain integration service, it will not call `http://localhost:8000`, but it will need to call -`http://evolved5g_blockchain_sender:8000`, since the name of the Blockchain Integration app container on the Docker network is `evolved5g_blockchain_sender`. +docker-compose run --rm composer dump-autoload +``` -So, when running the 3 repositories via Docker, the `.env` file should be altered as such: + +Then, we can set up the DB schema and populating the DB: ```bash -CRYPTO_SENDER_BASE_URL=http://evolved5g_blockchain_sender:8000/ -TM_FORUM_API_BASE_URL=http://evolved5g_pilot_tmf_api_container:8080/tmf-api/ +docker-compose run --rm artisan migrate + +docker-compose run --rm artisan db:seed ``` -## Laravel initialization with Docker -After running `docker-compose up --build -d` in the root Laravel directory, the app will be available at [http://localhost:89](http://localhost:89). -In order to run all Laravel installation-specific commands (like `php artisan migrate` , `npm install`, etc) we can use the utility Docker containers that are defined in `docker-compose.yml`. +Make the soft link from `app/storage/` to `public/storage`: -For example, we can run the migrations in the app that runs in the Docker container by running: +```bash +docker-compose run --rm artisan storage:link +``` + +Install and compile all frontend npm dependencies: ```bash -docker-compose run --rm artisan migrate +docker-compose run --rm npm install + +docker-compose run --rm npm run dev ``` All the essential Laravel commands have also defined as shortcut in the `Makefile` that is in the root directory. So if you want to run the migrations, simply run `make migrate`. + +## How to debug + +- Install and configure Xdebug on your machine +- At Chrome + install [Xdebug helper](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?utm_source=chrome-app-launcher-info-dialog) +- At PhpStorm/IntelliJ click the "Start listening for PHP debug connections" + +## About the Blockchain Integration + +The Evolved-5G Marketplace makes use of the Ethereum Blockchain, in order to create digital signatures when a Netapp is +bought. + +In order to do so, every time a purchase is made, the app communicates with an external Nodejs REST API, that makes the +request to the Ethereum Blockchain. + +This script can be found in this GitHub +repository: [ETH Transaction Sender](https://github.com/EVOLVED-5G/marketplace-blockchain-integration). + +In order to install the script, clone the repository and then set up the NodeJS/Express app in order to run on the :8000 +port of the host machine. +Then, edit the `CRYPTO_SENDER_BASE_URL` variable in the `.env` file, so that Laravel knows where to find the endpoint. +An example can be found in the `.env.example` file. + +**NOTE** + +If the `CRYPTO_SENDER_BASE_URL` variable is left empty, then the app will regard the Blockchain integration as +non-functional and will not make the API call. + +## About the TM Forum Integration + +The Evolved-5G Marketplace makes use of the TM Forum API, in order to create product offerings when a Netapp is created. + +In order to do so, every time a netapp is created **and is set to have a fixed price**, the app communicates with an +external TM Forum REST API, that stores the relevant information for the product offering. + +The TM Forum implementation can be found in this GitHub +repository: [TM Forum API](https://github.com/EVOLVED-5G/marketplace-tmf620-api). + +In order to install the TM Forum Backend, clone the repository and then use the provider Docker files in order to make +it available on the :8080 port of the host machine. +Then, edit the `TM_FORUM_API_BASE_URL` variable in the `.env` file, so that Laravel knows where to find the endpoint. An +example can be found in the `.env.example` file. + +**NOTE** + +If the `TM_FORUM_API_BASE_URL` variable is left empty, then the app will regard the TM Forum API integration as +non-functional and will not make the API call. + diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index d4c9448..4f36fbc 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -2,12 +2,24 @@ namespace App\Http\Controllers; - +use App\Models\User; use Illuminate\Http\Request; class DashboardController extends Controller { public function index() { + $user = User::find(auth()->user()->id); + return view('my-account-settings-dashboard', compact('user')); + } + public function update(Request $request) + { + $user = User::find(auth()->user()->id); + $user->email = $request->email; + $user->name = $request->name; + $user->business_name = $request->business; + $user->social_number = $request->social_number; + $user->update(); + return view('my-account-settings-dashboard', compact('user')); } } diff --git a/database/migrations/2022_06_03_145949_add_column_to_user.php b/database/migrations/2022_06_03_145949_add_column_to_user.php new file mode 100644 index 0000000..5b88468 --- /dev/null +++ b/database/migrations/2022_06_03_145949_add_column_to_user.php @@ -0,0 +1,33 @@ +string('business_name')->nullable(); + $table->string('social_number')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + // + }); + } +} diff --git a/docker-compose.yml b/docker-compose.yml index be31a85..228b82a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.1" +version: "3.5" services: php: diff --git a/resources/js/app.js b/resources/js/app.js index 070a507..9f71a5d 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -15,7 +15,7 @@ import getLodash from "lodash/get"; import eachRightLodash from "lodash/eachRight"; import replaceLodash from "lodash/replace"; import CKEditor from '@ckeditor/ckeditor5-vue2'; -import editNetapp from "./vue-components/edit-netapp.vue"; +import editNetapp from "./vue-components/editNetapp.vue"; import ProductCatalog from "./vue-components/productCatalog.vue"; import PurchasedNetappModal from './vue-components/common/PurchasedNetappModal.vue' import MarketplaceOverview from './vue-components/admin-components/marketplace-overview.vue' @@ -60,11 +60,13 @@ Vue.mixin({ }, purchaseNetapp(formData, refreshPage = false) { this.handleLoader('show'); + console.log('test'); axios .post(`${process.env.MIX_API_URL}/api/purchase-netapp`, formData) .then((response) => { this.handleLoader('hide'); this.showPurchasedModel = true + console.log(this.showPurchasedModel); }) .catch((error) => { console.log(error); diff --git a/resources/js/vue-components/CreateNetApp.vue b/resources/js/vue-components/CreateNetApp.vue index c793cea..418648c 100644 --- a/resources/js/vue-components/CreateNetApp.vue +++ b/resources/js/vue-components/CreateNetApp.vue @@ -296,8 +296,9 @@ For example (my-net-app)
This will make your net app available at - {{ this.appurl }}/my-net-app. You should use only alphanumeric - characters, underscores (_) or dashes (-).
@@ -305,7 +306,7 @@
{{ errors.first('payAsGo.' +mainIndex +'.prices.' +index +'.cost') }}{{ + errors.first( + "payAsGo." + + mainIndex + + ".prices." + + index + + ".cost" + ) + }}
@@ -1070,7 +1090,6 @@
@@ -1090,10 +1109,11 @@ :netappId="this.netappId" :link="'/edit-netapp/' + this.netappId" > -

Your NetApp has been created!

-

- At this moment your NetApp is not visible to the Product Catalogue. You can change its status to Public in the Edit page -

+

Your NetApp has been created!

+

+ At this moment your NetApp is not visible to the Product + Catalogue. You can change its status to Public in the Edit page +

@@ -1115,6 +1135,8 @@ export default { categories: { type: Array, default: () => [] }, types: { type: Array, default: () => [] }, privacy_url: { type: String }, + business: { type: String, default: () => null }, + social: { type: String, default: () => null }, }, data() { return { @@ -1183,8 +1205,8 @@ export default { logo: null, version: null, publishedBy: null, - businessName: null, - socialNumber: null, + businessName: this.business, + socialNumber: this.social, }, deployment: { imageUrl: null, @@ -1209,9 +1231,9 @@ export default { getDashboardRoute() { return route("welcome-dashboard"); }, - getEditNetappRoute() { - return route("edit-netapp", this.netappId); - }, + getEditNetappRoute() { + return route("edit-netapp", this.netappId); + }, changeUploadStatus() { console.log("change upload status"); this.uploadLicenseFile = true; @@ -1407,7 +1429,7 @@ export default { from: price.fromInput, to: price.toInput, unlimited: false, - cost: price.costInput?? 0, + cost: price.costInput ?? 0, plan_category: price.categoryInput, }; }), diff --git a/resources/js/vue-components/common/ModalComponent.vue b/resources/js/vue-components/common/ModalComponent.vue index dc52da0..a028500 100644 --- a/resources/js/vue-components/common/ModalComponent.vue +++ b/resources/js/vue-components/common/ModalComponent.vue @@ -8,7 +8,7 @@ :class="classes" >