Compare commits
1 commit
master
...
mostly-wor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
640e8d34ab |
|
|
@ -65,7 +65,7 @@ GEM
|
||||||
puma (6.6.1)
|
puma (6.6.1)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
racc (1.8.1)
|
racc (1.8.1)
|
||||||
rack (3.2.0)
|
rack (3.2.1)
|
||||||
rack-test (2.2.0)
|
rack-test (2.2.0)
|
||||||
rack (>= 1.3)
|
rack (>= 1.3)
|
||||||
rainbow (3.1.1)
|
rainbow (3.1.1)
|
||||||
|
|
@ -78,7 +78,7 @@ GEM
|
||||||
listen (~> 3.0)
|
listen (~> 3.0)
|
||||||
roda (3.95.0)
|
roda (3.95.0)
|
||||||
rack
|
rack
|
||||||
rubocop (1.80.0)
|
rubocop (1.80.1)
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
language_server-protocol (~> 3.17.0.2)
|
language_server-protocol (~> 3.17.0.2)
|
||||||
lint_roller (~> 1.1.0)
|
lint_roller (~> 1.1.0)
|
||||||
|
|
@ -93,7 +93,7 @@ GEM
|
||||||
parser (>= 3.3.7.2)
|
parser (>= 3.3.7.2)
|
||||||
prism (~> 1.4)
|
prism (~> 1.4)
|
||||||
ruby-progressbar (1.13.0)
|
ruby-progressbar (1.13.0)
|
||||||
sequel (5.95.1)
|
sequel (5.96.0)
|
||||||
bigdecimal
|
bigdecimal
|
||||||
sqlite3 (2.7.3-aarch64-linux-gnu)
|
sqlite3 (2.7.3-aarch64-linux-gnu)
|
||||||
sqlite3 (2.7.3-aarch64-linux-musl)
|
sqlite3 (2.7.3-aarch64-linux-musl)
|
||||||
|
|
|
||||||
30
app.rb
30
app.rb
|
|
@ -11,6 +11,7 @@ require_relative 'models/assistant'
|
||||||
class App < Roda
|
class App < Roda
|
||||||
plugin :render, escape: true
|
plugin :render, escape: true
|
||||||
plugin :sessions, secret: ENV.delete('APP_SESSION_SECRET')
|
plugin :sessions, secret: ENV.delete('APP_SESSION_SECRET')
|
||||||
|
plugin :all_verbs
|
||||||
|
|
||||||
route do |r|
|
route do |r|
|
||||||
r.root do
|
r.root do
|
||||||
|
|
@ -27,14 +28,41 @@ class App < Roda
|
||||||
@assistant = Assistant.new
|
@assistant = Assistant.new
|
||||||
view :edit
|
view :edit
|
||||||
end
|
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
|
r.post do
|
||||||
@assistant = Assistant.new(r.params)
|
@assistant = Assistant.new(r.params)
|
||||||
if @assistant.save
|
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
|
else
|
||||||
r.halt(404)
|
r.halt(404)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
r.delete ':id' do |id|
|
||||||
|
@assistant = Assistant[id]
|
||||||
|
@assistant.destroy if @assistant
|
||||||
|
r.redirect '/'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ Sequel.migration do
|
||||||
String :capabilities
|
String :capabilities
|
||||||
String :test_results
|
String :test_results
|
||||||
DateTime :created_at, null: false, default: Sequel::CURRENT_TIMESTAMP
|
DateTime :created_at, null: false, default: Sequel::CURRENT_TIMESTAMP
|
||||||
|
DateTime :updated_at
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ class Assistant < Sequel::Model
|
||||||
def validate
|
def validate
|
||||||
super
|
super
|
||||||
errors.add(:name, 'must be present') if name.nil? || name.empty?
|
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
|
end
|
||||||
|
|
||||||
# Optional: Add custom methods for common operations
|
# Optional: Add custom methods for common operations
|
||||||
|
|
@ -18,7 +19,16 @@ class Assistant < Sequel::Model
|
||||||
where(name: name).first
|
where(name: name).first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.find_by_run_command(run_command)
|
||||||
|
where(run_command: run_command).first
|
||||||
|
end
|
||||||
|
|
||||||
def self.active
|
def self.active
|
||||||
where(active: true)
|
where(active: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Helper to check if this is a new record
|
||||||
|
def new?
|
||||||
|
id.nil?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
<th>Evaluation Rate</th>
|
<th>Evaluation Rate</th>
|
||||||
<th>Capabilities</th>
|
<th>Capabilities</th>
|
||||||
<th>Created At</th>
|
<th>Created At</th>
|
||||||
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -25,6 +26,13 @@
|
||||||
<td><%= assistant.eval_rate || 'N/A' %></td>
|
<td><%= assistant.eval_rate || 'N/A' %></td>
|
||||||
<td><%= assistant.capabilities || '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><%= 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>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
@ -32,3 +40,5 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<p>No assistants found in the database.</p>
|
<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