8383 :disabled =" !config.enabled"
8484 :config-entries =" config_entries"
8585 @submit =" onSubmit"
86+ @action =" onAction"
8687 />
8788 </v-card-text >
8889 </section >
@@ -104,10 +105,13 @@ import {
104105import EditConfig from " ./EditConfig.vue" ;
105106import { watch } from " vue" ;
106107import { openLinkInNewTab } from " @/helpers/utils" ;
108+ import { nanoid } from " nanoid" ;
107109
108110// global refs
109111const router = useRouter ();
110112const config = ref <PlayerConfig >();
113+ const sessionId = nanoid (11 );
114+ const loading = ref (false );
111115
112116// props
113117const props = defineProps <{
@@ -203,6 +207,37 @@ const onSubmit = async function (values: Record<string, ConfigValueType>) {
203207 router .push ({ name: " playersettings" });
204208};
205209
210+ const onAction = async function (
211+ action : string ,
212+ values : Record <string , ConfigValueType >,
213+ ) {
214+ loading .value = true ;
215+ // append existing ConfigEntry values to allow
216+ // values be passed between flow steps
217+ for (const entry of Object .values (config .value ! .values )) {
218+ if (entry .value !== undefined && values [entry .key ] == undefined ) {
219+ values [entry .key ] = entry .value ;
220+ }
221+ }
222+ // ensure the session id is passed along (for auth actions)
223+ values [" session_id" ] = sessionId ;
224+ api
225+ .getPlayerConfigEntries (config .value ! .player_id , action , values )
226+ .then ((entries ) => {
227+ config .value ! .values = {};
228+ for (const entry of entries ) {
229+ config .value ! .values [entry .key ] = entry ;
230+ }
231+ })
232+ .catch ((err ) => {
233+ // TODO: make this a bit more fancy someday
234+ alert (err );
235+ })
236+ .finally (() => {
237+ loading .value = false ;
238+ });
239+ };
240+
206241const openDspConfig = function () {
207242 router .push (` /settings/editplayer/${props .playerId }/dsp ` );
208243};
0 commit comments