8bitkick commited on
Commit
67364a3
·
1 Parent(s): f81875f

Update install button text and enhance installation process with start app functionality

Browse files
Files changed (1) hide show
  1. index.html +35 -7
index.html CHANGED
@@ -194,7 +194,7 @@
194
  <div id="install-panel">
195
  <h3>Install to Reachy Mini</h3>
196
  <input type="url" id="dashboardUrl" placeholder="http://reachy-dashboard:8000" value="http://localhost:8000" />
197
- <button id="installBtn" class="install-btn"><span>📥</span><span>Install On R</span></button>
198
  <div id="installStatus" class="install-status"></div>
199
  </div>
200
  </div>
@@ -233,7 +233,9 @@
233
  const dashURL = dashInput.value.trim();
234
  if(!dashURL){ showStatus('error','Enter dashboard URL'); return; }
235
  btn.disabled=true; btn.innerHTML='⏳ Installing...'; showStatus('info','Sending install request...');
 
236
  try {
 
237
  const payload = {
238
  name: '8bitkick/reachy_mini_3d_web_viz',
239
  source_kind: 'hf_space',
@@ -241,19 +243,45 @@
241
  url: 'https://huggingface.co/spaces/8bitkick/reachy_mini_3d_web_viz',
242
  extra: { additionalProp1: {} }
243
  };
244
- const resp = await fetch(dashURL+'/api/apps/install',{
245
  method:'POST',
246
  headers:{'Content-Type':'application/json','accept':'application/json'},
247
  body: JSON.stringify(payload)
248
  });
249
- const result = await resp.json().catch(()=>({}));
250
- if(!resp.ok) throw new Error(result.detail||'Install failed');
251
- showStatus('success','Install started for '+payload.name+'!');
252
- setTimeout(()=>{showStatus('info','Check reachy output for progress.');},2500);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  } catch(err){
254
  showStatus('error','Failed: '+err.message);
255
  } finally {
256
- btn.disabled=false; btn.innerHTML='<span>📥</span><span>Install On R</span>';
257
  }
258
  }
259
  btn.addEventListener('click', install);
 
194
  <div id="install-panel">
195
  <h3>Install to Reachy Mini</h3>
196
  <input type="url" id="dashboardUrl" placeholder="http://reachy-dashboard:8000" value="http://localhost:8000" />
197
+ <button id="installBtn" class="install-btn"><span>📥</span><span>Install On Robot</span></button>
198
  <div id="installStatus" class="install-status"></div>
199
  </div>
200
  </div>
 
233
  const dashURL = dashInput.value.trim();
234
  if(!dashURL){ showStatus('error','Enter dashboard URL'); return; }
235
  btn.disabled=true; btn.innerHTML='⏳ Installing...'; showStatus('info','Sending install request...');
236
+
237
  try {
238
+ // Step 1: Install the app
239
  const payload = {
240
  name: '8bitkick/reachy_mini_3d_web_viz',
241
  source_kind: 'hf_space',
 
243
  url: 'https://huggingface.co/spaces/8bitkick/reachy_mini_3d_web_viz',
244
  extra: { additionalProp1: {} }
245
  };
246
+ const installResp = await fetch(dashURL+'/api/apps/install',{
247
  method:'POST',
248
  headers:{'Content-Type':'application/json','accept':'application/json'},
249
  body: JSON.stringify(payload)
250
  });
251
+ const installResult = await installResp.json().catch(()=>({}));
252
+
253
+ if(!installResp.ok) {
254
+ // If already installed, that's ok, we'll try to start it anyway
255
+ if(installResult.detail && installResult.detail.includes('already installed')) {
256
+ showStatus('info','App already installed, starting...');
257
+ } else {
258
+ throw new Error(installResult.detail||'Install failed');
259
+ }
260
+ } else {
261
+ showStatus('success','Install complete! Starting app...');
262
+ }
263
+
264
+ // Step 2: Start the app
265
+ btn.innerHTML='⏳ Starting...';
266
+ const startResp = await fetch(dashURL+'/api/apps/start-app/reachy_mini_web_viz',{
267
+ method:'POST',
268
+ headers:{'accept':'application/json'},
269
+ body: ''
270
+ });
271
+ const startResult = await startResp.json().catch(()=>({}));
272
+
273
+ if(!startResp.ok) throw new Error(startResult.detail||'Failed to start app');
274
+
275
+ if(startResult.state === 'running') {
276
+ showStatus('success','App is now running on Reachy Mini!');
277
+ } else {
278
+ showStatus('info',`App state: ${startResult.state}`);
279
+ }
280
+
281
  } catch(err){
282
  showStatus('error','Failed: '+err.message);
283
  } finally {
284
+ btn.disabled=false; btn.innerHTML='<span>📥</span><span>Install & Start</span>';
285
  }
286
  }
287
  btn.addEventListener('click', install);