-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f734aa
commit c9dde55
Showing
12 changed files
with
327 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use crate::{ | ||
auth::DelegatedIdentityWire, | ||
state::{canisters::Canisters, content_seed_client::ContentSeedClient}, | ||
}; | ||
use leptos::*; | ||
|
||
#[component] | ||
pub fn YoutubeUpload( | ||
canisters: Canisters<true>, | ||
#[prop(optional)] url: Option<String>, | ||
) -> impl IntoView { | ||
let response = RwSignal::new(String::new()); | ||
let url_value = RwSignal::new(String::new()); | ||
|
||
if let Some(val) = url { | ||
url_value.set_untracked(val); | ||
} | ||
|
||
let create_short_lived_delegated_identity = |canisters: &Canisters<true>| { | ||
let id = canisters.identity(); | ||
DelegatedIdentityWire::delegate_short_lived_identity(id) | ||
}; | ||
|
||
let on_submit = create_action(move |_| { | ||
let canisters_copy = canisters.clone(); | ||
async move { | ||
let delegated_identity = create_short_lived_delegated_identity(&canisters_copy); | ||
let content_seed_client: ContentSeedClient = expect_context(); | ||
let res = content_seed_client | ||
.upload_content(url_value(), delegated_identity) | ||
.await; | ||
match res { | ||
Err(e) => response.set(e.to_string()), | ||
_ => response.set("Submitted!".to_string()), | ||
}; | ||
} | ||
}); | ||
|
||
view! { | ||
{move || { | ||
view! { | ||
<div data-hk="1-0-0-3" class="flex h-full items-center justify-around p-4"> | ||
<div data-hk="1-0-0-4" class="flex flex-col items-center justify-center"> | ||
<div class="flex h-full flex-col justify-around gap-6"> | ||
<div class="flex basis-9/12 flex-col items-center justify-center"> | ||
<h1 data-hk="1-0-0-5" class="text-2xl md:text-3xl text-white"> | ||
VIDEO IMPORTER | ||
</h1> | ||
</div> | ||
<div class="flex basis-3/12 flex-col justify-around items-center gap-4"> | ||
<input | ||
type="text" | ||
value=move || url_value.get() | ||
on:input=move |ev| { | ||
let val = event_target_value(&ev); | ||
url_value.set(val); | ||
} | ||
|
||
placeholder=" Paste your link here" | ||
class="p-1 md:text-xl" | ||
/> | ||
<button | ||
type="submit" | ||
class="border border-solid px-4 text-xl md:text-2xl w-fit text-white hover:bg-white hover:text-black" | ||
on:click=move |_| on_submit.dispatch(()) | ||
> | ||
|
||
Submit | ||
</button> | ||
<p class="text-base md:text-lg text-white">{response()}</p> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
}} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.