parent
e836c4264a
commit
de42499444
|
@ -1,43 +0,0 @@
|
|||
pipeline {
|
||||
agent any
|
||||
environment {
|
||||
OUTPUT_DIR = "${env.BRANCH_NAME == "main" ? "plate-tool" : "plate-tool-beta"}"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh '''
|
||||
. "$HOME/.cargo/env"
|
||||
trunk build --release --public-url "cool-stuff/$OUTPUT_DIR/"
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Archive') {
|
||||
steps {
|
||||
zip zipFile: "dist.zip", archive: true, dir: "dist/"
|
||||
archiveArtifacts artifacts: "dist.zip", fingerprint: true
|
||||
}
|
||||
}
|
||||
stage('Transfer') {
|
||||
steps {
|
||||
sh 'echo "put -r dist/" | sftp oracle'
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
sh '''
|
||||
ssh oracle "sudo rm -rf /usr/share/nginx/html/$OUTPUT_DIR/ && sudo mv dist /usr/share/nginx/html/$OUTPUT_DIR"
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs(notFailBuild: true,
|
||||
deleteDirs: true,
|
||||
cleanWhenNotBuilt: false,
|
||||
patterns: [[pattern: 'target/', type: 'EXCLUDE']])
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,3 +35,16 @@ dialog > form[method="dialog"] {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.close_button {
|
||||
color: red;
|
||||
position: absolute;
|
||||
top: 5%;
|
||||
right: 2%;
|
||||
background: rgba(0%,0%,0%,10%);
|
||||
|
||||
&:hover {
|
||||
color: rgb(0%,100%,100%);
|
||||
background: rgba(0%,0%,0%,80%);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ use lazy_static::lazy_static;
|
|||
use regex::Regex;
|
||||
use wasm_bindgen::{prelude::*, JsCast, JsValue};
|
||||
use web_sys::{
|
||||
Blob, FileReader, HtmlAnchorElement, HtmlButtonElement, HtmlDialogElement, HtmlFormElement,
|
||||
HtmlInputElement, HtmlOptionElement, HtmlSelectElement, Url,
|
||||
Blob, FileReader, HtmlAnchorElement, HtmlButtonElement, HtmlDialogElement, HtmlElement,
|
||||
HtmlFormElement, HtmlInputElement, HtmlOptionElement, HtmlSelectElement, Url,
|
||||
};
|
||||
use yew::prelude::*;
|
||||
use yewdux::prelude::*;
|
||||
|
@ -22,6 +22,20 @@ use crate::data::csv::{state_to_csv, TransferRecord};
|
|||
|
||||
type NoParamsCallback = Box<dyn Fn(()) -> ()>;
|
||||
|
||||
fn create_close_button(close: &Closure<dyn FnMut(Event)>) -> HtmlElement {
|
||||
let document = web_sys::window().unwrap().document().unwrap();
|
||||
let close_button = document
|
||||
.create_element("button")
|
||||
.unwrap()
|
||||
.dyn_into::<HtmlElement>()
|
||||
.unwrap();
|
||||
close_button.set_text_content(Some("✖"));
|
||||
close_button.set_class_name("close_button");
|
||||
close_button.set_onclick(Some(close.as_ref().unchecked_ref()));
|
||||
|
||||
return close_button;
|
||||
}
|
||||
|
||||
pub fn toggle_in_transfer_hashes_callback(
|
||||
main_dispatch: Dispatch<MainState>,
|
||||
) -> Callback<web_sys::MouseEvent> {
|
||||
|
@ -169,7 +183,10 @@ pub fn import_json_button_callback(main_dispatch: Dispatch<MainState>) -> Callba
|
|||
})
|
||||
};
|
||||
modal.set_onclose(Some(onclose_callback.as_ref().unchecked_ref()));
|
||||
|
||||
let close_button = create_close_button(&onclose_callback);
|
||||
onclose_callback.forget();
|
||||
modal.append_child(&close_button).unwrap();
|
||||
|
||||
let form = document
|
||||
.create_element("form")
|
||||
|
@ -431,3 +448,55 @@ pub fn import_transfer_csv_input_callback(
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn import_transfer_csv_callback(main_dispatch: Dispatch<MainState>) -> Callback<MouseEvent> {
|
||||
Callback::from(move |_| {
|
||||
let window = web_sys::window().unwrap();
|
||||
let document = window.document().unwrap();
|
||||
let body = document.body().unwrap();
|
||||
let modal = document
|
||||
.create_element("dialog")
|
||||
.unwrap()
|
||||
.dyn_into::<HtmlDialogElement>()
|
||||
.unwrap();
|
||||
modal.set_text_content(Some("Import File:"));
|
||||
let onclose_callback = {
|
||||
let modal = modal.clone();
|
||||
Closure::<dyn FnMut(_)>::new(move |_: Event| {
|
||||
modal.remove();
|
||||
})
|
||||
};
|
||||
modal.set_onclose(Some(onclose_callback.as_ref().unchecked_ref()));
|
||||
|
||||
let close_button = create_close_button(&onclose_callback);
|
||||
onclose_callback.forget();
|
||||
modal.append_child(&close_button).unwrap();
|
||||
|
||||
let form = document
|
||||
.create_element("form")
|
||||
.unwrap()
|
||||
.dyn_into::<HtmlFormElement>()
|
||||
.unwrap();
|
||||
let input = document
|
||||
.create_element("input")
|
||||
.unwrap()
|
||||
.dyn_into::<HtmlInputElement>()
|
||||
.unwrap();
|
||||
input.set_type("file");
|
||||
input.set_accept(".csv");
|
||||
form.append_child(&input).unwrap();
|
||||
|
||||
let input_callback = {
|
||||
let main_dispatch = main_dispatch.clone();
|
||||
let modal = modal.clone();
|
||||
import_transfer_csv_input_callback(main_dispatch, modal)
|
||||
};
|
||||
input.set_onchange(Some(input_callback.as_ref().unchecked_ref()));
|
||||
input_callback.forget(); // Magic straight from the docs, don't touch :(
|
||||
|
||||
modal.append_child(&form).unwrap();
|
||||
body.append_child(&modal).unwrap();
|
||||
modal.show_modal().unwrap();
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -72,53 +72,8 @@ pub fn MainWindow() -> Html {
|
|||
main_window_callbacks::import_json_button_callback(main_dispatch)
|
||||
};
|
||||
|
||||
let import_transfer_csv_callback = {
|
||||
Callback::from(move |_| {
|
||||
let window = web_sys::window().unwrap();
|
||||
let document = window.document().unwrap();
|
||||
let body = document.body().unwrap();
|
||||
let modal = document
|
||||
.create_element("dialog")
|
||||
.unwrap()
|
||||
.dyn_into::<HtmlDialogElement>()
|
||||
.unwrap();
|
||||
modal.set_text_content(Some("Import File:"));
|
||||
let onclose_callback = {
|
||||
let modal = modal.clone();
|
||||
Closure::<dyn FnMut(_)>::new(move |_: Event| {
|
||||
modal.remove();
|
||||
})
|
||||
};
|
||||
modal.set_onclose(Some(onclose_callback.as_ref().unchecked_ref()));
|
||||
onclose_callback.forget();
|
||||
|
||||
let form = document
|
||||
.create_element("form")
|
||||
.unwrap()
|
||||
.dyn_into::<HtmlFormElement>()
|
||||
.unwrap();
|
||||
let input = document
|
||||
.create_element("input")
|
||||
.unwrap()
|
||||
.dyn_into::<HtmlInputElement>()
|
||||
.unwrap();
|
||||
input.set_type("file");
|
||||
input.set_accept(".csv");
|
||||
form.append_child(&input).unwrap();
|
||||
|
||||
let input_callback = {
|
||||
let main_dispatch = main_dispatch.clone();
|
||||
let modal = modal.clone();
|
||||
main_window_callbacks::import_transfer_csv_input_callback(main_dispatch, modal)
|
||||
};
|
||||
input.set_onchange(Some(input_callback.as_ref().unchecked_ref()));
|
||||
input_callback.forget(); // Magic straight from the docs, don't touch :(
|
||||
|
||||
modal.append_child(&form).unwrap();
|
||||
body.append_child(&modal).unwrap();
|
||||
modal.show_modal().unwrap();
|
||||
})
|
||||
};
|
||||
let import_transfer_csv_callback =
|
||||
main_window_callbacks::import_transfer_csv_callback(main_dispatch.clone());
|
||||
|
||||
html! {
|
||||
<>
|
||||
|
@ -163,22 +118,3 @@ pub fn MainWindow() -> Html {
|
|||
</>
|
||||
}
|
||||
}
|
||||
|
||||
fn save_str(data: &str, name: &str) {
|
||||
let blob =
|
||||
Blob::new_with_str_sequence(&Array::from_iter(std::iter::once(JsValue::from_str(data))));
|
||||
if let Ok(blob) = blob {
|
||||
let url = Url::create_object_url_with_blob(&blob).expect("We have a blob, why not URL?");
|
||||
// Beneath is the cool hack to download files
|
||||
let window = web_sys::window().unwrap();
|
||||
let document = window.document().unwrap();
|
||||
let anchor = document
|
||||
.create_element("a")
|
||||
.unwrap()
|
||||
.dyn_into::<HtmlAnchorElement>()
|
||||
.unwrap();
|
||||
anchor.set_download(name);
|
||||
anchor.set_href(&url);
|
||||
anchor.click();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue