market and gui patches

This commit is contained in:
creating2morrow 2023-06-10 04:17:41 -04:00
parent e245c1d160
commit 543f2befde
11 changed files with 82 additions and 2 deletions

View file

@ -1209,6 +1209,7 @@ dependencies = [
"hex", "hex",
"hmac", "hmac",
"jwt", "jwt",
"lazy_static 1.4.0",
"lmdb-rs", "lmdb-rs",
"log 0.4.17", "log 0.4.17",
"rand", "rand",

View file

@ -1209,6 +1209,7 @@ dependencies = [
"hex", "hex",
"hmac", "hmac",
"jwt", "jwt",
"lazy_static 1.4.0",
"lmdb-rs", "lmdb-rs",
"log 0.4.17", "log 0.4.17",
"rand", "rand",

View file

@ -1199,6 +1199,7 @@ dependencies = [
"hex", "hex",
"hmac", "hmac",
"jwt", "jwt",
"lazy_static 1.4.0",
"lmdb-rs", "lmdb-rs",
"log 0.4.17", "log 0.4.17",
"rand", "rand",

View file

@ -1225,3 +1225,16 @@ impl Default for FinalizeOrderResponse {
} }
} }
} }
/// Response for the vendor mode
#[derive(Serialize, Deserialize, Debug)]
#[serde(crate = "rocket::serde")]
pub struct VendorModeResponse {
pub mode: bool,
}
impl Default for VendorModeResponse {
fn default() -> Self {
VendorModeResponse { mode: false }
}
}

View file

