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

Update Documentation #486

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

Conversation

93Kamuran
Copy link
Contributor

Pull Request checklist

Please confirm you have completed any of the necessary steps below.

  • Meaningful Pull Request title and description
  • Changes tested as described above
  • Added appropriate documentation for the change.
  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

@93Kamuran 93Kamuran requested a review from dmohns February 18, 2025 14:08
@dmohns
Copy link
Member

dmohns commented Feb 19, 2025

Hey @93Kamuran

I see you are essentially deleting all the documentation for Environment variables. But I don't understand why 🙈

It looks to me like these are used. And, not only that they are crucial to configuring MPM.

Let's use MAIL_ as an example... As a administrator of an MPM instance, how should I configure the email sending for my instance when not using the corresponding environment variables?

Instead of deleting these could you please instead update the documentation to actually reflect what these environment variables do?

For example SUNKING_API_URL... This ENV is the default URL that get's used when the SUNKING plugin get's enabled. It doesn't look like the user can customise this in the plugin view.

@93Kamuran
Copy link
Contributor Author

Hey @93Kamuran

I see you are essentially deleting all the documentation for Environment variables. But I don't understand why 🙈

It looks to me like these are used. And, not only that they are crucial to configuring MPM.

Let's use MAIL_ as an example... As a administrator of an MPM instance, how should I configure the email sending for my instance when not using the corresponding environment variables?

Instead of deleting these could you please instead update the documentation to actually reflect what these environment variables do?

For example SUNKING_API_URL... This ENV is the default URL that get's used when the SUNKING plugin get's enabled. It doesn't look like the user can customise this in the plugin view.

We have "mail_settings" table in tenant databases. The missing part is; We need to add one more settings tab for email settings on settings page. (We can not send all emails in the system for all tenants from one email address right?)

If you check the other areas I removed essipecially related plugins like "api url", we have default value on plugin table migrations.

@dmohns
Copy link
Member

dmohns commented Feb 19, 2025

If you check the other areas I removed essipecially related plugins like "api url", we have default value on plugin table migrations.

Yeah, but the default value is taken from ENV. For example SUNKING: https://github.com/EnAccess/micropowermanager/blob/main/src/backend/database/migrations/micropowermanager/2022_14_12_create_sun_king_tables.php#L13

If the ENV is empty, the table will also be empty. Or am I missing something?

@dmohns
Copy link
Member

dmohns commented Feb 19, 2025

We have "mail_settings" table in tenant databases. The missing part is; We need to add one more settings tab for email settings on settings page. (We can not send all emails in the system for all tenants from one email address right?)

Mail is a bit more complicated I think. There should be two mail settings.

First one is for instance level email to clients/tenants. I.e. if users sign up so they get Welcome email. This looks like it's actually hardcoded in the code: https://github.com/EnAccess/micropowermanager/blob/main/src/backend/app/Helpers/MailHelper.php#L19

Second one, is client emails to customers. I'm not even so sure this is a relevant use-case? I was thinking the client<>customer communication is done via SMS exclusively?

@93Kamuran
Copy link
Contributor Author

If you check the other areas I removed essipecially related plugins like "api url", we have default value on plugin table migrations.

Yeah, but the default value is taken from ENV. For example SUNKING: https://github.com/EnAccess/micropowermanager/blob/main/src/backend/database/migrations/micropowermanager/2022_14_12_create_sun_king_tables.php#L13

If the ENV is empty, the table will also be empty. Or am I missing something?

solved that with an update.

@dmohns
Copy link
Member

dmohns commented Feb 19, 2025

solved that with an update.

Unfortunately, it doesn't work like this 🙈

Few things:

  • Changing "past" migrations is extremely dangerous it can lead to highly inconsistent situations. We should only do this in exceptional cases.
  • In this specific case: When you remove the default value being read from ENV there is no way to use the production URL anymore. If I deploy the prod version, how would I customise it to point to SunKing live env?

Also, the scope of this PR is documentation only. In here, let's try to only document the status-quo. If you want to improve the way these are handled, please send a separate PR for that.

@93Kamuran
Copy link
Contributor Author

solved that with an update.

Unfortunately, it doesn't work like this 🙈

Few things:

  • Changing "past" migrations is extremely dangerous it can lead to highly inconsistent situations. We should only do this in exceptional cases.
  • In this specific case: When you remove the default value being read from ENV there is no way to use the production URL anymore. If I deploy the prod version, how would I customise it to point to SunKing live env?

Also, the scope of this PR is documentation only. In here, let's try to only document the status-quo. If you want to improve the way these are handled, please send a separate PR for that.

