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
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
Eugene Shen
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
Hide 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 */
/*jslint indent: 2, nomen: true */
/*global window, rJS, RSVP, console
, loopEventListener
*/
/*global window, rJS, RSVP, console */
(
function
(
window
,
rJS
,
RSVP
,
loopEventListener
)
{
(
function
(
window
,
rJS
,
RSVP
)
{
"
use strict
"
;
"
use strict
"
;
var
WIDGET_GRAPH_URL
=
"
../gadget_officejs_widget_graph_chart.html
"
;
var
WIDGET_GRAPH_URL
=
"
../gadget_officejs_widget_graph_chart.html
"
;
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
function
getCheckDateAndRefreshGraphFunction
(
gadget
)
{
function
getCheckDateAndRefreshGraphFunction
(
gadget
)
{
return
function
checkDateAndRefreshGraph
()
{
return
function
checkDateAndRefreshGraph
()
{
var
from_date
,
at_date
,
i
;
var
from_date
,
at_date
,
i
;
from_date
=
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="from_date"]
'
).
value
;
from_date
=
gadget
.
element
.
querySelector
(
'
[name="from_date"]
'
).
value
;
at_date
=
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="at_date"]
'
).
value
;
at_date
=
gadget
.
element
.
querySelector
(
'
[name="at_date"]
'
).
value
;
if
(
at_date
!==
""
&&
from_date
!==
""
)
{
if
(
at_date
!==
""
&&
from_date
!==
""
)
{
console
.
log
(
"
will need to get data
"
);
console
.
log
(
"
will need to get data
"
);
return
gadget
.
jio_allDocs
({
return
gadget
.
jio_allDocs
({
...
@@ -70,12 +70,8 @@
...
@@ -70,12 +70,8 @@
rJS
(
window
)
rJS
(
window
)
.
ready
(
function
(
gadget
)
{
.
ready
(
function
(
gadget
)
{
gadget
.
property_dict
=
{};
gadget
.
property_dict
=
{
return
gadget
.
getElement
()
};
.
push
(
function
(
element
)
{
gadget
.
property_dict
.
element
=
element
;
gadget
.
property_dict
.
deferred
=
RSVP
.
defer
();
});
})
})
//////////////////////////////////////////////
//////////////////////////////////////////////
...
@@ -90,35 +86,22 @@
...
@@ -90,35 +86,22 @@
console
.
log
(
"
gadget_erp5_test_result_performance_graph, render, options
"
,
option_dict
);
console
.
log
(
"
gadget_erp5_test_result_performance_graph, render, options
"
,
option_dict
);
var
gadget
=
this
;
var
gadget
=
this
;
gadget
.
property_dict
.
option_dict
=
option_dict
.
value
;
gadget
.
property_dict
.
option_dict
=
option_dict
.
value
;
return
new
RSVP
.
Queue
()
gadget
.
renderGraph
();
//Launch as a service, not blocking, we could run other job if we wish.
.
push
(
function
()
{
return
gadget
.
property_dict
.
deferred
.
resolve
();
});
})
})
/////////////////////////////////////////
/////////////////////////////////////////
// Render text content gadget
// Render text content gadget
/////////////////////////////////////////
/////////////////////////////////////////
.
declare
Service
(
function
()
{
.
declare
Job
(
"
renderGraph
"
,
function
()
{
var
gadget
=
this
,
var
gadget
=
this
,
graph_gadget
=
null
;
graph_gadget
=
null
;
return
new
RSVP
.
Queue
()
return
gadget
.
declareGadget
(
.
push
(
function
()
{
return
gadget
.
property_dict
.
deferred
.
promise
;
})
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
declareGadget
(
WIDGET_GRAPH_URL
,
WIDGET_GRAPH_URL
,
{
{
scope
:
"
graph
"
,
scope
:
"
graph
"
,
element
:
gadget
.
property_dict
.
element
.
querySelector
(
"
.document-content
"
)
element
:
gadget
.
element
.
querySelector
(
"
.document-content
"
)
})
})
]);
.
push
(
function
(
graph_gadget
)
{
})
.
push
(
function
(
result
)
{
graph_gadget
=
result
[
0
];
gadget
.
property_dict
.
graph_widget
=
graph_gadget
;
gadget
.
property_dict
.
graph_widget
=
graph_gadget
;
gadget
.
property_dict
.
graph_data_dict
=
{
data
:
[{
gadget
.
property_dict
.
graph_data_dict
=
{
data
:
[{
value_dict
:
{
0
:
[],
value_dict
:
{
0
:
[],
...
@@ -138,31 +121,18 @@
...
@@ -138,31 +121,18 @@
var
now
=
new
Date
(),
last_month
,
tomorrow
;
var
now
=
new
Date
(),
last_month
,
tomorrow
;
last_month
=
new
Date
(
now
.
valueOf
()
-
86400
*
1000
*
30
);
// - 30 days
last_month
=
new
Date
(
now
.
valueOf
()
-
86400
*
1000
*
30
);
// - 30 days
tomorrow
=
new
Date
(
now
.
valueOf
()
+
86400
*
1000
*
1
);
// + 1 day
tomorrow
=
new
Date
(
now
.
valueOf
()
+
86400
*
1000
*
1
);
// + 1 day
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="from_date"]
'
).
value
=
getDateAsString
(
last_month
);
gadget
.
element
.
querySelector
(
'
[name="from_date"]
'
).
value
=
getDateAsString
(
last_month
);
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="at_date"]
'
).
value
=
getDateAsString
(
tomorrow
);
gadget
.
element
.
querySelector
(
'
[name="at_date"]
'
).
value
=
getDateAsString
(
tomorrow
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
getCheckDateAndRefreshGraphFunction
(
gadget
)();
return
getCheckDateAndRefreshGraphFunction
(
gadget
)();
});
})
.
declareService
(
function
()
{
var
gadget
=
this
;
return
loopEventListener
(
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="from_date"]
'
),
'
change
'
,
false
,
function
()
{
getCheckDateAndRefreshGraphFunction
(
gadget
)();
});
});
})
})
.
declareService
(
function
()
{
.
onEvent
(
'
change
'
,
function
(
evt
)
{
var
gadget
=
this
;
if
(
evt
.
target
===
this
.
element
.
querySelector
(
'
[name="from_date"]
'
))
{
return
loopEventListener
(
return
getCheckDateAndRefreshGraphFunction
(
this
)();
gadget
.
property_dict
.
element
.
querySelector
(
'
[name="at_date"]
'
),
}
else
if
(
evt
.
target
===
this
.
element
.
querySelector
(
'
[name="at_date"]
'
))
{
'
change
'
,
return
getCheckDateAndRefreshGraphFunction
(
this
)();
false
,
}
function
()
{
getCheckDateAndRefreshGraphFunction
(
gadget
)();
});
});
});
}(
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