This is still misleading. The getServerTimestamp service returns a Long,
not a Timestamp.
Also, it would be nice if the service returned something useful, like a
java.sql.Timestamp or a java.lang.String - so the service can be reused.
It appears this service is being tailored to a specific use case.
-Adrian
On 12/31/2012 7:50 PM, jler...@apache.org wrote:
Author: jleroux
Date: Mon Dec 31 19:50:54 2012
New Revision: 1427233
URL: http://svn.apache.org/viewvc?rev=1427233&view=rev
Log:
Complete the server hour on webtools jobs list, with the help of Adrian and Atul
Remarks:
* Finally date.format-1.2.3-min.js is quite useful
* I renamed the getServerHour service to getServerTimestamp. It now returns a
Long, easier to parse to a date in javascript
* I renamed WindowClockJs.ftl to ServerHour24HourFormatJs.ftl
Added:
ofbiz/trunk/framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl
- copied, changed from r1427046,
ofbiz/trunk/framework/common/webcommon/includes/WindowClockJs.ftl
Removed:
ofbiz/trunk/framework/common/webcommon/includes/WindowClockJs.ftl
Modified:
ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml
ofbiz/trunk/framework/common/servicedef/services.xml
ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml
ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js
ofbiz/trunk/framework/webtools/widget/ServiceScreens.xml
Modified:
ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml?rev=1427233&r1=1427232&r2=1427233&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml
(original)
+++ ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml Mon
Dec 31 19:50:54 2012
@@ -347,8 +347,9 @@ under the License.
<field-to-result field="exist"/>
</simple-method>
- <simple-method method-name="getServerHour" login-required="false">
- <set field="nowDateString"
value="${groovy:org.ofbiz.base.util.UtilDateTime.nowDateString('yyyy-MM-dd HH:mm:ss')}"/>
- <field-to-result field="nowDateString"/>
+ <simple-method method-name="getServerTimestamp" login-required="false">
+ <now field="serverTimestamp" type="java.lang.Long"/>
+ <field-to-result field="serverTimestamp"/>
</simple-method>
+
</simple-methods>
Modified: ofbiz/trunk/framework/common/servicedef/services.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services.xml?rev=1427233&r1=1427232&r2=1427233&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/servicedef/services.xml (original)
+++ ofbiz/trunk/framework/common/servicedef/services.xml Mon Dec 31 19:50:54
2012
@@ -781,9 +781,9 @@ under the License.
<attribute name="geoList" mode="OUT" type="java.util.List"/>
</service>
- <service name="getServerHour" engine="simple" auth="false"
- location="component://common/script/org/ofbiz/common/CommonServices.xml"
invoke="getServerHour">
- <attribute name="nowDateString" mode="OUT" type="String"/>
+ <service name="getServerTimestamp" engine="simple" auth="false"
+ location="component://common/script/org/ofbiz/common/CommonServices.xml"
invoke="getServerTimestamp">
+ <attribute name="serverTimestamp" mode="OUT" type="Long"/>
</service>
<service name="createJsLanguageFileMapping" engine="java" auth="false" use-transaction="false"
Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml?rev=1427233&r1=1427232&r2=1427233&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml
(original)
+++ ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml Mon
Dec 31 19:50:54 2012
@@ -253,9 +253,9 @@ under the License.
<response name="error" type="request" value="json"/>
</request-map>
- <request-map uri="getServerHour">
+ <request-map uri="getServerTimestamp">
<security https="true" auth="true"/>
- <event type="service" invoke="getServerHour"/>
+ <event type="service" invoke="getServerTimestamp"/>
<response name="success" type="request" value="json"/>
<response name="error" type="request" value="json"/>
</request-map>
Copied:
ofbiz/trunk/framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl
(from r1427046,
ofbiz/trunk/framework/common/webcommon/includes/WindowClockJs.ftl)
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl?p2=ofbiz/trunk/framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl&p1=ofbiz/trunk/framework/common/webcommon/includes/WindowClockJs.ftl&r1=1427046&r2=1427233&rev=1427233&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/includes/WindowClockJs.ftl (original)
+++
ofbiz/trunk/framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl
Mon Dec 31 19:50:54 2012
@@ -19,8 +19,17 @@ under the License.
<script type="text/javascript">
jQuery(document).ready(function() {
window.setInterval(function(){clock()}, 1000);
+ var serverTimestamp = 0;
+ var date
function clock() {
- jQuery("#${clockField}").text("${uiLabelMap.CommonServerHour}: " +
getServerHour("getServerHour"));
+ if (jQuery("#${clockField}").text() === "${uiLabelMap.CommonServerHour}:")
{
+ serverTimestamp = getServerTimestamp("getServerTimestamp");
+ date = new Date(serverTimestamp);
+ jQuery("#${clockField}").text("${uiLabelMap.CommonServerHour}: " +
dateFormat(date, "yyyy-mm-dd HH:MM:ss"));
+ } else {
+ date.setSeconds(date.getSeconds() + 1);
+ jQuery("#${clockField}").text("${uiLabelMap.CommonServerHour}: " +
dateFormat(date, "yyyy-mm-dd HH:MM:ss"));
+ }
}
})
</script>
\ No newline at end of file
Modified: ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js?rev=1427233&r1=1427232&r2=1427233&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js Mon Dec 31
19:50:54 2012
@@ -144,7 +144,7 @@ function checkUomConversion(request, par
return data['exist'];
}
-function getServerHour(request){
+function getServerTimestamp(request){
data = getServiceResult(request);
- return data['nowDateString'];
+ return data['serverTimestamp'];
}
\ No newline at end of file
Modified: ofbiz/trunk/framework/webtools/widget/ServiceScreens.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/widget/ServiceScreens.xml?rev=1427233&r1=1427232&r2=1427233&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/widget/ServiceScreens.xml (original)
+++ ofbiz/trunk/framework/webtools/widget/ServiceScreens.xml Mon Dec 31
19:50:54 2012
@@ -49,7 +49,7 @@ under the License.
<set field="tabButtonItem" value="findJob"/>
<set field="jobCtx" from-field="parameters"/>
<set field="dummy" value="${groovy: if
('SERVICE_PENDING'.equals(jobCtx.statusId)) jobCtx.jobId = ''}"/> <!-- To more easily see current
pending jobs and possibly cancel some others -->
- <!-- fields for WindowClockJs.ftl -->
+ <!-- fields for ServerHour24HourFormatJs.ftl -->
<set field="clockField" value="FindJobs_clock_title"/>
</actions>
<widgets>
@@ -57,7 +57,7 @@ under the License.
<decorator-section name="body">
<section>
<widgets>
- <platform-specific><html><html-template
location="component://common/webcommon/includes/WindowClockJs.ftl"/></html></platform-specific>
+ <platform-specific><html><html-template
location="component://common/webcommon/includes/ServerHour24HourFormatJs.ftl"/></html></platform-specific>
<decorator-screen name="FindScreenDecorator"
location="component://common/widget/CommonScreens.xml">
<decorator-section name="search-options">
<include-form name="FindJobs"
location="component://webtools/widget/ServiceForms.xml"/>