Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.7.2 #109

Merged
merged 45 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a703fd2
chore: bump version number
joshtenorio Dec 10, 2024
5c6fc09
misc: upload file table height adjusted
joshtenorio Dec 10, 2024
23849a9
start working on ignore list and add ci
joshtenorio Dec 10, 2024
27f0374
fix ci
joshtenorio Dec 10, 2024
27882bb
fix ci
joshtenorio Dec 10, 2024
96ef8ed
fix ci
joshtenorio Dec 10, 2024
ddf95f3
fix ci
joshtenorio Dec 10, 2024
5c47413
fix ci
joshtenorio Dec 10, 2024
ce5d304
fix ci
joshtenorio Dec 10, 2024
1303a8f
fix ci
joshtenorio Dec 10, 2024
f3d67a0
fix ci
joshtenorio Dec 10, 2024
ceba5d3
fix ci
joshtenorio Dec 10, 2024
93e1987
fix ci
joshtenorio Dec 10, 2024
fdd8081
fix ci (add pnpm)
joshtenorio Dec 10, 2024
5cfa1e8
remove windows from ci for speed purposes
joshtenorio Dec 10, 2024
86d2060
misc: hide dev settings on release build
joshtenorio Dec 12, 2024
5347ebb
misc: add link for wiki website
joshtenorio Dec 12, 2024
c01b0b9
fix: break long filepaths in download/upload pages
joshtenorio Dec 14, 2024
28d6abf
helper functions for linux support
joshtenorio Dec 14, 2024
56e0b63
more linux support code
joshtenorio Dec 16, 2024
00a8e97
todo test linux support
joshtenorio Dec 16, 2024
ae00d22
start refactoring db access into dal struct
joshtenorio Dec 16, 2024
daca598
fix ci
joshtenorio Dec 16, 2024
9c75f79
dal tests, start commands crate
joshtenorio Dec 16, 2024
ad5d6ef
network file for requests
joshtenorio Dec 16, 2024
daea615
more dal stuff
joshtenorio Dec 16, 2024
bb03964
dal project sync test cases
joshtenorio Dec 17, 2024
397a4c4
test
joshtenorio Dec 17, 2024
9bd0c71
???
joshtenorio Dec 18, 2024
b2c2456
misc: remove unused project buttons
joshtenorio Dec 18, 2024
34500ac
misc: improve UI when app is fullscreen
joshtenorio Dec 18, 2024
764cbe6
misc: add dev-only tooling for debug purposes
joshtenorio Dec 18, 2024
feb0be3
misc: improve pagination ui in project history page
joshtenorio Dec 18, 2024
2730f27
mwe file filter, doesnt work w/ selection yet
joshtenorio Dec 18, 2024
3231e86
mwe for combining file filters with selection, need to make it cleaner
joshtenorio Dec 18, 2024
82a1057
move get_conflicts sql into dal
joshtenorio Dec 19, 2024
9ce281e
some dev tooling
joshtenorio Dec 21, 2024
072d53c
staging dev tooling changes
joshtenorio Dec 21, 2024
6dccdb0
remove un-needed commented code
joshtenorio Dec 21, 2024
8699922
misc: project history entries are more compact now
joshtenorio Dec 21, 2024
9598724
remove vertical padding from file table if not using filter
joshtenorio Dec 21, 2024
dfc8b9c
misc: redesign loading data symbol
joshtenorio Dec 21, 2024
701ce44
misc: added file filter to improve selecting files for upload
joshtenorio Jan 4, 2025
3ad9837
make filter/setfilter parameters for filetable optional
joshtenorio Jan 4, 2025
a1e54cc
re
joshtenorio Jan 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
push:
branches:
- dev

env:
CARGO_TERM_COLOR: always

jobs:
test-tauri:
strategy:
fail-fast: false
matrix:
include:
- platform: "ubuntu-22.04"
args: ""
#- platform: "windows-latest"
# args: ""

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf

- name: install frontend dependencies
run: pnpm install # change this to npm, pnpm or bun depending on which one you use.

- name: run rust tests
run: cargo test --verbose
working-directory: ./src-tauri
# If tagName and releaseId are omitted tauri-action will only build the app and won't try to upload any assets.
#- uses: tauri-apps/tauri-action@v0
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# args: ${{ matrix.args }}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ $ pnpm tauri dev
# for building installers, etc.
$ $env:TAURI_SIGNING_PRIVATE_KEY="Path or content of your private key"
$ pnpm tauri build

