mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-23 18:19:30 -04:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab00de476c | ||
|
|
9b4689bf2a | ||
|
|
0c38109b6b | ||
|
|
e968f1cea5 |
Generated
+1
@@ -809,6 +809,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"assertor",
|
||||
"base64 0.22.1",
|
||||
"build_metadata",
|
||||
"bytes 1.10.0",
|
||||
"chrono",
|
||||
"const_format",
|
||||
|
||||
@@ -186,6 +186,7 @@ toml = "0.8.22"
|
||||
url = { version = "2.5.4", features = ["serde"] }
|
||||
|
||||
# Internal libs
|
||||
build_metadata = { path = "crates/lib/build_metadata" }
|
||||
crockford = { path = "crates/lib/data/crockford" }
|
||||
enums = { path = "crates/_types/enums" }
|
||||
enums_public = { path = "crates/_types/enums_public" }
|
||||
|
||||
@@ -23,6 +23,7 @@ tauri-build = { version = "2.1.1", features = [] }
|
||||
workspace-build-acceleration = { workspace = true }
|
||||
|
||||
# Internal
|
||||
build_metadata = { workspace = true }
|
||||
crockford = { workspace = true }
|
||||
errors = { workspace = true }
|
||||
fal_client = { workspace = true }
|
||||
|
||||
@@ -6,6 +6,9 @@ use std::str::FromStr;
|
||||
pub type CommandResult<SuccessPayload, ErrType, ErrPayload> =
|
||||
Result<CommandSuccessResponseWrapper<SuccessPayload>, CommandErrorResponseWrapper<ErrType, ErrPayload>>;
|
||||
|
||||
/// Easy to use infallible response.
|
||||
pub type InfallibleResponse<SuccessPayload> = CommandSuccessResponseWrapper<SuccessPayload>;
|
||||
|
||||
/// No inner payloads for this type. Just strings as messages.
|
||||
pub type SimpleCommandResult = CommandResult<(), (), ()>;
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
use crate::core::commands::command_response_wrapper::{CommandResult, InfallibleResponse, SerializeMarker};
|
||||
use crate::core::state::os_platform::OsPlatform;
|
||||
use crate::services::fal::commands::fal_background_removal_command::FalBackgroundRemovalSuccessResponse;
|
||||
use base64::prelude::BASE64_STANDARD;
|
||||
use base64::Engine;
|
||||
use chrono::{DateTime, Utc};
|
||||
use image::codecs::png::{CompressionType, FilterType, PngEncoder};
|
||||
use image::ImageReader;
|
||||
use log::info;
|
||||
use serde_derive::Serialize;
|
||||
use std::io::Cursor;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct BuildInfoResponse {
|
||||
pub build_timestamp: DateTime<Utc>,
|
||||
pub git_commit_id: Option<String>,
|
||||
pub git_commit_short_id: Option<String>,
|
||||
pub git_commit_timestamp: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
impl SerializeMarker for BuildInfoResponse {}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_build_info_command() -> InfallibleResponse<BuildInfoResponse> {
|
||||
info!("get_build_info_command called...");
|
||||
|
||||
let build_timestamp = build_metadata::build_timestamp();
|
||||
let git_commit_id = build_metadata::git_commit_id();
|
||||
let git_commit_short_id = build_metadata::git_commit_short_id();
|
||||
let git_commit_timestamp = build_metadata::git_commit_timestamp();
|
||||
|
||||
BuildInfoResponse {
|
||||
build_timestamp,
|
||||
git_commit_id: git_commit_id.map(|s| s.to_string()),
|
||||
git_commit_short_id: git_commit_short_id.map(|s| s.to_string()),
|
||||
git_commit_timestamp,
|
||||
}.into()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod app_preferences;
|
||||
pub mod command_response_wrapper;
|
||||
pub mod flip_image;
|
||||
pub mod get_build_info_command;
|
||||
pub mod platform_info_command;
|
||||
|
||||
@@ -6,6 +6,7 @@ use tauri::Manager;
|
||||
use crate::core::commands::app_preferences::get_app_preferences_command::get_app_preferences_command;
|
||||
use crate::core::commands::app_preferences::update_app_preference_command::update_app_preferences_command;
|
||||
use crate::core::commands::flip_image::flip_image;
|
||||
use crate::core::commands::get_build_info_command::get_build_info_command;
|
||||
use crate::core::commands::platform_info_command::platform_info_command;
|
||||
use crate::core::state::app_preferences::app_preferences_manager::load_app_preferences_or_default;
|
||||
use crate::core::state::data_dir::app_data_root::AppDataRoot;
|
||||
@@ -164,6 +165,7 @@ pub fn run() {
|
||||
fal_kling_image_to_video_command,
|
||||
flip_image,
|
||||
get_app_preferences_command,
|
||||
get_build_info_command,
|
||||
get_fal_api_key_command,
|
||||
open_sora_login_command,
|
||||
platform_info_command,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
fn main() {
|
||||
// Tell Cargo that if the given file changes, to rerun this build script.
|
||||
println!("cargo::rerun-if-changed=Cargo.toml");
|
||||
// TODO: Use this to test the GIT_SHA, etc. files that CI dumps into the working directory
|
||||
// println!("cargo::rerun-if-changed=Cargo.toml");
|
||||
|
||||
// Make build info available in the main crate sources.
|
||||
build_info_build::build_script();
|
||||
|
||||
@@ -3,7 +3,7 @@ use build_info::chrono::{DateTime, Utc};
|
||||
|
||||
build_info::build_info!(fn version);
|
||||
|
||||
pub fn build_timestamp() -> DateTime<Utc>{
|
||||
pub fn build_timestamp() -> DateTime<Utc> {
|
||||
version().timestamp
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
GetBuildInfo,
|
||||
GetBuildInfoPayload,
|
||||
} from "@storyteller/tauri-api";
|
||||
import { Label } from "@storyteller/ui-label";
|
||||
|
||||
interface AboutSettingsPaneProps {}
|
||||
|
||||
export const AboutSettingsPane = (args: AboutSettingsPaneProps) => {
|
||||
const [buildInfo, setBuildInfo] = useState<
|
||||
GetBuildInfoPayload | undefined
|
||||
>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
const prefs = await GetBuildInfo();
|
||||
setBuildInfo(prefs.payload);
|
||||
};
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col">
|
||||
<Label htmlFor="play-sounds">
|
||||
Build Timestamp
|
||||
</Label>
|
||||
<div>{buildInfo?.build_timestamp}</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="success-sound">Git Commit ID</Label>
|
||||
<div>{buildInfo?.git_commit_id}</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="success-sound">Git Commit Short ID</Label>
|
||||
<div>{buildInfo?.git_commit_short_id}</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="success-sound">Git Commit Timestamp</Label>
|
||||
<div>{buildInfo?.git_commit_timestamp}</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -5,11 +5,13 @@ import {
|
||||
faUser,
|
||||
faCog,
|
||||
faVolumeHigh,
|
||||
faCircleInfo,
|
||||
} from "@fortawesome/pro-solid-svg-icons";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { MiscSettingsPane } from "./panes/MiscSettingsPane";
|
||||
import { AudioSettingsPane } from "./panes/AudioSettingsPane";
|
||||
import { AccountSettingsPane } from "./panes/AccountSettings/AccountSettingsPane";
|
||||
import { AboutSettingsPane } from "./panes/AboutSettingsPane";
|
||||
|
||||
interface SettingsModalProps {
|
||||
isOpen: boolean;
|
||||
@@ -18,7 +20,7 @@ interface SettingsModalProps {
|
||||
}
|
||||
|
||||
//type SettingsSection = "misc" | "audio" | "accounts" | "video" | "image";
|
||||
type SettingsSection = "general" | "accounts" | "alerts";
|
||||
type SettingsSection = "general" | "accounts" | "alerts" | "about";
|
||||
|
||||
export const SettingsModal = ({ isOpen, onClose, globalAccountLogoutCallback }: SettingsModalProps) => {
|
||||
const [selectedSection, setSelectedSection] =
|
||||
@@ -28,6 +30,7 @@ export const SettingsModal = ({ isOpen, onClose, globalAccountLogoutCallback }:
|
||||
{ id: "general" as const, label: "General", icon: faCog },
|
||||
{ id: "accounts" as const, label: "Accounts", icon: faUser },
|
||||
{ id: "alerts" as const, label: "Alerts", icon: faVolumeHigh },
|
||||
{ id: "about" as const, label: "About", icon: faCircleInfo},
|
||||
//{ id: "video" as const, label: "Video", icon: faVideo },
|
||||
//{ id: "image" as const, label: "Image", icon: faImage },
|
||||
];
|
||||
@@ -40,14 +43,8 @@ export const SettingsModal = ({ isOpen, onClose, globalAccountLogoutCallback }:
|
||||
return <MiscSettingsPane />;
|
||||
case "accounts":
|
||||
return <AccountSettingsPane globalAccountLogoutCallback={globalAccountLogoutCallback} />;
|
||||
//case "video":
|
||||
// return <VideoSettingsPane />;
|
||||
//case "image":
|
||||
// return (
|
||||
// <div>
|
||||
// <button className="text-blue-600">Various Image Settings...</button>
|
||||
// </div>
|
||||
// );
|
||||
case "about":
|
||||
return <AboutSettingsPane />;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,3 +10,4 @@ export * from "./lib/sora/CheckSoraSession.js";
|
||||
export * from "./lib/sora/LogoutSoraSession.js";
|
||||
export * from "./lib/sora/SoraImageRemix.js";
|
||||
export * from "./lib/sora/useSoraLoginListener.js";
|
||||
export * from "./lib/system/GetBuildInfo.js";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { CommandResult } from "../common/CommandStatus";
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { CommandResult } from "../common/CommandStatus";
|
||||
|
||||
export interface GetBuildInfoSuccess extends CommandResult {
|
||||
payload: GetBuildInfoPayload;
|
||||
}
|
||||
|
||||
export interface GetBuildInfoPayload {
|
||||
build_timestamp: string;
|
||||
git_commit_id?: string | null;
|
||||
git_commit_short_id?: string | null;
|
||||
git_commit_timestamp?: string | null;
|
||||
}
|
||||
|
||||
// Returns the Success and Error variants directly.
|
||||
// Throws on Network/Tauri errors.
|
||||
export const GetBuildInfo = async () : Promise<GetBuildInfoSuccess> => {
|
||||
try {
|
||||
return await invoke("get_build_info_command") as GetBuildInfoSuccess;
|
||||
} catch (error) {
|
||||
// NB: Endpoint should be infalliable
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user