From 7918c3b991ed468baf5d0f9ed11641e08812c16f Mon Sep 17 00:00:00 2001 From: vinney cavallo Date: Thu, 18 May 2023 10:43:10 -0400 Subject: [PATCH 1/2] osprey ui: WIP boot/doom 'trial' concept --- front/src/api/types/osprey-poke.ts | 2 +- front/src/api/types/osprey-response.ts | 42 ++++++++++++++++++++++++-- front/src/store/osprey-state.ts | 1 + front/src/types/osprey-types.ts | 12 ++++++-- front/src/views/osprey/BootNDoom.vue | 8 +++++ 5 files changed, 60 insertions(+), 5 deletions(-) diff --git a/front/src/api/types/osprey-poke.ts b/front/src/api/types/osprey-poke.ts index 028a2c2..48a02f0 100644 --- a/front/src/api/types/osprey-poke.ts +++ b/front/src/api/types/osprey-poke.ts @@ -76,7 +76,7 @@ export interface RepeatArchivePayload { export interface DoomPayload { doom: { limit: number; - age: number; + age: number; // as "~h1", "~d30", etc group: T.Flag; } } diff --git a/front/src/api/types/osprey-response.ts b/front/src/api/types/osprey-response.ts index c4705f6..1e636ce 100644 --- a/front/src/api/types/osprey-response.ts +++ b/front/src/api/types/osprey-response.ts @@ -24,10 +24,48 @@ export enum OspreyResponseFaces { ArchiveStatusUpdate = "ARCHIVE-STATUS-UPDATE", Dooming = "DOOMING", DoomDone = "DOOMBOT-RESULTS", - Booting = "BOOTING", - BootDone = "BOOTBOT-RESULTS", + + OspreyKickBooting = "KICK-BOOTING", + OspreyKickExecuting = "KICK-EXECUTING", + OspreyKickPardoning = "KICK-PARDONING", + Booting = "BOOTING", // TODO: remove? + BootDone = "BOOTBOT-RESULTS", // TODO: remove? RestoreStatusUpdate = "RESTORE-STATUS-UPDATE", + + OspreyStateOnTrial = "OSPREY-STATE-ON-TRIAL", +} + +export interface OspreyStateOnTrialResponse { + type: Api.ResponseTypes.Scry; + fact: { + [key: string]: O.Defendants // keys will be a hashes. can have many groups on trial + } +} + +export interface OspreyKickBootingResponse { + type: Api.ResponseTypes.Fact; + face: OspreyResponseFaces.OspreyKickBooting; + fact: { + rank: string; + group: T.Flag; + } +} + +export interface OspreyKickExecutingResponse { + type: Api.ResponseTypes.Fact; + face: OspreyResponseFaces.OspreyKickExecuting; + fact: { + id: string; // hash of defendants + } +} + +export interface OspreyKickPardoningResponse { + type: Api.ResponseTypes.Fact; + face: OspreyResponseFaces.OspreyKickPardoning; + fact: { + id: string; // hash of defendants + } } export interface RestoredNewGroup { diff --git a/front/src/store/osprey-state.ts b/front/src/store/osprey-state.ts index 95c26f4..9ed9326 100644 --- a/front/src/store/osprey-state.ts +++ b/front/src/store/osprey-state.ts @@ -26,6 +26,7 @@ export const ospreyState = { diaries: [] as Array, every: [] as Array, mailslot: [] as Array, + courtroom: {} as { [key: string]: O.Defendants }, archiveLoadingState: {} as { ArchiveLoader }, diff --git a/front/src/types/osprey-types.ts b/front/src/types/osprey-types.ts index b58da2a..2ff11b6 100644 --- a/front/src/types/osprey-types.ts +++ b/front/src/types/osprey-types.ts @@ -4,8 +4,8 @@ export interface Schedule { next: number; // hoon seconds last: number; // hoon seconds area: { - flag: T.Flag; - type: string; // like "GROUP" + type: string; // like "GROUP" or "ALL-HOSTED" + flag: T.Flag; // when "ALL-HOSTED", there is no flag present }; } @@ -25,3 +25,11 @@ export interface MailDataContent { members: Array; group: T.Flag; } + +export interface Defendants { + flag: T.Flag, // the group + type: "doom" | "boot", + limit: number, // TODO: or is this a string? + age: string, // hoon time ago + ships: Array +} diff --git a/front/src/views/osprey/BootNDoom.vue b/front/src/views/osprey/BootNDoom.vue index 6238654..f43e43b 100644 --- a/front/src/views/osprey/BootNDoom.vue +++ b/front/src/views/osprey/BootNDoom.vue @@ -37,6 +37,10 @@ +
+court:
+{{ courtroom }}
+      
@@ -66,5 +70,9 @@ const ospreyStore = useStore() const groups = computed>(() => { return ospreyStore.state.groups }) + +const courtroom = computed<{ [key: string]: O.Defendants }>(() => { + return ospreyStore.state.courtroom +}) From e7334e09e8b6fcd8ae0f9ddef4e4b51938ce7ad2 Mon Sep 17 00:00:00 2001 From: vinney cavallo Date: Thu, 18 May 2023 12:57:34 -0400 Subject: [PATCH 2/2] osprey ui: add courtroom to state; pokes, scries for trials; WIP dump to screen --- front/src/api/ospreyAPI.ts | 20 +++++ front/src/api/ospreyActionPoker.ts | 26 ++++++ front/src/api/ospreyScrier.ts | 10 +++ front/src/api/types/osprey-poke.ts | 18 +++- front/src/api/types/osprey-response.ts | 104 +++++++++++++++-------- front/src/store/actions.ts | 1 + front/src/store/mutations.ts | 1 + front/src/store/osprey-action-types.ts | 1 + front/src/store/osprey-actions.ts | 35 ++++++++ front/src/store/osprey-mutation-types.ts | 2 + front/src/store/osprey-mutations.ts | 14 ++- front/src/views/osprey/BootNDoom.vue | 21 ++++- 12 files changed, 214 insertions(+), 39 deletions(-) diff --git a/front/src/api/ospreyAPI.ts b/front/src/api/ospreyAPI.ts index c9bdb64..244834a 100644 --- a/front/src/api/ospreyAPI.ts +++ b/front/src/api/ospreyAPI.ts @@ -16,6 +16,7 @@ export const Scries = { Heaps() { return scryHeaps() }, Groups() { return scryGroups() }, Diaries() { return scryDiaries() }, + Trial() { return scryTrial() }, } export const Pokes = { @@ -27,6 +28,8 @@ export const Pokes = { RepeatArchive(flag, typeString, schedule) { return pokeRepeatArchive(flag, typeString, schedule) }, Doom(args) { return pokeDoom(args) }, Boot(args) { return pokeBoot(args) }, + Execute(args) { return pokeExec(args) }, + Pardon(args) { return pokePardon(args) }, MailOpen(args) { return pokeMailOpen(args) }, MailSend(args) { return pokeMailSend(args) }, @@ -36,6 +39,11 @@ export const Pokes = { //// +export function scryTrial(): Promise { + const scrier = new OS.ScryTrial() + return scrier.scry() +} + export function scrySchedule(): Promise { const scrier = new OS.ScrySchedule() return scrier.scry() @@ -78,6 +86,18 @@ export function scryDiaries(): Promise { //// +export function pokeExec(hash: string): Promise + { + const poker = new OA.Execute(hash) + return poker.poke() +} + +export function pokePardon(hash: string): Promise + { + const poker = new OA.Pardon(hash) + return poker.poke() +} + export function pokeArchiveMine(): Promise { const poker = new OA.ArchiveMine() diff --git a/front/src/api/ospreyActionPoker.ts b/front/src/api/ospreyActionPoker.ts index 1f43302..4406c3a 100644 --- a/front/src/api/ospreyActionPoker.ts +++ b/front/src/api/ospreyActionPoker.ts @@ -170,3 +170,29 @@ export class Boot extends OspreyAction { super(json) } } + +export class Execute extends OspreyAction { + declare payload: OP.ExecutePayload['exec']['id'] + + constructor(args: OP.ExecutePayload['exec']['id']) { + const json: OP.ExecutePayload = { + exec: { + id: args + } + } + super(json) + } +} + +export class Pardon extends OspreyAction { + declare payload: OP.PardonPayload['stop']['id'] + + constructor(args: OP.PardonPayload['stop']['id']) { + const json: OP.PardonPayload = { + stop: { + id: args + } + } + super(json) + } +} diff --git a/front/src/api/ospreyScrier.ts b/front/src/api/ospreyScrier.ts index 5a1e291..67a24b8 100644 --- a/front/src/api/ospreyScrier.ts +++ b/front/src/api/ospreyScrier.ts @@ -20,6 +20,16 @@ class OspreyScry { } } +export class ScryTrial extends OspreyScry { + constructor() { + super('/on-trial') + } + + scry(): Promise { + return super.scry() + } +} + export class ScrySchedule extends OspreyScry { constructor() { super('/schedule') diff --git a/front/src/api/types/osprey-poke.ts b/front/src/api/types/osprey-poke.ts index 48a02f0..d964b60 100644 --- a/front/src/api/types/osprey-poke.ts +++ b/front/src/api/types/osprey-poke.ts @@ -88,6 +88,19 @@ export interface BootPayload { } } +export interface ExecutePayload { + exec: { + id: string; + } +} + +export interface PardonPayload { + stop: { + id: string; + } +} + + // TODO: don't use export interface ArchiveDmPayload { chat: { @@ -118,4 +131,7 @@ export type OspreyPoke = MailOpenPayload | MailSendPayload | MailReadPayload | - MailKillPayload + MailKillPayload | + ExecutePayload | + PardonPayload + diff --git a/front/src/api/types/osprey-response.ts b/front/src/api/types/osprey-response.ts index 1e636ce..9c9a305 100644 --- a/front/src/api/types/osprey-response.ts +++ b/front/src/api/types/osprey-response.ts @@ -22,14 +22,15 @@ export enum OspreyResponseFaces { OspreyScheduleCancel = "ARCHIVE-SCHEDULE-CANCEL", ArchiveStart = "ARCHIVE-START", ArchiveStatusUpdate = "ARCHIVE-STATUS-UPDATE", - Dooming = "DOOMING", - DoomDone = "DOOMBOT-RESULTS", + OspreyKickDooming = "KICK-DOOMING", OspreyKickBooting = "KICK-BOOTING", + + Dooming = "DOOMING", // TODO: remove? + DoomDone = "DOOMBOT-RESULTS", // TODO: remove? + OspreyKickExecuting = "KICK-EXECUTING", OspreyKickPardoning = "KICK-PARDONING", - Booting = "BOOTING", // TODO: remove? - BootDone = "BOOTBOT-RESULTS", // TODO: remove? RestoreStatusUpdate = "RESTORE-STATUS-UPDATE", @@ -38,12 +39,24 @@ export enum OspreyResponseFaces { export interface OspreyStateOnTrialResponse { type: Api.ResponseTypes.Scry; + face: OspreyResponseFaces.OspreyStateOnTrial fact: { [key: string]: O.Defendants // keys will be a hashes. can have many groups on trial } } -export interface OspreyKickBootingResponse { +// On initial +export interface OspreyResponseKickDooming { + type: Api.ResponseTypes.Fact; + face: OspreyResponseFaces.OspreyKickDooming; + fact: { + seconds: number; + group: T.Flag; + } +} + +// On initial +export interface OspreyResponseKickBooting { type: Api.ResponseTypes.Fact; face: OspreyResponseFaces.OspreyKickBooting; fact: { @@ -248,7 +261,7 @@ export interface OspreyResponseArchiveStatusUpdate { export interface OspreyResponseDoomStart { type: Api.ResponseTypes.Fact; - face: OspreyResponseFaces.Dooming; + face: OspreyResponseFaces.OspreyKickDooming; fact: { seconds: number; group: T.Flag; @@ -266,7 +279,7 @@ export interface OspreyResponseDoomDone { export interface OspreyResponseBootStart { type: Api.ResponseTypes.Fact; - face: OspreyResponseFaces.Booting; + face: OspreyResponseFaces.OspreyKickBooting; fact: { rank: string; group: T.Flag; @@ -293,10 +306,12 @@ export type OspreyResponse = | OspreyResponseHostedDiaries | OspreyResponseArchiveStart | OspreyResponseArchiveStatusUpdate - | OspreyResponseDoomStart + | OspreyResponseKickDooming // start | OspreyResponseDoomDone - | OspreyResponseBootStart - | OspreyResponseBootDone + | OspreyResponseKickBooting // start + | OspreyResponseBootDone // done + | OspreyKickExecutingResponse + | OspreyKickPardoningResponse | OspreyResponseMailslot | OspreyResponseMailOpen | OspreyResponseMailSending @@ -305,6 +320,51 @@ export type OspreyResponse = | OspreyResponseMailReading | OspreyResponseMailReadDone | OspreyResponseMailKilled + | OspreyStateOnTrialResponse + +export const IsOspreyOnTrialResponse = ( + r: OspreyResponse +): r is OspreyStateOnTrialResponse => { + return r.face === OspreyResponseFaces.OspreyStateOnTrial; +}; + +export const IsOspreyResponseDoomStart = ( + r: OspreyResponse +): r is OspreyResponseKickDooming => { + return r.face === OspreyResponseFaces.OspreyKickDooming; +}; + +export const IsOspreyResponseDoomDone = ( + r: OspreyResponse +): r is OspreyResponseDoomDone => { + return r.face === OspreyResponseFaces.DoomDone; +}; + +export const IsOspreyResponseBootStart = ( + r: OspreyResponse +): r is OspreyResponseKickBooting => { + return r.face === OspreyResponseFaces.OspreyKickBooting; +}; + +// TODO: wut this? +export const IsOspreyResponseBootDone = ( + r: OspreyResponse +): r is OspreyResponseBootDone => { + return r.face === OspreyResponseFaces.BootDone; +}; + +export const IsOspreyKickExecutingResponse = ( + r: OspreyResponse +): r is OspreyKickExecutingResponse => { + return r.face === OspreyResponseFaces.OspreyKickExecuting; +}; + +export const IsOspreyKickPardoningResponse = ( + r: OspreyResponse +): r is OspreyKickPardoningResponse => { + return r.face === OspreyResponseFaces.OspreyKickPardoning; +}; +/// export const IsOspreyHostedEvery = ( r: OspreyResponse @@ -358,30 +418,6 @@ export const IsOspreyResponseArchiveStatusUpdate = ( return r.face === OspreyResponseFaces.ArchiveStatusUpdate; }; -export const IsOspreyResponseDoomStart = ( - r: OspreyResponse -): r is OspreyResponseDoomStart => { - return r.face === OspreyResponseFaces.Dooming; -}; - -export const IsOspreyResponseDoomDone = ( - r: OspreyResponse -): r is OspreyResponseDoomDone => { - return r.face === OspreyResponseFaces.DoomDone; -}; - -export const IsOspreyResponseBootStart = ( - r: OspreyResponse -): r is OspreyResponseBootStart => { - return r.face === OspreyResponseFaces.Booting; -}; - -export const IsOspreyResponseBootDone = ( - r: OspreyResponse -): r is OspreyResponseBootDone => { - return r.face === OspreyResponseFaces.BootDone; -}; - export const IsOspreyResponseMailslot = ( r: OspreyResponse ): r is OspreyResponseMailslot => { diff --git a/front/src/store/actions.ts b/front/src/store/actions.ts index 58df1bb..23fb29d 100644 --- a/front/src/store/actions.ts +++ b/front/src/store/actions.ts @@ -157,6 +157,7 @@ export const actions: ActionTree & Actions = { if (PR.IsBirdLeftFact(data)) { console.log('BirdLeftFact ', data) dispatch(ActionTypes.SCRY_FLOKS) + dispatch(ActionTypes.SCRY_AVAIL_CHATS) } }, diff --git a/front/src/store/mutations.ts b/front/src/store/mutations.ts index dd184a0..474a7ea 100644 --- a/front/src/store/mutations.ts +++ b/front/src/store/mutations.ts @@ -3,6 +3,7 @@ import { MutationTypes } from "./mutation-types"; import { State } from "./state"; import * as T from "@/types"; import * as P from "@/types/parrot-types"; +import * as P from "@/types/parrot-types"; import { sigShip } from "@/helpers" diff --git a/front/src/store/osprey-action-types.ts b/front/src/store/osprey-action-types.ts index 04855a2..f9eac63 100644 --- a/front/src/store/osprey-action-types.ts +++ b/front/src/store/osprey-action-types.ts @@ -10,4 +10,5 @@ export enum OspreyActionTypes { ScryChats = 'SCRY_CHATS', ScryHeaps = 'SCRY_HEAPS', ScryDiaries = 'SCRY_DIARIES', + ScryTrial = 'SCRY_TRIAL', } diff --git a/front/src/store/osprey-actions.ts b/front/src/store/osprey-actions.ts index 84b18b0..9bd4f4a 100644 --- a/front/src/store/osprey-actions.ts +++ b/front/src/store/osprey-actions.ts @@ -37,6 +37,10 @@ export interface Actions { { commit }: AugmentedActionContext, deskName: string ): void; + + [ActionTypes.ScryTrial]( + { commit }: AugmentedActionContext + ): void; } export const actions: ActionTree & Actions = { @@ -61,6 +65,12 @@ export const actions: ActionTree & Actions = { console.log('got slots') } + if (OR.IsOspreyOnTrialResponse(data)) { + // TODO: + console.log('got courtroom') + commit(MutationTypes.CourtroomSet, data.fact) + } + // TODO if (OR.IsOspreyResponseMailSending(data)) { console.log('sending mail...') @@ -162,8 +172,10 @@ export const actions: ActionTree & Actions = { if (OR.IsOspreyResponseDoomStart(data)) { console.log('doom started...') + dispatch(ActionTypes.ScryTrial) console.log(data) } + if (OR.IsOspreyResponseDoomDone(data)) { console.log('doom done') console.log(data) @@ -171,10 +183,24 @@ export const actions: ActionTree & Actions = { if (OR.IsOspreyResponseBootStart(data)) { console.log('boot started...') + dispatch(ActionTypes.ScryTrial) console.log(data) } + if (OR.IsOspreyResponseBootDone(data)) { console.log('boot done') + dispatch(ActionTypes.ScryTrial) + console.log(data) + } + + if (OR.IsOspreyKickExecutingResponse(data)) { + console.log('kick executed started...') + dispatch(ActionTypes.ScryTrial) + console.log(data) + } + if (OR.IsOspreyKickPardoningResponse(data)) { + console.log('kick pardoned...') + dispatch(ActionTypes.ScryTrial) console.log(data) } @@ -206,6 +232,15 @@ export const actions: ActionTree & Actions = { }) }, + [ActionTypes.ScryTrial]( + ctx, + ) { + console.log('dispatching ScryTrial action...') + return Scries.Trial().then((r: OR.OspreyStateOnTrialResponse) => { + ctx.commit(MutationTypes.CourtroomSet, r.fact) + }) + }, + [ActionTypes.ScryMailslots]( ctx, ) { diff --git a/front/src/store/osprey-mutation-types.ts b/front/src/store/osprey-mutation-types.ts index 057f3b9..879a45b 100644 --- a/front/src/store/osprey-mutation-types.ts +++ b/front/src/store/osprey-mutation-types.ts @@ -12,4 +12,6 @@ export enum OspreyMutationTypes { DiariesSet = 'DIARIES_SET', ArchiveLoaderSet = 'ARCHIVE_LOADER_SET', + + CourtroomSet = 'CourtroomSet', } diff --git a/front/src/store/osprey-mutations.ts b/front/src/store/osprey-mutations.ts index 0e280a5..f07006a 100644 --- a/front/src/store/osprey-mutations.ts +++ b/front/src/store/osprey-mutations.ts @@ -1,5 +1,5 @@ import { MutationTree } from "vuex"; -import { OspreyMutationTypes as MutationTypes } from "./osprey-mutation-types"; +import { OspreyMutationTypes as MutationTypes, OspreyMutationTypes } from "./osprey-mutation-types"; import { OspreyState } from "./osprey-state"; import * as T from "@/types"; import * as L from "@/types/loading-types"; @@ -8,6 +8,11 @@ import * as O from "@/types/osprey-types"; import { sigShip } from "@/helpers" export type OspreyMutations = { + [MutationTypes.CourtroomSet]( + state: S, + payload: { [key: string]: O.Defendants } + ): void; + [MutationTypes.ScheduleSet]( state: S, payload: Array @@ -48,6 +53,13 @@ export type OspreyMutations = { }; export const mutations: MutationTree & OspreyMutations = { + [MutationTypes.CourtroomSet]( + state: OspreyState, + payload: Parameters[1] + ) { + state.courtroom = payload + }, + [MutationTypes.ScheduleSet]( state: OspreyState, payload: Array diff --git a/front/src/views/osprey/BootNDoom.vue b/front/src/views/osprey/BootNDoom.vue index f43e43b..d949e86 100644 --- a/front/src/views/osprey/BootNDoom.vue +++ b/front/src/views/osprey/BootNDoom.vue @@ -37,10 +37,15 @@
-
 court:
-{{ courtroom }}
-      
+
+
+  hash: {{ hash }}
+  trial: {{ trial }}
+
+ + +
@@ -74,5 +79,15 @@ const groups = computed>(() => { const courtroom = computed<{ [key: string]: O.Defendants }>(() => { return ospreyStore.state.courtroom }) + +const execute = (hash: string) => { + console.log('exec ', hash) + Pokes.Execute(hash) +} + +const pardon = (hash: string) => { + console.log('pardon ', hash) + Pokes.Pardon(hash) +}