# to run rust tests
$ cd src-tauri
$ cargo test
$ cargo test -- --nocapture # to run tests with println
```
### Recommended IDE Setup

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "glassy_pdm_client",
"private": true,
"version": "0.7.1",
"version": "0.7.2",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "glassy_pdm_client"
version = "0.7.1"
version = "0.7.2"
description = "glassyPDM"
authors = ["Joshua Tenorio"]
license = "GPL"
Expand Down Expand Up @@ -30,6 +30,9 @@ fs-chunker = "0.5.0"
tauri-plugin-log = "2.0.1"
log = "0.4"
fs_extra = "1.3.0"
#specta = { version = "=2.0.0-rc.20" }
#tauri-specta = { version = "=2.0.0-rc.20", features = ["derive", "typescript"] }
#specta-typescript = "0.0.7"
# cap = { version = "0.1.2", features = ["stats"] }

[features]
Expand Down
6 changes: 6 additions & 0 deletions src-tauri/migrations/3_local_ignore.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE projectignorelist (
pil_id INTEGER PRIMARY KEY NOT NULL,
pid INTEGER NOT NULL,
url TEXT NOT NULL,
path TEXT NOT NULL
);
3 changes: 3 additions & 0 deletions src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod project;

// TODO move types into here
124 changes: 124 additions & 0 deletions src-tauri/src/commands/project.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
use crate::{
file::translate_filepath, types::RemoteFile, util::open_directory, dal::DataAccessLayer
};
use merkle_hash::{bytes_to_hex, Algorithm, MerkleTree};
use serde::{Deserialize, Serialize};
use sqlx::{Pool, Row, Sqlite};
use std::path::{Path, PathBuf};
use std::fs::{self, remove_dir_all};
use tauri::State;
use tokio::sync::Mutex;
use crate::types::LocalProject;


#[tauri::command]
pub async fn get_local_projects(
state_mutex: State<'_, Mutex<Pool<Sqlite>>>,
) -> Result<Vec<LocalProject>, ()> {
let pool = state_mutex.lock().await;
let dal = DataAccessLayer::new(&pool);
let server = dal.get_active_server().await.unwrap();

let pid_query = sqlx::query("SELECT DISTINCT pid FROM file")
.fetch_all(&*pool)
.await;
let mut output: Vec<LocalProject> = vec![];
match pid_query {
Ok(rows) => {
for row in rows {
let pid = row.get::<i32, &str>("pid");
let query =
sqlx::query("SELECT title, team_name FROM project WHERE url = $1 AND pid = $2")
.bind(server.clone())
.bind(pid)
.fetch_one(&*pool)
.await;

match query {
Ok(row) => output.push(LocalProject {
pid: pid,
title: row.get::<String, &str>("title").to_string(),
team_name: row.get::<String, &str>("team_name").to_string(),
}),
Err(err) => {
println!("error: {}", err);
}
}
}
}
Err(err) => {
println!("error: {}", err);
}
}
Ok(output)
}

#[tauri::command]
pub async fn open_project_dir(
pid: i32,
state_mutex: State<'_, Mutex<Pool<Sqlite>>>,
) -> Result<(), ()> {
let pool = state_mutex.lock().await;
let dal = DataAccessLayer::new(&pool);

let project_dir = dal.get_project_dir(pid).await.unwrap();
let _ = fs::create_dir_all(&project_dir);
let mut pb = PathBuf::new();
pb.push(project_dir);
open_directory(pb);

return Ok(());
}

#[tauri::command]
pub async fn clear_file_table(pid: i32, commit: String, delete: bool, state_mutex: State<'_, Mutex<Pool<Sqlite>>>) -> Result<(), ()> {
let pool = state_mutex.lock().await;
let dal = DataAccessLayer::new(&pool);

if commit == "latest" {
let _ = dal.clear_file_table_for_project(pid).await;
return Ok(());
}
let res = dal.clear_file_table_for_project_after_commit(pid, commit.parse().unwrap()).await;
if !delete {
return Ok(())
}
match res {
Ok(hehez) => {
// delete the files!
let proj_dir = dal.get_project_dir(pid).await.unwrap();
if proj_dir == "" {
log::warn!("did not get a project dir, so could not delete files");
return Ok(());
}
for hehe in hehez {
let path = proj_dir.clone() + "\\" + &hehe;
let _ = fs::remove_file(path);

// TODO try to delete its directories
}
},
Err(err) => {
log::warn!("did not delete the files")
}
}
return Ok(());
}

#[tauri::command]
pub async fn delete_project(pid: i32, state_mutex: State<'_, Mutex<Pool<Sqlite>>>) -> Result<(), String> {
let pool = state_mutex.lock().await;
let dal = DataAccessLayer::new(&pool);

let _ = dal.clear_file_table_for_project(pid).await;

// delete project folder
let project_dir = dal.get_project_dir(pid).await.unwrap();
match remove_dir_all(Path::new(&project_dir)) {
Ok(_res) => {},
Err(err) => {
log::error!("could not delete the trash: {}", err);
}
}
Ok(())
}
92 changes: 22 additions & 70 deletions src-tauri/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{types::SettingsOptions, util::get_active_server};
use crate::{dal::DataAccessLayer, types::SettingsOptions};
use fs_extra::dir::{move_dir, CopyOptions};
use sqlx::{Pool, Row, Sqlite};
use tauri::State;
Expand All @@ -7,32 +7,17 @@ use tokio::sync::Mutex;
#[tauri::command]
pub async fn get_server_name(state_mutex: State<'_, Mutex<Pool<Sqlite>>>) -> Result<String, ()> {
let pool = state_mutex.lock().await;
let output = sqlx::query("SELECT name FROM server WHERE active = 1")
.fetch_one(&*pool)
.await;
let dal = DataAccessLayer::new(&pool);

match output {
Ok(row) => Ok(row.get::<String, &str>("name")),
Err(err) => {
println!("asdfasdf {}", err);
Ok("glassyPDM".to_string())
}
}
dal.get_server_name().await
}

#[tauri::command]
pub async fn get_server_url(state_mutex: State<'_, Mutex<Pool<Sqlite>>>) -> Result<String, ()> {
let pool = state_mutex.lock().await;
let dal = DataAccessLayer::new(&pool);

let output = sqlx::query("SELECT CASE WHEN debug_active = 1 THEN debug_url ELSE url END as url FROM server WHERE active = 1").fetch_one(&*pool).await;

match output {
Ok(row) => Ok(row.get::<String, &str>("url")),
Err(err) => {
println!("asdfasdf {}", err);
Ok("".to_string())
}
}
dal.get_current_server().await
}

#[tauri::command]
Expand Down Expand Up @@ -84,18 +69,8 @@ pub async fn add_server(
state_mutex: State<'_, Mutex<Pool<Sqlite>>>,
) -> Result<bool, ()> {
let pool = state_mutex.lock().await;
sqlx::query(
"INSERT INTO server (url, clerk_publickey, local_dir, name, active, debug_url, debug_active) VALUES (?, ?, ?, ?, ?, ?, ?);"
)
.bind(url)
.bind(clerk)
.bind(local_dir)
.bind(name)
.bind(1)
.bind("http://localhost:5000")
.bind(0)
.execute(&*pool)
.await.unwrap();
let dal = DataAccessLayer::new(&pool);
let _ = dal.add_server(url, clerk, local_dir, name).await;
Ok(true)
}

Expand Down Expand Up @@ -137,6 +112,7 @@ pub async fn set_local_dir(
log::info!("setting local directory to {}", dir);
log::info!("parent dir: {}", parent_dir);
let pool = state_mutex.lock().await;
let dal = DataAccessLayer::new(&pool);
let old_server_dir = get_server_dir(&pool).await.unwrap();
let _ = sqlx::query("UPDATE server SET local_dir = ? WHERE active = 1")
.bind(dir.clone())
Expand All @@ -145,7 +121,7 @@ pub async fn set_local_dir(

if move_files {
log::info!("moving files...");
// TODO linux testing
// TODO linux testing + support
let options = CopyOptions::new();
match move_dir(old_server_dir.clone(), parent_dir.clone(), &options) {
Ok(_) => return Ok(true),
Expand All @@ -155,21 +131,16 @@ pub async fn set_local_dir(
}
}
}
let url = get_active_server(&pool).await.unwrap();

let url = dal.get_active_server().await.unwrap();
if url == "" {
log::warn!("could not obtain active server url");
return Ok(false);
}

// clear file and project table
let _ = sqlx::query("delete from project WHERE url = $1")
.bind(url.clone())
.execute(&*pool)
.await;

let _ = sqlx::query("delete from file")
.execute(&*pool)
.await;
let _ = dal.clear_project_table(url).await;
let _ = dal.clear_file_table().await;
Ok(true)
}

Expand All @@ -182,36 +153,17 @@ pub async fn cmd_get_cache_setting(state_mutex: State<'_, Mutex<Pool<Sqlite>>>)
#[tauri::command]
pub async fn cmd_set_cache_setting(new_cache: bool, state_mutex: State<'_, Mutex<Pool<Sqlite>>>) -> Result<bool, ()> {
let pool = state_mutex.lock().await;
let url = get_active_server(&pool).await.unwrap();
let dal = DataAccessLayer::new(&pool);

match sqlx::query("UPDATE server SET cache_setting = $1 WHERE url = $2")
.bind(if new_cache { 1 } else { 0 })
.bind(url)
.execute(&*pool)
.await {
Ok(_o) => {
Ok(true)
},
Err(err) => {
log::error!("could not set cache setting due to db error: {}", err);
Ok(false)
}
}
dal.update_cache_setting(new_cache).await
}

pub async fn get_cache_setting(pool: &Pool<Sqlite>) -> Result<bool, ()> {
let url = get_active_server(pool).await.unwrap();
match sqlx::query("SELECT cache_setting FROM server WHERE url = $1")
.bind(url)
.fetch_one(pool)
.await {
Ok(row) => {
let setting = row.get::<u32, &str>("cache_setting");
Ok(if setting == 1 { true } else { false })
},
Err(err) => {
log::error!("could not retrieve cache setting due to db error: {}", err);
Ok(false)
}
}
let dal = DataAccessLayer::new(pool);
dal.get_cache_setting().await
}

#[tauri::command]
pub fn is_dev_mode() -> bool {
return tauri::is_dev();
}
Loading