Changing "past" migrations is extremely dangerous it can lead to highly inconsistent situations. We should only do this in exceptional cases.

 - Thank you for telling this to me :) If I'm not wrong there is no deployed version of the project still. Anyway  we can create an update migration or revert SunKing url in environment_variables.md file. Just tell me your preference please.

Also, the scope of this PR is documentation only. In here, let's try to only document the status-quo. If you want to improve the way these are handled, please send a separate PR for that.

-  So if you choose first option please create a task for this and let me create an update migration.     

@93Kamuran
Copy link
Contributor Author

We have "mail_settings" table in tenant databases. The missing part is; We need to add one more settings tab for email settings on settings page. (We can not send all emails in the system for all tenants from one email address right?)

Mail is a bit more complicated I think. There should be two mail settings.

First one is for instance level email to clients/tenants. I.e. if users sign up so they get Welcome email. This looks like it's actually hardcoded in the code: https://github.com/EnAccess/micropowermanager/blob/main/src/backend/app/Helpers/MailHelper.php#L19

Second one, is client emails to customers. I'm not even so sure this is a relevant use-case? I was thinking the client<>customer communication is done via SMS exclusively?

DESCRIBE mail_settings;

id
mail_host
mail_port
mail_encryption
mail_username
mail_password
created_at
updated_at

Each tenant should specify its on mail settings, for an email which is gonna sent by MPM behalf tenant. MPM needs a email settings page/section also email sending functions should be updated accordingly.

@dmohns
Copy link
Member

dmohns commented Feb 19, 2025

We have "mail_settings" table in tenant databases. The missing part is; We need to add one more settings tab for email settings on settings page. (We can not send all emails in the system for all tenants from one email address right?)

Mail is a bit more complicated I think. There should be two mail settings.
First one is for instance level email to clients/tenants. I.e. if users sign up so they get Welcome email. This looks like it's actually hardcoded in the code: https://github.com/EnAccess/micropowermanager/blob/main/src/backend/app/Helpers/MailHelper.php#L19
Second one, is client emails to customers. I'm not even so sure this is a relevant use-case? I was thinking the client<>customer communication is done via SMS exclusively?

DESCRIBE mail_settings;

id mail_host mail_port mail_encryption mail_username mail_password created_at updated_at

Each tenant should specify its on mail settings, for an email which is gonna sent by MPM behalf tenant. MPM needs a email settings page/section also email sending functions should be updated accordingly.

