diff --git a/.github/workflows/main_blazor-appl.yml b/.github/workflows/main_blazor-appl.yml new file mode 100644 index 00000000..ddae11e1 --- /dev/null +++ b/.github/workflows/main_blazor-appl.yml @@ -0,0 +1,66 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Blazor-appl - Build and deploy + +on: + push: + branches: + - main + paths: + - "src/apps/blazor-app/**" + - ".github/workflows/main_blazor-appl.yml" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: src/apps/blazor-app + + steps: + - uses: actions/checkout@v2 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "7.0.x" + include-prerelease: true + + - name: Build with dotnet + run: | + yarn + dotnet build -c Release + + - name: dotnet publish + run: dotnet publish -c Release -o ./publish + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: .net-app + path: src/apps/blazor-app/publish + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: "Production" + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: .net-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: "blazor-appl" + slot-name: "Production" + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_7CF290DC47994C3BA43A303FCF5A89CA }} + package: . diff --git a/.github/workflows/main_dot-net-api.yml b/.github/workflows/main_dot-net-api.yml new file mode 100644 index 00000000..21161fa1 --- /dev/null +++ b/.github/workflows/main_dot-net-api.yml @@ -0,0 +1,64 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy - dot-net-api + +on: + push: + branches: + - "main" + paths: + - "src/apps/api/**" + - ".github/workflows/main_dot-net-api.yml" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: src/apps/api + + steps: + - uses: actions/checkout@v2 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "7.0.x" + include-prerelease: true + + - name: Build with dotnet + run: dotnet build -c Release + + - name: dotnet publish + run: dotnet publish -c Release -o ./publish + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: .net-app + path: src/apps/api/publish + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: "Production" + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: .net-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: "dot-net-api" + slot-name: "Production" + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_D7DCB7DDE31F4AA9879DA722FF5637EE }} + package: . diff --git a/.github/workflows/main_express-microservice.yml b/.github/workflows/main_express-microservice.yml new file mode 100644 index 00000000..d0cdcc6e --- /dev/null +++ b/.github/workflows/main_express-microservice.yml @@ -0,0 +1,78 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Express - Build and Deploy + +on: + push: + branches: + - main + paths: + - "src/apps/services/**" + - ".github/workflows/main_express-microservice.yml" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: src + + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js version + uses: actions/setup-node@v1 + with: + node-version: "18.x" + + - name: yarn install and build + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + cache-dependency-path: | + src/yarn.lock + src/package-lock.json + - run: | + yarn + yarn nx run services:build --configuration=production + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: node-app + path: | + src/dist/apps/services + src/package.json + src/.puppeteerrc.cjs + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: "Production" + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: node-app + + - run: mv dist/apps/services/* . + + - run: yarn add puppeteer + + - run: yarn --production + + - name: "Deploy to Azure Web App" + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: "express-microservice" + slot-name: "Production" + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_B5AD89411527464CA08BE8E4F87274B2 }} + package: . diff --git a/.github/workflows/main_libs.yml b/.github/workflows/main_libs.yml new file mode 100644 index 00000000..e5646c69 --- /dev/null +++ b/.github/workflows/main_libs.yml @@ -0,0 +1,64 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy - libs + +on: + push: + branches: + - "main" + paths: + - "src/libs/**" + - ".github/workflows/main_libs.yml" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: src/libs/shared-utils + + steps: + - uses: actions/checkout@v2 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "7.0.x" + include-prerelease: true + + - name: Build with dotnet + run: dotnet build -c Release + + - name: dotnet publish + run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: .net-app + path: ${{env.DOTNET_ROOT}}/myapp + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: "Production" + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: .net-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: "libs" + slot-name: "Production" + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_927C1878D22148E4A15E97F5A738E248 }} + package: . diff --git a/src/.gitignore b/src/.gitignore index 52d93566..3d9edbee 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -42,4 +42,5 @@ Thumbs.db .env .env.* -apps/machine-learning/* \ No newline at end of file +apps/machine-learning/* +/.cache \ No newline at end of file diff --git a/src/.puppeteerrc.cjs b/src/.puppeteerrc.cjs new file mode 100644 index 00000000..a7021076 --- /dev/null +++ b/src/.puppeteerrc.cjs @@ -0,0 +1,9 @@ +const {join} = require('path'); + +/** + * @type {import("puppeteer").Configuration} + */ +module.exports = { + // Changes the cache location for Puppeteer. + cacheDirectory: join(__dirname, '.cache', 'puppeteer'), +}; \ No newline at end of file diff --git a/src/apps/blazor-app/Components/Dashboard/LocationItem.razor b/src/apps/blazor-app/Components/Dashboard/LocationItem.razor index 197bfff7..49828fe4 100644 --- a/src/apps/blazor-app/Components/Dashboard/LocationItem.razor +++ b/src/apps/blazor-app/Components/Dashboard/LocationItem.razor @@ -10,7 +10,7 @@

@Title

-

@Text

+

@Text

diff --git a/src/apps/blazor-app/Components/SolarScore/Results.razor b/src/apps/blazor-app/Components/SolarScore/Results.razor index f78f1fef..55caebcf 100644 --- a/src/apps/blazor-app/Components/SolarScore/Results.razor +++ b/src/apps/blazor-app/Components/SolarScore/Results.razor @@ -55,8 +55,10 @@ @* Solar Score and Potential Savings *@
- Rob - + Rob + @if (solarScore == -1) { @@ -103,9 +105,9 @@

R

- @{ - var savings = Math.Round(avgEnergyProduction * 2.5 * 30, 0); - } + @{ + var savings = Math.Round(avgEnergyProduction * 2.5 * 30, 0); + }

@savings

p/m

@@ -117,7 +119,8 @@ Rob T Posing @* Potential System *@ - + @if (locationData == null) { @@ -198,7 +201,7 @@

@tooltipService.GetTooltip("number of panels")

+ count="@tempNumOfPanels" />
@@ -209,19 +212,22 @@

@tooltipService.GetTooltip("battery utilisation")

-
- @{ - var percentage = chargingLimitPercentage + "%"; - } +
+ @{ + var percentage = chargingLimitPercentage + "%"; + }
-
+

@chargingLimitPercentage

-

%

+

+ %

@@ -235,7 +241,7 @@

@tooltipService.GetTooltip("number of batteries")

+ count="@tempNumOfBatteries" />
-

You can add or remove appliances to get more accurate power usages for your location on our calculations page.

+

You can add or remove appliances to get more accurate power usages for your location on our + calculations page.

Go to calculations page now?

@@ -294,7 +301,9 @@ public double avgEnergyProduction = 0.0; public string? satteliteImage; public int numOfPanels = 8; + public int tempNumOfPanels = 8; public int numOfBatteries = 3; + public int tempNumOfBatteries = 3; public double appliancePowerUsage = 0.0; public int numFridges = 2; public int numStove = 2; @@ -315,16 +324,20 @@ panelTimer.AutoReset = false; panelTimer.Enabled = true; - batteryTimer = new Timer(200); + batteryTimer = new Timer(100); batteryTimer.Elapsed += SetRunningHours; batteryTimer.AutoReset = false; batteryTimer.Enabled = true; } - private async Task GetSatteliteImage() { - if(locationData != null && locationData.satteliteImageData == null) { - locationData = await locationDataClass.GetSatelliteImageData(locationData.latitude, locationData.longitude, locationData); - if(locationData != null && locationData.satteliteImageData != null) { + private async Task GetSatteliteImage() + { + if (locationData != null && locationData.satteliteImageData == null) + { + locationData = await locationDataClass.GetSatelliteImageData(locationData.latitude, locationData.longitude, + locationData); + if (locationData != null && locationData.satteliteImageData != null) + { Console.WriteLine("Getting sattelite image"); satteliteImage = rooftopDataHandler.GetSatelliteImage(locationData.satteliteImageData); StateHasChanged(); @@ -346,14 +359,14 @@ private void ResetPanelTimer(ChangeEventArgs e) { - numOfPanels = int.Parse(e.Value!.ToString()!); + tempNumOfPanels = Convert.ToInt32(e.Value); panelTimer.Stop(); panelTimer.Start(); } private void ResetBatteryTimer(ChangeEventArgs e) { - numOfBatteries = int.Parse(e.Value!.ToString()!); + tempNumOfBatteries = Convert.ToInt32(e.Value); batteryTimer.Stop(); batteryTimer.Start(); } @@ -369,6 +382,7 @@ private async void SetRunningHours(Object? source, ElapsedEventArgs e) { + numOfBatteries = tempNumOfBatteries; if (locationData != null) { SetGraphicValues(); diff --git a/src/apps/blazor-app/Pages/Report.razor b/src/apps/blazor-app/Pages/Report.razor index 58057ba9..0971f5dc 100644 --- a/src/apps/blazor-app/Pages/Report.razor +++ b/src/apps/blazor-app/Pages/Report.razor @@ -208,7 +208,8 @@ private DataHandlers.SolarDataHandler solarDataHandler = new DataHandlers.SolarDataHandler(); private DataHandlers.SystemsDataHandler systemsDataHandler = new DataHandlers.SystemsDataHandler(); private SharedUtils.reportClass reportClass = new SharedUtils.reportClass(); - private SharedUtils.reportAllApplianceClass reportAllApplianceClass = new SharedUtils.reportAllApplianceClass(); + private SharedUtils.reportAllApplianceClass reportAllApplianceClass = new + SharedUtils.reportAllApplianceClass(); private SharedUtils.locationDataClass locationDataClass = new SharedUtils.locationDataClass(); private SharedUtils.systemClass systemClass = new SharedUtils.systemClass(); @@ -256,7 +257,6 @@ { system = result; } - resultLocationData = await locationDataClass.GetLocationData(latitude, longitude); if (resultLocationData != null) { @@ -272,6 +272,7 @@ usableHours = Math.Round(solarCalculator.getSunlightHours(resultLocationData!.solarPanelsData, true), 2); annualKWGenerated = solarDataHandler.getAnnualKwGenerated(system.numberOfPanels, resultLocationData.solarPanelsData); wholeroofstats = resultLocationData.solarPanelsData!.solarPotential!.wholeRoofStats; + } reportAllAppliance = await reportAllApplianceClass.GetReportAllApplianceByReportId(int.Parse(ReportId!)); runningHoursPercentage = systemsDataHandler.CalculateRunningHours(system.numberOfBatteries, system.batterySize * 1000, @@ -310,7 +311,6 @@ homeSize = report.homeSize + "-Home3.svg"; } isLoaded = true; - StateHasChanged(); } else diff --git a/src/apps/blazor-app/glibc-2.29.tar.gz b/src/apps/blazor-app/glibc-2.29.tar.gz new file mode 100644 index 00000000..63332788 Binary files /dev/null and b/src/apps/blazor-app/glibc-2.29.tar.gz differ diff --git a/src/apps/blazor-app/wwwroot/assets/LED Lights.svg b/src/apps/blazor-app/wwwroot/assets/LED Lights.svg new file mode 100644 index 00000000..2d2a095f --- /dev/null +++ b/src/apps/blazor-app/wwwroot/assets/LED Lights.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/apps/services/src/controllers/report/report.controller.ts b/src/apps/services/src/controllers/report/report.controller.ts index d28b94b1..71d660dc 100644 --- a/src/apps/services/src/controllers/report/report.controller.ts +++ b/src/apps/services/src/controllers/report/report.controller.ts @@ -265,11 +265,12 @@ export default class ReportController { try { const { userId, reportId } = req.params; console.log( - 'Generating report, report id: ' + reportId + ' for user: ' + userId + 'Generating report, report id: ' + reportId + ' For user: ' + userId ); // Launch the browser and open a new blank page const browser = await puppeteer.launch({ headless: true, + args: [ '--disable-gpu', '--disable-setuid-sandbox', '--no-sandbox', '--no-zygote' ] }); const page = await browser.newPage(); const frontend_port = process.env.FRONTEND_PORT; diff --git a/src/scripts/requirements.txt b/src/scripts/requirements.txt new file mode 100644 index 00000000..5844e8fd --- /dev/null +++ b/src/scripts/requirements.txt @@ -0,0 +1,5 @@ +requests==2.31.0 +python-dotenv +google-auth +earthengine-api +ee \ No newline at end of file