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
Boxiang Sun
gitlab-ce
Commits
910f513a
Commit
910f513a
authored
Mar 05, 2018
by
George Tsiolis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move MemoryGraph and MemoryUsage vue components
parent
67feb7cd
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
93 deletions
+89
-93
app/assets/javascripts/vue_merge_request_widget/components/memory_usage.vue
...ipts/vue_merge_request_widget/components/memory_usage.vue
+47
-40
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_deployment.js
...e_merge_request_widget/components/mr_widget_deployment.js
+4
-4
app/assets/javascripts/vue_shared/components/memory_graph.vue
...assets/javascripts/vue_shared/components/memory_graph.vue
+27
-11
changelogs/unreleased/refactor-move-mr-widget-memory-usage-and-graph-components.yml
...ctor-move-mr-widget-memory-usage-and-graph-components.yml
+5
-0
spec/javascripts/vue_mr_widget/components/mr_widget_memory_usage_spec.js
...s/vue_mr_widget/components/mr_widget_memory_usage_spec.js
+3
-15
spec/javascripts/vue_shared/components/memory_graph_spec.js
spec/javascripts/vue_shared/components/memory_graph_spec.js
+3
-23
No files found.
app/assets/javascripts/vue_merge_request_widget/components/m
r_widget_memory_usage.js
→
app/assets/javascripts/vue_merge_request_widget/components/m
emory_usage.vue
View file @
910f513a
<
script
>
import
statusCodes
from
'
../../lib/utils/http_status
'
;
import
statusCodes
from
'
../../lib/utils/http_status
'
;
import
{
bytesToMiB
}
from
'
../../lib/utils/number_utils
'
;
import
{
bytesToMiB
}
from
'
../../lib/utils/number_utils
'
;
import
{
backOff
}
from
'
../../lib/utils/common_utils
'
;
import
{
backOff
}
from
'
../../lib/utils/common_utils
'
;
import
MemoryGraph
from
'
../../vue_shared/components/memory_graph
'
;
import
MemoryGraph
from
'
../../vue_shared/components/memory_graph
.vue
'
;
import
MRWidgetService
from
'
../services/mr_widget_service
'
;
import
MRWidgetService
from
'
../services/mr_widget_service
'
;
export
default
{
export
default
{
name
:
'
MemoryUsage
'
,
name
:
'
MemoryUsage
'
,
components
:
{
MemoryGraph
,
},
props
:
{
props
:
{
metricsUrl
:
{
metricsUrl
:
{
type
:
String
,
type
:
String
,
...
@@ -28,9 +32,6 @@ export default {
...
@@ -28,9 +32,6 @@ export default {
backOffRequestCounter
:
0
,
backOffRequestCounter
:
0
,
};
};
},
},
components
:
{
'
mr-memory-graph
'
:
MemoryGraph
,
},
computed
:
{
computed
:
{
shouldShowLoading
()
{
shouldShowLoading
()
{
return
this
.
loadingMetrics
&&
!
this
.
hasMetrics
&&
!
this
.
loadFailed
;
return
this
.
loadingMetrics
&&
!
this
.
hasMetrics
&&
!
this
.
loadFailed
;
...
@@ -57,6 +58,10 @@ export default {
...
@@ -57,6 +58,10 @@ export default {
return
'
unchanged
'
;
return
'
unchanged
'
;
},
},
},
},
mounted
()
{
this
.
loadingMetrics
=
true
;
this
.
loadMetrics
();
},
methods
:
{
methods
:
{
getMegabytes
(
bytesString
)
{
getMegabytes
(
bytesString
)
{
const
valueInBytes
=
Number
(
bytesString
).
toFixed
(
2
);
const
valueInBytes
=
Number
(
bytesString
).
toFixed
(
2
);
...
@@ -114,23 +119,25 @@ export default {
...
@@ -114,23 +119,25 @@ export default {
});
});
},
},
},
},
mounted
()
{
};
this
.
loadingMetrics
=
true
;
</
script
>
this
.
loadMetrics
();
},
<
template
>
template
:
`
<div
class=
"mr-info-list clearfix mr-memory-usage js-mr-memory-usage"
>
<div
class=
"mr-info-list clearfix mr-memory-usage js-mr-memory-usage"
>
<p
<p
v-if=
"shouldShowLoading"
v-if=
"shouldShowLoading"
class=
"usage-info js-usage-info usage-info-loading"
>
class=
"usage-info js-usage-info usage-info-loading"
>
<i
<i
class=
"fa fa-spinner fa-spin usage-info-load-spinner"
class=
"fa fa-spinner fa-spin usage-info-load-spinner"
aria-hidden="true" />Loading deployment statistics
aria-hidden=
"true"
>
</i>
Loading deployment statistics
</p>
</p>
<p
<p
v-if=
"shouldShowMemoryGraph"
v-if=
"shouldShowMemoryGraph"
class=
"usage-info js-usage-info"
>
class=
"usage-info js-usage-info"
>
<a :href="metricsMonitoringUrl">Memory</a> usage <b>{{memoryChangeType}}</b> from {{memoryFrom}}MB to {{memoryTo}}MB
<a
:href=
"metricsMonitoringUrl"
>
Memory
</a>
usage
<b>
{{
memoryChangeType
}}
</b>
from
{{
memoryFrom
}}
MB to
{{
memoryTo
}}
MB
</p>
</p>
<p
<p
v-if=
"shouldShowLoadFailure"
v-if=
"shouldShowLoadFailure"
...
@@ -142,12 +149,12 @@ export default {
...
@@ -142,12 +149,12 @@ export default {
class=
"usage-info js-usage-info usage-info-unavailable"
>
class=
"usage-info js-usage-info usage-info-unavailable"
>
Deployment statistics are not available currently
Deployment statistics are not available currently
</p>
</p>
<mr-
memory-graph
<
memory-graph
v-if=
"shouldShowMemoryGraph"
v-if=
"shouldShowMemoryGraph"
:metrics=
"memoryMetrics"
:metrics=
"memoryMetrics"
:deploymentT
ime="deploymentTime"
:deployment-t
ime=
"deploymentTime"
height=
"25"
height=
"25"
width="100" />
width=
"100"
/>
</div>
</div>
`
,
</
template
>
};
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_deployment.js
View file @
910f513a
import
{
getTimeago
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
getTimeago
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
visitUrl
}
from
'
../../lib/utils/url_utility
'
;
import
{
visitUrl
}
from
'
../../lib/utils/url_utility
'
;
import
Flash
from
'
../../flash
'
;
import
Flash
from
'
../../flash
'
;
import
MemoryUsage
from
'
./m
r_widget_memory_usag
e
'
;
import
MemoryUsage
from
'
./m
emory_usage.vu
e
'
;
import
StatusIcon
from
'
./mr_widget_status_icon.vue
'
;
import
StatusIcon
from
'
./mr_widget_status_icon.vue
'
;
import
MRWidgetService
from
'
../services/mr_widget_service
'
;
import
MRWidgetService
from
'
../services/mr_widget_service
'
;
...
@@ -12,8 +12,8 @@ export default {
...
@@ -12,8 +12,8 @@ export default {
service
:
{
type
:
Object
,
required
:
true
},
service
:
{
type
:
Object
,
required
:
true
},
},
},
components
:
{
components
:
{
'
mr-widget-memory-usage
'
:
MemoryUsage
,
MemoryUsage
,
'
status-icon
'
:
StatusIcon
,
StatusIcon
,
},
},
methods
:
{
methods
:
{
formatDate
(
date
)
{
formatDate
(
date
)
{
...
@@ -100,7 +100,7 @@ export default {
...
@@ -100,7 +100,7 @@ export default {
class="btn btn-default btn-xs">
class="btn btn-default btn-xs">
Stop environment
Stop environment
</button>
</button>
<m
r-widget-m
emory-usage
<memory-usage
v-if="deployment.metrics_url"
v-if="deployment.metrics_url"
:metrics-url="deployment.metrics_url"
:metrics-url="deployment.metrics_url"
:metrics-monitoring-url="deployment.metrics_monitoring_url"
:metrics-monitoring-url="deployment.metrics_monitoring_url"
...
...
app/assets/javascripts/vue_shared/components/memory_graph.
js
→
app/assets/javascripts/vue_shared/components/memory_graph.
vue
View file @
910f513a
<
script
>
import
{
getTimeago
}
from
'
../../lib/utils/datetime_utility
'
;
import
{
getTimeago
}
from
'
../../lib/utils/datetime_utility
'
;
export
default
{
export
default
{
...
@@ -22,6 +23,9 @@ export default {
...
@@ -22,6 +23,9 @@ export default {
return
`Deployed
${
deployedSince
}
`
;
return
`Deployed
${
deployedSince
}
`
;
},
},
},
},
mounted
()
{
this
.
renderGraph
(
this
.
deploymentTime
,
this
.
metrics
);
},
methods
:
{
methods
:
{
/**
/**
* Returns metric value index in metrics array
* Returns metric value index in metrics array
...
@@ -103,15 +107,27 @@ export default {
...
@@ -103,15 +107,27 @@ export default {
this
.
dotY
=
dotY
;
this
.
dotY
=
dotY
;
},
},
},
},
mounted
()
{
};
this
.
renderGraph
(
this
.
deploymentTime
,
this
.
metrics
);
</
script
>
},
template
:
`
<
template
>
<div
class=
"memory-graph-container"
>
<div
class=
"memory-graph-container"
>
<svg class="has-tooltip" :title="getFormattedMedian" :width="width" :height="height" xmlns="http://www.w3.org/2000/svg">
<svg
<path :d="pathD" :viewBox="pathViewBox" />
class=
"has-tooltip"
<circle r="1.5" :cx="dotX" :cy="dotY" tranform="translate(0 -1)" />
:title=
"getFormattedMedian"
:width=
"width"
:height=
"height"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
:d=
"pathD"
:viewBox=
"pathViewBox"
/>
<circle
r=
"1.5"
:cx=
"dotX"
:cy=
"dotY"
tranform=
"translate(0 -1)"
/>
</svg>
</svg>
</div>
</div>
`
,
</
template
>
};
changelogs/unreleased/refactor-move-mr-widget-memory-usage-and-graph-components.yml
0 → 100644
View file @
910f513a
---
title
:
Move MemoryGraph and MemoryUsage vue components
merge_request
:
17533
author
:
George Tsiolis
type
:
performance
spec/javascripts/vue_mr_widget/components/mr_widget_memory_usage_spec.js
View file @
910f513a
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
memoryUsageComponent
from
'
~/vue_merge_request_widget/components/mr_widget_memory_usag
e
'
;
import
MemoryUsage
from
'
~/vue_merge_request_widget/components/memory_usage.vu
e
'
;
import
MRWidgetService
from
'
~/vue_merge_request_widget/services/mr_widget_service
'
;
import
MRWidgetService
from
'
~/vue_merge_request_widget/services/mr_widget_service
'
;
const
url
=
'
/root/acets-review-apps/environments/15/deployments/1/metrics
'
;
const
url
=
'
/root/acets-review-apps/environments/15/deployments/1/metrics
'
;
...
@@ -34,7 +34,7 @@ const metricsMockData = {
...
@@ -34,7 +34,7 @@ const metricsMockData = {
};
};
const
createComponent
=
()
=>
{
const
createComponent
=
()
=>
{
const
Component
=
Vue
.
extend
(
memoryUsageComponent
);
const
Component
=
Vue
.
extend
(
MemoryUsage
);
return
new
Component
({
return
new
Component
({
el
:
document
.
createElement
(
'
div
'
),
el
:
document
.
createElement
(
'
div
'
),
...
@@ -67,21 +67,9 @@ describe('MemoryUsage', () => {
...
@@ -67,21 +67,9 @@ describe('MemoryUsage', () => {
el
=
vm
.
$el
;
el
=
vm
.
$el
;
});
});
describe
(
'
props
'
,
()
=>
{
it
(
'
should have props with defaults
'
,
()
=>
{
const
{
metricsUrl
}
=
memoryUsageComponent
.
props
;
const
MetricsUrlTypeClass
=
metricsUrl
.
type
;
Vue
.
nextTick
(()
=>
{
expect
(
new
MetricsUrlTypeClass
()
instanceof
String
).
toBeTruthy
();
expect
(
metricsUrl
.
required
).
toBeTruthy
();
});
});
});
describe
(
'
data
'
,
()
=>
{
describe
(
'
data
'
,
()
=>
{
it
(
'
should have default data
'
,
()
=>
{
it
(
'
should have default data
'
,
()
=>
{
const
data
=
memoryUsageComponent
.
data
();
const
data
=
MemoryUsage
.
data
();
expect
(
Array
.
isArray
(
data
.
memoryMetrics
)).
toBeTruthy
();
expect
(
Array
.
isArray
(
data
.
memoryMetrics
)).
toBeTruthy
();
expect
(
data
.
memoryMetrics
.
length
).
toBe
(
0
);
expect
(
data
.
memoryMetrics
.
length
).
toBe
(
0
);
...
...
spec/javascripts/vue_shared/components/memory_graph_spec.js
View file @
910f513a
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
memoryGraphComponent
from
'
~/vue_shared/components/memory_graph
'
;
import
MemoryGraph
from
'
~/vue_shared/components/memory_graph.vue
'
;
import
{
mockMetrics
,
mockMedian
,
mockMedianIndex
}
from
'
./mock_data
'
;
import
{
mockMetrics
,
mockMedian
,
mockMedianIndex
}
from
'
./mock_data
'
;
const
defaultHeight
=
'
25
'
;
const
defaultHeight
=
'
25
'
;
const
defaultWidth
=
'
100
'
;
const
defaultWidth
=
'
100
'
;
const
createComponent
=
()
=>
{
const
createComponent
=
()
=>
{
const
Component
=
Vue
.
extend
(
memoryGraphComponent
);
const
Component
=
Vue
.
extend
(
MemoryGraph
);
return
new
Component
({
return
new
Component
({
el
:
document
.
createElement
(
'
div
'
),
el
:
document
.
createElement
(
'
div
'
),
...
@@ -32,29 +32,9 @@ describe('MemoryGraph', () => {
...
@@ -32,29 +32,9 @@ describe('MemoryGraph', () => {
el
=
vm
.
$el
;
el
=
vm
.
$el
;
});
});
describe
(
'
props
'
,
()
=>
{
it
(
'
should have props with defaults
'
,
(
done
)
=>
{
const
{
metrics
,
deploymentTime
,
width
,
height
}
=
memoryGraphComponent
.
props
;
Vue
.
nextTick
(()
=>
{
const
typeClassMatcher
=
(
propItem
,
expectedType
)
=>
{
const
PropItemTypeClass
=
propItem
.
type
;
expect
(
new
PropItemTypeClass
()
instanceof
expectedType
).
toBeTruthy
();
expect
(
propItem
.
required
).
toBeTruthy
();
};
typeClassMatcher
(
metrics
,
Array
);
typeClassMatcher
(
deploymentTime
,
Number
);
typeClassMatcher
(
width
,
String
);
typeClassMatcher
(
height
,
String
);
done
();
});
});
});
describe
(
'
data
'
,
()
=>
{
describe
(
'
data
'
,
()
=>
{
it
(
'
should have default data
'
,
()
=>
{
it
(
'
should have default data
'
,
()
=>
{
const
data
=
memoryGraphComponent
.
data
();
const
data
=
MemoryGraph
.
data
();
const
dataValidator
=
(
dataItem
,
expectedType
,
defaultVal
)
=>
{
const
dataValidator
=
(
dataItem
,
expectedType
,
defaultVal
)
=>
{
expect
(
typeof
dataItem
).
toBe
(
expectedType
);
expect
(
typeof
dataItem
).
toBe
(
expectedType
);
expect
(
dataItem
).
toBe
(
defaultVal
);
expect
(
dataItem
).
toBe
(
defaultVal
);
...
...
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