My question is: Form the code it looks like the mail_settings is not used, but the config object is (and config object will be controlled via env variables. Can you point me to the place where the values from the table are used?

@93Kamuran
Copy link
Contributor Author

My question is: Form the code it looks like the mail_settings is not used, but the config object is (and config object will be controlled via env variables. Can you point me to the place where the values from the table are used?

Yes, you're right! I re-checked the source code and noticed that we use mailing only for sending emails to tenant admins. and that functions use configs from config/mail.php.

"mail_settings" may stay for tenant databases. We may consider using it in mailing operations between tenant & end customers in future.

So I'm gonna revert my changes related mail envs.

Comment on lines -149 to -154
| Environment Variable | Default | Description |
| -------------------- | ---------------------------------- | ------------------------------------------- |
| `AIRTEL_REQUEST_URL` | **Required** (when plugin is used) | The Airtel service URL. |
| `AIRTEL_USERNAME` | **Required** (when plugin is used) | The Airtel username. |
| `AIRTEL_PASSWORD` | **Required** (when plugin is used) | The Airtel password. |
| `AIRTEL_IPS` | `[]` | List of IP whitelisted for Airtel services. |
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AirtelTransactionProvider should be removed. We need to develop a plugin for Airtel If we're planning that in future.

Comment on lines -160 to -164
| Environment Variable | Default | Description |
| -------------------- | ---------------------------------- | -------------------------------------------------------- |
| `CALIN_CLIENT_URL` | **Required** (when plugin is used) | Calin Meter client URL used for generating STS tokens. |
| `CALIN_USER_ID` | **Required** (when plugin is used) | Calin Meter API username used for generating STS tokens. |
| `CALIN_KEY` | **Required** (when plugin is used) | Calin Meter API key used for generating STS tokens. |
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CalinReadMeter.php is not using. We have plugins for Calin & Calin Smart meters. The code sample you shared me is legacy code from very old versions of MPM. So that can be removed.

Comment on lines -169 to -173
| Environment Variable | Default | Description |
| -------------------- | ---------------------------------- | ---------------------------------------------------------- |
| `METER_DATA_URL` | **Required** (when plugin is used) | Calin Meter API URL used for consumption data upload. |
| `METER_DATA_KEY` | **Required** (when plugin is used) | Calin Meter API key used for consumption data upload. |
| `METER_DATA_USER` | **Required** (when plugin is used) | Calin Meter API username used for consumption data upload. |
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CalinReadMeter.php is not using. We have plugins for Calin & Calin Smart meters. The code sample you shared me is legacy code from very old versions of MPM. So that can be removed.

Comment on lines -175 to -186
#### Calin Smart Meters

For detailed information see [Calin Smart Meter Developer Documentation](https://www.szcalinmeter.com/).

| Environment Variable | Default | Description |
| ------------------------------ | ---------------------------------- | ------------------------------------------------------------------------- |
| `CALIN_SMART_COMPANY_NAME` | **Required** (when plugin is used) | Calin Smart Meter company name used for communication with Calin API. |
| `CALIN_SMART_PURCHASE_API_URL` | **Required** (when plugin is used) | Calin Smart Meter Purchase API URL used for communication with Calin API. |
| `CALIN_SMART_CLEAR_API_URL` | **Required** (when plugin is used) | Calin Smart Meter Clear API URL used for communication with Calin API. |
| `CALIN_SMART_USER_NAME` | **Required** (when plugin is used) | Calin Smart Meter username used for communication with Calin API. |
| `CALIN_SMART_PASSWORD` | **Required** (when plugin is used) | Calin Smart Meter password used for communication with Calin API. |
| `CALIN_SMART_PASSWORD_VENT` | **Required** (when plugin is used) | Calin Smart Meter password vent used for communication with Calin API. |
Copy link
Member

Choose a reason for hiding this comment

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

Please also remove the corresponding section in services.php. https://github.com/EnAccess/micropowermanager/blob/main/src/backend/config/services.php#L55-L64

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CalinReadMeter.php is not using. We have plugins for Calin & Calin Smart meters. The code sample you shared me is legacy code from very old versions of MPM. So that can be removed.

Comment on lines -193 to -202
| Environment Variable | Default | Description |
| ------------------------------- | ---------------------------------- | --------------------------- |
| `VODACOM_SPID` | **Required** (when plugin is used) | Vodacom SPID. |
| `VODACOM_SPPASSWORD` | **Required** (when plugin is used) | Vodacom SPPASSWORD. |
| `VODACOM_IPS` | **Required** (when plugin is used) | Vodacom IPs. |
| `VODACOM_REQUEST_URL` | **Required** (when plugin is used) | Vodacom Request API URL. |
| `VODACOM_BROKER_CRT` | **Required** (when plugin is used) | Path to broker `.crt` file. |
| `VODACOM_SLL_KEY` | **Required** (when plugin is used) | Path to `.key` file. |
| `VODACOM_CERTIFICATE_AUTHORITY` | **Required** (when plugin is used) | Path to `.cer` file. |
| `VODACOM_SSL_CERT` | **Required** (when plugin is used) | Path to `.pem` file. |
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

VodacomTransactionProvider should be removed. We need to develop a plugin for Airtel If we're planning that in future.

Comment on lines -208 to -211
| Environment Variable | Default | Description |
| -------------------- | ---------------------------------- | -------------------------------------------------------------------------------- |
| `SUNKING_API_URL` | **Required** (when plugin is used) | SunKing API URL. For example `https://dev.assetcontrol.central.glp apps.com/v2`. |

Copy link
Member

Choose a reason for hiding this comment

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

This has to stay for now, see below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -10,7 +10,7 @@ public function up() {
Schema::connection('tenant')->create('sun_king_api_credentials', static function (Blueprint $table) {
$table->increments('id');
$table->string('auth_url')->default('https://auth.central.glpapps.com/auth/realms/glp-dev/protocol/openid-connect/token');
$table->string('api_url')->default(config('services.sunKing.url'));
$table->string('api_url')->default('https://assetcontrol.central.glpapps.com/v2');
Copy link
Member

Choose a reason for hiding this comment

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

We can only do this, once we have a section in the WebUI for Tenants to set their SunKing URL. Please remove it for now.

Copy link
Contributor Author

@93Kamuran 93Kamuran Mar 3, 2025

Choose a reason for hiding this comment

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

This is fixed value, So we need to set it into "sun_king_api_credentials" table with default value once "install plugin" command runs. We do not need to show this information on UI side.

Copy link
Member

Choose a reason for hiding this comment

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

How would I (as a platform admin) then change my development environment to use the SunKing sandbox?

@dmohns
Copy link
Member

dmohns commented Mar 3, 2025

Hey @93Kamuran

thanks for your responses. So, my point is: I don't want to remove these from the docs, as long as they are "used" (or mentioned, really) in the code. If I understand your comments correctly none of the code blocks where these appear is actually getting executed? Could you instead then simply remove the code (and the corresponding section of the docs)?

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.

2 participants