Skip to content

Commit

Permalink
Merge branch 'NetManagerMapFunc' of github.com:AKATWIJUKA-ELIA/AirQo-…
Browse files Browse the repository at this point in the history
…frontend into NetManagerMapFunc
  • Loading branch information
AKATWIJUKA-ELIA committed Feb 24, 2025
2 parents 16e067a + d489ec9 commit 8af9540
Show file tree
Hide file tree
Showing 44 changed files with 5,560 additions and 1,031 deletions.
35 changes: 30 additions & 5 deletions .github/workflows/deploy-frontends-to-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,36 @@ jobs:
- name: Delete Old Versions
run: |-
service="default"
versions=$(gcloud app versions list --service=$service --sort-by '~LAST_DEPLOYED' --format 'value(VERSION.ID)' | grep -v 'maintenance' | sort -r | tail -n +4)
for version in $versions; do
echo "Deleting version: $version for service: $service"
gcloud app versions delete "$version" --service=$service --quiet
done
versions=$(gcloud app versions list --service=$service --sort-by '~LAST_DEPLOYED' --format 'value(VERSION.ID)' | grep -v 'maintenance' | sort -r | tail -n +4)
for version in $versions; do
echo "Attempting to delete version: $version for service: $service"
attempt=1
max_attempts=3
while [ $attempt -le $max_attempts ]; do
# Check for ongoing operations
if gcloud app operations list --format="value(name)" --filter="status=RUNNING" | grep -q .; then
echo "Another operation is still running. Waiting 30 seconds... (Attempt $attempt/$max_attempts)"
sleep 30
((attempt++))
else
if gcloud app versions delete "$version" --service=$service --quiet; then
echo "Successfully deleted version: $version"
break
else
echo "Failed to delete version: $version. Retrying... ($attempt/$max_attempts)"
sleep 10
((attempt++))
fi
fi
done
if [ $attempt -gt $max_attempts ]; then
echo "Skipping version: $version after $max_attempts failed attempts."
fi
done
### build and push calibrate app image ###
calibrate-app:
Expand Down
98 changes: 82 additions & 16 deletions mobile-v3/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,62 @@ class AirqoMobile extends StatelessWidget {
}
}

// class Decider extends StatefulWidget {
// @override
// _DeciderState createState() => _DeciderState();
// }

