Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alecs_myu
erp5
Commits
6edd92c8
Commit
6edd92c8
authored
Apr 07, 2017
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_test_result: simplify performance graph gadget code by using renderjs recent features
parent
349b9a44
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
52 deletions
+22
-52
bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/test_result_js/gadget_erp5_test_result_performance_graph.js.js
...result_js/gadget_erp5_test_result_performance_graph.js.js
+22
-52
No files found.
bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/test_result_js/gadget_erp5_test_result_performance_graph.js.js
View file @
6edd92c8
/*jslint indent: 2, nomen: true */
/*global window, rJS, RSVP, console
, loopEventListener
*/
(
function
(
window
,
rJS
,
RSVP
,
loopEventListener
)
{
/*global window, rJS, RSVP, console */
(
function
(
window
,
rJS
,
RSVP
)
{
"
use strict
"
;
var
WIDGET_GRAPH_URL
=
"
../gadget_officejs_widget_graph_chart.html
"
;
...
...
@@ -23,8 +23,8 @@
function
getCheckDateAndRefreshGraphFunction
(
gadget
)
{
return
function
checkDateAndRefreshGraph
()
{
var
from_date
,
at_date
,
i
;
from_date
=
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="from_date"]
'
).
value
;
at_date
=
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="at_date"]
'
).
value
;
from_date
=
gadget
.
element
.
querySelector
(
'
[name="from_date"]
'
).
value
;
at_date
=
gadget
.
element
.
querySelector
(
'
[name="at_date"]
'
).
value
;
if
(
at_date
!==
""
&&
from_date
!==
""
)
{
console
.
log
(
"
will need to get data
"
);
return
gadget
.
jio_allDocs
({
...
...
@@ -70,12 +70,8 @@
rJS
(
window
)
.
ready
(
function
(
gadget
)
{
gadget
.
property_dict
=
{};
return
gadget
.
getElement
()
.
push
(
function
(
element
)
{
gadget
.
property_dict
.
element
=
element
;
gadget
.
property_dict
.
deferred
=
RSVP
.
defer
();
});
gadget
.
property_dict
=
{
};
})
//////////////////////////////////////////////
...
...
@@ -90,35 +86,22 @@
console
.
log
(
"
gadget_erp5_test_result_performance_graph, render, options
"
,
option_dict
);
var
gadget
=
this
;
gadget
.
property_dict
.
option_dict
=
option_dict
.
value
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
property_dict
.
deferred
.
resolve
();
});
gadget
.
renderGraph
();
//Launch as a service, not blocking, we could run other job if we wish.
})
/////////////////////////////////////////
// Render text content gadget
/////////////////////////////////////////
.
declare
Service
(
function
()
{
.
declare
Job
(
"
renderGraph
"
,
function
()
{
var
gadget
=
this
,
graph_gadget
=
null
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
property_dict
.
deferred
.
promise
;
})
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
declareGadget
(
return
gadget
.
declareGadget
(
WIDGET_GRAPH_URL
,
{
scope
:
"
graph
"
,
element
:
gadget
.
property_dict
.
element
.
querySelector
(
"
.document-content
"
)
})
]);
element
:
gadget
.
element
.
querySelector
(
"
.document-content
"
)
})
.
push
(
function
(
result
)
{
graph_gadget
=
result
[
0
];
.
push
(
function
(
graph_gadget
)
{
gadget
.
property_dict
.
graph_widget
=
graph_gadget
;
gadget
.
property_dict
.
graph_data_dict
=
{
data
:
[{
value_dict
:
{
0
:
[],
...
...
@@ -138,31 +121,18 @@
var
now
=
new
Date
(),
last_month
,
tomorrow
;
last_month
=
new
Date
(
now
.
valueOf
()
-
86400
*
1000
*
30
);
// - 30 days
tomorrow
=
new
Date
(
now
.
valueOf
()
+
86400
*
1000
*
1
);
// + 1 day
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="from_date"]
'
).
value
=
getDateAsString
(
last_month
);
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="at_date"]
'
).
value
=
getDateAsString
(
tomorrow
);
gadget
.
element
.
querySelector
(
'
[name="from_date"]
'
).
value
=
getDateAsString
(
last_month
);
gadget
.
element
.
querySelector
(
'
[name="at_date"]
'
).
value
=
getDateAsString
(
tomorrow
);
})
.
push
(
function
()
{
getCheckDateAndRefreshGraphFunction
(
gadget
)();
});
})
.
declareService
(
function
()
{
var
gadget
=
this
;
return
loopEventListener
(
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="from_date"]
'
),
'
change
'
,
false
,
function
()
{
getCheckDateAndRefreshGraphFunction
(
gadget
)();
return
getCheckDateAndRefreshGraphFunction
(
gadget
)();
});
})
.
declareService
(
function
()
{
var
gadget
=
this
;
return
loopEventListener
(
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="at_date"]
'
),
'
change
'
,
false
,
function
()
{
getCheckDateAndRefreshGraphFunction
(
gadget
)();
});
.
onEvent
(
'
change
'
,
function
(
evt
)
{
if
(
evt
.
target
===
this
.
element
.
querySelector
(
'
[name="from_date"]
'
))
{
return
getCheckDateAndRefreshGraphFunction
(
this
)();
}
else
if
(
evt
.
target
===
this
.
element
.
querySelector
(
'
[name="at_date"]
'
))
{
return
getCheckDateAndRefreshGraphFunction
(
this
)();
}
});
}(
window
,
rJS
,
RSVP
,
loopEventListener
));
}(
window
,
rJS
,
RSVP
));
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