Skip to content
2 changes: 2 additions & 0 deletions app/api/v1/entities/webpage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ class Webpage < Grape::Entity
expose :dynamic_yield_category, documentation: { type: 'String', desc: "Dynamic Yield Webpage Category" }

expose :tables_widget_json, documentation: {type: 'Hash', is_array: true, desc: 'Tables Widget Data as JSON'}
expose :charts_widget_json, documentation: {type: 'Hash', is_array: true, desc: 'Charts Widget Data as JSON'}

with_options if: { full: true } do
expose :user, with: '::V1::Entities::User', documentation: {type: 'User', desc: 'Owner'}
expose :url, documentation: { type: 'String', desc: 'URL of Webpage' }

expose :tables_widget_yaml, documentation: {type: 'Hash', is_array: true, desc: 'Tables Widget Data as YAML'}
expose :charts_widget_yaml, documentation: {type: 'Hash', is_array: true, desc: 'Charts Widget Data as YAML'}
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions app/assets/legacy_templates/webpages/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
ng-model="data.webpage.tables_widget_yaml"
placeholder="YAML-formatted table data"></textarea>
</div>
<div class="form-group">
<label for="charts_widget_yaml">Charts Data</label>
<textarea id="charts_widget_yaml" name="charts_widget_yaml" class="form-control" rows="15"
ng-model="data.webpage.charts_widget_yaml"
placeholder="YAML-formatted chart data"></textarea>
</div>
</form>
</div>
</tab>
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/searchable_webpage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module SearchableWebpage
indexes :noarchive, :type => :boolean, :index => :not_analyzed
indexes :noimageindex, :type => :boolean, :index => :not_analyzed
indexes :tables_widget, :type => :nested, :enabled => false
indexes :charts_widget, :type => :nested, :enabled => false
end

def as_indexed_json(options = {})
Expand Down
17 changes: 17 additions & 0 deletions app/models/webpage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Webpage < ApplicationRecord
include SearchableWebpage

serialize :tables_widget
serialize :charts_widget

scope :find_by_protocol_agnostic_url, ->(suffix) { where('url LIKE :suffix', suffix: "%#{suffix}") }

Expand Down Expand Up @@ -30,4 +31,20 @@ def tables_widget_json
def tables_widget_json= p
self.tables_widget = JSON.parse(p, quirks_mode: true) # Quirks mode will let us parse a null JSON object
end

def charts_widget_yaml
charts_widget.to_yaml
end

def charts_widget_yaml= p
self.charts_widget = YAML.load(p)
end

def charts_widget_json
charts_widget.to_json
end

def charts_widget_json= p
self.charts_widget = JSON.parse(p, quirks_mode: true) # Quirks mode will let us parse a null JSON object
end
end
5 changes: 5 additions & 0 deletions db/migrate/20170519201648_add_charts_widget_to_webpage.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddChartsWidgetToWebpage < ActiveRecord::Migration[5.0]
def change
add_column :webpages, :charts_widget, :jsonb
end
end
163 changes: 87 additions & 76 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170417185915) do
ActiveRecord::Schema.define(version: 20170519201648) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -58,14 +58,19 @@
end

create_table "categories", force: :cascade do |t|
t.string "name", limit: 255
t.integer "user_id", null: false
t.string "name"
t.integer "user_id", null: false
t.integer "parent_id"
t.integer "lft"
t.integer "rgt"
t.integer "depth"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["depth"], name: "index_categories_on_depth", using: :btree
t.index ["lft"], name: "index_categories_on_lft", using: :btree
t.index ["parent_id"], name: "index_categories_on_parent_id", using: :btree
t.index ["rgt"], name: "index_categories_on_rgt", using: :btree
t.index ["user_id"], name: "index_categories_on_user_id", using: :btree
end

create_table "categories_posts", id: false, force: :cascade do |t|
Expand Down Expand Up @@ -208,23 +213,24 @@
end

