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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
d4d607f6
Commit
d4d607f6
authored
Feb 05, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
b19dfcbc
91b1e9dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
0 deletions
+99
-0
app/assets/javascripts/lib/utils/icon_utils.js
app/assets/javascripts/lib/utils/icon_utils.js
+18
-0
app/assets/javascripts/monitoring/components/charts/area.vue
app/assets/javascripts/monitoring/components/charts/area.vue
+14
-0
spec/javascripts/lib/utils/icon_utils_spec.js
spec/javascripts/lib/utils/icon_utils_spec.js
+67
-0
No files found.
app/assets/javascripts/lib/utils/icon_utils.js
0 → 100644
View file @
d4d607f6
/* eslint-disable import/prefer-default-export */
import
axios
from
'
~/lib/utils/axios_utils
'
;
/**
* Retrieve SVG icon path content from gitlab/svg sprite icons
* @param {String} name
*/
export
const
getSvgIconPathContent
=
name
=>
axios
.
get
(
gon
.
sprite_icons
)
.
then
(({
data
:
svgs
})
=>
new
DOMParser
()
.
parseFromString
(
svgs
,
'
text/xml
'
)
.
querySelector
(
`#
${
name
}
path`
)
.
getAttribute
(
'
d
'
),
)
.
catch
(()
=>
null
);
app/assets/javascripts/monitoring/components/charts/area.vue
View file @
d4d607f6
...
...
@@ -2,6 +2,7 @@
import
{
GlAreaChart
}
from
'
@gitlab/ui/dist/charts
'
;
import
dateFormat
from
'
dateformat
'
;
import
{
debounceByAnimationFrame
}
from
'
~/lib/utils/common_utils
'
;
import
{
getSvgIconPathContent
}
from
'
~/lib/utils/icon_utils
'
;
let
debouncedResize
;
...
...
@@ -48,6 +49,7 @@ export default {
return
{
width
:
0
,
height
:
0
,
scatterSymbol
:
undefined
,
};
},
computed
:
{
...
...
@@ -121,6 +123,8 @@ export default {
return
{
type
:
'
scatter
'
,
data
:
this
.
recentDeployments
.
map
(
deployment
=>
[
deployment
.
createdAt
,
0
]),
symbol
:
this
.
scatterSymbol
,
symbolSize
:
14
,
};
},
xAxisLabel
()
{
...
...
@@ -140,12 +144,22 @@ export default {
created
()
{
debouncedResize
=
debounceByAnimationFrame
(
this
.
onResize
);
window
.
addEventListener
(
'
resize
'
,
debouncedResize
);
this
.
getScatterSymbol
();
},
methods
:
{
formatTooltipText
(
params
)
{
const
[
date
,
value
]
=
params
;
return
[
dateFormat
(
date
,
'
dd mmm yyyy, h:MMtt
'
),
value
.
toFixed
(
3
)];
},
getScatterSymbol
()
{
getSvgIconPathContent
(
'
rocket
'
)
.
then
(
path
=>
{
if
(
path
)
{
this
.
scatterSymbol
=
`path://
${
path
}
`
;
}
})
.
catch
(()
=>
{});
},
onResize
()
{
const
{
width
,
height
}
=
this
.
$refs
.
areaChart
.
$el
.
getBoundingClientRect
();
this
.
width
=
width
;
...
...
spec/javascripts/lib/utils/icon_utils_spec.js
0 → 100644
View file @
d4d607f6
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
*
as
iconUtils
from
'
~/lib/utils/icon_utils
'
;
describe
(
'
Icon utils
'
,
()
=>
{
describe
(
'
getSvgIconPathContent
'
,
()
=>
{
let
spriteIcons
;
beforeAll
(()
=>
{
spriteIcons
=
gon
.
sprite_icons
;
gon
.
sprite_icons
=
'
mockSpriteIconsEndpoint
'
;
});
afterAll
(()
=>
{
gon
.
sprite_icons
=
spriteIcons
;
});
let
axiosMock
;
let
mockEndpoint
;
let
getIcon
;
const
mockName
=
'
mockIconName
'
;
const
mockPath
=
'
mockPath
'
;
beforeEach
(()
=>
{
axiosMock
=
new
MockAdapter
(
axios
);
mockEndpoint
=
axiosMock
.
onGet
(
gon
.
sprite_icons
);
getIcon
=
iconUtils
.
getSvgIconPathContent
(
mockName
);
});
afterEach
(()
=>
{
axiosMock
.
restore
();
});
it
(
'
extracts svg icon path content from sprite icons
'
,
done
=>
{
mockEndpoint
.
replyOnce
(
200
,
`<svg><symbol id="
${
mockName
}
"><path d="
${
mockPath
}
"/></symbol></svg>`
,
);
getIcon
.
then
(
path
=>
{
expect
(
path
).
toBe
(
mockPath
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
returns null if icon path content does not exist
'
,
done
=>
{
mockEndpoint
.
replyOnce
(
200
,
``
);
getIcon
.
then
(
path
=>
{
expect
(
path
).
toBe
(
null
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
returns null if an http error occurs
'
,
done
=>
{
mockEndpoint
.
replyOnce
(
500
);
getIcon
.
then
(
path
=>
{
expect
(
path
).
toBe
(
null
);
done
();
})
.
catch
(
done
.
fail
);
});
});
});
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