Skip to content

Commit

Permalink
New calendar page (#1096)
Browse files Browse the repository at this point in the history
* feat(frontend): new (mostly) empty calendar page

* frontend(website): add new dayjs plugin

* feat(frontend): generate new layout for calendar

* chore(utils): use correct spelling

* refactor(backend): change order of arguments

* chore(backend): remove all moka stuff

* chore(frontend): change paddings

* chore(website): add ids to sections in features page

* chore(frontend): do not automatically refresh metadata details

* feat(frontend): start with new calendar page

* feat(frontend): display total number of events in the calendar

* feat(frontend): get basic new calendar working

* feat(frontend): finish up new calendar page

* chore(frontend): remove old calendar and use new one

* fix(frontend): show left label in calendar

* chore(frontend): remove useless dayjs plugin

* fix(frontend): show toast when password is too short

* chore(frontend): remove useless invariant calls

* fix(backend): select correct field types for monitored entities

* feat(frontend): deploy job to update entity if it is partial in loader
  • Loading branch information
IgnisDa authored Nov 5, 2024
1 parent e75f765 commit 4e11d89
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 317 deletions.
102 changes: 0 additions & 102 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ itertools = "=0.13.0"
futures = "=0.3.31"
hashbag = "=0.1.12"
markdown = "=1.0.0-alpha.21"
moka = { version = "=0.12.8", features = ["future"] }
nanoid = "=0.4.0"
openidconnect = "=3.5.0"
regex = "=1.11.1"
Expand Down
1 change: 0 additions & 1 deletion apps/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ integration-service = { path = "../../crates/services/integration" }
itertools = { workspace = true }
logs-wheel = "=0.3.1"
media-models = { path = "../../crates/models/media" }
moka = { workspace = true }
migrations = { path = "../../crates/migrations" }
miscellaneous-resolver = { path = "../../crates/resolvers/miscellaneous" }
miscellaneous-service = { path = "../../crates/services/miscellaneous" }
Expand Down
12 changes: 3 additions & 9 deletions apps/backend/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use axum::{
};
use background::{ApplicationJob, CoreApplicationJob};
use cache_service::CacheService;
use chrono::Duration;
use collection_resolver::{CollectionMutation, CollectionQuery};
use collection_service::CollectionService;
use common_utils::{ryot_log, FRONTEND_OAUTH_ENDPOINT};
Expand All @@ -28,7 +27,6 @@ use integration_service::IntegrationService;
use itertools::Itertools;
use miscellaneous_resolver::{MiscellaneousMutation, MiscellaneousQuery};
use miscellaneous_service::MiscellaneousService;
use moka::future::Cache;
use openidconnect::{
core::{CoreClient, CoreProviderMetadata},
reqwest::async_http_client,
Expand All @@ -48,13 +46,13 @@ use user_service::UserService;

/// All the services that are used by the app
pub struct AppServices {
pub miscellaneous_service: Arc<MiscellaneousService>,
pub app_router: Router,
pub importer_service: Arc<ImporterService>,
pub exporter_service: Arc<ExporterService>,
pub exercise_service: Arc<ExerciseService>,
pub integration_service: Arc<IntegrationService>,
pub statistics_service: Arc<StatisticsService>,
pub app_router: Router,
pub integration_service: Arc<IntegrationService>,
pub miscellaneous_service: Arc<MiscellaneousService>,
}

#[allow(clippy::too_many_arguments)]
Expand All @@ -73,9 +71,6 @@ pub async fn create_app_services(
config.file_storage.s3_bucket_name.clone(),
));
let cache_service = CacheService::new(&db);
let commit_cache = Cache::builder()
.time_to_live(Duration::try_hours(1).unwrap().to_std().unwrap())
.build();
let supporting_service = Arc::new(
SupportingService::new(
is_pro,
Expand All @@ -84,7 +79,6 @@ pub async fn create_app_services(
cache_service,
config.clone(),
oidc_client,
commit_cache,
file_storage_service.clone(),
perform_application_job,
perform_core_application_job,
Expand Down
83 changes: 2 additions & 81 deletions apps/frontend/app/components/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,12 @@ import {
rem,
} from "@mantine/core";
import { useDebouncedValue, useDidUpdate, useDisclosure } from "@mantine/hooks";
import { Form, Link, useFetcher, useNavigate } from "@remix-run/react";
import {
Form,
Link,
useFetcher,
useNavigate,
useRevalidator,
} from "@remix-run/react";
import {
DeployUpdateMetadataGroupJobDocument,
DeployUpdateMetadataJobDocument,
DeployUpdatePersonJobDocument,
EntityLot,
GridPacking,
type MediaLot,
type MediaSource,
MetadataDetailsDocument,
MetadataGroupDetailsDocument,
PersonDetailsDocument,
type ReviewItem,
UserReviewScale,
} from "@ryot/generated/graphql/backend/graphql";
Expand All @@ -71,7 +59,6 @@ import {
IconTrash,
IconX,
} from "@tabler/icons-react";
import { useMutation, useQuery } from "@tanstack/react-query";
import Cookies from "js-cookie";
import type { ReactNode, Ref } from "react";
import { useState } from "react";
Expand All @@ -82,7 +69,6 @@ import { withQuery } from "ufo";
import {
PRO_REQUIRED_MESSAGE,
ThreePointSmileyRating,
clientGqlService,
convertDecimalToThreePointSmiley,
dayjsLib,
getSurroundingElements,
Expand Down Expand Up @@ -132,81 +118,16 @@ export const ApplicationGrid = (props: {
};

export const MediaDetailsLayout = (props: {
children: Array<ReactNode | (ReactNode | undefined)>;
images: Array<string | null | undefined>;
entityDetails: { id: string; lot: EntityLot; isPartial?: boolean | null };
children: Array<ReactNode | (ReactNode | undefined)>;
externalLink?: {
source: MediaSource;
lot?: MediaLot;
href?: string | null;
};
}) => {
const revalidator = useRevalidator();
const [activeImageId, setActiveImageId] = useState(0);
const fallbackImageUrl = useFallbackImageUrl();
const [mutationHasRunOnce, setMutationHasRunOnce] = useState(false);
const entityIsPartial = useQuery({
queryKey: ["MediaDetailsLayout", "entityIsPartial", props.entityDetails],
queryFn: async () => {
const isPartial = await match(props.entityDetails.lot)
.with(EntityLot.Metadata, () =>
clientGqlService
.request(MetadataDetailsDocument, {
metadataId: props.entityDetails.id,
})
.then((data) => data.metadataDetails.isPartial),
)
.with(EntityLot.Person, () =>
clientGqlService
.request(PersonDetailsDocument, {
personId: props.entityDetails.id,
})
.then((data) => data.personDetails.details.isPartial),
)
.with(EntityLot.MetadataGroup, () =>
clientGqlService
.request(MetadataGroupDetailsDocument, {
metadataGroupId: props.entityDetails.id,
})
.then((data) => data.metadataGroupDetails.details.isPartial),
)
.run();
return isPartial;
},
refetchInterval: (query) =>
query.state.data
? dayjsLib.duration(2, "seconds").asMilliseconds()
: false,
enabled: props.entityDetails.isPartial === true,
});
const commitEntity = useMutation({
mutationFn: async () =>
match(props.entityDetails.lot)
.with(EntityLot.Metadata, () =>
clientGqlService.request(DeployUpdateMetadataJobDocument, {
metadataId: props.entityDetails.id,
}),
)
.with(EntityLot.MetadataGroup, () =>
clientGqlService.request(DeployUpdateMetadataGroupJobDocument, {
metadataGroupId: props.entityDetails.id,
}),
)
.with(EntityLot.Person, () =>
clientGqlService.request(DeployUpdatePersonJobDocument, {
personId: props.entityDetails.id,
}),
)
.run(),
onSuccess: () => {
setMutationHasRunOnce(true);
setTimeout(() => revalidator.revalidate(), 5000);
},
});

useDidUpdate(() => {
if (entityIsPartial.data && !mutationHasRunOnce) commitEntity.mutate();
}, [entityIsPartial]);

return (
<Flex direction={{ base: "column", md: "row" }} gap="lg">
Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/app/lib/generals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ declare global {
}
}

dayjs.extend(relativeTime);
dayjs.extend(duration);
dayjs.extend(localizedFormat);
dayjs.extend(utc);
dayjs.extend(duration);
dayjs.extend(timezone);
dayjs.extend(relativeTime);
dayjs.extend(localizedFormat);

export { dayjs as dayjsLib };

Expand Down
Loading

0 comments on commit 4e11d89

Please sign in to comment.