FINAL BEFORE SUBMITION :(
This commit is contained in:
@@ -616,12 +616,12 @@ function getImports() {
|
|||||||
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
||||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper3831 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper3975 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 267, __wbg_adapter_18);
|
const ret = makeMutClosure(arg0, arg1, 302, __wbg_adapter_18);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper6495 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper6639 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 294, __wbg_adapter_21);
|
const ret = makeMutClosure(arg0, arg1, 329, __wbg_adapter_21);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -659,7 +659,7 @@ function initSync(module) {
|
|||||||
|
|
||||||
async function init(input) {
|
async function init(input) {
|
||||||
if (typeof input === 'undefined') {
|
if (typeof input === 'undefined') {
|
||||||
input = new URL('db-frontend-26b4e8491c3f6360_bg.wasm', import.meta.url);
|
input = new URL('db-frontend-12bfbd74b2a545ed_bg.wasm', import.meta.url);
|
||||||
}
|
}
|
||||||
const imports = getImports();
|
const imports = getImports();
|
||||||
|
|
||||||
BIN
frontend/dist/db-frontend-12bfbd74b2a545ed_bg.wasm
vendored
Normal file
BIN
frontend/dist/db-frontend-12bfbd74b2a545ed_bg.wasm
vendored
Normal file
Binary file not shown.
BIN
frontend/dist/db-frontend-26b4e8491c3f6360_bg.wasm
vendored
BIN
frontend/dist/db-frontend-26b4e8491c3f6360_bg.wasm
vendored
Binary file not shown.
6
frontend/dist/index.html
vendored
6
frontend/dist/index.html
vendored
@@ -2,10 +2,10 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Ze greatest</title>
|
<title>Ze greatest</title>
|
||||||
|
|
||||||
<link rel="preload" href="/db-frontend-26b4e8491c3f6360_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
|
<link rel="preload" href="/db-frontend-12bfbd74b2a545ed_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
|
||||||
<link rel="modulepreload" href="/db-frontend-26b4e8491c3f6360.js"></head>
|
<link rel="modulepreload" href="/db-frontend-12bfbd74b2a545ed.js"></head>
|
||||||
<body>
|
<body>
|
||||||
<script type="module">import init from '/db-frontend-26b4e8491c3f6360.js';init('/db-frontend-26b4e8491c3f6360_bg.wasm');</script><script>(function () {
|
<script type="module">import init from '/db-frontend-12bfbd74b2a545ed.js';init('/db-frontend-12bfbd74b2a545ed_bg.wasm');</script><script>(function () {
|
||||||
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
var url = protocol + '//' + window.location.host + '/_trunk/ws';
|
var url = protocol + '//' + window.location.host + '/_trunk/ws';
|
||||||
var poll_interval = 5000;
|
var poll_interval = 5000;
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ impl UseAble for CommonAdmin {
|
|||||||
|
|
||||||
//Wwasm bingdengen code
|
//Wwasm bingdengen code
|
||||||
const DRIVER_URL: &str = "http://db.sewelam.tech/api/driver/50";
|
const DRIVER_URL: &str = "http://db.sewelam.tech/api/driver/50";
|
||||||
const ADMIN_URL: &str = "http://db.sewelam.tech/api/admin/";
|
const ADMIN_URL: &str = "http://db.sewelam.tech/api/admin/69422";
|
||||||
const TICKET_URL: &str = "http://db.sewelam.tech/api/ticket/";
|
const TICKET_URL: &str = "http://db.sewelam.tech/api/ticket/32";
|
||||||
const FUNNY_TXT_URL: &str = "https://whatthecommit.com/index.txt";
|
const FUNNY_TXT_URL: &str = "https://whatthecommit.com/index.txt";
|
||||||
const INCORRECT_URL: &str = "http://libkyy.cf";
|
const INCORRECT_URL: &str = "http://libkyy.cf";
|
||||||
//Generic Msg for our states
|
//Generic Msg for our states
|
||||||
@@ -58,29 +58,31 @@ pub enum Msg<T> {
|
|||||||
GetData,
|
GetData,
|
||||||
GetError,
|
GetError,
|
||||||
}
|
}
|
||||||
pub struct RandomCommit {
|
pub struct TextRequestComponent {
|
||||||
commit: FetchState<String>,
|
text_request: FetchState<String>,
|
||||||
}
|
}
|
||||||
//This trait is for all yew components
|
//This trait is for all yew components
|
||||||
impl Component for RandomCommit {
|
impl Component for TextRequestComponent {
|
||||||
type Message = Msg<String>;
|
type Message = Msg<String>;
|
||||||
type Properties = ();
|
type Properties = ();
|
||||||
fn create(_ctx: &Context<Self>) -> Self {
|
fn create(_ctx: &Context<Self>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
commit: FetchState::NotFetching, //Default state is not fetching anything
|
text_request: FetchState::NotFetching, //Default state is not fetching anything
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
|
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
|
||||||
match msg {
|
match msg {
|
||||||
Msg::SetDataFetchState(fetch_state) => {
|
Msg::SetDataFetchState(fetch_state) => {
|
||||||
self.commit = fetch_state;
|
self.text_request = fetch_state;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Msg::GetData => {
|
Msg::GetData => {
|
||||||
ctx.link().send_future(async {
|
ctx.link().send_future(async {
|
||||||
match fetch_url_text(FUNNY_TXT_URL).await {
|
match fetch_url_text(TICKET_URL).await {
|
||||||
Ok(commit) => Msg::SetDataFetchState(FetchState::Success(commit)),
|
Ok(text_request) => {
|
||||||
|
Msg::SetDataFetchState(FetchState::Success(text_request))
|
||||||
|
}
|
||||||
Err(err) => Msg::SetDataFetchState(FetchState::Failed(err)),
|
Err(err) => Msg::SetDataFetchState(FetchState::Failed(err)),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -90,8 +92,10 @@ impl Component for RandomCommit {
|
|||||||
}
|
}
|
||||||
Msg::GetError => {
|
Msg::GetError => {
|
||||||
ctx.link().send_future(async {
|
ctx.link().send_future(async {
|
||||||
match fetch_url_text(INCORRECT_URL).await {
|
match fetch_url_text(ADMIN_URL).await {
|
||||||
Ok(commit) => Msg::SetDataFetchState(FetchState::Success(commit)),
|
Ok(text_request) => {
|
||||||
|
Msg::SetDataFetchState(FetchState::Success(text_request))
|
||||||
|
}
|
||||||
Err(err) => Msg::SetDataFetchState(FetchState::Failed(err)),
|
Err(err) => Msg::SetDataFetchState(FetchState::Failed(err)),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -103,11 +107,14 @@ impl Component for RandomCommit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn view(&self, ctx: &Context<Self>) -> Html {
|
fn view(&self, ctx: &Context<Self>) -> Html {
|
||||||
match &self.commit {
|
match &self.text_request {
|
||||||
FetchState::NotFetching => html! {
|
FetchState::NotFetching => html! {
|
||||||
<>
|
<>
|
||||||
<button onclick={ctx.link().callback(|_| Msg::GetData)}>
|
<button onclick={ctx.link().callback(|_| Msg::GetData)}>
|
||||||
{ "Get commit msg" }
|
{ "Get Example Ticket" }
|
||||||
|
</button>
|
||||||
|
<button onclick={ctx.link().callback(|_| Msg::GetError)}>
|
||||||
|
{ "Get Example Admin " }
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
},
|
},
|
||||||
@@ -240,3 +247,5 @@ async fn fetch_url_text(url: &'static str) -> Result<String, FetchError> {
|
|||||||
let text = JsFuture::from(resp.text()?).await?;
|
let text = JsFuture::from(resp.text()?).await?;
|
||||||
Ok(text.as_string().unwrap())
|
Ok(text.as_string().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Admin component
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
mod fetching;
|
mod fetching;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
use crate::fetching::DriverComponent;
|
use crate::fetching::{DriverComponent, TextRequestComponent};
|
||||||
|
|
||||||
#[function_component]
|
#[function_component]
|
||||||
fn App() -> Html {
|
fn App() -> Html {
|
||||||
let entered_id = 50;
|
let entered_id = 50;
|
||||||
html! {
|
html! {
|
||||||
<div>
|
<div>
|
||||||
<h2> {"Better?"} </h2>
|
<h1> {"API response examples"} </h1>
|
||||||
|
<h2> {"Drivers"} </h2>
|
||||||
<DriverComponent {entered_id}/>
|
<DriverComponent {entered_id}/>
|
||||||
|
<h2> {"Admins and Tickets" } </h2>
|
||||||
|
<TextRequestComponent/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ async fn api_admin(id: web::Path<i32>) -> impl Responder {
|
|||||||
"Content-Type, Content-Length, User-Agent, X-Requested-With, Range, DNT ",
|
"Content-Type, Content-Length, User-Agent, X-Requested-With, Range, DNT ",
|
||||||
))
|
))
|
||||||
.body(format!(
|
.body(format!(
|
||||||
"Admin ID: {}, Admin Name: {}, Admin Email: {}",
|
"Admin ID: {}, Admin Name: {}, Admin Address: {}",
|
||||||
fetched_admin_data.id, fetched_admin_data.name, fetched_admin_data.address
|
fetched_admin_data.id, fetched_admin_data.name, fetched_admin_data.address
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ async fn api_driver(id: web::Path<i32>) -> impl Responder {
|
|||||||
"Content-Type, Content-Length, User-Agent, X-Requested-With, Range, DNT ",
|
"Content-Type, Content-Length, User-Agent, X-Requested-With, Range, DNT ",
|
||||||
))
|
))
|
||||||
.body(format!(
|
.body(format!(
|
||||||
"Driver ID: {}, Driver Name: {}, Driver Email: {}",
|
"Driver ID: {}, Driver Name: {}, Driver Address: {}",
|
||||||
fetched_driver_data.id, fetched_driver_data.name, fetched_driver_data.address
|
fetched_driver_data.id, fetched_driver_data.name, fetched_driver_data.address
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user