Skip to content

Commit

Permalink
Merge pull request #147 from ASM-Studios/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Mael-RABOT authored Dec 10, 2024
2 parents ddabaae + 0604c19 commit a85787b
Show file tree
Hide file tree
Showing 158 changed files with 9,990 additions and 2,343 deletions.
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
VITE_PORT=8081
NODE_ENV=development # development or production
VITE_PORT=8081

# Server database environment variables
DB_NAME=area
DB_PASSWORD=change-me
DB_HOST=mariadb
DB_PORT=3306
DB_USER=root
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

ssl/
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TARGET_MAX_CHAR_NUM=20

.PHONY: start build stop restart reset logs clean help

PROJECT_IMAGES = area-client-web area-client-mobile
PROJECT_IMAGES = area-client-web area-client-mobile area-server mariadb rabbitmq

## Show help
help:
Expand All @@ -33,6 +33,10 @@ help:
start:
docker compose up -d

## Start containers in detached mode for production
start-prod:
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d

## Build and start containers in detached mode
build:
docker compose up --build -d
Expand Down
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ With AREA, you can create automated workflows that integrate various services an
## Table of Contents

- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation & Usage](#installation--usage)
- [Prerequisites](#prerequisites)
- [Installation & Usage](#installation--usage)
- [Documentation](#documentation)
- [Requirements](#requirements)
- [Usage](#usage)
- [Requirements](#requirements)
- [Usage](#usage)
- [Tests](#tests)
- [License](#license)
- [Contributors](#contributors)
Expand All @@ -19,50 +19,39 @@ With AREA, you can create automated workflows that integrate various services an

### Prerequisites

- vite js
- go
- docker
- make

### Installation & Usage

<details>
<summary>Click to expand</summary>

1. Clone the repo

```sh
git clone [email protected]:ASM-Studios/AREA.git
```

2. Create .env files

- Run the following command to create private env files

```sh
cp .env.example .env
cp server/.env.server.example server/.env.server
cp client_web/.env.local.example .env.local
cp client_mobile/.env.mobile.example .env.mobile
```

- Fill the .env, .env.web and .env.mobile files

3. Install NPM packages
```sh
cd AREA/client-web
npm install
```
4. Run the project

3. Install Go packages
```sh
cd AREA/server
<TODO>
make start
```

4. Run the project
```sh
cd AREA/client-web
npm run start
```
```sh
cd AREA/server
go run ./...
```
</details>

### Documentation
Expand All @@ -87,6 +76,7 @@ The documentation is automatically built and deployed to GitHub Pages when a pus
You can consult the documentation online at [AREA Documentation](https://asm-studios.github.io/AREA/).

You can build the documentation locally by running the following command:

```sh
cd AREA/docs
make docs
Expand Down
15 changes: 1 addition & 14 deletions client_mobile/.env.mobile.example
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
VITE_PORT=8081
VITE_ENDPOINT=http://localhost:8080

VITE_GOOGLE_CLIENT_ID=
VITE_GOOGLE_CLIENT_SECRET=

VITE_MICROSOFT_CLIENT_ID=

VITE_LINKEDIN_CLIENT_ID=
VITE_LINKEDIN_CLIENT_SECRET=

VITE_SPOTIFY_CLIENT_ID=
VITE_SPOTIFY_CLIENT_SECRET=

# Server URLs
API_URL=http://localhost:8080
WEB_CLIENT_URL=http://localhost:8081
MOBILE_CLIENT_URL=http://localhost:8082
BACKEND_BASE_URL=http://10.109.253.48:8080

# OAuth credentials
GITHUB_CLIENT_ID=your_github_client_id
Expand Down
47 changes: 32 additions & 15 deletions client_mobile/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
FROM ghcr.io/cirruslabs/flutter:stable
FROM ghcr.io/cirruslabs/flutter:3.24.5 AS builder

WORKDIR /app

ARG VITE_PORT
ARG VITE_ENDPOINT
ARG VITE_GOOGLE_CLIENT_ID
ARG VITE_GOOGLE_CLIENT_SECRET
ARG VITE_MICROSOFT_CLIENT_ID
ARG VITE_LINKEDIN_CLIENT_ID
ARG VITE_LINKEDIN_CLIENT_SECRET
ARG VITE_SPOTIFY_CLIENT_ID
ARG VITE_SPOTIFY_CLIENT_SECRET
# Create a non-root user and give permissions to Android SDK directory
RUN useradd -m -d /home/flutteruser -s /bin/bash flutteruser && \
chown -R flutteruser:flutteruser /app && \
chown -R flutteruser:flutteruser /sdks/flutter && \
chown -R flutteruser:flutteruser /opt/android-sdk-linux && \
mkdir -p /opt/android-sdk-linux/licenses && \
chown -R flutteruser:flutteruser /opt/android-sdk-linux/licenses

USER flutteruser

RUN git config --global --add safe.directory /sdks/flutter && \
git config --global --add safe.directory /app

# Ensure Flutter is properly set up
RUN flutter doctor -v && \
flutter config --no-analytics

COPY --chown=flutteruser:flutteruser pubspec.* ./

RUN flutter pub get

COPY --chown=flutteruser:flutteruser . .

ARG API_URL
ARG WEB_CLIENT_URL
ARG MOBILE_CLIENT_URL
ARG GITHUB_CLIENT_ID
ARG GITHUB_CLIENT_SECRET

COPY . .
# Accept Android licenses and install SDK components
RUN yes | sdkmanager --licenses && \
sdkmanager "build-tools;30.0.3"

RUN flutter pub get
RUN flutter build apk --release
# Clean and get dependencies again after copying all files
RUN flutter clean && \
flutter pub get

RUN mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/client.apk
RUN chmod -R 755 build/app/outputs/flutter-apk/
RUN flutter build apk --release
RUN mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/client.apk
4 changes: 2 additions & 2 deletions client_mobile/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ 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 "com.android.application" version "7.3.1" apply false
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
}

include ":app"
Binary file added client_mobile/assets/images/discord.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 client_mobile/assets/images/google.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 client_mobile/assets/images/microsoft.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 client_mobile/assets/images/spotify.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 client_mobile/assets/images/spotify_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions client_mobile/lib/data/action.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:client_mobile/data/parameter.dart';

class WorkflowActionReaction {
final int id;
final String name;
final String description;
final List<Parameter> parameters;
String? serviceName;
int? serviceId;

WorkflowActionReaction({
required this.id,
required this.name,
required this.description,
required this.parameters,
this.serviceName,
this.serviceId
});

factory WorkflowActionReaction.fromJson(Map<String, dynamic> json) {
return WorkflowActionReaction(
id: json['id'],
name: json['name'],
description: json['description'] ?? "",
parameters: json['parameters'] != null
? (json['parameters'] as List)
.map((param) => Parameter.fromJson(param))
.toList()
: [],
);
}

Map<String, dynamic> toJson(String type) {
return {
'id': id,
'name': name,
'type': type,
'description': description,
'parameters': parameters.map((p) => p.toJson()).toList(),
};
}
}
29 changes: 29 additions & 0 deletions client_mobile/lib/data/parameter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Parameter {
final String name;
final String description;
final String type;
String? value;

Parameter({
required this.name,
required this.description,
required this.type,
this.value,
});

factory Parameter.fromJson(Map<String, dynamic> json) {
return Parameter(
name: json['name'],
description: json['description'] ?? "",
type: json['type'],
);
}

Map<String, dynamic> toJson() {
return {
'name': name,
'type': type,
'value': value
};
}
}
52 changes: 52 additions & 0 deletions client_mobile/lib/data/service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import 'package:client_mobile/data/action.dart';

class WorkflowService {
final int id;
final String name;
final List<WorkflowActionReaction> actions;
final List<WorkflowActionReaction> reactions;

WorkflowService({
required this.id,
required this.name,
required this.actions,
required this.reactions,
});

factory WorkflowService.fromJson(Map<String, dynamic> json) {
try {
return WorkflowService(
id: json['id'] ?? 0,
name: json['name'] ??
'Unknown',
actions: _parseActionsOrReactions(json['actions']),
reactions: _parseActionsOrReactions(json['reactions']),
);
} catch (e) {
print('Error parsing WorkflowService: $e');
return WorkflowService(
id: 0, name: 'Unknown', actions: [], reactions: []);
}
}

static List<WorkflowActionReaction> _parseActionsOrReactions(dynamic data) {
if (data == null) {
return [];
}
if (data is List) {
return data.map((item) => WorkflowActionReaction.fromJson(item)).toList();
} else {
print('Expected a list for actions or reactions, but got: $data');
return [];
}
}

Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'actions': actions.map((a) => a.toJson("action")).toList(),
'reactions': reactions.map((r) => r.toJson("reaction")).toList(),
};
}
}
36 changes: 36 additions & 0 deletions client_mobile/lib/data/service_metadata.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:flutter/material.dart';

class ServiceMetadata {
final String name;
final Color color;
final String imagePath;

ServiceMetadata({
required this.name,
required this.color,
required this.imagePath,
});

static List<ServiceMetadata> services = [
ServiceMetadata(
name: "spotify",
color: Colors.green,
imagePath: 'assets/images/spotify.png'),
ServiceMetadata(
name: "discord",
color: Colors.lightBlue,
imagePath: 'assets/images/discord.png'),
ServiceMetadata(
name: "microsoft",
color: Colors.grey,
imagePath: 'assets/images/microsoft.png'),
ServiceMetadata(
name: "google",
color: Colors.amber,
imagePath: 'assets/images/google.png'),
];

static ServiceMetadata? getServiceByName(String name) {
return services.firstWhere((service) => service.name == name);
}
}
Loading

0 comments on commit a85787b

Please sign in to comment.