Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
6da0ab7d
Commit
6da0ab7d
authored
Jan 20, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Github Importer: AJAX update status
parent
f9fb7667
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
9 deletions
+34
-9
app/controllers/github_imports_controller.rb
app/controllers/github_imports_controller.rb
+6
-1
app/views/github_imports/create.js.haml
app/views/github_imports/create.js.haml
+4
-2
app/views/github_imports/status.html.haml
app/views/github_imports/status.html.haml
+21
-6
config/routes.rb
config/routes.rb
+1
-0
lib/gitlab/github/project_creator.rb
lib/gitlab/github/project_creator.rb
+2
-0
No files found.
app/controllers/github_imports_controller.rb
View file @
6da0ab7d
...
@@ -22,6 +22,11 @@ class GithubImportsController < ApplicationController
...
@@ -22,6 +22,11 @@ class GithubImportsController < ApplicationController
@repos
.
reject!
{
|
repo
|
already_added_projects_names
.
include?
repo
.
full_name
}
@repos
.
reject!
{
|
repo
|
already_added_projects_names
.
include?
repo
.
full_name
}
end
end
def
jobs
jobs
=
current_user
.
created_projects
.
where
(
import_type:
"github"
).
to_json
(
:only
=>
[
:id
,
:import_status
])
render
json:
jobs
end
def
create
def
create
@repo_id
=
params
[
:repo_id
].
to_i
@repo_id
=
params
[
:repo_id
].
to_i
repo
=
octo_client
.
repo
(
@repo_id
)
repo
=
octo_client
.
repo
(
@repo_id
)
...
@@ -42,7 +47,7 @@ class GithubImportsController < ApplicationController
...
@@ -42,7 +47,7 @@ class GithubImportsController < ApplicationController
namespace
.
add_owner
(
current_user
)
namespace
.
add_owner
(
current_user
)
end
end
Gitlab
::
Github
::
ProjectCreator
.
new
(
repo
,
namespace
,
current_user
).
execute
@project
=
Gitlab
::
Github
::
ProjectCreator
.
new
(
repo
,
namespace
,
current_user
).
execute
end
end
private
private
...
...
app/views/github_imports/create.js.haml
View file @
6da0ab7d
...
@@ -12,5 +12,7 @@
...
@@ -12,5 +12,7 @@
target_field.find('input').prop("value", origin_namespace)
target_field.find('input').prop("value", origin_namespace)
-
else
-
else
:plain
:plain
$("table.import-jobs tbody").prepend($("tr#repo_
#{
@repo_id
}
"))
job = $("tr#repo_
#{
@repo_id
}
")
$("tr#repo_
#{
@repo_id
}
").addClass("active").find(".import-actions").html("<i class='fa fa-spinner fa-spin'></i> started")
job.attr("id", "project_
#{
@project
.
id
}
")
$("table.import-jobs tbody").prepend(job)
job.addClass("active").find(".import-actions").html("<i class='fa fa-spinner fa-spin'></i> started")
app/views/github_imports/status.html.haml
View file @
6da0ab7d
...
@@ -4,8 +4,6 @@
...
@@ -4,8 +4,6 @@
%p
.light
%p
.light
Select projects you want to import.
Select projects you want to import.
%span
.pull-right
Reload to see the progress.
%hr
%hr
%table
.table.import-jobs
%table
.table.import-jobs
...
@@ -16,11 +14,11 @@
...
@@ -16,11 +14,11 @@
%th
Status
%th
Status
%tbody
%tbody
-
@already_added_projects
.
each
do
|
project
|
-
@already_added_projects
.
each
do
|
project
|
%tr
{
id:
"
repo
_#{project.id}"
,
class:
"#{project_status_css_class(project.import_status)}"
}
%tr
{
id:
"
project
_#{project.id}"
,
class:
"#{project_status_css_class(project.import_status)}"
}
%td
=
project
.
import_source
%td
=
project
.
import_source
%td
%td
%strong
=
link_to
project
.
name_with_namespace
,
project
%strong
=
link_to
project
.
name_with_namespace
,
project
%td
%td
.job-status
-
if
project
.
import_status
==
'finished'
-
if
project
.
import_status
==
'finished'
%span
.cgreen
%span
.cgreen
%i
.fa.fa-check
%i
.fa.fa-check
...
@@ -33,7 +31,7 @@
...
@@ -33,7 +31,7 @@
%td
=
repo
.
full_name
%td
=
repo
.
full_name
%td
.import-target
%td
.import-target
=
repo
.
full_name
=
repo
.
full_name
%td
.import-actions
%td
.import-actions
.job-status
=
button_tag
"Add"
,
class:
"btn btn-add-to-import"
=
button_tag
"Add"
,
class:
"btn btn-add-to-import"
...
@@ -46,3 +44,20 @@
...
@@ -46,3 +44,20 @@
new_namespace = tr.find(".import-target input").prop("value")
new_namespace = tr.find(".import-target input").prop("value")
tr.find(".import-target").empty().append(new_namespace + "/" + tr.find(".import-target").data("project_name"))
tr.find(".import-target").empty().append(new_namespace + "/" + tr.find(".import-target").data("project_name"))
$.post "
#{
github_import_url
}
", {repo_id: id, new_namespace: new_namespace}, dataType: 'script'
$.post "
#{
github_import_url
}
", {repo_id: id, new_namespace: new_namespace}, dataType: 'script'
setInterval (->
$.get "
#{
jobs_github_import_path
}
", (data)->
$.each data, (i, job) ->
job_item = $("#project_" + job.id)
status_field = job_item.find(".job-status")
if job.import_status == 'finished'
job_item.removeClass("active").addClass("success")
status_field.html('<span class="cgreen"><i class="fa fa-check"></i> done</span>')
else if job.import_status == 'started'
status_field.html("<i class='fa fa-spinner fa-spin'></i> started")
else
status_field.html(job.import_status)
), 4000
config/routes.rb
View file @
6da0ab7d
...
@@ -57,6 +57,7 @@ Gitlab::Application.routes.draw do
...
@@ -57,6 +57,7 @@ Gitlab::Application.routes.draw do
resource
:github_import
,
only:
[
:create
,
:new
]
do
resource
:github_import
,
only:
[
:create
,
:new
]
do
get
:status
get
:status
get
:callback
get
:callback
get
:jobs
end
end
#
#
...
...
lib/gitlab/github/project_creator.rb
View file @
6da0ab7d
...
@@ -31,6 +31,8 @@ module Gitlab
...
@@ -31,6 +31,8 @@ module Gitlab
@project
.
import_start
@project
.
import_start
end
end
end
end
@project
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment