Skip to content

Commit

Permalink
Merge pull request #28 from go-bazzinga/rupansh/profile-view
Browse files Browse the repository at this point in the history
feat: initial profile view
  • Loading branch information
rupansh-sekar-yral authored Jan 12, 2024
2 parents b1a7354 + 7fd8315 commit 622d295
Show file tree
Hide file tree
Showing 23 changed files with 1,082 additions and 71 deletions.
213 changes: 213 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ serde-wasm-bindgen = { version = "0.6.3" }
futures = "0.3.30"
leptos-use = "0.9.0"
reqwest = { version = "0.11.23", default-features = false }
serde_bytes = "0.11.14"
hex = "0.4.3"
leptos_icons = "0.2.0"
icondata = "0.3.0"

[build-dependencies]
candid_parser = "0.1.1"
Expand Down
101 changes: 101 additions & 0 deletions did/user_index.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
type CanisterInstallMode = variant { reinstall; upgrade; install };
type CanisterStatusResponse = record {
status : CanisterStatusType;
memory_size : nat;
cycles : nat;
settings : DefiniteCanisterSettings;
idle_cycles_burned_per_day : nat;
module_hash : opt vec nat8;
};
type CanisterStatusType = variant { stopped; stopping; running };
type DefiniteCanisterSettings = record {
freezing_threshold : nat;
controllers : vec principal;
memory_allocation : nat;
compute_allocation : nat;
};
type KnownPrincipalType = variant {
CanisterIdUserIndex;
CanisterIdConfiguration;
CanisterIdProjectMemberIndex;
CanisterIdTopicCacheIndex;
CanisterIdRootCanister;
CanisterIdDataBackup;
CanisterIdPostCache;
CanisterIdSNSController;
UserIdGlobalSuperAdmin;
};
type RejectionCode = variant {
NoError;
CanisterError;
SysTransient;
DestinationInvalid;
Unknown;
SysFatal;
CanisterReject;
};
type Result = variant {
Ok : record { CanisterStatusResponse };
Err : record { RejectionCode; text };
};
type Result_1 = variant { Ok; Err : SetUniqueUsernameError };
type SetUniqueUsernameError = variant {
UsernameAlreadyTaken;
SendingCanisterDoesNotMatchUserCanisterId;
UserCanisterEntryDoesNotExist;
};
type SystemTime = record {
nanos_since_epoch : nat32;
secs_since_epoch : nat64;
};
type UpgradeStatus = record {
version_number : nat64;
last_run_on : SystemTime;
failed_canister_ids : vec record { principal; principal; text };
successful_upgrade_count : nat32;
};
type UserAccessRole = variant {
CanisterController;
ProfileOwner;
CanisterAdmin;
ProjectCanister;
};
type UserIndexInitArgs = record {
known_principal_ids : opt vec record { KnownPrincipalType; principal };
access_control_map : opt vec record { principal; vec UserAccessRole };
};
service : (UserIndexInitArgs) -> {
backup_all_individual_user_canisters : () -> ();
get_index_details_is_user_name_taken : (text) -> (bool) query;
get_index_details_last_upgrade_status : () -> (UpgradeStatus) query;
get_requester_principals_canister_id_create_if_not_exists_and_optionally_allow_referrer : (
opt principal,
) -> (principal);
get_user_canister_id_from_unique_user_name : (text) -> (opt principal) query;
get_user_canister_id_from_user_principal_id : (principal) -> (
opt principal,
) query;
get_user_canister_status : (principal) -> (Result);
get_user_index_canister_count : () -> (nat64) query;
get_user_index_canister_cycle_balance : () -> (nat) query;
get_well_known_principal_value : (KnownPrincipalType) -> (
opt principal,
) query;
receive_data_from_backup_canister_and_restore_data_to_heap : (
principal,
principal,
text,
) -> ();
set_permission_to_upgrade_individual_canisters : (bool) -> (text);
start_upgrades_for_individual_canisters : () -> (text);
update_index_with_unique_user_name_corresponding_to_user_principal_id : (
text,
principal,
) -> (Result_1);
upgrade_specific_individual_user_canister_with_latest_wasm : (
principal,
principal,
opt CanisterInstallMode,
bool,
) -> (text);
}
3 changes: 2 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error_template::{AppError, ErrorTemplate},
page::{err::ServerErrorPage, post_view::PostView, root::RootPage},
page::{err::ServerErrorPage, post_view::PostView, profile::ProfileView, root::RootPage},
state::canisters::Canisters,
};
use leptos::*;
Expand Down Expand Up @@ -29,6 +29,7 @@ pub fn App() -> impl IntoView {
<Routes>
<Route path="/" view=RootPage/>
<Route path="/hot-or-not/:canister_id/:post_id" view=PostView/>
<Route path="/profile/:id" view=ProfileView/>
<Route path="/error" view=ServerErrorPage/>
</Routes>
</main>
Expand Down
1 change: 1 addition & 0 deletions src/canister/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Auto generated bindings for canisters
include!(concat!(env!("OUT_DIR"), "/did/mod.rs"));
pub mod utils;

pub const AGENT_URL: &str = "https://ic0.app";
11 changes: 11 additions & 0 deletions src/canister/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use std::fmt::Display;

use crate::consts::CF_STREAM_BASE;

pub fn bg_url(uid: impl Display) -> String {
format!("{CF_STREAM_BASE}/{uid}/thumbnails/thumbnail.jpg")
}

pub fn stream_url(uid: impl Display) -> String {
format!("{CF_STREAM_BASE}/{uid}/manifest/video.m3u8")
}
Loading

0 comments on commit 622d295

Please sign in to comment.