Compare commits
1 commit
master
...
mostly-wor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
640e8d34ab |
|
|
@ -65,7 +65,7 @@ GEM
|
|||
puma (6.6.1)
|
||||
nio4r (~> 2.0)
|
||||
racc (1.8.1)
|
||||
rack (3.2.0)
|
||||
rack (3.2.1)
|
||||
rack-test (2.2.0)
|
||||
rack (>= 1.3)
|
||||
rainbow (3.1.1)
|
||||
|
|
@ -78,7 +78,7 @@ GEM
|
|||
listen (~> 3.0)
|
||||
roda (3.95.0)
|
||||
rack
|
||||
rubocop (1.80.0)
|
||||
rubocop (1.80.1)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (~> 3.17.0.2)
|
||||
lint_roller (~> 1.1.0)
|
||||
|
|
@ -93,7 +93,7 @@ GEM
|
|||
parser (>= 3.3.7.2)
|
||||
prism (~> 1.4)
|
||||
ruby-progressbar (1.13.0)
|
||||
sequel (5.95.1)
|
||||
sequel (5.96.0)
|
||||
bigdecimal
|
||||
sqlite3 (2.7.3-aarch64-linux-gnu)
|
||||
sqlite3 (2.7.3-aarch64-linux-musl)
|
||||
|
|
|
|||
30
app.rb
30
app.rb
|
|
@ -11,6 +11,7 @@ require_relative 'models/assistant'
|
|||
class App < Roda
|
||||
plugin :render, escape: true
|
||||
plugin :sessions, secret: ENV.delete('APP_SESSION_SECRET')
|
||||
plugin :all_verbs
|
||||
|
||||
route do |r|
|
||||
r.root do
|
||||
|
|
@ -27,14 +28,41 @@ class App < Roda
|
|||
@assistant = Assistant.new
|
||||
view :edit
|
||||
end
|
||||
|
||||
r.get ':id/edit' do |id|
|
||||
@page_title = 'Edit Assistant'
|
||||
@assistant = Assistant[id]
|
||||
if @assistant.nil?
|
||||
r.halt(404)
|
||||
else
|
||||
view :edit
|
||||
end
|
||||
end
|
||||
|
||||
r.post do
|
||||
@assistant = Assistant.new(r.params)
|
||||
if @assistant.save
|
||||
r.redirect '/' # change to just r.redirect when get a host.org/assistants page up
|
||||
r.redirect '/'
|
||||
else
|
||||
@page_title = 'Create New Assistant'
|
||||
view :edit
|
||||
end
|
||||
end
|
||||
|
||||
r.put ':id' do |id|
|
||||
@assistant = Assistant[id]
|
||||
if @assistant && @assistant.update(r.params)
|
||||
r.redirect '/'
|
||||
else
|
||||
r.halt(404)
|
||||
end
|
||||
end
|
||||
|
||||
r.delete ':id' do |id|
|
||||
@assistant = Assistant[id]
|
||||
@assistant.destroy if @assistant
|
||||
r.redirect '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ Sequel.migration do
|
|||
String :capabilities
|
||||
String :test_results
|
||||
DateTime :created_at, null: false, default: Sequel::CURRENT_TIMESTAMP
|
||||
DateTime :updated_at
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class Assistant < Sequel::Model
|
|||
def validate
|
||||
super
|
||||
errors.add(:name, 'must be present') if name.nil? || name.empty?
|
||||
errors.add(:run_command, 'must be present') if run_command.nil? || run_command.empty?
|
||||
end
|
||||
|
||||
# Optional: Add custom methods for common operations
|
||||
|
|
@ -18,7 +19,16 @@ class Assistant < Sequel::Model
|
|||
where(name: name).first
|
||||
end
|
||||
|
||||
def self.find_by_run_command(run_command)
|
||||
where(run_command: run_command).first
|
||||
end
|
||||
|
||||
def self.active
|
||||
where(active: true)
|
||||
end
|
||||
|
||||
# Helper to check if this is a new record
|
||||
def new?
|
||||
id.nil?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
<th>Evaluation Rate</th>
|
||||
<th>Capabilities</th>
|
||||
<th>Created At</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -25,10 +26,19 @@
|
|||
<td><%= assistant.eval_rate || 'N/A' %></td>
|
||||
<td><%= assistant.capabilities || 'N/A' %></td>
|
||||
<td><%= assistant.created_at.strftime('%Y-%m-%d %H:%M') if assistant.created_at %></td>
|
||||
<td>
|
||||
<a class="button is-small is-info" href="/assistants/<%= assistant.id %>/edit">Edit</a>
|
||||
<form method="post" action="/assistants/<%= assistant.id %>" style="display:inline;">
|
||||
<input type="hidden" name="_method" value="delete">
|
||||
<button class="button is-small is-danger" type="submit" onclick="return confirm('Are you sure?')">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p>No assistants found in the database.</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<p><a class="button is-primary" href="/assistants/new">Add New Assistant</a></p>
|
||||
|
|
|
|||
Loading…
Reference in a new issue