@ -212,7 +212,7 @@ pub fn get_app_contact_port() -> u16 {
args.contact_port args.contact_port
} }
/// app message port /// app market port
pub fn get_app_market_port() -> u16 { pub fn get_app_market_port() -> u16 {
let args = args::Args::parse(); let args = args::Args::parse();
args.marketplace_port args.marketplace_port
@ -417,7 +417,7 @@ fn start_micro_servers() {
.expect("failed to start contact server"); .expect("failed to start contact server");
debug!("{:?}", c_output.stdout); debug!("{:?}", c_output.stdout);
info!("starting marketplace admin server"); info!("starting marketplace admin server");
let mut market_path = "neveko-contact/target/debug/neveko_market"; let mut market_path = "neveko-market/target/debug/neveko_market";
if env == ReleaseEnvironment::Production { if env == ReleaseEnvironment::Production {
market_path = "neveko_market"; market_path = "neveko_market";
} }

View file

@ -2,7 +2,9 @@
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
use eframe::egui; use eframe::egui;
use image::Luma;
use neveko_core::*; use neveko_core::*;
use qrcode::QrCode;
use std::{ use std::{
sync::mpsc::{ sync::mpsc::{
Receiver, Receiver,
@ -23,8 +25,10 @@ pub struct HomeApp {
is_editing_connections: bool, is_editing_connections: bool,
is_init: bool, is_init: bool,
is_installing: bool, is_installing: bool,
is_qr_set: bool,
is_loading: bool, is_loading: bool,
is_timeout: bool, is_timeout: bool,
is_showing_qr: bool,
is_updated: bool, is_updated: bool,
// Sender/Receiver for async notifications. // Sender/Receiver for async notifications.
i2p_status_tx: Sender<i2p::ProxyStatus>, i2p_status_tx: Sender<i2p::ProxyStatus>,
@ -39,6 +43,7 @@ pub struct HomeApp {
xmr_rpc_ver_rx: Receiver<reqres::XmrRpcVersionResponse>, xmr_rpc_ver_rx: Receiver<reqres::XmrRpcVersionResponse>,
can_refresh_tx: Sender<bool>, can_refresh_tx: Sender<bool>,
can_refresh_rx: Receiver<bool>, can_refresh_rx: Receiver<bool>,
pub qr: egui_extras::RetainedImage,
// application state set // application state set
s_xmr_address: reqres::XmrRpcAddressResponse, s_xmr_address: reqres::XmrRpcAddressResponse,
s_xmr_balance: reqres::XmrRpcBalanceResponse, s_xmr_balance: reqres::XmrRpcBalanceResponse,
@ -61,6 +66,8 @@ impl Default for HomeApp {
let is_init = true; let is_init = true;
let is_installing = false; let is_installing = false;
let is_loading = false; let is_loading = false;
let is_qr_set = false;
let is_showing_qr = false;
let is_timeout = false; let is_timeout = false;
let is_updated = false; let is_updated = false;
let (core_timeout_tx, core_timeout_rx) = std::sync::mpsc::channel(); let (core_timeout_tx, core_timeout_rx) = std::sync::mpsc::channel();
@ -71,6 +78,7 @@ impl Default for HomeApp {
let (can_refresh_tx, can_refresh_rx) = std::sync::mpsc::channel(); let (can_refresh_tx, can_refresh_rx) = std::sync::mpsc::channel();
let (i2p_status_tx, i2p_status_rx) = std::sync::mpsc::channel(); let (i2p_status_tx, i2p_status_rx) = std::sync::mpsc::channel();
let (installation_tx, installation_rx) = std::sync::mpsc::channel(); let (installation_tx, installation_rx) = std::sync::mpsc::channel();
let contents = std::fs::read("./assets/qr.png").unwrap_or(Vec::new());
let s_xmr_rpc_ver = Default::default(); let s_xmr_rpc_ver = Default::default();
let s_xmr_address = Default::default(); let s_xmr_address = Default::default();
let s_xmr_balance = Default::default(); let s_xmr_balance = Default::default();
@ -96,6 +104,8 @@ impl Default for HomeApp {
is_init, is_init,
is_installing, is_installing,
is_loading, is_loading,
is_qr_set,
is_showing_qr,
is_timeout, is_timeout,
is_updated, is_updated,
xmrd_get_info_tx, xmrd_get_info_tx,
@ -110,6 +120,7 @@ impl Default for HomeApp {
i2p_status_rx, i2p_status_rx,
can_refresh_rx, can_refresh_rx,
can_refresh_tx, can_refresh_tx,
qr: egui_extras::RetainedImage::from_image_bytes("qr.png", &contents).unwrap(),
// state of self defaults // state of self defaults
s_xmr_address, s_xmr_address,
s_xmr_balance, s_xmr_balance,
@ -161,6 +172,38 @@ impl eframe::App for HomeApp {
} }
} }
// I2P Address QR
//-----------------------------------------------------------------------------------
let mut is_showing_qr = self.is_showing_qr;
egui::Window::new("")
.open(&mut is_showing_qr)
.vscroll(true)
.show(ctx, |ui| {
let mut i2p_address = i2p::get_destination(None);
if !self.is_qr_set && i2p_address != utils::empty_string() {
let code = QrCode::new(&i2p_address).unwrap();
let image = code.render::<Luma<u8>>().build();
let file_path = format!(
"/home/{}/.neveko/i2p-qr.png",
std::env::var("USER").unwrap_or(String::from("user"))
);
image.save(&file_path).unwrap();
self.is_qr_set = true;
let contents = std::fs::read(&file_path).unwrap_or(Vec::new());
self.qr = egui_extras::RetainedImage::from_image_bytes("i2p-qr.png", &contents)
.unwrap();
ctx.request_repaint();
}
self.qr.show(ui);
let address_label = ui.label("copy: \t");
ui.text_edit_singleline(&mut i2p_address)
.labelled_by(address_label.id);
ui.label("\n");
if ui.button("Exit").clicked() {
self.is_showing_qr = false;
}
});
// Installation Error window // Installation Error window
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
let mut has_install_failed = self.has_install_failed; let mut has_install_failed = self.has_install_failed;
@ -302,6 +345,11 @@ impl eframe::App for HomeApp {
ui.label(format!("- status: {}\n- address: {}", str_i2p_status, i2p_address)); ui.label(format!("- status: {}\n- address: {}", str_i2p_status, i2p_address));
}); });
}); });
ui.horizontal(|ui| {
if ui.button("Show QR").clicked() {
self.is_showing_qr = true;
}
});
ui.label("____________________________________________________________________\n"); ui.label("____________________________________________________________________\n");
ui.label("\n\n"); ui.label("\n\n");
ui.horizontal(|ui| { ui.horizontal(|ui| {

View file

@ -98,6 +98,10 @@ impl eframe::App for WalletApp {
ctx.request_repaint(); ctx.request_repaint();
} }
self.qr.show(ui); self.qr.show(ui);
let address_label = ui.label("copy: \t");
ui.text_edit_singleline(&mut self.s_xmr_address)
.labelled_by(address_label.id);
ui.label("\n");
if ui.button("Exit").clicked() { if ui.button("Exit").clicked() {
self.is_showing_qr = false; self.is_showing_qr = false;
} }

View file

@ -1248,6 +1248,7 @@ dependencies = [
"hex", "hex",
"hmac", "hmac",
"jwt", "jwt",
"lazy_static 1.4.0",
"lmdb-rs", "lmdb-rs",
"log 0.4.17", "log 0.4.17",
"rand", "rand",

View file

@ -99,4 +99,13 @@ pub async fn sign_and_submit_multisig(
} }
Custom(Status::Ok, Json(Default::default())) Custom(Status::Ok, Json(Default::default()))
} }
/// toggle vendor mode
#[get("/")]
pub async fn toggle_vendor_mode(
_token: auth::BearerToken,
) -> Custom<Json<reqres::VendorModeResponse>> {
let mode = utils::toggle_vendor_enabled();
Custom(Status::Ok, Json(reqres::VendorModeResponse { mode }))
}
// END JSON APIs // END JSON APIs

View file

@ -37,4 +37,5 @@ async fn rocket() -> _ {
controller::update_product controller::update_product
], ],
) )
.mount("/vendor/mode", routes![controller::toggle_vendor_mode])
} }

View file

@ -1199,6 +1199,7 @@ dependencies = [
"hex", "hex",
"hmac", "hmac",
"jwt", "jwt",
"lazy_static 1.4.0",
"lmdb-rs", "lmdb-rs",
"log 0.4.17", "log 0.4.17",
"rand", "rand",