Skip to content

Commit d3f7f37

Browse files
committed
Integrating the scaffoldvuer as a view.
1 parent dcaaa96 commit d3f7f37

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

pmrapp/src/view.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::str::FromStr;
55

66
use crate::error::AppError;
77

8+
use argon_sds_archive::ArgonSdsArchive;
89
use crate::view::cellml_codegen::CellMLCodegen;
910
use crate::view::cellml_math::CellMLMath;
1011
use crate::view::cellml_metadata::CellMLMetadata;
@@ -13,6 +14,7 @@ use crate::view::view::View;
1314

1415
#[derive(Debug, PartialEq)]
1516
pub enum EFView {
17+
ArgonSdsArchive,
1618
CellMLCodegen,
1719
CellMLMath,
1820
CellMLMetadata,
@@ -25,6 +27,7 @@ impl FromStr for EFView {
2527

2628
fn from_str(s: &str) -> Result<Self, Self::Err> {
2729
match s {
30+
"argon_sds_archive" => Ok(EFView::ArgonSdsArchive),
2831
"cellml_codegen" => Ok(EFView::CellMLCodegen),
2932
"cellml_math" => Ok(EFView::CellMLMath),
3033
"cellml_metadata" => Ok(EFView::CellMLMetadata),
@@ -44,6 +47,7 @@ impl std::fmt::Display for EFView {
4447
#[component]
4548
pub fn ExposureFileView(view_key: EFView) -> impl IntoView {
4649
match view_key {
50+
EFView::ArgonSdsArchive => view! { <ArgonSdsArchive/> }.into_any(),
4751
EFView::CellMLCodegen => view! { <CellMLCodegen/> }.into_any(),
4852
EFView::CellMLMath => view! { <CellMLMath/> }.into_any(),
4953
EFView::CellMLMetadata => view! { <CellMLMetadata/> }.into_any(),
@@ -52,6 +56,7 @@ pub fn ExposureFileView(view_key: EFView) -> impl IntoView {
5256
}
5357
}
5458

59+
mod argon_sds_archive;
5560
mod cellml_codegen;
5661
mod cellml_math;
5762
mod cellml_metadata;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use pmrcore::exposure::{ExposureFile, ExposureFileView};
2+
use crate::exposure::{
3+
api::read_safe_index_html,
4+
ViewPath,
5+
};
6+
use leptos::prelude::*;
7+
use leptos_meta::{Link, Script};
8+
9+
// TODO determine if this view module is the default main view for all
10+
// exposure files with regards to documentation for the file itself.
11+
// There may be multiple ways to render this so in effect under this
12+
// pmrplatform, views under a simple name is simply expecting some
13+
// "serialized" data that fits the particular view. In this case it
14+
// would be some index.html.
15+
16+
#[component]
17+
pub fn ArgonSdsArchive() -> impl IntoView {
18+
let ef = expect_context::<ExposureFile>();
19+
let efv = expect_context::<ExposureFileView>();
20+
let view_path = expect_context::<ViewPath>();
21+
22+
let url = format!(
23+
"/data/exposure/{}/{}/{}/{}",
24+
ef.exposure_id,
25+
ef.id,
26+
efv.view_key.as_ref().expect("this is inside a resolved view"),
27+
"derivative/Scaffold/scaffold_metadata.json",
28+
);
29+
30+
view! {
31+
<Script id="scaffoldvuer" src="https://unpkg.com/vue@2.6.10"/>
32+
// <Script id="scaffoldvuer" src="/pkg/scaffoldvuer-wc.umd.min.js"/>
33+
<Script id="scaffoldvuer" type_="module" src="https://unpkg.com/@abi-software/scaffoldvuer@1.6.2-wc/dist/scaffoldvuer-wc.js"/>
34+
<Link id="scaffoldvuer_stylesheet" href="https://unpkg.com/@abi-software/scaffoldvuer@1.6.2-wc/dist/style.css" rel="stylesheet"/>
35+
<h1>
36+
"Exposure "{ef.exposure_id}
37+
" - ExposureFile "{ef.workspace_file_path}
38+
</h1>
39+
<div id="ArgonSdsArchive">
40+
<div>
41+
<scaffoldvuer-wc url=url/>
42+
</div>
43+
</div>
44+
}
45+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
div#ArgonSdsArchive {
2+
height: 80vh;
3+
}
4+
5+
div#ArgonSdsArchive > div {
6+
height: 100%;
7+
z-index: 1000;
8+
position: relative;
9+
}

pmrapp/style/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@use '../node_modules/highlight.js/styles/github.min.css';
2+
@use "_argon_sds_archive";
23

34
body {
45
font-family: 'Arial', sans-serif;

0 commit comments

Comments
 (0)