这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions server/src/handlers/page_handler.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
use std::env;

use crate::{
data::models::{DatasetConfiguration, Pool, SearchMethod, SortOptions, TypoOptions, UnifiedId},
errors::ServiceError,
get_env,
operators::dataset_operator::get_dataset_by_id_query,
};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
use minijinja::context;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;

use crate::data::models::Templates;

use super::chunk_handler::{ChunkFilter, ScoringOptions};
use super::{
auth_handler::LoggedUser,
chunk_handler::{ChunkFilter, ScoringOptions},
};

#[derive(Serialize, Deserialize, Debug, Clone, ToSchema, Default)]
pub enum PublicPageTheme {
Expand Down Expand Up @@ -157,6 +162,7 @@ pub async fn public_page(
dataset_id: web::Path<uuid::Uuid>,
pool: web::Data<Pool>,
templates: Templates<'_>,
req: HttpRequest,
) -> Result<HttpResponse, ServiceError> {
let dataset_id = dataset_id.into_inner();

Expand All @@ -169,10 +175,16 @@ pub async fn public_page(
"Server hostname for OpenID provider must be set"
);

let logged_in = req.extensions().get::<LoggedUser>().is_some();
let dashboard_url =
env::var("ADMIN_DASHBOARD_URL").unwrap_or("https://dashboard.trieve.ai".to_string());

if config.PUBLIC_DATASET.enabled {
let templ = templates.get_template("page.html").unwrap();
let response_body = templ
.render(context! {
logged_in,
dashboard_url,
params => PublicPageParameters {
dataset_id: Some(dataset_id),
base_url: Some(base_server_url.to_string()),
Expand Down
41 changes: 37 additions & 4 deletions server/src/public/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
overflow: hidden;
font-family: 'Maven Pro', sans-serif;
line-height: 1.6;
margin: 2rem;
}

.basic {
position: relative;
display: flex;
position: relative;
align-items: center;
Expand All @@ -35,6 +32,35 @@
height: 100vh;
overflow: hidden;
}

.corner-logo {
max-width: 120px;
max-height: 80px;
position: fixed;
top: 0.8rem;
left: 0.8rem;
}

.dev-back-button {
background-color: #f5f5f5;
border-radius: 0.5rem;
border: 1px solid #e5e5e5;
color: black;
padding: 0.3rem;
font-size: 0.8rem;
position: fixed;
top: 0.5rem;
left: 0.5rem;
text-decoration: none;
}

.basic {
padding: 1rem;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
</style>

<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
Expand Down Expand Up @@ -93,6 +119,13 @@
</head>

<body>
{% if logged_in %}
<a class="dev-back-button" href="{{dashboard_url}}/dataset/{{params.datasetId}}/public-page">Back To Dashboard</a>
{% else %}
<a href="https://trieve.ai">
<img class="corner-logo" src="{{params.brandLogoImgSrcUrl|safe if (params.brandLogoImgSrcUrl is defined and params.brandLogoImgSrcUrl) else 'https://cdn.trieve.ai/trieve-logo.png'|safe}}"></img>
</a>
{% endif %}
<div class="basic">
<div id="root">
</div>
Expand Down