This commit is contained in:
che
2026-07-23 09:31:01 +05:00
commit 4cfc5d6ae6
64 changed files with 9779 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas
# Local SQLite databases
*.sqlite
*.sqlite-shm
*.sqlite-wal
+6155
View File
File diff suppressed because it is too large Load Diff
+28
View File
@@ -0,0 +1,28 @@
[package]
name = "ewa-mobile"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
default-run = "ewa-mobile"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "ewa_mobile_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
che-orm = { path = "../../che-orm/crates/che-orm" }
che-tauri = { path = "../../che-tauri" }
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
+5
View File
@@ -0,0 +1,5 @@
[database]
url = "sqlite://ewa-mobile.sqlite?mode=rwc"
[remote]
base_url = "http://localhost:3000"
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
+10
View File
@@ -0,0 +1,10 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"opener:default"
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 903 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

+10
View File
@@ -0,0 +1,10 @@
pub mod personemanagment;
pub mod users;
use che_tauri::InstalledApps;
pub fn installed_apps() -> InstalledApps {
InstalledApps::new()
.add(users::module())
.add(personemanagment::module())
}
@@ -0,0 +1,35 @@
use che_tauri::{Filter, FilterSet};
use super::models::{Employee, Message, Task};
static EMPLOYEE_FILTERS: &[Filter] = &[
Filter::exact("id"),
Filter::exact("name"),
Filter::contains("name"),
];
static TASK_FILTERS: &[Filter] = &[
Filter::exact("id"),
Filter::exact("name"),
Filter::contains("name"),
Filter::exact("author_id"),
Filter::exact("responsible_id"),
];
static MESSAGE_FILTERS: &[Filter] = &[
Filter::exact("id"),
Filter::exact("task_id"),
Filter::exact("employee_id"),
];
pub fn employee_filterset() -> FilterSet<Employee> {
FilterSet::new(EMPLOYEE_FILTERS)
}
pub fn task_filterset() -> FilterSet<Task> {
FilterSet::new(TASK_FILTERS)
}
pub fn message_filterset() -> FilterSet<Message> {
FilterSet::new(MESSAGE_FILTERS)
}
@@ -0,0 +1,4 @@
CREATE TABLE IF NOT EXISTS task (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
);
@@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS employee (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
avatar TEXT NOT NULL
);
ALTER TABLE task ADD COLUMN author_id INTEGER REFERENCES employee(id);
ALTER TABLE task ADD COLUMN responsible_id INTEGER REFERENCES employee(id);
@@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS message (
id INTEGER PRIMARY KEY AUTOINCREMENT,
task_id INTEGER NOT NULL REFERENCES task(id),
employee_id INTEGER NOT NULL REFERENCES employee(id),
text TEXT NOT NULL
);
@@ -0,0 +1,152 @@
{
"models": [
{
"table": "employee",
"fields": [
{
"name": "id",
"ty": "integer",
"primary_key": true,
"nullable": false,
"auto": true,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": null
},
{
"name": "name",
"ty": "text",
"primary_key": false,
"nullable": false,
"auto": false,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": null
},
{
"name": "avatar",
"ty": "text",
"primary_key": false,
"nullable": false,
"auto": false,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": null
}
]
},
{
"table": "message",
"fields": [
{
"name": "id",
"ty": "integer",
"primary_key": true,
"nullable": false,
"auto": true,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": null
},
{
"name": "task_id",
"ty": "integer",
"primary_key": false,
"nullable": false,
"auto": false,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": {
"table": "task",
"column": "id"
}
},
{
"name": "employee_id",
"ty": "integer",
"primary_key": false,
"nullable": false,
"auto": false,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": {
"table": "employee",
"column": "id"
}
},
{
"name": "text",
"ty": "text",
"primary_key": false,
"nullable": false,
"auto": false,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": null
}
]
},
{
"table": "task",
"fields": [
{
"name": "id",
"ty": "integer",
"primary_key": true,
"nullable": false,
"auto": true,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": null
},
{
"name": "name",
"ty": "text",
"primary_key": false,
"nullable": false,
"auto": false,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": null
},
{
"name": "author_id",
"ty": "integer",
"primary_key": false,
"nullable": true,
"auto": false,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": {
"table": "employee",
"column": "id"
}
},
{
"name": "responsible_id",
"ty": "integer",
"primary_key": false,
"nullable": true,
"auto": false,
"unique": false,
"max_length": null,
"default": null,
"foreign_key": {
"table": "employee",
"column": "id"
}
}
]
}
]
}
@@ -0,0 +1,35 @@
pub mod filters;
pub mod models;
pub mod serializers;
use che_tauri::{AppModule, ModuleContext};
pub fn module() -> TaskModule {
TaskModule
}
pub struct TaskModule;
impl AppModule for TaskModule {
fn name(&self) -> &'static str {
"personemanagment"
}
fn init(&self, ctx: &mut ModuleContext) {
ctx.resource::<models::Employee>(
"employee",
serializers::employee_serializer(),
filters::employee_filterset(),
);
ctx.resource::<models::Task>(
"task",
serializers::task_serializer(),
filters::task_filterset(),
);
ctx.resource::<models::Message>(
"message",
serializers::message_serializer(),
filters::message_filterset(),
);
}
}
@@ -0,0 +1,42 @@
use che_orm::Model;
#[derive(Debug, Clone, Model)]
#[model(table = "employee")]
pub struct Employee {
#[field(primary_key)]
pub id: i64,
pub name: String,
pub avatar: String,
}
#[derive(Debug, Clone, Model)]
#[model(table = "task")]
pub struct Task {
#[field(primary_key)]
pub id: i64,
pub name: String,
#[field(foreign_key = Employee)]
pub author_id: Option<i64>,
#[field(foreign_key = Employee)]
pub responsible_id: Option<i64>,
}
#[derive(Debug, Clone, Model)]
#[model(table = "message")]
pub struct Message {
#[field(primary_key)]
pub id: i64,
#[field(foreign_key = Task)]
pub task_id: i64,
#[field(foreign_key = Employee)]
pub employee_id: i64,
pub text: String,
}
@@ -0,0 +1,35 @@
use che_tauri::{Field, ModelSerializer};
use super::models::{Employee, Message, Task};
static EMPLOYEE_FIELDS: &[Field] = &[
Field::new("id").read_only(),
Field::new("name"),
Field::new("avatar"),
];
static TASK_FIELDS: &[Field] = &[
Field::new("id").read_only(),
Field::new("name"),
Field::new("author_id").required(false).nullable(),
Field::new("responsible_id").required(false).nullable(),
];
static MESSAGE_FIELDS: &[Field] = &[
Field::new("id").read_only(),
Field::new("task_id"),
Field::new("employee_id"),
Field::new("text"),
];
pub fn employee_serializer() -> ModelSerializer<Employee> {
ModelSerializer::new(EMPLOYEE_FIELDS)
}
pub fn task_serializer() -> ModelSerializer<Task> {
ModelSerializer::new(TASK_FIELDS)
}
pub fn message_serializer() -> ModelSerializer<Message> {
ModelSerializer::new(MESSAGE_FIELDS)
}
+13
View File
@@ -0,0 +1,13 @@
use che_tauri::{Filter, FilterSet};
use super::models::User;
static USERS_FILTERS: &[Filter] = &[
Filter::exact("id"),
Filter::exact("name"),
Filter::contains("name"),
];
pub fn user_filterset() -> FilterSet<User> {
FilterSet::new(USERS_FILTERS)
}
+26
View File
@@ -0,0 +1,26 @@
pub mod filters;
pub mod models;
pub mod serializers;
use che_tauri::{AppModule, ModuleContext};
pub fn module() -> UsersModule {
UsersModule
}
pub struct UsersModule;
impl AppModule for UsersModule {
fn name(&self) -> &'static str {
"users"
}
fn init(&self, ctx: &mut ModuleContext) {
ctx.remote_resource::<models::User>(
"users",
"/api/users",
serializers::user_serializer(),
filters::user_filterset(),
);
}
}
+10
View File
@@ -0,0 +1,10 @@
use che_orm::Model;
#[derive(Debug, Clone, Model)]
#[model(table = "users")]
pub struct User {
#[field(primary_key)]
pub id: i64,
pub name: String,
}
+9
View File
@@ -0,0 +1,9 @@
use che_tauri::{Field, ModelSerializer};
use super::models::User;
static USERS_FIELDS: &[Field] = &[Field::new("id").read_only(), Field::new("name")];
pub fn user_serializer() -> ModelSerializer<User> {
ModelSerializer::new(USERS_FIELDS)
}
+8
View File
@@ -0,0 +1,8 @@
use che_tauri::Management;
use ewa_mobile_lib::apps;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Management::new(apps::installed_apps()).run().await
}
+35
View File
@@ -0,0 +1,35 @@
pub mod apps;
use che_tauri::{ApiError, ApiRequest, AppState, TauriApi};
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[tauri::command]
async fn che_api(
api: tauri::State<'_, TauriApi>,
request: ApiRequest,
) -> Result<serde_json::Value, ApiError> {
api.dispatch(request).await
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let api = tauri::async_runtime::block_on(async {
let state = AppState::from_config_file("app.toml").await?;
TauriApi::new(state)
.install(apps::installed_apps())
.build()
.await
})
.expect("failed to initialize che-tauri");
tauri::Builder::default()
.manage(api)
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![greet, che_api])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
+6
View File
@@ -0,0 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
ewa_mobile_lib::run()
}
+35
View File
@@ -0,0 +1,35 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "ewa-mobile",
"version": "0.1.0",
"identifier": "com.che.ewa-mobile",
"build": {
"beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "ewa-mobile",
"width": 800,
"height": 600
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}