Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #27 from ruby-no-kai/track-card-editor
Browse files Browse the repository at this point in the history
better track card management
  • Loading branch information
sorah authored Aug 28, 2022
2 parents 12a846a + b067d46 commit 56bb314
Show file tree
Hide file tree
Showing 14 changed files with 594 additions and 103 deletions.
14 changes: 9 additions & 5 deletions app/controllers/api/control/track_cards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@ def index
.where('activation_at <= ?', ts)
.limit(10)
.order(activation_at: :desc)
.map(&:as_json)
else
cards = [
TrackCard.current_for(params[:track_slug])&.as_json,
*TrackCard.where(track: params[:track_slug]).candidate.map(&:as_json),
TrackCard.current_for(params[:track_slug]),
*TrackCard.where(track: params[:track_slug]).candidate.to_a,
]
end
render(json: {
track_cards: cards.compact,
track_cards: cards.compact.map { |_| _.as_json(control: true) },
})
end

def create
TrackCard.create!(track_card_params)
track_card = TrackCard.new(track_card_params)

now = Time.now
track_card.activation_at = now if track_card.activation_at < now

track_card.save!
EmitIvsMetadataJob.perform_now
render(json: {ok: true}.to_json)
end
Expand Down
8 changes: 4 additions & 4 deletions app/javascript/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export type Attendee = {
export type Conference = {
default_track: string;
track_order: TrackSlug[];
tracks: { [key: string]: Track };
tracks: { [key: TrackSlug]: Track };
};

export type TrackSlug = string;
Expand All @@ -329,11 +329,11 @@ export type Track = {
card: TrackCard | null;
card_candidate: TrackCard | null;
spotlights: ChatSpotlight[];
presences: { [key: string]: StreamPresence }; // key:kind
presences: { [key in TrackStreamKind]: StreamPresence }; // key:kind
viewerCount?: ViewerCount;
};

export interface TrackCard extends TrackCardHeader, TrackCardContent {}
export type TrackCard = TrackCardHeader & TrackCardContent;

export type TrackCardHeader = {
track: TrackSlug;
Expand Down Expand Up @@ -430,7 +430,7 @@ export type GetAppVersionResponse = {
release: string;
};

export type ChatSessionTracksBag = { [key: string]: TrackChatInfo | null };
export type ChatSessionTracksBag = { [key: TrackSlug]: TrackChatInfo | null };

export type GetChatSessionResponse = {
expiry: number;
Expand Down
13 changes: 13 additions & 0 deletions app/javascript/ContentCopyIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Material Icon: content-copy
import { createIcon } from "@chakra-ui/icons";

export const ContentCopyIcon = createIcon({
displayName: "ContentCopy",
viewBox: "0 0 24 24",
path: (
<>
<path d="m0 0h24v24h0z" fill="none" />
<path d="m16 1h4c-1.1 0-2 .9-2 2v14h2v3h12v1zm3 4h8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2v7c0-1.1-.9-2-2-2zm0 16h8v7h11v14z" />
</>
),
});
11 changes: 10 additions & 1 deletion app/javascript/ControlApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ export type ControlGetConferenceResponse = {
speakers: { [key: string]: ConferenceSpeaker };
};

export type ControlTrackCard = TrackCard & { id: number };

export type ControlGetTrackCardsResponse = {
track_cards: TrackCard[];
track_cards: ControlTrackCard[];
};

export type ControlListAttendeesResponse = {
Expand Down Expand Up @@ -121,6 +123,13 @@ export const ControlApi = {
return resp.json();
},

async deleteTrackCard(card: ControlTrackCard) {
const url = `/api/control/tracks/${encodeURIComponent(card.track)}/cards/${encodeURIComponent(card.id)}`;
const resp = await request(url, "DELETE", null, {});
mutate(`/api/control/tracks/${encodeURIComponent(card.track)}/cards`);
return resp.json();
},

useAttendeeList(query: string | null) {
return useSWR<ControlListAttendeesResponse, ApiError>(
query !== null ? `/api/control/attendees?query=${encodeURIComponent(query)}` : null,
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/ControlStreamPresence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ControlTrackCardForm = loadable(() => import("./ControlTrackCardForm"));

export type Props = {
track: Track;
}
};

export const ControlStreamPresence: React.FC<Props> = ({ track }) => {
// const { data: controlConferenceData } = ControlApi.useConference();
Expand Down Expand Up @@ -114,7 +114,8 @@ export const StreamPresenceBox: React.FC<{
<Button
minWidth="120px"
colorScheme={{ notready: "gray", golive: "teal", shutdown: "red" }[buttonAction]}
isDisabled={isRequesting || buttonAction === "notready"}
isLoading={isRequesting}
isDisabled={buttonAction === "notready"}
onClick={onPresenceUpdateButton}
>
{{ notready: "Go Live", golive: "Go Live", shutdown: "End Stream" }[buttonAction]}
Expand Down
Loading

0 comments on commit 56bb314

Please sign in to comment.