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
Léo-Paul Géneau
gitlab-ce
Commits
74520f23
Commit
74520f23
authored
May 09, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Encode state as base64 string
parent
baef6728
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
22 deletions
+27
-22
app/assets/javascripts/ci/build.coffee
app/assets/javascripts/ci/build.coffee
+14
-7
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+1
-8
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+3
-3
lib/ci/ansi2html.rb
lib/ci/ansi2html.rb
+9
-4
No files found.
app/assets/javascripts/ci/build.coffee
View file @
74520f23
class
CiBuild
class
CiBuild
@
interval
:
null
@
interval
:
null
@
state
:
null
constructor
:
(
build_url
,
build_status
)
->
constructor
:
(
build_url
,
build_status
,
build_state
)
->
clearInterval
(
CiBuild
.
interval
)
clearInterval
(
CiBuild
.
interval
)
@
state
=
build_state
@
initScrollButtonAffix
()
@
initScrollButtonAffix
()
if
build_status
==
"running"
||
build_status
==
"pending"
if
build_status
==
"running"
||
build_status
==
"pending"
...
@@ -26,14 +29,18 @@ class CiBuild
...
@@ -26,14 +29,18 @@ class CiBuild
CiBuild
.
interval
=
setInterval
=>
CiBuild
.
interval
=
setInterval
=>
if
window
.
location
.
href
.
split
(
"#"
).
first
()
is
build_url
if
window
.
location
.
href
.
split
(
"#"
).
first
()
is
build_url
$
.
ajax
$
.
ajax
url
:
build_url
url
:
build_url
+
"/trace.json?state="
+
encodeURIComponent
(
@
state
)
dataType
:
"json"
dataType
:
"json"
success
:
(
build
)
=>
success
:
(
log
)
=>
if
build
.
status
==
"running"
@
state
=
log
.
state
$
(
'#build-trace code'
).
html
build
.
trace_html
if
log
.
status
is
"running"
$
(
'#build-trace code'
).
append
'<i class="fa fa-refresh fa-spin"/>'
if
log
.
append
$
(
'.fa-refresh'
).
before
log
.
html
else
$
(
'#build-trace code'
).
html
log
.
html
$
(
'#build-trace code'
).
append
'<i class="fa fa-refresh fa-spin"/>'
@
checkAutoscroll
()
@
checkAutoscroll
()
else
if
build
.
status
!=
build_status
else
if
log
.
status
isnt
build_status
Turbolinks
.
visit
build_url
Turbolinks
.
visit
build_url
,
4000
,
4000
...
...
app/controllers/projects/builds_controller.rb
View file @
74520f23
...
@@ -41,7 +41,7 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -41,7 +41,7 @@ class Projects::BuildsController < Projects::ApplicationController
def
trace
def
trace
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
json
do
format
.
json
do
render
json:
@build
.
trace_with_state
(
params
_state
).
merge!
(
id:
@build
.
id
,
status:
@build
.
status
)
render
json:
@build
.
trace_with_state
(
params
[
:state
]
).
merge!
(
id:
@build
.
id
,
status:
@build
.
status
)
end
end
end
end
end
end
...
@@ -80,13 +80,6 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -80,13 +80,6 @@ class Projects::BuildsController < Projects::ApplicationController
private
private
def
params_state
begin
JSON
.
parse
(
params
[
:state
],
symbolize_names:
true
)
rescue
end
end
def
build
def
build
@build
||=
project
.
builds
.
unscoped
.
find_by!
(
id:
params
[
:id
])
@build
||=
project
.
builds
.
unscoped
.
find_by!
(
id:
params
[
:id
])
end
end
...
...
app/views/projects/builds/show.html.haml
View file @
74520f23
-
page_title
"
#{
@build
.
name
}
(#
#{
@build
.
id
}
)"
,
"Builds"
-
page_title
"
#{
@build
.
name
}
(#
#{
@build
.
id
}
)"
,
"Builds"
=
render
"header_title"
=
render
"header_title"
-
trace
=
build
.
trace_for
_state
-
trace
_with_state
=
@build
.
trace_with
_state
.build-page
.build-page
.row-content-block.top-block
.row-content-block.top-block
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
%pre
.trace
#build-trace
%pre
.trace
#build-trace
%code
.bash
%code
.bash
=
preserve
do
=
preserve
do
=
raw
trace
[
:html
]
=
raw
trace
_with_state
[
:html
]
-
if
@build
.
active?
-
if
@build
.
active?
%i
{
:class
=>
"fa fa-refresh fa-spin"
}
%i
{
:class
=>
"fa fa-refresh fa-spin"
}
...
@@ -219,4 +219,4 @@
...
@@ -219,4 +219,4 @@
:javascript
:javascript
new
CiBuild
(
"
#{
namespace_project_build_url
(
@project
.
namespace
,
@project
,
@build
)
}
"
,
"
#{
@build
.
status
}
"
,
"
#{
trace
[
:state
]
}
"
)
new
CiBuild
(
"
#{
namespace_project_build_url
(
@project
.
namespace
,
@project
,
@build
)
}
"
,
"
#{
@build
.
status
}
"
,
"
#{
trace
_with_state
[
:state
]
}
"
)
lib/ci/ansi2html.rb
View file @
74520f23
...
@@ -90,7 +90,7 @@ module Ci
...
@@ -90,7 +90,7 @@ module Ci
def
convert
(
raw
,
new_state
)
def
convert
(
raw
,
new_state
)
reset_state
reset_state
restore_state
(
new_state
)
if
new_state
&&
new_state
[
:offset
].
to_i
<
raw
.
length
restore_state
(
raw
,
new_state
)
if
new_state
start
=
@offset
start
=
@offset
ansi
=
raw
[
@offset
..-
1
]
ansi
=
raw
[
@offset
..-
1
]
...
@@ -187,15 +187,20 @@ module Ci
...
@@ -187,15 +187,20 @@ module Ci
end
end
def
state
def
state
STATE_PARAMS
.
inject
({})
do
|
h
,
param
|
state
=
STATE_PARAMS
.
inject
({})
do
|
h
,
param
|
h
[
param
]
=
send
(
param
)
h
[
param
]
=
send
(
param
)
h
h
end
end
Base64
.
urlsafe_encode64
(
state
.
to_json
)
end
end
def
restore_state
(
new_state
)
def
restore_state
(
raw
,
new_state
)
state
=
Base64
.
urlsafe_decode64
(
new_state
)
state
=
JSON
.
parse
(
state
,
symbolize_names:
true
)
return
if
state
[
:offset
].
to_i
>
raw
.
length
STATE_PARAMS
.
each
do
|
param
|
STATE_PARAMS
.
each
do
|
param
|
send
(
"
#{
param
}
="
.
to_sym
,
new_
state
[
param
])
send
(
"
#{
param
}
="
.
to_sym
,
state
[
param
])
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