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
6f824b15
Commit
6f824b15
authored
Oct 19, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve first implementation
parent
f95d7edd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
124 additions
and
3 deletions
+124
-3
app/assets/javascripts/cycle_analytics/cycle_analytics_bundle.js
...ets/javascripts/cycle_analytics/cycle_analytics_bundle.js
+55
-0
app/assets/javascripts/cycle_analytics/cycle_analytics_service.js.es6
...avascripts/cycle_analytics/cycle_analytics_service.js.es6
+28
-0
app/assets/javascripts/cycle_analytics/cycle_analytics_store.js.es6
.../javascripts/cycle_analytics/cycle_analytics_store.js.es6
+41
-0
app/assets/javascripts/dispatcher.js.es6
app/assets/javascripts/dispatcher.js.es6
+0
-3
No files found.
app/assets/javascripts/cycle_analytics/cycle_analytics_bundle.js
View file @
6f824b15
//= require vue
//= require_tree .
$
(()
=>
{
const
cycleAnalyticsEl
=
document
.
querySelector
(
'
#cycle-analytics
'
);
const
cycleAnalyticsStore
=
gl
.
cycleAnalytics
.
CycleAnalyticsStore
;
const
cycleAnalyticsService
=
new
gl
.
cycleAnalytics
.
CycleAnalyticsService
({
requestPath
:
cycleAnalyticsEl
.
dataset
.
requestPath
})
gl
.
cycleAnalyticsApp
=
new
Vue
({
el
:
'
#cycle-analytics
'
,
name
:
'
CycleAnalytics
'
,
data
:
cycleAnalyticsStore
.
state
,
created
()
{
this
.
fetchCycleAnalyticsData
();
},
methods
:
{
handleError
(
data
)
{
cycleAnalyticsStore
.
setErrorState
(
true
);
new
Flash
(
'
There was an error while fetching cycle analytics data.
'
);
},
initDropdown
()
{
const
$dropdown
=
$
(
'
.js-ca-dropdown
'
);
const
$label
=
$dropdown
.
find
(
'
.dropdown-label
'
);
$dropdown
.
find
(
'
li a
'
).
off
(
'
click
'
).
on
(
'
click
'
,
(
e
)
=>
{
e
.
preventDefault
();
const
$target
=
$
(
e
.
currentTarget
);
const
value
=
$target
.
data
(
'
value
'
);
$label
.
text
(
$target
.
text
().
trim
());
this
.
fetchCycleAnalyticsData
({
startDate
:
value
});
});
},
fetchCycleAnalyticsData
(
options
)
{
options
=
options
||
{
startDate
:
30
};
cycleAnalyticsStore
.
setLoadingState
(
true
);
cycleAnalyticsService
.
fetchCycleAnalyticsData
(
options
)
.
then
((
response
)
=>
{
cycleAnalyticsStore
.
setCycleAnalyticsData
(
response
);
this
.
initDropdown
();
})
.
fail
(()
=>
{
this
.
handleError
(
data
);
})
.
always
(()
=>
{
cycleAnalyticsStore
.
setLoadingState
(
false
);
});
}
}
});
});
app/assets/javascripts/cycle_analytics/cycle_analytics_service.js.es6
0 → 100644
View file @
6f824b15
((global) => {
global.cycleAnalytics = global.cycleAnalytics || {};
class CycleAnalyticsService {
constructor(options) {
this.requestPath = options.requestPath;
}
fetchCycleAnalyticsData(options) {
options = options || { startDate: 30 };
return $.ajax({
url: this.requestPath,
method: 'GET',
dataType: 'json',
contentType: 'application/json',
data: {
cycle_analytics: {
start_date: options.startDate
}
}
});
}
};
global.cycleAnalytics.CycleAnalyticsService = CycleAnalyticsService;
})(window.gl || (window.gl = {}));
app/assets/javascripts/cycle_analytics/cycle_analytics_store.js.es6
0 → 100644
View file @
6f824b15
((global) => {
global.cycleAnalytics = global.cycleAnalytics || {};
global.cycleAnalytics.CycleAnalyticsStore = {
state: {
isLoading: true,
hasError: false,
summary: '',
stats: '',
analytics: ''
},
setCycleAnalyticsData(data) {
this.state = Object.assign(this.state, this.decorateData(data));
},
decorateData(data) {
let newData = {};
newData.stats = data.stats || [];
newData.summary = data.summary || [];
newData.summary.forEach((item) => {
item.value = item.value || '-';
});
newData.stats.forEach((item) => {
item.value = item.value || '- - -';
});
newData.analytics = data;
return newData;
},
setLoadingState(state) {
this.state.isLoading = state;
},
setErrorState(state) {
this.state.hasError = state;
}
};
})(window.gl || (window.gl = {}));
app/assets/javascripts/dispatcher.js.es6
View file @
6f824b15
...
...
@@ -208,9 +208,6 @@
new gl.ProtectedBranchCreate();
new gl.ProtectedBranchEditList();
break;
case 'projects:cycle_analytics:show':
new gl.CycleAnalytics();
break;
}
switch (path.first()) {
case 'admin':
...
...
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