Author: apatel
Date: Fri Nov 16 17:13:55 2007 New Revision: 595890 URL: http://svn.apache.org/viewvc?rev=595890&view=rev Log: Show progress bar during file upload in Party Content. Added: ofbiz/trunk/applications/party/webapp/partymgr/js/ ofbiz/trunk/applications/party/webapp/partymgr/js/PartyProfileContent.js ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/ContentList.ftl Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/web.xml ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml?rev=595890&r1=595889&r2=595890&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml Fri Nov 16 17:13:55 2007 @@ -25,6 +25,7 @@ <owner>Copyright 2001-2007 The Apache Software Foundation</owner> <handler name="simplecontent" type="view" class="org.ofbiz.content.view.SimpleContentViewHandler"/> + <handler name="jsonservice" type="request" class="org.ofbiz.webapp.event.JSONServiceEventHandler"/> <!-- Events to run on every request before security (chains exempt) --> <!-- @@ -843,8 +844,20 @@ <request-map uri="uploadPartyContent"> <security auth="true" https="true"/> <event type="service" invoke="uploadPartyContentFile"/> - <response name="success" type="view" value="viewprofile"/> - <response name="error" type="view" value="viewprofile"/> + <response name="success" type="view" value="partyContentList"/> + <response name="error" type="view" value="EventMessages"/> + </request-map> + + <request-map uri="partyContentList"> + <security auth="true" https="true"/> + <response name="success" type="view" value="partyContentList"/> + </request-map> + + <request-map uri="getFileUploadProgressStatus"> + <security https="true" auth="false"/> + <event type="jsonservice" invoke="getFileUploadProgressStatus"/> + <response name="success" type="none"/> + <response name="error" type="none"/> </request-map> <request-map uri="img"> @@ -896,6 +909,7 @@ <view-map name="findparty" type="screen" page="component://party/widget/partymgr/PartyScreens.xml#findparty"/> <view-map name="viewprofile" type="screen" page="component://party/widget/partymgr/PartyScreens.xml#viewprofile"/> + <view-map name="partyContentList" type="screen" page="component://party/widget/partymgr/ProfileScreens.xml#ContentList"/> <view-map name="viewroles" type="screen" page="component://party/widget/partymgr/PartyScreens.xml#viewroles"/> <view-map name="linkparty" type="screen" page="component://party/widget/partymgr/PartyScreens.xml#linkparty"/> <view-map name="EditPartyRelationships" type="screen" page="component://party/widget/partymgr/PartyScreens.xml#EditPartyRelationships"/> Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/web.xml?rev=595890&r1=595889&r2=595890&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/web.xml (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/web.xml Fri Nov 16 17:13:55 2007 @@ -60,7 +60,7 @@ </init-param> <init-param> <param-name>allowedPaths</param-name> - <param-value>/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images:/static</param-value> + <param-value>/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images:/static:/js</param-value> </init-param> <init-param> <param-name>errorCode</param-name> Added: ofbiz/trunk/applications/party/webapp/partymgr/js/PartyProfileContent.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/js/PartyProfileContent.js?rev=595890&view=auto ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/js/PartyProfileContent.js (added) +++ ofbiz/trunk/applications/party/webapp/partymgr/js/PartyProfileContent.js Fri Nov 16 17:13:55 2007 @@ -0,0 +1,96 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +* */ + +var progressBar; + +Event.observe(window, 'load', function() { + Event.observe('uploadPartyContent', 'submit', uploadPartyContent); + Event.observe('uploadPartyContent', 'submit', getUploadProgressStatus); + progressBar = new Control.ProgressBar('progress_bar'); +}); +function uploadPartyContent(event){ + var targetFrame = $('target_upload'); + if(!targetFrame){ + $('partyContent').insert("<iframe id='target_upload' name='target_upload' style='display: none' src=''> </iframe>"); + } + $('uploadPartyContent').target="target_upload"; + Event.observe('target_upload', 'load', uploadCompleted); + var errordiv = $('content-messages'); + if(errordiv){ + $('content-messages').remove(); + } +} + +function uploadCompleted(event){ + var doc = getIframeDocument($('target_upload')); + var errordiv = doc.getElementById('content-messages'); + //console.log(errordiv); + if(errordiv){ + $('partyContent').insert(errordiv); + } + var partyContentListDiv = doc.getElementById('partyContentList'); + //console.log(partyContentListDiv); + if(partyContentListDiv){ + $('partyContentList').update(partyContentListDiv.innerHTML); + } + if($('progressBarSavingMsg')){ + $('progressBarSavingMsg').remove(); + } + progressBar.reset(); +} + +function getUploadProgressStatus(event){ + var i=0; + new PeriodicalExecuter(function(event){ + new Ajax.Request('/partymgr/control/getFileUploadProgressStatus', { + onSuccess: function(transport){ + var data = transport.responseText.evalJSON(true); + if (data._ERROR_MESSAGE_LIST_ != undefined) { + //console.log(data._ERROR_MESSAGE_LIST_); + //alert(data._ERROR_MESSAGE_LIST_); + }else if (data._ERROR_MESSAGE_ != undefined) { + //console.log(data._ERROR_MESSAGE_); + //alert(data._ERROR_MESSAGE_); + }else { + //console.log(data.readPercent); + var readPercent = data.readPercent; + progressBar.setProgress(readPercent); + if(readPercent > 99){ + $('uploadPartyContent').insert("<span id='progressBarSavingMsg' class='label'>Saving..</span>"); + event.stop(); + } + + } + }}); + },1); +} + +function getIframeDocument(frameElement) { + var doc = null; + if (frameElement.contentDocument) { + doc = frameElement.contentDocument; + } else if (frameElement.contentWindow) { + doc = frameElement.contentWindow.document; + } else if (frameElement.document) { + doc = frameElement.document; + } else { + return null; + } + return doc; +} Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl?rev=595890&r1=595889&r2=595890&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl Fri Nov 16 17:13:55 2007 @@ -16,47 +16,19 @@ specific language governing permissions and limitations under the License. --> - <div id="partyContent" class="screenlet"> <div class="screenlet-title-bar"> <h3>${uiLabelMap.PartyContent}</h3> </div> <div class="screenlet-body"> - <#if partyContent?has_content> - <table class="basic-table" cellspacing="0"> - <#list partyContent as pContent> - <#assign content = pContent.getRelatedOne("Content")> - <#assign contentType = content.getRelatedOneCache("ContentType")> - <#assign mimeType = content.getRelatedOneCache("MimeType")?if_exists> - <#assign status = content.getRelatedOneCache("StatusItem")> - <#assign pcType = pContent.getRelatedOne("PartyContentType")> - <tr> - <td class="button-col"><a href="<@ofbizUrl>EditPartyContents?contentId=${pContent.contentId}&partyId=${pContent.partyId}&partyContentTypeId=${pContent.partyContentTypeId}&fromDate=${pContent.fromDate}</@ofbizUrl>">${content.contentId}</a></td> - <td>${pcType.description?if_exists}</td> - <td>${content.contentName?if_exists}</td> - <td>${(contentType.get("description",locale))?if_exists}</td> - <td>${(mimeType.description)?if_exists}</td> - <td>${(status.get("description",locale))?if_exists}</td> - <td>${pContent.fromDate?if_exists}</td> - <td class="button-col"> - <#if (content.contentName?has_content)> - <a href="<@ofbizUrl>img/${content.contentName}?imgId=${content.dataResourceId}</@ofbizUrl>">${uiLabelMap.CommonView}</a> - </#if> - <a href="<@ofbizUrl>removePartyContent/viewprofile?contentId=${pContent.contentId}&partyId=${pContent.partyId}&partyContentTypeId=${pContent.partyContentTypeId}&fromDate=${pContent.fromDate}</@ofbizUrl>">${uiLabelMap.CommonRemove}</a> - </td> - </tr> - </#list> - </table> - <#else> - ${uiLabelMap.PartyNoContent} - </#if> + ${screens.render("component://party/widget/partymgr/ProfileScreens.xml#ContentList")} <hr/> <div class="label">${uiLabelMap.PartyAttachContent}</div> - <form method="post" enctype="multipart/form-data" action="<@ofbizUrl>uploadPartyContent</@ofbizUrl>"> + <form id="uploadPartyContent" method="post" enctype="multipart/form-data" action="<@ofbizUrl>uploadPartyContent</@ofbizUrl>"> <input type="hidden" name="dataCategoryId" value="PERSONAL"/> <input type="hidden" name="contentTypeId" value="DOCUMENT"/> <input type="hidden" name="statusId" value="CTNT_PUBLISHED"/> - <input type="hidden" name="partyId" value="${partyId}"/> + <input type="hidden" name="partyId" value="${partyId}" id="contentPartyId"/> <input type="file" name="uploadedFile" size="20"/> <select name="partyContentTypeId"> <option value="">${uiLabelMap.PartySelectPurpose}</option> @@ -78,6 +50,6 @@ </select> <input type="submit" value="${uiLabelMap.CommonUpload}"/> </form> + <div id='progress_bar'><div></div></div> </div> </div> - \ No newline at end of file Added: ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/ContentList.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/ContentList.ftl?rev=595890&view=auto ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/ContentList.ftl (added) +++ ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/ContentList.ftl Fri Nov 16 17:13:55 2007 @@ -0,0 +1,50 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + + + <div id="partyContentList"> + <#if partyContent?has_content> + <table class="basic-table" cellspacing="0"> + <#list partyContent as pContent> + <#assign content = pContent.getRelatedOne("Content")> + <#assign contentType = content.getRelatedOneCache("ContentType")> + <#assign mimeType = content.getRelatedOneCache("MimeType")?if_exists> + <#assign status = content.getRelatedOneCache("StatusItem")> + <#assign pcType = pContent.getRelatedOne("PartyContentType")> + <tr> + <td class="button-col"><a href="<@ofbizUrl>EditPartyContents?contentId=${pContent.contentId}&partyId=${pContent.partyId}&partyContentTypeId=${pContent.partyContentTypeId}&fromDate=${pContent.fromDate}</@ofbizUrl>">${content.contentId}</a></td> + <td>${pcType.description?if_exists}</td> + <td>${content.contentName?if_exists}</td> + <td>${(contentType.get("description",locale))?if_exists}</td> + <td>${(mimeType.description)?if_exists}</td> + <td>${(status.get("description",locale))?if_exists}</td> + <td>${pContent.fromDate?if_exists}</td> + <td class="button-col"> + <#if (content.contentName?has_content)> + <a href="<@ofbizUrl>img/${content.contentName}?imgId=${content.dataResourceId}</@ofbizUrl>">${uiLabelMap.CommonView}</a> + </#if> + <a href="<@ofbizUrl>removePartyContent/viewprofile?contentId=${pContent.contentId}&partyId=${pContent.partyId}&partyContentTypeId=${pContent.partyContentTypeId}&fromDate=${pContent.fromDate}</@ofbizUrl>">${uiLabelMap.CommonRemove}</a> + </td> + </tr> + </#list> + </table> + <#else> + ${uiLabelMap.PartyNoContent} + </#if> + </div> Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml?rev=595890&r1=595889&r2=595890&view=diff ============================================================================== --- ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml (original) +++ ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml Fri Nov 16 17:13:55 2007 @@ -64,6 +64,11 @@ <set field="headerItem" value="find"/> <set field="labelTitleProperty" value="PartyTaxAuthInfos"/> + <set field="layoutSettings.javaScripts[]" value="/images/prototypejs/prototype.js" global="true"/> + <set field="layoutSettings.javaScripts[]" value="/images/prototypejs/control.progress_bar.js" global="true"/> + <set field="layoutSettings.styleSheets[]" value="/images/prototypejs/progress_bar.css" global="true"/> + <set field="layoutSettings.javaScripts[]" value="/partymgr/js/PartyProfileContent.js" global="true"/> + <script location="component://party/webapp/partymgr/WEB-INF/actions/party/viewprofile.bsh"/> <script location="component://party/webapp/partymgr/WEB-INF/actions/party/getUserLoginPrimaryEmail.bsh"/> </actions> Modified: ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml?rev=595890&r1=595889&r2=595890&view=diff ============================================================================== --- ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml (original) +++ ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml Fri Nov 16 17:13:55 2007 @@ -304,9 +304,6 @@ <screen name="Content"> <section> <actions> - <entity-and entity-name="PartyContent" list-name="partyContent"> - <field-map field-name="partyId" env-name="parameters.partyId"/> - </entity-and> <entity-condition entity-name="PartyContentType" list-name="partyContentTypes"> <order-by field-name="description"/> </entity-condition> @@ -323,6 +320,25 @@ <platform-specific> <html> <html-template location="component://party/webapp/partymgr/party/profileblocks/Content.ftl"/> + </html> + </platform-specific> + </widgets> + </section> + </screen> + + <screen name="ContentList"> + <section> + <actions> + <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/> + <property-map resource="ContentUiLabels" map-name="uiLabelMap" global="true"/> + <entity-and entity-name="PartyContent" list-name="partyContent"> + <field-map field-name="partyId" env-name="parameters.partyId"/> + </entity-and> + </actions> + <widgets> + <platform-specific> + <html> + <html-template location="component://party/webapp/partymgr/party/profileblocks/ContentList.ftl"/> </html> </platform-specific> </widgets> |
Free forum by Nabble | Edit this page |