create_table "media", force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.integer "user_id"
t.string "attachment_file_name", limit: 255
t.string "attachment_content_type", limit: 255
t.string "attachment_file_name"
t.string "attachment_content_type"
t.integer "attachment_file_size"
t.datetime "attachment_updated_at"
t.string "dimensions", limit: 255
t.string "dimensions"
t.text "description"
t.string "alt", limit: 255
t.string "alt"
t.boolean "active"
t.datetime "deactive_at"
t.datetime "created_at"
t.datetime "updated_at"
t.string "digest", limit: 255
t.string "digest"
t.datetime "deleted_at"
t.hstore "meta"
t.string "type", limit: 255, default: "Media", null: false
t.string "type", default: "Media", null: false
t.index ["name"], name: "index_media_on_name", using: :btree
t.index ["user_id"], name: "index_media_on_user_id", using: :btree
end

Expand All @@ -234,48 +240,48 @@
end

create_table "oauth_access_grants", force: :cascade do |t|
t.integer "resource_owner_id", null: false
t.integer "application_id", null: false
t.string "token", limit: 255, null: false
t.integer "expires_in", null: false
t.text "redirect_uri", null: false
t.datetime "created_at", null: false
t.integer "resource_owner_id", null: false
t.integer "application_id", null: false
t.string "token", null: false
t.integer "expires_in", null: false
t.text "redirect_uri", null: false
t.datetime "created_at", null: false
t.datetime "revoked_at"
t.string "scopes", limit: 255
t.string "scopes"
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree
end

create_table "oauth_access_tokens", force: :cascade do |t|
t.integer "resource_owner_id"
t.integer "application_id"
t.string "token", limit: 255, null: false
t.string "refresh_token", limit: 255
t.string "token", null: false
t.string "refresh_token"
t.integer "expires_in"
t.datetime "revoked_at"
t.datetime "created_at", null: false
t.string "scopes", limit: 255
t.datetime "created_at", null: false
t.string "scopes"
t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree
t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree
t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree
end

create_table "oauth_applications", force: :cascade do |t|
t.string "name", limit: 255, null: false
t.string "uid", limit: 255, null: false
t.string "secret", limit: 255, null: false
t.text "redirect_uri", null: false
t.string "name", null: false
t.string "uid", null: false
t.string "secret", null: false
t.text "redirect_uri", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "owner_id"
t.string "owner_type", limit: 255
t.string "scopes", default: "", null: false
t.string "owner_type"
t.string "scopes", default: "", null: false
t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree
end

create_table "onet_occupations", force: :cascade do |t|
t.string "soc", limit: 255
t.string "title", limit: 255
t.string "soc"
t.string "title"
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
Expand All @@ -295,44 +301,45 @@
end

create_table "posts", force: :cascade do |t|
t.integer "user_id", null: false
t.string "title", limit: 255
t.integer "user_id", null: false
t.string "title"
t.datetime "published_at"
t.datetime "expired_at"
t.datetime "deleted_at"
t.boolean "draft", default: true, null: false
t.integer "comment_count", default: 0, null: false
t.boolean "draft", default: true, null: false
t.integer "comment_count", default: 0, null: false
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
t.string "short_description", limit: 255
t.integer "job_phase", null: false
t.integer "display", null: false
t.string "short_description"
t.integer "job_phase", null: false
t.integer "display", null: false
t.text "notes"
t.string "copyright_owner", limit: 255
t.string "seo_title", limit: 255
t.string "seo_description", limit: 255
t.string "seo_preview", limit: 255
t.string "custom_author", limit: 255
t.string "slug", null: false
t.string "copyright_owner"
t.string "seo_title"
t.string "seo_description"
t.string "seo_preview"
t.string "custom_author"
t.string "slug", null: false
t.integer "featured_media_id"
t.integer "primary_industry_id"
t.integer "primary_category_id"
t.integer "tile_media_id"
t.hstore "meta"
t.string "type", default: "Post", null: false
t.string "type", default: "Post", null: false
t.integer "author_id"
t.boolean "is_wysiwyg", default: true
t.boolean "noindex", default: false
t.boolean "nofollow", default: false
t.boolean "nosnippet", default: false
t.boolean "noodp", default: false
t.boolean "noarchive", default: false
t.boolean "noimageindex", default: false
t.boolean "is_sticky", default: false
t.boolean "is_wysiwyg", default: true
t.boolean "noindex", default: false
t.boolean "nofollow", default: false
t.boolean "nosnippet", default: false
t.boolean "noodp", default: false
t.boolean "noarchive", default: false
t.boolean "noimageindex", default: false
t.boolean "is_sticky", default: false
t.index ["author_id"], name: "index_posts_on_author_id", using: :btree
t.index ["slug"], name: "index_posts_on_slug", using: :btree
t.index ["type"], name: "index_posts_on_type", using: :btree
t.index ["user_id"], name: "index_posts_on_user_id", using: :btree
end

