@@ -865,10 +865,10 @@ class RailwayMCPServer {
865865const ROLES = ['owner','editor','viewer','admin'];
866866async function loadProjects(){
867867 const r = await fetch('/admin/api/projects'); const j = await r.json();
868- const rows = (j.projects||[]).map(p=>` < tr > < td > ${ p . id } </ td > < td > $ { p . name || '' } </td > < td > ${ p . is_public ? 'yes' :'no' } </ td >
869- < td > < button onclick = \ "togglePublic ( '${p.id}' , $ { ! p . is_public } ) \ "> make $ { ! p . is_public ?'public' :'private' } </button >
870- < button onclick = \ "viewMembers ( '${p.id}' ) \ "> members < / b u t t o n > < / td> < / tr > `).join('');
871- document.getElementById('projects').innerHTML = `< table > < tr > < th > id</ th > < th > name</ th > < th > public</ th > < th > actions</ th > </ tr > ${ rows } </ table > < div id = "members" > </ div > `;
868+ const rows = (j.projects||[]).map(p=>\ `<tr><td>\ ${p.id}</td><td>\ ${p.name||''}</td><td>\ ${p.is_public? 'yes':'no'}</td>
869+ <td><button onclick="togglePublic('\ ${p.id}',\ ${!p.is_public})">make \ ${!p.is_public?'public':'private'}</button>
870+ <button onclick="viewMembers('\ ${p.id}')">members</button></td></tr>\ `).join('');
871+ document.getElementById('projects').innerHTML = \ `<table><tr><th>id</th><th>name</th><th>public</th><th>actions</th></tr>\ ${rows}</table><div id="members"></div>\ `;
872872}
873873async function createProject(){
874874 const id = document.getElementById('newId').value; const name = document.getElementById('newName').value; const isPublic = document.getElementById('newPublic').checked;
@@ -881,12 +881,12 @@ async function togglePublic(id, isPublic){
881881}
882882async function viewMembers(id){
883883 const r = await fetch('/admin/api/projects/'+id+'/members'); const j = await r.json();
884- const rows = ( j . members || [ ] ) . map ( m => `<tr><td>${ m . user_id } </td><td>${ m . name || '' } </td><td>${ m . email || '' } </td><td>${ m . role } </td>
885- <td><button onclick=\ "removeMember('${ id } ','${ m . user_id } ')\ ">remove</button></td></tr>` ) . join ( '' ) ;
886- document . getElementById ( 'members' ) . innerHTML = `<h3>Members of ${ id } </h3>
887- <div class=\ "row\ "><input id=\ "mUser\ " placeholder=\ "user id\ "/><select id=\ "mRole\"> ${ ROLES . map ( r => `<option>${ r } </option>` ) . join ( '' ) } </select>
888- <button onclick=\ "addMember('${ id } ')\ ">add/update</button></div>
889- <table><tr><th>user</th><th>name</th><th>email</th><th>role</th><th>actions</th></tr>${ rows } </table>` ;
884+ const rows = (j.members||[]).map(m=>\ `<tr><td>\ ${m.user_id}</td><td>\ ${m.name||''}</td><td>\ ${m.email||''}</td><td>\ ${m.role}</td>
885+ <td><button onclick="removeMember('\ ${id}','\ ${m.user_id}')">remove</button></td></tr>\ `).join('');
886+ document.getElementById('members').innerHTML = \ `<h3>Members of \ ${id}</h3>
887+ <div class="row"><input id="mUser" placeholder="user id"/><select id="mRole">\ ${ROLES.map(r=>\ `<option>\ ${r}</option>\ `).join('')}</select>
888+ <button onclick="addMember('\ ${id}')">add/update</button></div>
889+ <table><tr><th>user</th><th>name</th><th>email</th><th>role</th><th>actions</th></tr>\ ${rows}</table>\ `;
890890}
891891async function addMember(id){
892892 const userId = document.getElementById('mUser').value; const role = document.getElementById('mRole').value;
@@ -900,8 +900,8 @@ async function removeMember(id, userId){
900900}
901901async function loadSessions(){
902902 const r = await fetch('/admin/api/sessions'); const j = await r.json();
903- const rows = ( j . sessions || [ ] ) . map ( s => `<tr><td>${ s . id } </td><td>${ s . user_id } </td><td>${ new Date ( s . created_at ) . toLocaleString ( ) } </td><td>${ new Date ( s . expires_at ) . toLocaleString ( ) } </td><td>${ s . ip || '' } </td><td>${ ( s . user_agent || '' ) . slice ( 0 , 40 ) } </td><td><button onclick=\ "killSession('${ s . id } ')\ ">terminate</button></td></tr>` ) . join ( '' ) ;
904- document . getElementById ( 'sessions' ) . innerHTML = `<table><tr><th>id</th><th>user</th><th>created</th><th>expires</th><th>ip</th><th>agent</th><th>actions</th></tr>${ rows } </table>` ;
903+ const rows = (j.sessions||[]).map(s=>\ `<tr><td>\ ${s.id}</td><td>\ ${s.user_id}</td><td>\ ${new Date(s.created_at).toLocaleString()}</td><td>\ ${new Date(s.expires_at).toLocaleString()}</td><td>\ ${s.ip||''}</td><td>\ ${(s.user_agent||'').slice(0,40)}</td><td><button onclick="killSession('\ ${s.id}')">terminate</button></td></tr>\ `).join('');
904+ document.getElementById('sessions').innerHTML = \ `<table><tr><th>id</th><th>user</th><th>created</th><th>expires</th><th>ip</th><th>agent</th><th>actions</th></tr>\ ${rows}</table>\ `;
905905}
906906async function killSession(id){
907907 await fetch('/admin/api/sessions/'+id,{method:'DELETE'});
0 commit comments