// class _DeciderState extends State<Decider> {
// @override
// Widget build(BuildContext context) {
// return BlocBuilder<ConnectivityBloc, ConnectivityState>(
// builder: (context, connectivityState) {
// logDebug('Current connectivity state: $connectivityState');
// return Stack(
// children: [
// FutureBuilder<String?>(
// future: HiveRepository.getData('token', HiveBoxNames.authBox),
//
// builder: (context, snapshot) {
//
//
// // Handle loading state
// if (snapshot.connectionState == ConnectionState.waiting) {
// return Scaffold(
// body: const Center(child: CircularProgressIndicator()),
// );
// }
// if (snapshot.connectionState == ConnectionState.done) {
// if (!snapshot.hasData) {
// return WelcomeScreen();
// } else {
// return NavPage();
// }
// } else {
// return Scaffold(body: Center(child: Text('An Error occured.')));
// }
// },
// ),
// if (connectivityState is ConnectivityOffline)
// Positioned(
// top: 0,
// left: 0,
// right: 0,
// child: NoInternetBanner(
// onClose: () {
// logInfo('No internet connection banner dismissed');
// context
// .read<ConnectivityBloc>()
// .add(ConnectivityBannerDismissed());
// },
// ),
// ),
// ],
// );
// },
// );
// }
// }
class Decider extends StatefulWidget {
@override
_DeciderState createState() => _DeciderState();
Expand All @@ -158,27 +214,38 @@ class _DeciderState extends State<Decider> {
logDebug('Current connectivity state: $connectivityState');
return Stack(
children: [
FutureBuilder<String?>(
future: HiveRepository.getData('token', HiveBoxNames.authBox),

builder: (context, snapshot) {

BlocBuilder<AuthBloc, AuthState>(
builder: (context, authState) {
debugPrint("Current AuthState: $authState");

// Handle loading state
if (snapshot.connectionState == ConnectionState.waiting) {
if (authState is AuthLoading) {
return Scaffold(
body: const Center(child: CircularProgressIndicator()),
);
}
if (snapshot.connectionState == ConnectionState.done) {
if (!snapshot.hasData) {
return WelcomeScreen();
} else {
return NavPage();
}
} else {
return Scaffold(body: Center(child: Text('An Error occured.')));

// Handle guest user
if (authState is GuestUser) {
return WelcomeScreen();
}

// Handle logged-in user
if (authState is AuthLoaded) {
return NavPage();
}

// Handle error state
if (authState is AuthLoadingError) {
return Scaffold(
body: Center(child: Text('Error: ${authState.message}')),
);
}

// Default fallback (e.g., AuthInitial)
return Scaffold(
body: const Center(child: CircularProgressIndicator()),
);
},
),
if (connectivityState is ConnectivityOffline)
Expand All @@ -200,5 +267,4 @@ class _DeciderState extends State<Decider> {
},
);
}
}

}
2 changes: 1 addition & 1 deletion mobile-v3/lib/src/app/auth/bloc/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
Future<void> _onAppStarted(AppStarted event, Emitter<AuthState> emit) async {
emit(AuthLoading());
try {
await Future.delayed(const Duration(milliseconds: 500));
//await Future.delayed(const Duration(milliseconds: 500));
final token = await HiveRepository.getData('token', HiveBoxNames.authBox);

if (token != null && token.isNotEmpty) {
Expand Down
40 changes: 38 additions & 2 deletions mobile-v3/lib/src/app/dashboard/pages/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ class _DashboardPageState extends State<DashboardPage> {
SizedBox(height: 16),
BlocBuilder<AuthBloc, AuthState>(
builder: (context, authState) {
if (authState is AuthLoading) {

return Text(
"Hi, 👋🏼",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.w700,
color: Theme.of(context).textTheme.headlineLarge?.color,
),
);
}

if (authState is GuestUser) {
return Text(
"Hi, Guest 👋🏼",
Expand All @@ -195,7 +207,9 @@ class _DashboardPageState extends State<DashboardPage> {
color: Theme.of(context).textTheme.headlineLarge?.color,
),
);
} else {
}

if (authState is AuthLoaded) {
return BlocBuilder<UserBloc, UserState>(
builder: (context, userState) {
if (userState is UserLoaded) {
Expand All @@ -209,7 +223,7 @@ class _DashboardPageState extends State<DashboardPage> {
);
}
return Text(
"Hi,👋🏼",
"Hi, 👋🏼",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.w700,
Expand All @@ -219,6 +233,28 @@ class _DashboardPageState extends State<DashboardPage> {
},
);
}

// Handle error state
if (authState is AuthLoadingError) {
return Text(
"Hi, 👋🏼",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.w700,
color: Theme.of(context).textTheme.headlineLarge?.color,
),
);
}

// Default fallback
return Text(
"Hi, 👋🏼",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.w700,
color: Theme.of(context).textTheme.headlineLarge?.color,
),
);
},
),

Expand Down
4 changes: 4 additions & 0 deletions netmanager-app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ build/Release
node_modules/
jspm_packages/

# Removing the idea
.idea/


# TypeScript v1 declaration files
typings/

Expand Down
2 changes: 0 additions & 2 deletions netmanager-app/app/(authenticated)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import "../globals.css";
import Layout from "../../components/layout";
import { Toaster } from "@/components/ui/sonner";

export default function AuthenticatedLayout({
children,
Expand All @@ -12,7 +11,6 @@ export default function AuthenticatedLayout({
return (
<Layout>
{children}
<Toaster />
</Layout>
);
}
72 changes: 72 additions & 0 deletions netmanager-app/app/(authenticated)/organizations/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"use client";

import type React from "react";
import { Suspense } from "react";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { OrganizationProfile } from "@/components/Organization/organization-profile";
import { TeamMembers } from "@/components/Organization/team-members";
import { OrganizationRoles } from "@/components/Organization/organization-roles";
import { Skeleton } from "@/components/ui/skeleton";
import { ArrowLeftIcon } from "lucide-react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { RouteGuard } from "@/components/route-guard";

const LoadingFallback = () => (
<div className="space-y-4">
<Skeleton className="h-8 w-3/4" />
<Skeleton className="h-64 w-full" />
</div>
);

const TabContent = ({
value,
children,
}: {
value: string;
children: React.ReactNode;
}) => (
<TabsContent value={value}>
<Suspense fallback={<LoadingFallback />}>{children}</Suspense>
</TabsContent>
);

const OrganizationDetailsPage = ({ params }: { params: { id: string } }) => {
const router = useRouter();

return (
<RouteGuard permission="CREATE_UPDATE_AND_DELETE_NETWORK_USERS">
<div className="container mx-auto">
{/* Back button */}
<Button
variant="ghost"
className="flex items-center space-x-2 mb-6"
onClick={() => router.push("/organizations")}
>
<ArrowLeftIcon className="h-4 w-4" />
<span>Back to Organizations</span>
</Button>
{/* Organization Details */}
<h1 className="text-3xl font-bold mb-6">Organization Details</h1>
<Tabs defaultValue="profile">
<TabsList className="grid grid-cols-3">
<TabsTrigger value="profile">Organization Profile</TabsTrigger>
<TabsTrigger value="members">Team Members</TabsTrigger>
<TabsTrigger value="roles">Organization Roles</TabsTrigger>
</TabsList>
<TabContent value="profile">
<OrganizationProfile organizationId={params.id} />
</TabContent>
<TabContent value="members">
<TeamMembers organizationId={params.id} />
</TabContent>
<TabContent value="roles">
<OrganizationRoles organizationId={params.id} />
</TabContent>
</Tabs>
</div>
</RouteGuard>
);
};

export default OrganizationDetailsPage;
16 changes: 16 additions & 0 deletions netmanager-app/app/(authenticated)/organizations/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use client";

import { OrganizationList } from "@/components/Organization/List";
import { RouteGuard } from "@/components/route-guard";

const OrganizationSettingsPage = () => {
return (
<RouteGuard permission="CREATE_UPDATE_AND_DELETE_NETWORK_USERS">
<div className="mx-auto">
<OrganizationList />
</div>
</RouteGuard>
);
};

export default OrganizationSettingsPage;
2 changes: 2 additions & 0 deletions netmanager-app/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Inter } from "next/font/google";
import "./globals.css";
import Providers from "./providers";
import { Toaster } from "@/components/ui/sonner";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -13,6 +14,7 @@ export default function RootLayout({
<html lang="en">
<body className={inter.className}>
<Providers>{children}</Providers>
<Toaster />
</body>
</html>
);
Expand Down
Loading

0 comments on commit 8af9540

Please sign in to comment.