diff --git a/assets/styles/kraken.scss b/assets/styles/kraken.scss index 215f01a..02f2d8e 100644 --- a/assets/styles/kraken.scss +++ b/assets/styles/kraken.scss @@ -62,13 +62,17 @@ body{ box-shadow: $box-shadow-2; } -#item-header{ - .item-name{ +#item-header, +#license-header{ + .item-name, + .license-name{ margin-bottom: 5px; } .item-created, - .item-updated{ + .item-updated, + .license-created, + .license-updated{ color: #666; font-size: 1.75rem; font-style: italic; diff --git a/db/migrations/0003_add_licenses_table.rb b/db/migrations/0003_add_licenses_table.rb new file mode 100644 index 0000000..cdb5ed8 --- /dev/null +++ b/db/migrations/0003_add_licenses_table.rb @@ -0,0 +1,22 @@ +Sequel.migration do + + up do + create_table(:licenses) do + primary_key :id + String :name, null: false + String :key, null: false + String :manufacturer + Integer :seats_used, default: 0 + Integer :seats_total, default: 1 + String :purchased_from + DateTime :purchased_at + DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP + DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP + end + end + + down do + drop_table(:licenses) + end + +end diff --git a/lib/models/license.rb b/lib/models/license.rb new file mode 100644 index 0000000..35cbd16 --- /dev/null +++ b/lib/models/license.rb @@ -0,0 +1,5 @@ +class License < Sequel::Model + + + +end diff --git a/lib/routes.rb b/lib/routes.rb index 55b8201..974e816 100644 --- a/lib/routes.rb +++ b/lib/routes.rb @@ -1,5 +1,5 @@ get '/' do - items = Item.all + items = Item.reverse(:updated_at).limit(10).all() erb :index, :locals => { :title => 'Dashboard', :items => items @@ -10,7 +10,7 @@ get '/item' do redirect '/item/list' end get '/item/list' do - items = Item.all + items = Item.reverse(:updated_at).all() erb :'item/list', :locals => { :title => 'List of Items', :items => items @@ -53,3 +53,42 @@ post '/item/:item_id/comment' do redirect "/item/#{item.id}" end + +get '/license' do + redirect '/license/list' +end +get '/license/list' do + licenses = License.reverse(:updated_at).all() + erb :'license/list', :locals => { + :title => 'List of Licenses', + :licenses => licenses + } +end + +get '/license/create' do + erb :'license/create', :locals => { + :title => 'Create New License' + } +end +post '/license/create' do + license = License.create( + name: params[:license_name], + key: params[:license_key], + manufacturer: params[:license_manufacturer], + seats_used: params[:license_seats_used], + seats_total: params[:license_seats_total], + purchased_from: params[:license_purchase_from], + purchased_at: params[:license_purchase_date] + ) + + redirect "/license/#{license.id}" +end + +get '/license/:license_id' do + license = License.where(id: params[:license_id]).first() + puts "#{license.name}" + erb :'license/view', :locals => { + :title => license.name, + :license => license + } +end diff --git a/raven.rb b/raven.rb index dbca99a..c39306a 100644 --- a/raven.rb +++ b/raven.rb @@ -23,6 +23,7 @@ DB = Sequel.connect(adapter: conf.get('database.adapter'), database: conf.get('d # Load models require_relative 'lib/models/item.rb' require_relative 'lib/models/item_comment.rb' +require_relative 'lib/models/license.rb' # Load helper functions require_relative 'lib/helpers.rb' diff --git a/views/item/list.erb b/views/item/list.erb index 7a6b17f..1bb7839 100644 --- a/views/item/list.erb +++ b/views/item/list.erb @@ -1,7 +1,21 @@ -
+There is nothing registered in your inventory yet.
+ <% end %> +There is nothing registered in your inventory yet.
+ <% end %> +License key: | +Manufacturer: | +Seats used: | +Seats total: | +Vendor: | +Purchase Date: | +
---|---|---|---|---|---|
<%= license.key %> | +<%= nullable(license.manufacturer) %> | +<%= nullable(license.seats_used) %> | +<%= nullable(license.seats_total) %> | +<%= nullable(license.purchased_from) %> | +<%= nullable(date_format(license.purchased_at)) %> | +