diff --git a/.github/workflows/app-test.yml b/.github/workflows/app-test.yml
index cd55bb8e..ac764a59 100644
--- a/.github/workflows/app-test.yml
+++ b/.github/workflows/app-test.yml
@@ -4,6 +4,9 @@ on:
branches:
- main
- dev
+ push:
+ branches:
+ - dev
jobs:
test:
diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml
deleted file mode 100644
index 5fca6e2d..00000000
--- a/.github/workflows/firebase-hosting-pull-request.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-# This file was auto-generated by the Firebase CLI
-# https://github.com/firebase/firebase-tools
-
-name: Deploy to Firebase Hosting on PR
-'on': pull_request
-jobs:
- build_and_preview:
- if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
- runs-on: ubuntu-latest
- permissions:
- contents: read
- pull-requests: write
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-node@v3
- with:
- node-version: "18"
- - name: Install Dependencies
- working-directory: ./app/WhereIsThePower
- run: npm install --frozen-lock
- - name: Update env
- uses: cschleiden/replace-tokens@v1.2
- with:
- tokenPrefix: '{'
- tokenSuffix: '}'
- files: ./app/WhereIsThePower/src/environments/environment.prod.ts
- env:
- MapboxApiKey: ${{ secrets.TEST_SECRET }}
- - name: Build app
- working-directory: ./app/WhereIsThePower
- run: npm run build
- - uses: FirebaseExtended/action-hosting-deploy@v0
- with:
- working-directory: ./app/WhereIsThePower
- repoToken: '${{ secrets.GITHUB_TOKEN }}'
- firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WHEREISTHEPOWER_33A66 }}'
- projectId: whereisthepower-33a66
diff --git a/.github/workflows/firebase_dev.yml b/.github/workflows/firebase_dev.yml
new file mode 100644
index 00000000..76328a0f
--- /dev/null
+++ b/.github/workflows/firebase_dev.yml
@@ -0,0 +1,42 @@
+name: Build and Deploy app to DEV site
+'on':
+ push:
+ branches:
+ - dev
+
+jobs:
+ build_and_deploy:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: actions/setup-node@v3
+ with:
+ node-version: "18"
+
+ - name: Install Dependencies
+ working-directory: ./app/WhereIsThePower
+ run: npm install --frozen-lock
+
+ - name: Inject Developer tags
+ run: |
+ sed -i 's||DEVELOPER SITE|g' app/WhereIsThePower/src/app/app.component.html
+ sed -i 's|
Where Is The Power|WITP-DEV|g' app/WhereIsThePower/src/index.html
+ sed -i 's|href="assets/icon/favicon.ico"|href="assets/Ramp.svg"|g' app/WhereIsThePower/src/index.html
+
+ - name: update Prod ENV file
+ run: |
+ sed -i 's/HelloAPIKey/${{ secrets.MAPBOX_API_KEY }}/g' app/WhereIsThePower/src/environments/environment.prod.ts
+
+ - name: Build app
+ working-directory: ./app/WhereIsThePower
+ run: npm run build
+
+ - uses: FirebaseExtended/action-hosting-deploy@v0
+ with:
+ repoToken: '${{ secrets.GITHUB_TOKEN }}'
+ firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WHEREISTHEPOWER_33A66 }}'
+ channelId: live
+ projectId: whereisthepower-33a66
+ target: dev
+ entrypoint: ./app/WhereIsThePower
\ No newline at end of file
diff --git a/.github/workflows/firebase_prod.yml b/.github/workflows/firebase_prod.yml
new file mode 100644
index 00000000..e5f2af18
--- /dev/null
+++ b/.github/workflows/firebase_prod.yml
@@ -0,0 +1,39 @@
+name: Build and Deploy app to PROD site
+'on':
+ push:
+ branches:
+ - main
+
+jobs:
+ build_and_deploy:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: actions/setup-node@v3
+ with:
+ node-version: "18"
+
+ - name: Install Dependencies
+ working-directory: ./app/WhereIsThePower
+ run: npm install --frozen-lock
+
+ - name: Remove consolelogs from production site
+ run: echo "if(window) { window.console.log = function() {}; }" >> app/WhereIsThePower/src/main.ts
+
+ - name: update Prod ENV file
+ run: |
+ sed -i 's/HelloAPIKey/${{ secrets.MAPBOX_API_KEY }}/g' app/WhereIsThePower/src/environments/environment.prod.ts
+
+ - name: Build app
+ working-directory: ./app/WhereIsThePower
+ run: npm run build
+
+ - uses: FirebaseExtended/action-hosting-deploy@v0
+ with:
+ repoToken: '${{ secrets.GITHUB_TOKEN }}'
+ firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WHEREISTHEPOWER_33A66 }}'
+ channelId: live
+ projectId: whereisthepower-33a66
+ target: prod
+ entrypoint: ./app/WhereIsThePower
\ No newline at end of file
diff --git a/api/src/ai.rs b/api/src/ai.rs
index bfcf37e5..eaba8701 100644
--- a/api/src/ai.rs
+++ b/api/src/ai.rs
@@ -9,7 +9,7 @@ use utoipa::ToSchema;
#[utoipa::path(post, tag = "AI", path = "/api/ai/info", request_body = AiInfoRequest)]
#[post("/ai/info", format = "application/json", data = "")]
pub async fn get_ai_info<'a>(request: Json) -> ApiResponse<'a, AiInfoResponse> {
- let mapbox_api_key = if let Ok(key) = env::var("MAPBOX_API_KEY") {
+ let mapbox_api_key = if let Ok(key) = dbg!(env::var("MAPBOX_API_KEY")) {
key
} else {
log::error!("We couldn't get the mapbox api key. The environment variable was not set!");
@@ -21,11 +21,12 @@ pub async fn get_ai_info<'a>(request: Json) -> ApiResponse<'a, Ai
match Command::new("python3")
.args([
- "src/avoid_cords.py",
+ "route.py",
serde_json::to_string(&request.into_inner())
.unwrap()
.as_ref(),
])
+ .current_dir("src")
.stdout(Stdio::piped())
.env("MAPBOX_API_KEY", mapbox_api_key)
.output()
@@ -56,19 +57,21 @@ pub async fn get_ai_info<'a>(request: Json) -> ApiResponse<'a, Ai
#[derive(Clone, Deserialize, Serialize, ToSchema)]
#[schema(example = json! {
AiInfoRequest {
- polygon: vec![
- [0.0, 0.0],
- [90.0, -90.0],
- [-90.0, 90.0],
- ]
+ origin: Box::new([28.3, -27.73]),
+ destination: Box::new([28.2651, -25.7597])
}
})]
pub struct AiInfoRequest {
- pub polygon: Vec<[f64; 2]>,
+ pub origin: Box<[f64; 2]>,
+ pub destination: Box<[f64; 2]>,
}
#[derive(Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct AiInfoResponse {
- pub coords_to_avoid: Vec<[f64; 2]>,
+ pub duration: f32,
+ pub distance: f32,
+ pub traffic_lights_avoided: Vec<[f32; 2]>,
+ pub instructions: Vec,
+ pub coordinates: Vec<[f32; 2]>,
}
diff --git a/api/src/loadshedding.rs b/api/src/loadshedding.rs
index de111bf1..2f69b3c9 100644
--- a/api/src/loadshedding.rs
+++ b/api/src/loadshedding.rs
@@ -16,6 +16,7 @@ use rocket::{
fairing::{self, Fairing, Info, Kind},
futures::{future::try_join_all, TryStreamExt},
post,
+ get,
serde::json::Json,
Orbit, Rocket, State,
};
@@ -193,6 +194,22 @@ pub async fn fetch_time_for_polygon<'a>(
}
}
+#[utoipa::path(get, path = "/api/fetchCurrentStage")]
+#[get("/fetchCurrentStage")]
+pub async fn get_current_stage<'a>(
+ loadshedding_stage: &State