create_table "role_permissions", force: :cascade do |t|
Expand All @@ -344,10 +351,11 @@

create_table "roles", force: :cascade do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "resource_type"
t.string "resource_id"
t.integer "resource_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree
t.index ["name"], name: "index_roles_on_name", using: :btree
end

Expand All @@ -363,10 +371,10 @@

create_table "taggings", force: :cascade do |t|
t.integer "tag_id"
t.string "taggable_type"
t.integer "taggable_id"
t.string "taggable_type", limit: 255
t.string "tagger_type"
t.integer "tagger_id"
t.string "tagger_type", limit: 255
t.string "context", limit: 128
t.datetime "created_at"
t.index ["context"], name: "index_taggings_on_context", using: :btree
Expand All @@ -381,9 +389,8 @@
end

create_table "tags", force: :cascade do |t|
t.string "name", limit: 255
t.integer "taggings_count", default: 0
t.integer "tenant_id", default: 1
t.string "name"
t.integer "taggings_count", default: 0
t.index ["name"], name: "index_tags_on_name", unique: true, using: :btree
end

Expand All @@ -398,43 +405,47 @@
t.string "contact_email", limit: 200
t.string "contact_phone", limit: 20
t.datetime "deleted_at"
t.string "contract", limit: 255
t.string "did", limit: 255
t.string "contract"
t.string "did"
t.datetime "active_at"
t.datetime "deactive_at"
t.integer "owner_id"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["did"], name: "index_tenants_on_did", using: :btree
t.index ["owner_id"], name: "index_tenants_on_owner_id", using: :btree
t.index ["parent_id"], name: "index_tenants_on_parent_id", using: :btree
end

create_table "users", force: :cascade do |t|
t.string "email", limit: 255, default: "", null: false
t.string "email", default: "", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "tenant_id", null: false
t.string "encrypted_password", limit: 255, default: "", null: false
t.string "reset_password_token", limit: 255
t.integer "tenant_id", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 255
t.string "last_sign_in_ip", limit: 255
t.string "firstname", limit: 255, null: false
t.string "lastname", limit: 255
t.string "locale", limit: 30, default: "en_US", null: false
t.string "timezone", limit: 30, default: "EST", null: false
t.boolean "admin", default: false, null: false
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "firstname", null: false
t.string "lastname"
t.string "locale", limit: 30, default: "en_US", null: false
t.string "timezone", limit: 30, default: "EST", null: false
t.boolean "admin", default: false, null: false
t.index ["email"], name: "index_users_on_email", unique: true, using: :btree
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
t.index ["tenant_id"], name: "index_users_on_tenant_id", using: :btree
end

create_table "users_roles", id: false, force: :cascade do |t|
t.integer "user_id"
t.integer "role_id"
t.integer "user_id"
t.integer "role_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree
end

Expand All @@ -457,10 +468,10 @@
t.boolean "noodp", default: false
t.boolean "noarchive", default: false
t.boolean "noimageindex", default: false
t.text "seo_keywords"
t.string "dynamic_yield_sku"
t.string "dynamic_yield_category"
t.jsonb "tables_widget"
t.jsonb "charts_widget"
t.index ["user_id"], name: "index_webpages_on_user_id", using: :btree
end

Expand Down