Commit 9f74b759 by Bui Minh Duc

implement login feature

parent 9c2d41ac
...@@ -48,6 +48,8 @@ gem 'redcarpet', '~> 3.3', '>= 3.3.4' ...@@ -48,6 +48,8 @@ gem 'redcarpet', '~> 3.3', '>= 3.3.4'
gem 'rubocop', '~> 0.46.0' gem 'rubocop', '~> 0.46.0'
gem 'sidekiq', '~> 4.2', '>= 4.2.7' gem 'sidekiq', '~> 4.2', '>= 4.2.7'
gem 'omniauth-github', '~> 1.1', '>= 1.1.2'
group :development, :test do group :development, :test do
gem 'byebug', platform: :mri gem 'byebug', platform: :mri
end end
......
...@@ -72,6 +72,7 @@ GEM ...@@ -72,6 +72,7 @@ GEM
ffi (1.9.14) ffi (1.9.14)
globalid (0.3.7) globalid (0.3.7)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
hashie (3.4.6)
i18n (0.7.0) i18n (0.7.0)
jbuilder (2.6.1) jbuilder (2.6.1)
activesupport (>= 3.0.0, < 5.1) activesupport (>= 3.0.0, < 5.1)
...@@ -80,6 +81,7 @@ GEM ...@@ -80,6 +81,7 @@ GEM
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
jwt (1.5.6)
listen (3.0.8) listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
...@@ -96,13 +98,29 @@ GEM ...@@ -96,13 +98,29 @@ GEM
momentjs-rails (2.15.1) momentjs-rails (2.15.1)
railties (>= 3.1) railties (>= 3.1)
multi_json (1.12.1) multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0) multipart-post (2.0.0)
mysql2 (0.4.5) mysql2 (0.4.5)
nio4r (1.2.1) nio4r (1.2.1)
nokogiri (1.7.0) nokogiri (1.7.0)
mini_portile2 (~> 2.1.0) mini_portile2 (~> 2.1.0)
oauth2 (1.3.0)
faraday (>= 0.8, < 0.11)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
octokit (4.6.2) octokit (4.6.2)
sawyer (~> 0.8.0, >= 0.5.3) sawyer (~> 0.8.0, >= 0.5.3)
omniauth (1.3.2)
hashie (>= 1.2, < 4)
rack (>= 1.0, < 3)
omniauth-github (1.1.2)
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
parser (2.3.3.1) parser (2.3.3.1)
ast (~> 2.2) ast (~> 2.2)
powerpack (0.1.1) powerpack (0.1.1)
...@@ -215,6 +233,7 @@ DEPENDENCIES ...@@ -215,6 +233,7 @@ DEPENDENCIES
momentjs-rails (>= 2.9.0) momentjs-rails (>= 2.9.0)
mysql2 (~> 0.4.5) mysql2 (~> 0.4.5)
octokit (~> 4.6, >= 4.6.2) octokit (~> 4.6, >= 4.6.2)
omniauth-github (~> 1.1, >= 1.1.2)
puma (~> 3.0) puma (~> 3.0)
rails (~> 5.0.0, >= 5.0.0.1) rails (~> 5.0.0, >= 5.0.0.1)
redcarpet (~> 3.3, >= 3.3.4) redcarpet (~> 3.3, >= 3.3.4)
......
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
// Place all the styles related to the sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
...@@ -25,4 +25,8 @@ class ApplicationController < ActionController::Base ...@@ -25,4 +25,8 @@ class ApplicationController < ActionController::Base
false false
end end
end end
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
end end
...@@ -26,7 +26,7 @@ class MainController < ApplicationController ...@@ -26,7 +26,7 @@ class MainController < ApplicationController
@repos = @repos || Repository.all @repos = @repos || Repository.all
@selected_repos_name = Other.where(data_type: 0).map{ |other| other.data } @selected_repos_name = Other.where(data_type: 0).map{ |other| other.data }
@selected_repos = Repository.where(name: @selected_repos_name).includes(issues: [:labels]).where("issues.closed_at IS NULL AND issues.is_pull IN (?)", type_of_issue_query).references(:issues) @selected_repos = Repository.where(name: @selected_repos_name).includes(issues: :labels).where("issues.closed_at IS NULL AND issues.is_pull IN (?)", type_of_issue_query).references(:issues)
@data_table = [] @data_table = []
@selected_repos.each do |repo| @selected_repos.each do |repo|
......
class SessionsController < ApplicationController
def create
auth = request.env["omniauth.auth"]
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
session[:user_id] = user.id
redirect_to root_url, :notice => "Signed in!"
end
def destroy
session[:user_id] = nil
redirect_to root_url, :notice => "Signed out!"
end
end
...@@ -43,7 +43,10 @@ class UsersController < ApplicationController ...@@ -43,7 +43,10 @@ class UsersController < ApplicationController
end end
end end
# @pulls = Issue.where(user_id: @user.id, is_pull: true) # @pulls = Issue.where(user_id: @user.id, is_pull: true)
end
def new
@current_user = current_user
end end
end end
...@@ -12,4 +12,9 @@ module ApplicationHelper ...@@ -12,4 +12,9 @@ module ApplicationHelper
mm.to_s + " minutes " + ss.to_s + " seconds" mm.to_s + " minutes " + ss.to_s + " seconds"
end end
end end
def current_user
current_user ||= User.find(session[:user_id]) if session[:user_id]
current_user
end
end end
module SessionsHelper
end
class Label < ApplicationRecord class Label < ApplicationRecord
belongs_to :repository has_many :label_repositories
has_many :repositories, through: :label_repositories
has_and_belongs_to_many :issues has_and_belongs_to_many :issues
end end
class LabelRepository < ApplicationRecord
belongs_to :label
belongs_to :repository
end
class Repository < ApplicationRecord class Repository < ApplicationRecord
has_many :issues has_many :issues
has_many :labels has_many :label_repositories
has_many :labels, through: :label_repositories
end end
class User < ApplicationRecord class User < ApplicationRecord
has_and_belongs_to_many :issues has_and_belongs_to_many :issues
has_many :own_issues, class_name: "Issue", foreign_key: "user_id" has_many :own_issues, class_name: "Issue", foreign_key: "user_id"
def self.create_with_omniauth(auth)
user = User.find_by(id: auth["uid"])
if user.nil?
user = User.new
user.id = auth["uid"]
user.login = auth["info"]["nickname"]
user.provider = auth["provider"]
end
user.name = auth["info"]["name"]
user.save
user
end
end end
...@@ -15,6 +15,20 @@ ...@@ -15,6 +15,20 @@
<li><%= link_to "User", users_path %></li> <li><%= link_to "User", users_path %></li>
<li><%= link_to "Repository", repositories_path %></li> <li><%= link_to "Repository", repositories_path %></li>
<li><%= link_to "Settings", settings_path %></li> <li><%= link_to "Settings", settings_path %></li>
<% if current_user %>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="glyphicon glyphicon-user"></span>
<%= current_user.name %>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="<%= signout_path %>"><span class="glyphicon glyphicon-log-out"></span> Log out</a></li>
</ul>
</li>
<% else %>
<li><a href="/auth/github"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
<% end %>
</ul> </ul>
</div> </div>
</div> </div>
......
...@@ -6,13 +6,29 @@ ...@@ -6,13 +6,29 @@
<div id="toolbar"> <div id="toolbar">
<form class="form-inline"> <form class="form-inline">
<div class='input-group date' id='from_date'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<div class='input-group date' id='to_date'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<div class="form-group"> <div class="form-group">
<label>Type</label> <select class="selectpicker" id="selectpicker1" multiple data-live-search="true" multiple data-selected-text-format="count > 3" data-actions-box="true" style="display: none;">
<% @repo.labels.each do |label| %>
<option><%= label.name %></option>
<% end %>
</select>
</div>
<div class="form-group"> <div class="form-group">
<%= select_tag "type", options_from_collection_for_select(@type, "first", "second", @current_type), { class: "form-control" } %> <%= select_tag "type", options_from_collection_for_select(@type, "first", "second", @current_type), { class: "form-control" } %>
<input type="submit" class="btn btn-default"> <input type="submit" class="btn btn-default">
</div> </div>
</div>
</form> </form>
</div> </div>
...@@ -60,3 +76,17 @@ ...@@ -60,3 +76,17 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$(document).on('ready', function(event) {
// location.reload();
$('#from_date').datetimepicker({
format: "DD/MM/YYYY",
showClear: true
});
$('#to_date').datetimepicker({
format: "DD/MM/YYYY",
showClear: true
});
});
</script>
<div class="container">
<% if @current_user %>
<h1><%= @current_user.name %></h1>
<% else %>
<%= link_to "Sign in with Github", "/auth/github" %>
<% end %>
</div>
...@@ -74,6 +74,12 @@ ...@@ -74,6 +74,12 @@
<td class="col-md-3"><%= "x 0.5" %></td> <td class="col-md-3"><%= "x 0.5" %></td>
<td class="col-md-3"><%= @score_after[2] * 0.5 %></td> <td class="col-md-3"><%= @score_after[2] * 0.5 %></td>
</tr> </tr>
<tr>
<td class="col-md-3">Large</td>
<td class="col-md-3"><%= @score_after[3] %></td>
<td class="col-md-3"><%= "x 1.0" %></td>
<td class="col-md-3"><%= @score_after[3] * 1.0 %></td>
</tr>
<tr style="font-weight: bold"> <tr style="font-weight: bold">
<td class="col-md-3 text-right">Total Comment (A)</td> <td class="col-md-3 text-right">Total Comment (A)</td>
<td class="col-md-3"><%= total_comment @score_after %></td> <td class="col-md-3"><%= total_comment @score_after %></td>
......
Rails.application.config.middleware.use OmniAuth::Builder do
provider :github, Rails.application.secrets.GITHUB_KEY, Rails.application.secrets.GITHUB_SECRET, scope: "user:email,user:follow"
end
...@@ -16,4 +16,7 @@ Rails.application.routes.draw do ...@@ -16,4 +16,7 @@ Rails.application.routes.draw do
get "/settings", to: "settings#index" get "/settings", to: "settings#index"
post "/settings/1", to: "settings#update_setting_1" post "/settings/1", to: "settings#update_setting_1"
get "/auth/:provider/callback" => "sessions#create"
get "/signout" => "sessions#destroy", :as => :signout
end end
class RemoveReferenceFromLabel < ActiveRecord::Migration[5.0]
def change
# execute "DROP INDEX index_labels_on_repository_id ON labels"
remove_foreign_key :labels, :repositories
remove_reference :labels, :repository, index: true
end
end
class CreateLabelRepositories < ActiveRecord::Migration[5.0]
def change
create_table :label_repositories do |t|
t.references :label, foreign_key: true
t.references :repository, foreign_key: true
t.timestamps
end
end
end
class AddSomeFieldsToUser < ActiveRecord::Migration[5.0]
def change
add_column :users, :provider, :string
add_column :users, :uid, :string
add_column :users, :name, :string
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170116025901) do ActiveRecord::Schema.define(version: 20170118072055) do
create_table "comments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| create_table "comments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
t.string "html_url" t.string "html_url"
...@@ -59,15 +59,22 @@ ActiveRecord::Schema.define(version: 20170116025901) do ...@@ -59,15 +59,22 @@ ActiveRecord::Schema.define(version: 20170116025901) do
t.index ["user_id", "issue_id"], name: "index_issues_users_on_user_id_and_issue_id", using: :btree t.index ["user_id", "issue_id"], name: "index_issues_users_on_user_id_and_issue_id", using: :btree
end end
create_table "label_repositories", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
t.integer "label_id"
t.integer "repository_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["label_id"], name: "index_label_repositories_on_label_id", using: :btree
t.index ["repository_id"], name: "index_label_repositories_on_repository_id", using: :btree
end
create_table "labels", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| create_table "labels", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
t.string "url" t.string "url"
t.string "name" t.string "name"
t.string "color" t.string "color"
t.boolean "default" t.boolean "default"
t.integer "repository_id"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["repository_id"], name: "index_labels_on_repository_id", using: :btree
end end
create_table "others", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| create_table "others", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
...@@ -134,6 +141,9 @@ ActiveRecord::Schema.define(version: 20170116025901) do ...@@ -134,6 +141,9 @@ ActiveRecord::Schema.define(version: 20170116025901) do
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.integer "team_id" t.integer "team_id"
t.boolean "team_ventura" t.boolean "team_ventura"
t.string "provider"
t.string "uid"
t.string "name"
t.index ["team_id"], name: "index_users_on_team_id", using: :btree t.index ["team_id"], name: "index_users_on_team_id", using: :btree
end end
...@@ -141,7 +151,8 @@ ActiveRecord::Schema.define(version: 20170116025901) do ...@@ -141,7 +151,8 @@ ActiveRecord::Schema.define(version: 20170116025901) do
add_foreign_key "comments", "users" add_foreign_key "comments", "users"
add_foreign_key "issues", "repositories" add_foreign_key "issues", "repositories"
add_foreign_key "issues", "users" add_foreign_key "issues", "users"
add_foreign_key "labels", "repositories" add_foreign_key "label_repositories", "labels"
add_foreign_key "label_repositories", "repositories"
add_foreign_key "review_comments", "issues" add_foreign_key "review_comments", "issues"
add_foreign_key "review_comments", "users" add_foreign_key "review_comments", "users"
add_foreign_key "timelines", "issues" add_foreign_key "timelines", "issues"
......
...@@ -1209,3 +1209,125 @@ I, [2017-01-17T17:00:03.540697 #14266] INFO -- : Insert issues ...@@ -1209,3 +1209,125 @@ I, [2017-01-17T17:00:03.540697 #14266] INFO -- : Insert issues
I, [2017-01-17T17:02:52.819647 #14266] INFO -- : Insert comments I, [2017-01-17T17:02:52.819647 #14266] INFO -- : Insert comments
I, [2017-01-17T17:03:30.814259 #14266] INFO -- : Insert review comments I, [2017-01-17T17:03:30.814259 #14266] INFO -- : Insert review comments
I, [2017-01-17T17:04:38.330120 #14266] INFO -- : Finished task update in 274.957304648s I, [2017-01-17T17:04:38.330120 #14266] INFO -- : Finished task update in 274.957304648s
I, [2017-01-17T18:00:03.599045 #15674] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-17T18:00:03.602557 #15674] INFO -- : Insert issues
I, [2017-01-17T18:02:50.183420 #15674] INFO -- : Insert comments
I, [2017-01-17T18:03:28.806906 #15674] INFO -- : Insert review comments
I, [2017-01-17T18:04:31.138710 #15674] INFO -- : Finished task update in 267.69487965s
I, [2017-01-17T19:00:03.331913 #16002] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-17T19:00:03.335492 #16002] INFO -- : Insert issues
I, [2017-01-17T19:02:51.252118 #16002] INFO -- : Insert comments
I, [2017-01-17T19:03:29.461120 #16002] INFO -- : Insert review comments
I, [2017-01-17T19:04:32.749020 #16002] INFO -- : Finished task update in 269.572373816s
I, [2017-01-17T20:00:03.943139 #16376] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-17T20:00:03.946626 #16376] INFO -- : Insert issues
I, [2017-01-17T20:02:49.957612 #16376] INFO -- : Insert comments
I, [2017-01-17T20:03:29.136630 #16376] INFO -- : Insert review comments
I, [2017-01-17T20:04:31.992370 #16376] INFO -- : Finished task update in 268.204070223s
I, [2017-01-17T21:00:03.141687 #16691] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-17T21:00:03.144885 #16691] INFO -- : Insert issues
I, [2017-01-17T21:02:50.818656 #16691] INFO -- : Insert comments
I, [2017-01-17T21:03:31.376324 #16691] INFO -- : Insert review comments
I, [2017-01-17T21:04:34.729707 #16691] INFO -- : Finished task update in 271.737716348s
I, [2017-01-17T22:00:03.809794 #17006] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-17T22:00:03.813070 #17006] INFO -- : Insert issues
I, [2017-01-17T22:02:57.867473 #17006] INFO -- : Insert comments
I, [2017-01-17T22:03:37.415592 #17006] INFO -- : Insert review comments
I, [2017-01-17T22:04:41.520408 #17006] INFO -- : Finished task update in 277.862494126s
I, [2017-01-17T23:00:03.656454 #17322] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-17T23:00:03.659948 #17322] INFO -- : Insert issues
I, [2017-01-17T23:02:58.472368 #17322] INFO -- : Insert comments
I, [2017-01-17T23:03:38.256895 #17322] INFO -- : Insert review comments
I, [2017-01-17T23:05:46.910475 #17322] INFO -- : Finished task update in 343.404358489s
I, [2017-01-18T00:00:03.026488 #17647] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T00:00:03.029894 #17647] INFO -- : Insert issues
I, [2017-01-18T00:02:52.647284 #17647] INFO -- : Insert comments
I, [2017-01-18T00:03:31.815346 #17647] INFO -- : Insert review comments
I, [2017-01-18T00:04:38.770822 #17647] INFO -- : Finished task update in 275.901051167s
I, [2017-01-18T01:00:03.839833 #17970] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T01:00:03.843405 #17970] INFO -- : Insert issues
I, [2017-01-18T01:02:54.193932 #17970] INFO -- : Insert comments
I, [2017-01-18T01:03:33.090302 #17970] INFO -- : Insert review comments
I, [2017-01-18T01:04:42.408417 #17970] INFO -- : Finished task update in 278.725285784s
I, [2017-01-18T02:00:03.527345 #18284] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T02:00:03.530482 #18284] INFO -- : Insert issues
I, [2017-01-18T02:02:56.019551 #18284] INFO -- : Insert comments
I, [2017-01-18T02:03:34.616701 #18284] INFO -- : Insert review comments
I, [2017-01-18T02:04:46.351758 #18284] INFO -- : Finished task update in 282.957287357s
I, [2017-01-18T03:00:03.510466 #18599] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T03:00:03.513737 #18599] INFO -- : Insert issues
I, [2017-01-18T03:02:55.194456 #18599] INFO -- : Insert comments
I, [2017-01-18T03:03:34.702270 #18599] INFO -- : Insert review comments
I, [2017-01-18T03:04:38.572891 #18599] INFO -- : Finished task update in 275.217399758s
I, [2017-01-18T04:00:03.686967 #18926] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T04:00:03.690388 #18926] INFO -- : Insert issues
I, [2017-01-18T04:02:51.809799 #18926] INFO -- : Insert comments
I, [2017-01-18T04:03:30.160598 #18926] INFO -- : Insert review comments
I, [2017-01-18T04:04:33.951986 #18926] INFO -- : Finished task update in 270.402028752s
I, [2017-01-18T05:00:03.121838 #19243] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T05:00:03.125372 #19243] INFO -- : Insert issues
I, [2017-01-18T05:02:50.729625 #19243] INFO -- : Insert comments
I, [2017-01-18T05:03:29.064951 #19243] INFO -- : Insert review comments
I, [2017-01-18T05:04:29.088598 #19243] INFO -- : Finished task update in 266.120214384s
I, [2017-01-18T06:00:03.247742 #19557] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T06:00:03.250929 #19557] INFO -- : Insert issues
I, [2017-01-18T06:02:52.181141 #19557] INFO -- : Insert comments
I, [2017-01-18T06:03:31.316798 #19557] INFO -- : Insert review comments
I, [2017-01-18T06:04:34.465748 #19557] INFO -- : Finished task update in 271.370921841s
I, [2017-01-18T07:00:03.623868 #20476] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T07:00:03.627292 #20476] INFO -- : Insert issues
I, [2017-01-18T07:02:49.796078 #20476] INFO -- : Insert comments
I, [2017-01-18T07:03:27.902237 #20476] INFO -- : Insert review comments
I, [2017-01-18T07:04:26.382020 #20476] INFO -- : Finished task update in 262.89536919s
I, [2017-01-18T08:00:03.796159 #21801] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T08:00:03.799417 #21801] INFO -- : Insert issues
I, [2017-01-18T08:02:53.779201 #21801] INFO -- : Insert comments
I, [2017-01-18T08:03:31.888668 #21801] INFO -- : Insert review comments
I, [2017-01-18T08:04:32.415493 #21801] INFO -- : Finished task update in 268.77316202s
I, [2017-01-18T09:00:03.595598 #26202] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T09:00:03.599179 #26202] INFO -- : Insert issues
I, [2017-01-18T09:02:52.476599 #26202] INFO -- : Insert comments
I, [2017-01-18T09:03:30.065058 #26202] INFO -- : Insert review comments
I, [2017-01-18T09:04:35.251373 #26202] INFO -- : Finished task update in 271.812594723s
I, [2017-01-18T09:24:41.834170 #27853] INFO -- : Begin task insert repository
I, [2017-01-18T09:24:41.834264 #27853] INFO -- : Insert repos
I, [2017-01-18T09:24:48.675651 #27853] INFO -- : Insert users
I, [2017-01-18T09:24:54.809174 #27853] INFO -- : Insert users
I, [2017-01-18T09:24:58.305287 #27853] INFO -- : Insert labels
I, [2017-01-18T09:28:46.921295 #27853] INFO -- : Finished task insert repository
I, [2017-01-18T09:35:45.937564 #28777] INFO -- : Begin task insert repository
I, [2017-01-18T09:35:45.937636 #28777] INFO -- : Insert repos
I, [2017-01-18T09:35:52.777739 #28777] INFO -- : Insert users
I, [2017-01-18T09:35:58.737397 #28777] INFO -- : Insert users
I, [2017-01-18T09:36:02.222221 #28777] INFO -- : Insert labels
I, [2017-01-18T09:40:28.973306 #28777] INFO -- : Finished task insert repository
I, [2017-01-18T10:00:03.426628 #30595] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T10:00:03.429961 #30595] INFO -- : Insert issues
I, [2017-01-18T10:02:52.671618 #30595] INFO -- : Insert comments
I, [2017-01-18T10:03:29.597376 #30595] INFO -- : Insert review comments
I, [2017-01-18T10:04:29.799891 #30595] INFO -- : Finished task update in 266.527805366s
I, [2017-01-18T10:37:49.046809 #777] INFO -- : Begin task insert repository
I, [2017-01-18T10:37:49.046914 #777] INFO -- : Insert repos
I, [2017-01-18T10:37:55.990760 #777] INFO -- : Insert users
I, [2017-01-18T10:38:02.031211 #777] INFO -- : Insert users
I, [2017-01-18T10:38:05.494212 #777] INFO -- : Insert labels
I, [2017-01-18T10:42:48.851535 #777] INFO -- : Finished task insert repository
I, [2017-01-18T11:00:03.925408 #3429] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T11:00:03.929270 #3429] INFO -- : Insert issues
I, [2017-01-18T11:02:47.994956 #3429] INFO -- : Insert comments
I, [2017-01-18T11:03:24.817093 #3429] INFO -- : Insert review comments
I, [2017-01-18T11:04:28.115325 #3429] INFO -- : Finished task update in 264.347569073s
I, [2017-01-18T12:00:03.233760 #6848] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T12:00:03.237834 #6848] INFO -- : Insert issues
I, [2017-01-18T12:02:45.998640 #6848] INFO -- : Insert comments
I, [2017-01-18T12:03:23.616452 #6848] INFO -- : Insert review comments
I, [2017-01-18T12:04:22.218155 #6848] INFO -- : Finished task update in 259.140449304s
I, [2017-01-18T13:00:03.418580 #8787] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T13:00:03.422586 #8787] INFO -- : Insert issues
I, [2017-01-18T13:02:49.049213 #8787] INFO -- : Insert comments
I, [2017-01-18T13:03:27.652488 #8787] INFO -- : Insert review comments
I, [2017-01-18T13:04:30.690522 #8787] INFO -- : Finished task update in 267.429486845s
I, [2017-01-18T14:00:03.798798 #10735] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T14:00:03.802621 #10735] INFO -- : Insert issues
I, [2017-01-18T15:00:04.369718 #15471] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2", "usedcar_v2", "usedcar_api"]
I, [2017-01-18T15:00:04.373572 #15471] INFO -- : Insert issues
...@@ -52,13 +52,20 @@ class GithubLoader ...@@ -52,13 +52,20 @@ class GithubLoader
db_label = Label.new db_label = Label.new
db_label.id = label.id db_label.id = label.id
db_label.url = label.url db_label.url = label.url
# db_label.repository_id = repo.id
end end
# db_label.repository_id = repo.id
db_label.name = normalized_label db_label.name = normalized_label
db_label.color = label.color db_label.color = label.color
db_label.default = label.default db_label.default = label.default
db_label.save db_label.save
label_repo = LabelRepository.find_by(label_id: db_label.id, repository_id: repo.id)
if label_repo.nil?
label_repo = LabelRepository.new
label_repo.label_id = db_label.id
label_repo.repository_id = repo.id
label_repo.save
end
end end
end end
end end
......
...@@ -40,7 +40,7 @@ namespace :github do ...@@ -40,7 +40,7 @@ namespace :github do
$logger.info "Begin task insert repository" $logger.info "Begin task insert repository"
loader.insert_repos($client) loader.insert_repos($client)
loader.insert_users($client) loader.insert_users($client)
# loader.insert_labels($client) loader.insert_labels($client)
$logger.info "Finished task insert repository" $logger.info "Finished task insert repository"
end end
......
{"files":{"tableExport-c85b00b832b8d61160510f2c23d9cb456a6cd26b0645291bef015eb09901b9e4.js":{"logical_path":"tableExport.js","mtime":"2016-11-29T14:55:01+07:00","size":15512,"digest":"c85b00b832b8d61160510f2c23d9cb456a6cd26b0645291bef015eb09901b9e4","integrity":"sha256-yFsAuDK41hFgUQ8sI9nLRWps0msGRSkb7wFesJkBueQ="},"application-5909bd6132b05f0ce11cbe2c603a15625db4513a023a59b81c2f70f6bd02d05a.js":{"logical_path":"application.js","mtime":"2017-01-12T16:08:57+07:00","size":830837,"digest":"5909bd6132b05f0ce11cbe2c603a15625db4513a023a59b81c2f70f6bd02d05a","integrity":"sha256-WQm9YTKwXwzhHL4sYDoVYl20UToCOlm4HC9w9r0C0Fo="},"application-c638f7a2d2650026bed6288ee69348d190e1c2409d17d921a78ba31faa8cd693.css":{"logical_path":"application.css","mtime":"2017-01-12T16:08:57+07:00","size":765136,"digest":"c638f7a2d2650026bed6288ee69348d190e1c2409d17d921a78ba31faa8cd693","integrity":"sha256-xjj3otJlACa+1iiO5pNI0ZDhwkCdF9khp4ujH6qM1pM="},"bootstrap/glyphicons-halflings-regular-13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407.eot":{"logical_path":"bootstrap/glyphicons-halflings-regular.eot","mtime":"2016-12-28T09:30:09+07:00","size":20127,"digest":"13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407","integrity":"sha256-E2NNqH2eI/jD7ZEIzhck0YOjmtBy5z4bPYy/ZG0tBAc="},"bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2":{"logical_path":"bootstrap/glyphicons-halflings-regular.woff2","mtime":"2016-12-28T09:30:09+07:00","size":18028,"digest":"fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c","integrity":"sha256-/hhdEaSWdokNR7t4MxKgzaWkTEA5IUCU55V7TAQO8Rw="},"bootstrap/glyphicons-halflings-regular-a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742.woff":{"logical_path":"bootstrap/glyphicons-halflings-regular.woff","mtime":"2016-12-28T09:30:09+07:00","size":23424,"digest":"a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742","integrity":"sha256-omOU9+3hAMoRjv8u2ghZYnWpg5uVnCJuFUOVV6WoB0I="},"bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf":{"logical_path":"bootstrap/glyphicons-halflings-regular.ttf","mtime":"2016-12-28T09:30:09+07:00","size":45404,"digest":"e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456","integrity":"sha256-45UEQJN1fYKvyxOJV9BqHqk2G9zwtELQahioBRr1dFY="},"bootstrap/glyphicons-halflings-regular-42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5.svg":{"logical_path":"bootstrap/glyphicons-halflings-regular.svg","mtime":"2016-12-28T09:30:09+07:00","size":108738,"digest":"42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5","integrity":"sha256-QvYGWdJlwaPDD5+kKry7Vr1KU69Ng9MW1t16NpA8Q+U="}},"assets":{"tableExport.js":"tableExport-c85b00b832b8d61160510f2c23d9cb456a6cd26b0645291bef015eb09901b9e4.js","application.js":"application-5909bd6132b05f0ce11cbe2c603a15625db4513a023a59b81c2f70f6bd02d05a.js","application.css":"application-c638f7a2d2650026bed6288ee69348d190e1c2409d17d921a78ba31faa8cd693.css","bootstrap/glyphicons-halflings-regular.eot":"bootstrap/glyphicons-halflings-regular-13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407.eot","bootstrap/glyphicons-halflings-regular.woff2":"bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2","bootstrap/glyphicons-halflings-regular.woff":"bootstrap/glyphicons-halflings-regular-a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742.woff","bootstrap/glyphicons-halflings-regular.ttf":"bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf","bootstrap/glyphicons-halflings-regular.svg":"bootstrap/glyphicons-halflings-regular-42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5.svg"}}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/*The MIT License (MIT)
Copyright (c) 2014 https://github.com/kayalshri/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.*/
jQuery.base64 = ( function( $ ) {
var _PADCHAR = "=",
_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
_VERSION = "1.0";
function _getbyte64( s, i ) {
// This is oddly fast, except on Chrome/V8.
// Minimal or no improvement in performance by using a
// object with properties mapping chars to value (eg. 'A': 0)
var idx = _ALPHA.indexOf( s.charAt( i ) );
if ( idx === -1 ) {
throw "Cannot decode base64";
}
return idx;
}
function _decode( s ) {
var pads = 0,
i,
b10,
imax = s.length,
x = [];
s = String( s );
if ( imax === 0 ) {
return s;
}
if ( imax % 4 !== 0 ) {
throw "Cannot decode base64";
}
if ( s.charAt( imax - 1 ) === _PADCHAR ) {
pads = 1;
if ( s.charAt( imax - 2 ) === _PADCHAR ) {
pads = 2;
}
// either way, we want to ignore this last block
imax -= 4;
}
for ( i = 0; i < imax; i += 4 ) {
b10 = ( _getbyte64( s, i ) << 18 ) | ( _getbyte64( s, i + 1 ) << 12 ) | ( _getbyte64( s, i + 2 ) << 6 ) | _getbyte64( s, i + 3 );
x.push( String.fromCharCode( b10 >> 16, ( b10 >> 8 ) & 0xff, b10 & 0xff ) );
}
switch ( pads ) {
case 1:
b10 = ( _getbyte64( s, i ) << 18 ) | ( _getbyte64( s, i + 1 ) << 12 ) | ( _getbyte64( s, i + 2 ) << 6 );
x.push( String.fromCharCode( b10 >> 16, ( b10 >> 8 ) & 0xff ) );
break;
case 2:
b10 = ( _getbyte64( s, i ) << 18) | ( _getbyte64( s, i + 1 ) << 12 );
x.push( String.fromCharCode( b10 >> 16 ) );
break;
}
return x.join( "" );
}
function _getbyte( s, i ) {
var x = s.charCodeAt( i );
if ( x > 255 ) {
throw "INVALID_CHARACTER_ERR: DOM Exception 5";
}
return x;
}
function _encode( s ) {
if ( arguments.length !== 1 ) {
throw "SyntaxError: exactly one argument required";
}
s = String( s );
var i,
b10,
x = [],
imax = s.length - s.length % 3;
if ( s.length === 0 ) {
return s;
}
for ( i = 0; i < imax; i += 3 ) {
b10 = ( _getbyte( s, i ) << 16 ) | ( _getbyte( s, i + 1 ) << 8 ) | _getbyte( s, i + 2 );
x.push( _ALPHA.charAt( b10 >> 18 ) );
x.push( _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) );
x.push( _ALPHA.charAt( ( b10 >> 6 ) & 0x3f ) );
x.push( _ALPHA.charAt( b10 & 0x3f ) );
}
switch ( s.length - imax ) {
case 1:
b10 = _getbyte( s, i ) << 16;
x.push( _ALPHA.charAt( b10 >> 18 ) + _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) + _PADCHAR + _PADCHAR );
break;
case 2:
b10 = ( _getbyte( s, i ) << 16 ) | ( _getbyte( s, i + 1 ) << 8 );
x.push( _ALPHA.charAt( b10 >> 18 ) + _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) + _ALPHA.charAt( ( b10 >> 6 ) & 0x3f ) + _PADCHAR );
break;
}
return x.join( "" );
}
return {
decode: _decode,
encode: _encode,
VERSION: _VERSION
};
}( jQuery ) );
(function($){
$.fn.extend({
tableExport: function(options) {
var defaults = {
separator: ',',
ignoreColumn: [],
tableName:'yourTableName',
type:'csv',
pdfFontSize:14,
pdfLeftMargin:20,
escape:'true',
htmlContent:'false',
consoleLog:'false'
};
var options = $.extend(defaults, options);
var el = this;
if(defaults.type == 'csv' || defaults.type == 'txt'){
// Header
var tdData ="";
$(el).find('thead').find('tr').each(function() {
tdData += "\n";
$(this).filter(':visible').find('th').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
tdData += '"' + parseString($(this)) + '"' + defaults.separator;
}
}
});
tdData = $.trim(tdData);
tdData = $.trim(tdData).substring(0, tdData.length -1);
});
// Row vs Column
$(el).find('tbody').find('tr').each(function() {
tdData += "\n";
$(this).filter(':visible').find('td').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
tdData += '"'+ parseString($(this)) + '"'+ defaults.separator;
}
}
});
//tdData = $.trim(tdData);
tdData = $.trim(tdData).substring(0, tdData.length -1);
});
//output
if(defaults.consoleLog == 'true'){
console.log(tdData);
}
var base64data = "base64," + $.base64.encode(tdData);
window.open('data:application/'+defaults.type+';filename=exportData;' + base64data);
}else if(defaults.type == 'sql'){
// Header
var tdData ="INSERT INTO `"+defaults.tableName+"` (";
$(el).find('thead').find('tr').each(function() {
$(this).filter(':visible').find('th').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
tdData += '`' + parseString($(this)) + '`,' ;
}
}
});
tdData = $.trim(tdData);
tdData = $.trim(tdData).substring(0, tdData.length -1);
});
tdData += ") VALUES ";
// Row vs Column
$(el).find('tbody').find('tr').each(function() {
tdData += "(";
$(this).filter(':visible').find('td').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
tdData += '"'+ parseString($(this)) + '",';
}
}
});
tdData = $.trim(tdData).substring(0, tdData.length -1);
tdData += "),";
});
tdData = $.trim(tdData).substring(0, tdData.length -1);
tdData += ";";
//output
//console.log(tdData);
if(defaults.consoleLog == 'true'){
console.log(tdData);
}
var base64data = "base64," + $.base64.encode(tdData);
window.open('data:application/sql;filename=exportData;' + base64data);
}else if(defaults.type == 'json'){
var jsonHeaderArray = [];
$(el).find('thead').find('tr').each(function() {
var tdData ="";
var jsonArrayTd = [];
$(this).filter(':visible').find('th').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
jsonArrayTd.push(parseString($(this)));
}
}
});
jsonHeaderArray.push(jsonArrayTd);
});
var jsonArray = [];
$(el).find('tbody').find('tr').each(function() {
var tdData ="";
var jsonArrayTd = [];
$(this).filter(':visible').find('td').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
jsonArrayTd.push(parseString($(this)));
}
}
});
jsonArray.push(jsonArrayTd);
});
var jsonExportArray =[];
jsonExportArray.push({header:jsonHeaderArray,data:jsonArray});
//Return as JSON
//console.log(JSON.stringify(jsonExportArray));
//Return as Array
//console.log(jsonExportArray);
if(defaults.consoleLog == 'true'){
console.log(JSON.stringify(jsonExportArray));
}
var base64data = "base64," + $.base64.encode(JSON.stringify(jsonExportArray));
window.open('data:application/json;filename=exportData;' + base64data);
}else if(defaults.type == 'xml'){
var xml = '<?xml version="1.0" encoding="utf-8"?>';
xml += '<tabledata><fields>';
// Header
$(el).find('thead').find('tr').each(function() {
$(this).filter(':visible').find('th').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
xml += "<field>" + parseString($(this)) + "</field>";
}
}
});
});
xml += '</fields><data>';
// Row Vs Column
var rowCount=1;
$(el).find('tbody').find('tr').each(function() {
xml += '<row id="'+rowCount+'">';
var colCount=0;
$(this).filter(':visible').find('td').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
xml += "<column-"+colCount+">"+parseString($(this))+"</column-"+colCount+">";
}
}
colCount++;
});
rowCount++;
xml += '</row>';
});
xml += '</data></tabledata>'
if(defaults.consoleLog == 'true'){
console.log(xml);
}
var base64data = "base64," + $.base64.encode(xml);
window.open('data:application/xml;filename=exportData;' + base64data);
}else if(defaults.type == 'excel' || defaults.type == 'doc'|| defaults.type == 'powerpoint' ){
//console.log($(this).html());
var excel="<table>";
// Header
$(el).find('thead').find('tr').each(function() {
excel += "<tr>";
$(this).filter(':visible').find('th').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
excel += "<td>" + parseString($(this))+ "</td>";
}
}
});
excel += '</tr>';
});
// Row Vs Column
var rowCount=1;
$(el).find('tbody').find('tr').each(function() {
excel += "<tr>";
var colCount=0;
$(this).filter(':visible').find('td').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
excel += "<td>"+parseString($(this))+"</td>";
}
}
colCount++;
});
rowCount++;
excel += '</tr>';
});
excel += '</table>'
if(defaults.consoleLog == 'true'){
console.log(excel);
}
var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:"+defaults.type+"' xmlns='http://www.w3.org/TR/REC-html40'>";
excelFile += "<head>";
excelFile += "<!--[if gte mso 9]>";
excelFile += "<xml>";
excelFile += "<x:ExcelWorkbook>";
excelFile += "<x:ExcelWorksheets>";
excelFile += "<x:ExcelWorksheet>";
excelFile += "<x:Name>";
excelFile += "{worksheet}";
excelFile += "</x:Name>";
excelFile += "<x:WorksheetOptions>";
excelFile += "<x:DisplayGridlines/>";
excelFile += "</x:WorksheetOptions>";
excelFile += "</x:ExcelWorksheet>";
excelFile += "</x:ExcelWorksheets>";
excelFile += "</x:ExcelWorkbook>";
excelFile += "</xml>";
excelFile += "<![endif]-->";
excelFile += "</head>";
excelFile += "<body>";
excelFile += excel;
excelFile += "</body>";
excelFile += "</html>";
var base64data = "base64," + $.base64.encode(excelFile);
window.open('data:application/vnd.ms-'+defaults.type+';filename=exportData.doc;' + base64data);
}else if(defaults.type == 'png'){
html2canvas($(el), {
onrendered: function(canvas) {
var img = canvas.toDataURL("image/png");
window.open(img);
}
});
}else if(defaults.type == 'pdf'){
var doc = new jsPDF('p','pt', 'a4', true);
doc.setFontSize(defaults.pdfFontSize);
// Header
var startColPosition=defaults.pdfLeftMargin;
$(el).find('thead').find('tr').each(function() {
$(this).filter(':visible').find('th').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
var colPosition = startColPosition+ (index * 50);
doc.text(colPosition,20, parseString($(this)));
}
}
});
});
// Row Vs Column
var startRowPosition = 20; var page =1;var rowPosition=0;
$(el).find('tbody').find('tr').each(function(index,data) {
rowCalc = index+1;
if (rowCalc % 26 == 0){
doc.addPage();
page++;
startRowPosition=startRowPosition+10;
}
rowPosition=(startRowPosition + (rowCalc * 10)) - ((page -1) * 280);
$(this).filter(':visible').find('td').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
var colPosition = startColPosition+ (index * 50);
doc.text(colPosition,rowPosition, parseString($(this)));
}
}
});
});
// Output as Data URI
doc.output('datauri');
}
function parseString(data){
if(defaults.htmlContent == 'true'){
content_data = data.html().trim();
}else{
content_data = data.text().trim();
}
if(defaults.escape == 'true'){
content_data = escape(content_data);
}
return content_data;
}
}
});
})(jQuery);
require 'test_helper'
class SessionsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
label: one
repository: one
two:
label: two
repository: two
require 'test_helper'
class LabelRepositoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment