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
de489f97
Commit
de489f97
authored
Apr 27, 2017
by
Filipa Lacerda
Committed by
Phil Hughes
Apr 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused code
parent
6ae76738
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
157 additions
and
98 deletions
+157
-98
app/assets/javascripts/commit/pipelines/pipelines_table.js
app/assets/javascripts/commit/pipelines/pipelines_table.js
+0
-9
app/assets/javascripts/pipelines/components/time_ago.js
app/assets/javascripts/pipelines/components/time_ago.js
+64
-37
app/assets/javascripts/pipelines/pipelines.js
app/assets/javascripts/pipelines/pipelines.js
+0
-10
app/assets/javascripts/pipelines/stores/pipelines_store.js
app/assets/javascripts/pipelines/stores/pipelines_store.js
+0
-31
app/assets/javascripts/vue_realtime_listener/index.js
app/assets/javascripts/vue_realtime_listener/index.js
+0
-9
app/assets/javascripts/vue_shared/components/pipelines_table_row.js
.../javascripts/vue_shared/components/pipelines_table_row.js
+29
-2
spec/javascripts/pipelines/time_ago_spec.js
spec/javascripts/pipelines/time_ago_spec.js
+64
-0
No files found.
app/assets/javascripts/commit/pipelines/pipelines_table.js
View file @
de489f97
...
@@ -106,15 +106,6 @@ export default Vue.component('pipelines-table', {
...
@@ -106,15 +106,6 @@ export default Vue.component('pipelines-table', {
eventHub
.
$on
(
'
refreshPipelines
'
,
this
.
fetchPipelines
);
eventHub
.
$on
(
'
refreshPipelines
'
,
this
.
fetchPipelines
);
},
},
beforeUpdate
()
{
if
(
this
.
state
.
pipelines
.
length
&&
this
.
$children
&&
!
this
.
isMakingRequest
&&
!
this
.
isLoading
)
{
this
.
store
.
startTimeAgoLoops
.
call
(
this
,
Vue
);
}
},
beforeDestroyed
()
{
beforeDestroyed
()
{
eventHub
.
$off
(
'
refreshPipelines
'
);
eventHub
.
$off
(
'
refreshPipelines
'
);
},
},
...
...
app/assets/javascripts/pipelines/components/time_ago.js
View file @
de489f97
...
@@ -2,68 +2,95 @@ import iconTimerSvg from 'icons/_icon_timer.svg';
...
@@ -2,68 +2,95 @@ import iconTimerSvg from 'icons/_icon_timer.svg';
import
'
../../lib/utils/datetime_utility
'
;
import
'
../../lib/utils/datetime_utility
'
;
export
default
{
export
default
{
props
:
{
finishedTime
:
{
type
:
String
,
required
:
true
,
},
duration
:
{
type
:
Number
,
required
:
true
,
},
},
data
()
{
data
()
{
return
{
return
{
currentTime
:
new
Date
(),
iconTimerSvg
,
iconTimerSvg
,
};
};
},
},
props
:
[
'
pipeline
'
],
updated
()
{
$
(
this
.
$refs
.
tooltip
).
tooltip
(
'
fixTitle
'
);
},
computed
:
{
computed
:
{
timeAgo
()
{
hasDuration
()
{
return
gl
.
utils
.
getTimeago
()
;
return
this
.
duration
>
0
;
},
},
localTimeFinished
()
{
return
gl
.
utils
.
formatDate
(
this
.
pipeline
.
details
.
finished_at
);
hasFinishedTime
()
{
return
this
.
finishedTime
!==
''
;
},
},
timeStopped
()
{
const
changeTime
=
this
.
currentTime
;
localTimeFinished
()
{
const
options
=
{
return
gl
.
utils
.
formatDate
(
this
.
finishedTime
);
weekday
:
'
long
'
,
year
:
'
numeric
'
,
month
:
'
short
'
,
day
:
'
numeric
'
,
};
options
.
timeZoneName
=
'
short
'
;
const
finished
=
this
.
pipeline
.
details
.
finished_at
;
if
(
!
finished
&&
changeTime
)
return
false
;
return
({
words
:
this
.
timeAgo
.
format
(
finished
)
});
},
},
duration
()
{
const
{
duration
}
=
this
.
pipeline
.
details
;
durationFormated
()
{
const
date
=
new
Date
(
duration
*
1000
);
const
date
=
new
Date
(
this
.
duration
*
1000
);
let
hh
=
date
.
getUTCHours
();
let
hh
=
date
.
getUTCHours
();
let
mm
=
date
.
getUTCMinutes
();
let
mm
=
date
.
getUTCMinutes
();
let
ss
=
date
.
getSeconds
();
let
ss
=
date
.
getSeconds
();
if
(
hh
<
10
)
hh
=
`0
${
hh
}
`
;
// left pad
if
(
mm
<
10
)
mm
=
`0
${
mm
}
`
;
if
(
hh
<
10
)
{
if
(
ss
<
10
)
ss
=
`0
${
ss
}
`
;
hh
=
`0
${
hh
}
`
;
}
if
(
mm
<
10
)
{
mm
=
`0
${
mm
}
`
;
}
if
(
ss
<
10
)
{
ss
=
`0
${
ss
}
`
;
}
if
(
duration
!==
null
)
return
`
${
hh
}
:
${
mm
}
:
${
ss
}
`
;
return
`
${
hh
}
:
${
mm
}
:
${
ss
}
`
;
return
false
;
},
},
},
methods
:
{
finishedTimeFormated
()
{
changeTime
()
{
const
timeAgo
=
gl
.
utils
.
getTimeago
();
this
.
currentTime
=
new
Date
();
return
timeAgo
.
format
(
this
.
finishedTime
);
},
},
},
},
template
:
`
template
:
`
<td class="pipelines-time-ago">
<td class="pipelines-time-ago">
<p class="duration" v-if='duration'>
<p
<span v-html="iconTimerSvg"></span>
class="duration"
{{duration}}
v-if="hasDuration">
<span
v-html="iconTimerSvg">
</span>
{{durationFormated}}
</p>
</p>
<p class="finished-at" v-if='timeStopped'>
<i class="fa fa-calendar"></i>
<p
class="finished-at"
v-if="hasFinishedTime">
<i
class="fa fa-calendar"
aria-hidden="true" />
<time
<time
ref="tooltip"
data-toggle="tooltip"
data-toggle="tooltip"
data-placement="top"
data-placement="top"
data-container="body"
data-container="body"
:
data-original-title='localTimeFinished'
>
:
title="localTimeFinished"
>
{{
timeStopped.words
}}
{{
finishedTimeFormated
}}
</time>
</time>
</p>
</p>
</td>
</td>
...
...
app/assets/javascripts/pipelines/pipelines.js
View file @
de489f97
import
Vue
from
'
vue
'
;
import
Visibility
from
'
visibilityjs
'
;
import
Visibility
from
'
visibilityjs
'
;
import
PipelinesService
from
'
./services/pipelines_service
'
;
import
PipelinesService
from
'
./services/pipelines_service
'
;
import
eventHub
from
'
./event_hub
'
;
import
eventHub
from
'
./event_hub
'
;
...
@@ -161,15 +160,6 @@ export default {
...
@@ -161,15 +160,6 @@ export default {
eventHub
.
$on
(
'
refreshPipelines
'
,
this
.
fetchPipelines
);
eventHub
.
$on
(
'
refreshPipelines
'
,
this
.
fetchPipelines
);
},
},
beforeUpdate
()
{
if
(
this
.
state
.
pipelines
.
length
&&
this
.
$children
&&
!
this
.
isMakingRequest
&&
!
this
.
isLoading
)
{
this
.
store
.
startTimeAgoLoops
.
call
(
this
,
Vue
);
}
},
beforeDestroyed
()
{
beforeDestroyed
()
{
eventHub
.
$off
(
'
refreshPipelines
'
);
eventHub
.
$off
(
'
refreshPipelines
'
);
},
},
...
...
app/assets/javascripts/pipelines/stores/pipelines_store.js
View file @
de489f97
/* eslint-disable no-underscore-dangle*/
import
VueRealtimeListener
from
'
../../vue_realtime_listener
'
;
export
default
class
PipelinesStore
{
export
default
class
PipelinesStore
{
constructor
()
{
constructor
()
{
this
.
state
=
{};
this
.
state
=
{};
...
@@ -30,32 +27,4 @@ export default class PipelinesStore {
...
@@ -30,32 +27,4 @@ export default class PipelinesStore {
this
.
state
.
pageInfo
=
paginationInfo
;
this
.
state
.
pageInfo
=
paginationInfo
;
}
}
/**
* FIXME: Move this inside the component.
*
* Once the data is received we will start the time ago loops.
*
* Everytime a request is made like retry or cancel a pipeline, every 10 seconds we
* update the time to show how long as passed.
*
*/
startTimeAgoLoops
()
{
const
startTimeLoops
=
()
=>
{
this
.
timeLoopInterval
=
setInterval
(()
=>
{
this
.
$children
[
0
].
$children
.
reduce
((
acc
,
component
)
=>
{
const
timeAgoComponent
=
component
.
$children
.
filter
(
el
=>
el
.
$options
.
_componentTag
===
'
time-ago
'
)[
0
];
acc
.
push
(
timeAgoComponent
);
return
acc
;
},
[]).
forEach
(
e
=>
e
.
changeTime
());
},
10000
);
};
startTimeLoops
();
const
removeIntervals
=
()
=>
clearInterval
(
this
.
timeLoopInterval
);
const
startIntervals
=
()
=>
startTimeLoops
();
VueRealtimeListener
(
removeIntervals
,
startIntervals
);
}
}
}
app/assets/javascripts/vue_realtime_listener/index.js
deleted
100644 → 0
View file @
6ae76738
export
default
(
removeIntervals
,
startIntervals
)
=>
{
window
.
removeEventListener
(
'
focus
'
,
startIntervals
);
window
.
removeEventListener
(
'
blur
'
,
removeIntervals
);
window
.
removeEventListener
(
'
onbeforeload
'
,
removeIntervals
);
window
.
addEventListener
(
'
focus
'
,
startIntervals
);
window
.
addEventListener
(
'
blur
'
,
removeIntervals
);
window
.
addEventListener
(
'
onbeforeload
'
,
removeIntervals
);
};
app/assets/javascripts/vue_shared/components/pipelines_table_row.js
View file @
de489f97
/* eslint-disable no-param-reassign */
/* eslint-disable no-param-reassign */
import
AsyncButtonComponent
from
'
../../pipelines/components/async_button.vue
'
;
import
AsyncButtonComponent
from
'
../../pipelines/components/async_button.vue
'
;
import
PipelinesActionsComponent
from
'
../../pipelines/components/pipelines_actions
'
;
import
PipelinesActionsComponent
from
'
../../pipelines/components/pipelines_actions
'
;
import
PipelinesArtifactsComponent
from
'
../../pipelines/components/pipelines_artifacts
'
;
import
PipelinesArtifactsComponent
from
'
../../pipelines/components/pipelines_artifacts
'
;
...
@@ -166,6 +165,32 @@ export default {
...
@@ -166,6 +165,32 @@ export default {
}
}
return
undefined
;
return
undefined
;
},
},
/**
* Timeago components expects a number
*
* @return {type} description
*/
pipelineDuration
()
{
if
(
this
.
pipeline
.
details
&&
this
.
pipeline
.
details
.
duration
)
{
return
this
.
pipeline
.
details
.
duration
;
}
return
0
;
},
/**
* Timeago component expects a String.
*
* @return {String}
*/
pipelineFinishedAt
()
{
if
(
this
.
pipeline
.
details
&&
this
.
pipeline
.
details
.
finished_at
)
{
return
this
.
pipeline
.
details
.
finished_at
;
}
return
''
;
},
},
},
template
:
`
template
:
`
...
@@ -192,7 +217,9 @@ export default {
...
@@ -192,7 +217,9 @@ export default {
</div>
</div>
</td>
</td>
<time-ago :pipeline="pipeline"/>
<time-ago
:duration="pipelineDuration"
:finished-time="pipelineFinishedAt" />
<td class="pipeline-actions">
<td class="pipeline-actions">
<div class="pull-right btn-group">
<div class="pull-right btn-group">
...
...
spec/javascripts/pipelines/time_ago_spec.js
0 → 100644
View file @
de489f97
import
Vue
from
'
vue
'
;
import
timeAgo
from
'
~/pipelines/components/time_ago
'
;
describe
(
'
Timeago component
'
,
()
=>
{
let
TimeAgo
;
beforeEach
(()
=>
{
TimeAgo
=
Vue
.
extend
(
timeAgo
);
});
describe
(
'
with duration
'
,
()
=>
{
it
(
'
should render duration and timer svg
'
,
()
=>
{
const
component
=
new
TimeAgo
({
propsData
:
{
duration
:
10
,
finishedTime
:
''
,
},
}).
$mount
();
expect
(
component
.
$el
.
querySelector
(
'
.duration
'
)).
toBeDefined
();
expect
(
component
.
$el
.
querySelector
(
'
.duration svg
'
)).
toBeDefined
();
});
});
describe
(
'
without duration
'
,
()
=>
{
it
(
'
should not render duration and timer svg
'
,
()
=>
{
const
component
=
new
TimeAgo
({
propsData
:
{
duration
:
0
,
finishedTime
:
''
,
},
}).
$mount
();
expect
(
component
.
$el
.
querySelector
(
'
.duration
'
)).
toBe
(
null
);
});
});
describe
(
'
with finishedTime
'
,
()
=>
{
it
(
'
should render time and calendar icon
'
,
()
=>
{
const
component
=
new
TimeAgo
({
propsData
:
{
duration
:
0
,
finishedTime
:
'
2017-04-26T12:40:23.277Z
'
,
},
}).
$mount
();
expect
(
component
.
$el
.
querySelector
(
'
.finished-at
'
)).
toBeDefined
();
expect
(
component
.
$el
.
querySelector
(
'
.finished-at i.fa-calendar
'
)).
toBeDefined
();
expect
(
component
.
$el
.
querySelector
(
'
.finished-at time
'
)).
toBeDefined
();
});
});
describe
(
'
without finishedTime
'
,
()
=>
{
it
(
'
should not render time and calendar icon
'
,
()
=>
{
const
component
=
new
TimeAgo
({
propsData
:
{
duration
:
0
,
finishedTime
:
''
,
},
}).
$mount
();
expect
(
component
.
$el
.
querySelector
(
'
.finished-at
'
)).
toBe
(
null
);
});
});
});
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