Compare commits

..

10 Commits

14 changed files with 176 additions and 50 deletions

2
.env.development Normal file
View File

@ -0,0 +1,2 @@
ENV_NAME=development
BASE_URL=https://syncrow-dev.azurewebsites.net

2
.env.production Normal file
View File

@ -0,0 +1,2 @@
ENV_NAME=production
BASE_URL=https://syncrow-staging.azurewebsites.net

2
.env.staging Normal file
View File

@ -0,0 +1,2 @@
ENV_NAME=staging
BASE_URL=https://syncrow-staging.azurewebsites.net

View File

@ -0,0 +1,60 @@
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.2' # Specify the Flutter version you want to use
- name: Install dependencies
run: flutter pub get
- name: Build Flutter Web App
run: flutter build web
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_MUSHROOM_0D31A3303 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/build/web" # App source code path
api_location: "" # Api source code path - optional
output_location: "/build/web" # Built app content directory - optional
###### End of Repository/Build Configurations ######
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_MUSHROOM_0D31A3303 }}
action: "close"

61
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,61 @@
{
"configurations": [
{
"name": "DEVELOPMENT",
"request": "launch",
"type": "dart",
"args": [
"--dart-define",
"FLAVOR=development"
],
"flutterMode": "debug"
},{
"name": "STAGING",
"request": "launch",
"type": "dart",
"args": [
"--dart-define",
"FLAVOR=staging"
],
"flutterMode": "debug"
},{
"name": "PRODUCTION",
"request": "launch",
"type": "dart",
"args": [
"--dart-define",
"FLAVOR=production"
],
"flutterMode": "debug"
},
]
}

View File

@ -1,6 +1,7 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart';
@ -11,8 +12,12 @@ import 'package:syncrow_web/utils/constants/routes_const.dart';
import 'package:syncrow_web/utils/theme/theme.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
initialSetup();
try {
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
await dotenv.load(fileName: '.env.$environment');
WidgetsFlutterBinding.ensureInitialized();
initialSetup();
} catch (_) {}
runApp(MyApp());
}

View File

@ -58,7 +58,7 @@ class ReportsTable extends StatelessWidget {
TableCellWidget(value: date),
TableCellWidget(value: time),
TableCellWidget(
value: '${data.value!} $thirdColumnDescription',
value: '${data.value!} ${thirdColumnDescription ?? ''}',
onTap: () => onRowTap(index),
),
],

View File

@ -99,7 +99,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
try {
await DevicesManagementApi.getDeviceReports(deviceId, event.code)
.then((value) {
emit(DeviceReportsState(deviceReport: value));
emit(DeviceReportsState(deviceReport: value, code:event.code));
});
} catch (e) {
emit(DeviceReportsFailedState(error: e.toString()));

View File

@ -42,7 +42,8 @@ class DeviceReportsLoadingState extends WallSensorState {}
class DeviceReportsState extends WallSensorState {
final DeviceReport deviceReport;
const DeviceReportsState({required this.deviceReport});
final String code;
const DeviceReportsState({required this.deviceReport, required this.code});
}
class DeviceReportsFailedState extends WallSensorState {

View File

@ -38,8 +38,10 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
} else if (state is DeviceReportsState) {
return ReportsTable(
report: state.deviceReport,
thirdColumnTitle: "Value",
thirdColumnDescription: "Lux",
thirdColumnTitle:
state.code == 'illuminance_value' ? "Value" : 'Status',
thirdColumnDescription:
state.code == 'illuminance_value' ? "Lux" : null,
onRowTap: (index) {},
onClose: () {
context.read<WallSensorBloc>().add(BackToGridViewEvent());

View File

@ -1,16 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class SpaseManagementicon extends StatelessWidget {
const SpaseManagementicon({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(),
);
}
}

View File

@ -1,41 +1,35 @@
abstract class ApiEndpoints {
static const String baseUrl = 'https://syncrow-dev.azurewebsites.net';
// static const String baseUrl = 'http://100.107.182.63:4001'; //Localhost
//https://syncrow-staging.azurewebsites.net
////////////////////////////////////// Authentication ///////////////////////////////
static const String signUp = '$baseUrl/authentication/user/signup';
static const String login = '$baseUrl/authentication/user/login';
static const String forgetPassword =
'$baseUrl/authentication/user/forget-password';
static const String sendOtp = '$baseUrl/authentication/user/send-otp';
static const String verifyOtp = '$baseUrl/authentication/user/verify-otp';
static const String getRegion = '$baseUrl/region';
static const String visitorPassword = '$baseUrl/visitor-password';
static const String getDevices = '$baseUrl/visitor-password/devices';
import 'package:flutter_dotenv/flutter_dotenv.dart';
static const String sendOnlineOneTime =
'$baseUrl/visitor-password/temporary-password/online/one-time';
abstract class ApiEndpoints {
static String baseUrl = dotenv.env['BASE_URL'] ?? '';
static const String signUp = '/authentication/user/signup';
static const String login = '/authentication/user/login';
static const String forgetPassword = '/authentication/user/forget-password';
static const String sendOtp = '/authentication/user/send-otp';
static const String verifyOtp = '/authentication/user/verify-otp';
static const String getRegion = '/region';
static const String visitorPassword = '/visitor-password';
static const String getDevices = '/visitor-password/devices';
static const String sendOnlineOneTime = '/visitor-password/temporary-password/online/one-time';
static const String sendOnlineMultipleTime =
'$baseUrl/visitor-password/temporary-password/online/multiple-time';
'/visitor-password/temporary-password/online/multiple-time';
//offline Password
static const String sendOffLineOneTime =
'$baseUrl/visitor-password/temporary-password/offline/one-time';
static const String sendOffLineOneTime = '/visitor-password/temporary-password/offline/one-time';
static const String sendOffLineMultipleTime =
'$baseUrl/visitor-password/temporary-password/offline/multiple-time';
'/visitor-password/temporary-password/offline/multiple-time';
static const String getUser = '$baseUrl/user/{userUuid}';
static const String getUser = '/user/{userUuid}';
////// Devices Management ////////////////
static const String getAllDevices = '$baseUrl/device';
static const String getDeviceStatus =
'$baseUrl/device/{uuid}/functions/status';
static const String getAllDevices = '/device';
static const String getDeviceStatus = '/device/{uuid}/functions/status';
static const String deviceControl = '$baseUrl/device/{uuid}/control';
static const String deviceControl = '/device/{uuid}/control';
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
static const String getDeviceLogs =
'$baseUrl/device/report-logs/{uuid}?code={code}';
static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
}

View File

@ -150,6 +150,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "8.1.5"
flutter_dotenv:
dependency: "direct main"
description:
name: flutter_dotenv
sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77"
url: "https://pub.dev"
source: hosted
version: "5.1.0"
flutter_lints:
dependency: "direct dev"
description:

View File

@ -48,6 +48,8 @@ dependencies:
go_router:
intl: ^0.19.0
dropdown_search: ^5.0.6
flutter_dotenv: ^5.1.0
dev_dependencies:
flutter_test:
@ -77,6 +79,9 @@ flutter:
- assets/icons/
- assets/images/
- assets/
- .env.development
- .env.staging
- .env.production
# An image asset can refer to one or more resolution-specific "variants", see