Skip to content

Commit

Permalink
Merge pull request #196 from COS301-SE-2024/development
Browse files Browse the repository at this point in the history
Final Demo 3 merge
  • Loading branch information
ChuufMaster authored Aug 12, 2024
2 parents a7b6d97 + 0f9e583 commit e606f63
Show file tree
Hide file tree
Showing 155 changed files with 15,213 additions and 3,129 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/deploy_dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# 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 ASP.Net Core app to Azure Web App - BeakPeekApi

env:
# DOTNET_ROOT: ./dotnet/BeakPeekApi/
DOTNET_ROOT: .
AZURE_SQL_CONNECTIONSTRING: ${{ secrets.AZURE_SQL_CONNECTIONSTRING }}
on:
push:
branches:
- main
- development
paths-ignore:
- 'doc/**'
- 'res/**'
- 'beakpeek/**'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.x'
include-prerelease: true

- name: Get App Setting
run: |
cd ./dotnet/BeakPeekApi
cp ../../appsettings.json .
- name: Build with dotnet
run: dotnet build --configuration Release ./dotnet/BeakPeekApi/BeakPeekApi.csproj

- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/BeakPeekApi ./dotnet/BeakPeekApi/BeakPeekApi.csproj

- name: Copy CSV files
run: |
mkdir -p ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species
cp -r ./res/species/* ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species/
mkdir -p ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species_list/
cp -r ./res/species_list/* ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species_list/
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/BeakPeekApi

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: .net-app

- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F91BBE34AB4B45898BF82BFADF359BE8 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_F1EE328E09964C2EA0E92A6629C60647 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_97F61458BB2B43A89AB06261472988FE }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'BeakPeekBirdApi'
slot-name: 'Production'
package: .

9 changes: 8 additions & 1 deletion .github/workflows/main_beakpeekapi.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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 ASP.Net Core app to Azure Web App - BeakPeekApi
name: Deploy Dotnet to Azure

env:
# DOTNET_ROOT: ./dotnet/BeakPeekApi/
Expand Down Expand Up @@ -30,6 +30,11 @@ jobs:
dotnet-version: '8.x'
include-prerelease: true

- name: Get App Setting
run: |
cd ./dotnet/BeakPeekApi
cp ../../appsettings.json .
- name: Build with dotnet
run: dotnet build --configuration Release ./dotnet/BeakPeekApi/BeakPeekApi.csproj

Expand All @@ -40,6 +45,8 @@ jobs:
run: |
mkdir -p ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species
cp -r ./res/species/* ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species/
mkdir -p ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species_list/
cp -r ./res/species_list/* ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species_list/
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
BeakPeek/lib/config_azure.dart
beakpeek/android/app/src/main/AndroidManifest.xml
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<img src="https://img.shields.io/github/issues/COS301-SE-2024/BeakPeek?style=for-the-badge" alt="Issues">
<img src="https://img.shields.io/github/issues-closed/COS301-SE-2024/BeakPeek?style=for-the-badge" alt="Issues">
</br>
<img src="https://img.shields.io/github/actions/workflow/status/COS301-SE-2024/BeakPeek/dotnet.yml?style=for-the-badge" alt=".NET Tests">
<img src="https://img.shields.io/github/actions/workflow/status/COS301-SE-2024/BeakPeek/flutter.yml?style=for-the-badge" alt="Flutter Tests">
<img src="https://img.shields.io/github/actions/workflow/status/COS301-SE-2024/BeakPeek/main_beakpeekapi.yml?style=for-the-badge" alt=".Net Deploy">
<img src="https://github.com/COS301-SE-2024/BeakPeek/actions/workflows/main_beakpeekapi.yml/badge.svg" alt="dotnet deploy">
<img src="https://github.com/COS301-SE-2024/BeakPeek/actions/workflows/flutter.yml/badge.svg" alt="dotnet deploy">
<img src="https://github.com/COS301-SE-2024/BeakPeek/actions/workflows/dotnet.yml/badge.svg" alt="dotnet deploy">

</p>

<h2>☁️About</h2>
Expand Down Expand Up @@ -54,8 +55,20 @@

[![Demo 2](https://img.youtube.com/vi/LUgWIDLSAU8/0.jpg)](https://youtu.be/LUgWIDLSAU8)

<h2 href="">System Requirement Specification</h1>
<h2 href="">System Requirement Specification</h2>
<a href="https://github.com/COS301-SE-2024/BeakPeek/wiki/SRS-v1" > SRSv1 </a>
<a href="https://github.com/COS301-SE-2024/BeakPeek/wiki/SRS-v2" > SRSv2 </a>
<a href="https://github.com/COS301-SE-2024/BeakPeek/wiki/SRS-v3" > SRSv3 </a>

<h2 href="">Code Quality</h2>
<a href="doc/Installation/Installation_Manual.pdf" > Code Quality </a>

<h2 href=""> Installation Manual </h2>

<a href="doc/Code_Qaulity/CodeQaulity.pdf" > Installation Manual </a>

<h2 href=""> SRS </h2>

<a href="doc/SRS_SoftwareRequirementSpecification/SRS v2.pdf" > SRSv2 pdf</a>
</div>

Expand Down
2 changes: 1 addition & 1 deletion dotnet/BeakPeekApi/appsettings.json → appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
}
9 changes: 8 additions & 1 deletion beakpeek/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,11 @@ app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
/android/app/release

# Azure Config file
/lib/config_azure.dart
/test/home_test.dart
/test/bird_sheet_test.dart
/test/Map/map_info_test.dart
/test/Map/map_test.dart
2 changes: 1 addition & 1 deletion beakpeek/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ android {
targetSdk = flutter.targetSdkVersion
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
manifestPlaceholders += [appAuthRedirectScheme: 'com.redirectScheme.comm']
multiDexEnabled true
}

buildTypes {
Expand Down
23 changes: 22 additions & 1 deletion beakpeek/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.beakpeek">

<application
android:label="beakpeek"
android:name="${applicationName}"
Expand Down Expand Up @@ -30,6 +33,22 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<intent-filter>
<action android:name="com.example.beakpeek.HANDLE_AUTHORIZATION_RESPONSE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

<activity
android:name="com.linusu.flutter_web_auth_2.CallbackActivity"
android:exported="true">
<intent-filter android:label="flutter_web_auth_2">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.example.beakpeek"/>
</intent-filter>
</activity>

<!-- Don't delete the meta-data below.
Expand All @@ -39,6 +58,8 @@
android:value="2" />
</application>



<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
13 changes: 13 additions & 0 deletions beakpeek/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
buildscript {
ext.kotlin_version = '1.7.10' // Update if necessary
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25"
// classpath 'dev.flutter:flutter-gradle-plugin:1.0.0' // Ensure this is the correct version
}
}

allprojects {
repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion beakpeek/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "org.jetbrains.kotlin.android" version "1.9.25" apply false
}

include ":app"
Binary file modified beakpeek/assets/icons/Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added beakpeek/assets/icons/Logo_no_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added beakpeek/assets/images/quiz_placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions beakpeek/devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:
50 changes: 50 additions & 0 deletions beakpeek/lib/Controller/Azure/login.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// ignore_for_file: use_build_context_synchronously

import 'package:flutter/material.dart';
import 'package:flutter_web_auth_2/flutter_web_auth_2.dart';
import 'package:go_router/go_router.dart';
import 'dart:convert' show jsonDecode;
import 'package:http/http.dart' as http;
import 'package:beakpeek/config_azure.dart' as config;

void loginFunction(BuildContext context) async {
final url = Uri.https(
'beakpeak.b2clogin.com',
'beakpeak.onmicrosoft.com/B2C_1_SignUpAndSignInUserFlow/oauth2/v2.0/authorize',
{
'response_type': 'code',
'client_id': config.clientID,
'redirect_uri': config.redirectURL,
'scope': config.scope,
},
);

final result = await FlutterWebAuth2.authenticate(
url: url.toString(), callbackUrlScheme: 'com.example.beakpeek');

final code = Uri.parse(result).queryParameters['code'];

final tokenUrl = Uri.https(config.initialUrl, config.tokenUrl);

final response = await http.post(
tokenUrl,
body: {
'client_id': config.clientID,
'scope': 'openid',
'redirect_uri': config.redirectURL,
'grant_type': 'authorization_code',
'code': code,
},
);

if (response.statusCode == 400) {
context.go('/');
return;
}

final accessToken = jsonDecode(response.body)['id_token'] as String;

config.accessToken = accessToken;
config.loggedIN = true;
context.go('/home');
}
Loading

0 comments on commit e606f63

Please sign in to comment.