ilscipio/scipio-erp

View on GitHub
framework/webtools/widget/ServiceScreens.xml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is subject to the terms and conditions defined in the
files 'LICENSE' and 'NOTICE', which are part of this source
code package.
-->

<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">

    <screen name="ServiceList">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleServiceList"/>
                <set field="activeSubMenuItem" value="serviceList"/>
                <script location="component://webtools/webapp/webtools/WEB-INF/actions/service/AvailableServices.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <platform-specific>
                            <html>
                                <html-template location="component://webtools/webapp/webtools/service/availableservices.ftl"/>
                            </html>
                        </platform-specific>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="FindJob">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleJobList"/>
                <set field="activeSubMenuItem" 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 ServerHour24HourFormatJs.ftl -->
                <set field="clockField" value="FindJobs_clock_title"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <!-- SCIPIO: 2018-08-28: TODO: REVIEW: JobManagerLock 
                        <include-screen name="JobManagerLockEnable"/>-->
                        <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
                            <decorator-section name="search-options">
                                <container style="${styles.grid_row}">
                                    <container style="${styles.grid_medium}9 ${styles.grid_cell}">
                                        <include-form name="FindJobs" location="component://webtools/widget/ServiceForms.xml"/>
                                    </container>
                                    <container style="${styles.grid_medium}3 ${styles.grid_cell} ${styles.text_right}">
                                        <include-screen name="serverTimeClock"/>
                                    </container>
                                </container>
                            </decorator-section>
                            <decorator-section name="search-results">
                                <include-form name="ListJobs" location="component://webtools/widget/ServiceForms.xml"/>
                            </decorator-section>
                        </decorator-screen>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    <screen name="JobDetails">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleJobDetails"/>
                <set field="activeSubMenuItem" value="findJob"/>
                <script location="component://webtools/webapp/webtools/WEB-INF/actions/service/JobDetails.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet><!-- title="${uiLabelMap.PageTitleJobDetails}" -->
                            <include-form name="JobDetails" location="component://webtools/widget/ServiceForms.xml"/>
                        </screenlet>
                        <screenlet title="${uiLabelMap.WebtoolsRunTimeDataInfo}">
                            <include-form name="JobRuntimeDataInfo" location="component://webtools/widget/ServiceForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    <!-- SCIPIO: replaces the old FindJobs.clock field (broken JS) -->
    <screen name="serverTimeClock">
        <section>
            <actions>
            </actions>
            <widgets>
                <platform-specific><html><html-template location="component://common/webcommon/includes/ServerHour24HourFormatJs.ftl"/></html></platform-specific>
                <platform-specific><html><html-template><![CDATA[
                    <label for="${clockField}" class="serverTimeClock-label">${uiLabelMap.CommonServerHour}:</label> <#t/>
                    <span id="${clockField}" style="white-space: nowrap;" class="serverTimeClock-value">...</span><#t/>
                ]]></html-template></html></platform-specific>
            </widgets>
        </section>
    </screen>

    <screen name="ThreadList">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleThreadList"/>
                <set field="activeSubMenuItem" value="threadList"/>
                <script location="component://webtools/webapp/webtools/WEB-INF/actions/service/Threads.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.WebtoolsServiceEngineThreads}">
                            <include-form name="PoolState" location="component://webtools/widget/ServiceForms.xml"/>
                            <include-form name="ListJavaThread" location="component://webtools/widget/ServiceForms.xml"/>
                        </screenlet>
                        <screenlet title="${uiLabelMap.WebtoolsGeneralJavaThreads}">
                            <platform-specific>
                                <html><html-template location="component://webtools/webapp/webtools/service/threads.ftl"/></html>
                            </platform-specific>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="ScheduleJob">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleScheduleJob"/>
                <set field="activeSubMenuItem" value="scheduleJob"/>
                <script location="component://webtools/webapp/webtools/WEB-INF/actions/service/ScheduleJob.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <!-- SCIPIO: 2018-08-28: TODO: REVIEW: JobManagerLock 
                        <include-screen name="JobManagerLockEnable"/>-->
                        <screenlet title="${uiLabelMap.WebtoolsStep1ServiceAndRecurrenceInfo}">
                            <include-form name="scheduleJob" location="component://webtools/widget/ServiceForms.xml"/>
                            <section>
                                <actions>
                                    <set field="serviceNameInputIdExpr" value="#scheduleJob input[name=SERVICE_NAME]"/>
                                </actions>
                                <widgets>
                                    <include-screen name="serviceNameAutocomplete"/>
                                </widgets>
                            </section>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="RunService">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleRunService"/>
                <set field="activeSubMenuItem" value="runService"/>
                <script location="component://webtools/webapp/webtools/WEB-INF/actions/service/ScheduleJob.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet>
                            <include-form name="runService" location="component://webtools/widget/ServiceForms.xml"/>
                            <section>
                                <actions>
                                    <set field="serviceNameInputIdExpr" value="#runService input[name=SERVICE_NAME]"/>
                                </actions>
                                <widgets>
                                    <include-screen name="serviceNameAutocomplete"/>
                                </widgets>
                            </section>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="serviceNameAutocomplete">
        <section>
            <actions>
                <script lang="groovy"><![CDATA[
                    if (!context.serviceNames) {
                        context.serviceNames = dispatcher.getDispatchContext().getAllServiceNames();
                    }
                    context.serviceNamesMatchMode = context.serviceNamesMatchMode ?: "best";
                    context.serviceNamesMaxMatch = context.serviceNamesMaxMatch ?: -1;
                ]]></script>
            </actions>
            <widgets>
                <platform-specific>
                    <html><html-template lang="ftl"><![CDATA[
                        <@script>
                          $(function() {
                            var serviceNames = <@objectAsScript object=(serviceNames![]) lang="js"/>;

                            var matchBestName = function(sourceList, term, mode, maxCount) {
                                var i = 0, t = term, tlc = t.toLowerCase(), sw = [], swci = [], cnt = [], cntci = [];
                                var c = 0;
                                for (i = 0; (i < serviceNames.length && (maxCount <= 0 || c < maxCount)); i++) {
                                    var s = serviceNames[i];
                                    if (s.startsWith(t)) {
                                        sw.push(s);
                                        c++;
                                    } else {
                                        var slc = s.toLowerCase();
                                        if (slc.startsWith(tlc)) {
                                            swci.push(s);
                                            c++;
                                        } else if (s.includes(t)) {
                                            cnt.push(s);
                                            c++;
                                        } else if (slc.includes(tlc)) {
                                            cntci.push(s);
                                            c++;
                                        }
                                    }
                                }
                                return sw.concat(swci).concat(cnt).concat(cntci);
                            };

                            $("${raw(serviceNameInputIdExpr)}").autocomplete({
                              <#if serviceNamesMatchMode == "best">
                                source: function(request, response) {
                                    response(matchBestName(serviceNames, request.term, "best", ${serviceNamesMaxMatch!-1}));
                                }
                              <#else><#--<#elseif serviceNamesMatchMode == "contains">-->
                                source: serviceNames
                              </#if>
                            });
                          });
                        </@script>
                    ]]></html-template></html>
                </platform-specific>
            </widgets>
        </section>
    </screen>

    <screen name="setServiceParameters">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleScheduleJob"/>
                <set field="activeSubMenuItem" value="scheduleJob"/>
                <script location="component://webtools/webapp/webtools/WEB-INF/actions/service/ScheduleJob.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.WebtoolsStep2ServiceParameters}">
                            <platform-specific>
                                <html><html-template location="component://webtools/webapp/webtools/service/setServiceParameter.ftl"/></html>
                            </platform-specific>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="setSyncServiceParameters">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleScheduleJob"/>
                <set field="activeSubMenuItem" value="runService"/>
                <script location="component://webtools/webapp/webtools/WEB-INF/actions/service/ScheduleJob.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet>
                            <platform-specific>
                                <html><html-template location="component://webtools/webapp/webtools/service/setServiceParameterSync.ftl"/></html>
                            </platform-specific>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="ServiceResult">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleScheduleJob"/>
                <set field="activeSubMenuItem" value="runService"/>
                <script location="component://webtools/webapp/webtools/WEB-INF/actions/service/ServiceResult.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <platform-specific>
                            <html><html-template location="component://webtools/webapp/webtools/service/serviceResult.ftl"/></html>
                        </platform-specific>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="FindJobManagerLock">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleJobManagerLockList"/>
                <set field="tabButtonItem" value="FindJobManagerLock"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <container style="page-title"><label text="${uiLabelMap[titleProperty]}"></label></container>
                        <section>
                            <condition><if-has-permission permission="SERVICE_JM_LOCK"/></condition>
                            <widgets>
                                <container style="button-bar">
                                    <!-- SCIPIO: FIXME (future): link-type not available yet
                                    <link target="AddJobManagerLock" text="${uiLabelMap.CommonAdd}" style="buttontext create" link-type="layered-modal"/>-->
                                </container>
                            </widgets>
                        </section>
                        <screenlet id="searchOptions" name="findScreenlet" collapsible="true" title="${uiLabelMap.CommonSearchOptions}">
                            <container id="search-options">
                                <include-form name="FindJobManagerLock" location="component://webtools/widget/ServiceForms.xml"/>
                            </container>
                        </screenlet>
                        <screenlet padded="false">
                            <label style="h3" text="${uiLabelMap.CommonSearchResults}"/>
                            <container id="search-results">
                                <include-form name="ListJobManagerLock" location="component://webtools/widget/ServiceForms.xml"/>
                            </container>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    <screen name="AddJobManagerLock">
        <section>
            <widgets>
                <decorator-screen name="PopUpDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <include-form name="AddJobManagerLock" location="component://webtools/widget/ServiceForms.xml"/>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    <screen name="JobManagerLockEnable">
        <section>
            <actions>
                <entity-condition entity-name="JobManagerLock" list="currentJobManagerLocks" filter-by-date="true">
                    <order-by field-name="fromDate"/>
                </entity-condition>
                <entity-condition entity-name="JobManagerLock" list="nextJobManagerLocks" filter-by-date="false">
                    <condition-list>
                        <condition-expr field-name="fromDate" operator="greater" from-field="nowTimestamp"/>
                        <condition-list combine="or">
                            <condition-expr field-name="thruDate" operator="greater" from-field="nowTimestamp"/>
                            <condition-expr field-name="thruDate" operator="equals" from-field="nullField"/>
                        </condition-list>
                    </condition-list>
                    <order-by field-name="fromDate"/>
                </entity-condition>
            </actions>
            <widgets>
                <section>
                    <condition>
                        <or>
                            <not><if-empty field="currentJobManagerLocks"/></not>
                            <not><if-empty field="nextJobManagerLocks"/></not>
                        </or>
                    </condition>
                    <widgets>
                        <screenlet title="${uiLabelMap.WebtoolsJobManagerLockEnable}">
                            <section>
                                 <condition>
                                     <not><if-empty field="currentJobManagerLocks"/></not>
                                 </condition>
                                 <actions>
                                     <set field="jobManagerLocks" from-field="currentJobManagerLocks"/>
                                 </actions>
                                 <widgets>
                                     <label style="h3">${uiLabelMap.WebtoolsCurrentJobManagerLock}</label>
                                     <include-grid location="component://webtools/widget/ServiceForms.xml" name="JobManagerLockEnable"/>
                                 </widgets>
                             </section>
                             <section>
                                 <condition>
                                     <not><if-empty field="nextJobManagerLocks"/></not>
                                 </condition>
                                 <actions>
                                     <set field="jobManagerLocks" from-field="nextJobManagerLocks"/>
                                 </actions>
                                 <widgets>
                                     <label style="h3">${uiLabelMap.WebtoolsNextJobManagerLock}</label>
                                     <include-grid location="component://webtools/widget/ServiceForms.xml" name="JobManagerLockEnable"/>
                                 </widgets>
                             </section>
                         </screenlet>
                    </widgets>
                </section>
            </widgets>
        </section>
    </screen>

    <!-- SCIPIO -->
    <screen name="JobStats">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleJobStats"/>
                <set field="activeSubMenuItem" value="jobStats"/>
                <set field="jobCtx" from-field="parameters"/>
                <!-- fields for ServerHour24HourFormatJs.ftl -->
                <set field="clockField" value="FindJobs_clock_title"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonServiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <container style="${styles.grid_row}">
                            <container style="${styles.grid_medium}9 ${styles.grid_cell}">
                                <include-screen name="currentJobStats"/>
                            </container>
                            <container style="${styles.grid_medium}3 ${styles.grid_cell} ${styles.text_right}">
                                <include-screen name="serverTimeClock"/>
                            </container>
                        </container>
                        <container style="${styles.grid_row}">
                            <container style="${styles.grid_medium}12 ${styles.grid_cell}">
                                <platform-specific>
                                    <html><html-template><![CDATA[
                                        <form name="" action="<@pageUrl uri='clearGlobalJobStats'/>" method="post">
                                            <input type="submit" value="Clear Global Stats"/>
                                        </form>
                                    ]]></html-template></html>
                                </platform-specific>
                            </container>
                        </container>
                        <container style="${styles.grid_row}">
                            <container style="${styles.grid_medium}12 ${styles.grid_cell}">
                                <section>
                                    <actions>
                                        <set field="jobType" value="generic"/>
                                        <set field="title" value="Generic Jobs (non-persisted)"/>
                                    </actions>
                                    <widgets><include-screen name="globalJobStats"/></widgets>
                                </section>
                            </container>
                        </container>
                        <container style="${styles.grid_row}">
                            <container style="${styles.grid_medium}12 ${styles.grid_cell}">
                                <section>
                                    <actions>
                                        <set field="jobType" value="persist"/>
                                        <set field="title" value="Persisted Jobs"/>
                                    </actions>
                                    <widgets><include-screen name="globalJobStats"/></widgets>
                                </section>
                            </container>
                        </container>
                        <container style="${styles.grid_row}">
                            <container style="${styles.grid_medium}12 ${styles.grid_cell}">
                                <section>
                                    <actions>
                                        <set field="jobType" value="purge"/>
                                        <set field="title" value="Purge Jobs"/>
                                    </actions>
                                    <widgets><include-screen name="globalJobStats"/></widgets>
                                </section>
                            </container>
                        </container>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    <screen name="currentJobStats">
        <section>
            <actions>
                <set field="title" value="Current Jobs"/>
                <script lang="groovy"><![CDATA[
                    context.jobList = org.ofbiz.service.job.JobPoller.getInstance().getCurrentServiceStatsMapList();
                ]]></script>
            </actions>
            <widgets>
                <platform-specific>
                    <html>
                        <html-template location="component://webtools/webapp/webtools/service/currentJobStats.ftl"/>
                    </html>
                </platform-specific>
            </widgets>
        </section>
    </screen>
    <screen name="globalJobStats">
        <section>
            <actions>
                <script lang="groovy"><![CDATA[
                    context.jobList = org.ofbiz.service.job.JobPoller.getInstance().getGlobalServiceStatsMapList(context.jobType ?: parameters.jobType);
                ]]></script>
            </actions>
            <widgets>
                <platform-specific>
                    <html>
                        <html-template location="component://webtools/webapp/webtools/service/globalJobStats.ftl"/>
                    </html>
                </platform-specific>
            </widgets>
        </section>
    </screen>
</screens>