diff --git a/README.md b/README.md index e07bdc3705..7b2b7e1b8c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # carbon-device-mgt - +
+ - Java7
+ - Java8 WSO2 CONNECTED DEVICE MANAGEMENT COMPONENTS diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index 383f52c040..495ffbee35 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT bundle WSO2 Carbon - API Management Annotations WSO2 Carbon - API Management Custom Annotation Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index 42028ef9f5..a84f27c301 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,12 +21,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../pom.xml 4.0.0 - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT org.wso2.carbon.apimgt.application.extension.api war WSO2 Carbon - API Application Management API diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java index 1f043c7b86..0c78488a2d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java @@ -47,6 +47,7 @@ public class ApiPermissionFilter implements Filter { private static final String PERMISSION_PREFIX = "/permission/admin"; private static List permissions; private static final String WEBAPP_CONTEXT = "/api-application-registration"; + private static final String DEFAULT_ADMIN_ROLE = "admin"; @Override public void init(FilterConfig filterConfig) throws ServletException { InputStream permissionStream = filterConfig.getServletContext().getResourceAsStream(PERMISSION_CONFIG_PATH); @@ -122,7 +123,17 @@ public class ApiPermissionFilter implements Filter { UserRealm userRealm = APIUtil.getRealmService().getTenantUserRealm(PrivilegedCarbonContext .getThreadLocalCarbonContext().getTenantId()); String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(username); - return userRealm.getAuthorizationManager().isUserAuthorized(tenantAwareUsername, permission, action); + boolean status = userRealm.getAuthorizationManager() + .isUserAuthorized(tenantAwareUsername, permission, action); + if (!status) { + String[] roles = userRealm.getUserStoreManager().getRoleListOfUser(tenantAwareUsername); + for (String role : roles) { + if (role.equals(DEFAULT_ADMIN_ROLE)) { + return true; + } + } + } + return status; } catch (UserStoreException e) { String errorMsg = String.format("Unable to authorize the user : %s", username); log.error(errorMsg, e); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/WEB-INF/web.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/WEB-INF/web.xml index 3a900cd914..823bf51d73 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/WEB-INF/web.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/WEB-INF/web.xml @@ -59,6 +59,43 @@ ApiPermissionFilter org.wso2.carbon.apimgt.application.extension.api.filter.ApiPermissionFilter + + + HttpHeaderSecurityFilter + org.apache.catalina.filters.HttpHeaderSecurityFilter + + hstsEnabled + false + + + + + ContentTypeBasedCachePreventionFilter + org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter + + patterns + text/html" ,application/json" ,text/plain + + + filterAction + enforce + + + httpHeaders + Cache-Control: no-store, no-cache, must-revalidate, private + + + + + HttpHeaderSecurityFilter + /* + + + + ContentTypeBasedCachePreventionFilter + /* + + ApiPermissionFilter /* diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 0d0f89a335..5f115d7a1d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,12 +22,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../pom.xml 4.0.0 - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT org.wso2.carbon.apimgt.application.extension bundle WSO2 Carbon - API Application Management diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java index 8cad8b016f..611679e512 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java @@ -26,6 +26,12 @@ import org.wso2.carbon.apimgt.application.extension.exception.APIManagerExceptio */ public interface APIManagementProviderService { + /** + * Check whether the tier is loaded for the tenant. + * @return + */ + boolean isTierLoaded(); + /** * Generate and retreive application keys. if the application does exist then * create it and subscribe to apis that are grouped with the tags. diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index b97146a02d..bc92961f64 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -45,8 +45,22 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private static final String CONTENT_TYPE = "application/json"; private static final int MAX_API_PER_TAG = 200; private static final String APP_TIER_TYPE = "application"; - private static final Map tiersMap = new HashMap<>(); - private static final int MAX_ATTEMPTS = 20; + + public boolean isTierLoaded() { + StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() + .getStoreClient(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext() + .getTenantDomain(); + try { + + storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, + APP_TIER_TYPE, + tenantDomain, CONTENT_TYPE, null, null); + return true; + } catch (FeignException e) { + return false; + } + } @Override public void removeAPIApplication(String applicationName, String username) throws APIManagerException { @@ -72,31 +86,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throws APIManagerException { StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() .getStoreClient(); - //This is a fix to avoid race condition and trying to load tenant related tiers before invocation. String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext() .getTenantDomain(); - String tiersLoadedForTenant = tiersMap.get(tenantDomain); - - if (tiersLoadedForTenant == null) { - boolean tierLoaded = false; - int attempts = 0; - do { - try { - storeClient.getIndividualTier() - .tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, APP_TIER_TYPE, - tenantDomain, CONTENT_TYPE, null, null); - tiersMap.put(tenantDomain, "exist"); - tierLoaded = true; - } catch (FeignException e) { - attempts++; - try { - Thread.sleep(500); - } catch (InterruptedException ex) { - log.warn("Interrupted the waiting for tier availability."); - } - } - } while ((!tierLoaded) && attempts < MAX_ATTEMPTS); - } ApplicationList applicationList = storeClient.getApplications() .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml index f3b7a65b96..969a408d19 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -21,13 +21,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handlers - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT bundle WSO2 Carbon - API Security Handler Component WSO2 Carbon - API Management Security Handler Module @@ -76,6 +76,7 @@ WSO2 Carbon - API Security Handler Component org.apache.axiom.*, + javax.security.cert.*, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.*, org.apache.axis2.*, @@ -90,7 +91,8 @@ org.w3c.dom, org.apache.synapse, org.apache.synapse.core.axis2, - org.apache.synapse.rest + org.apache.synapse.rest, + org.wso2.carbon.certificate.mgt.core.impl diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandler.java index c5fe71dd4a..2891e06179 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandler.java @@ -31,11 +31,17 @@ import org.wso2.carbon.apimgt.handlers.invoker.RESTInvoker; import org.wso2.carbon.apimgt.handlers.invoker.RESTResponse; import org.wso2.carbon.apimgt.handlers.utils.AuthConstants; import org.wso2.carbon.apimgt.handlers.utils.Utils; +import org.wso2.carbon.certificate.mgt.core.impl.CertificateGenerator; import org.wso2.carbon.context.PrivilegedCarbonContext; +import javax.security.cert.CertificateEncodingException; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; @@ -140,6 +146,21 @@ public class AuthenticationHandler extends AbstractHandler { if (log.isDebugEnabled()) { log.debug("Verify response:" + response.getContent()); } + } else if (headers.containsKey(AuthConstants.MUTUAL_AUTH_HEADER)) { + javax.security.cert.X509Certificate[] certs = + (javax.security.cert.X509Certificate[]) axisMC.getProperty(AuthConstants.CLIENT_CERTIFICATE); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + ByteArrayInputStream bais = new ByteArrayInputStream(certs[0].getEncoded()); + X509Certificate x509 = (X509Certificate) cf.generateCertificate(bais); + if (bais != null) { + bais.close(); + } + if (x509 != null) { + headers.put(AuthConstants.PROXY_MUTUAL_AUTH_HEADER, CertificateGenerator.getCommonName(x509)); + return true; + } else { + response = null; + } } else if (headers.containsKey(AuthConstants.ENCODED_PEM)) { String encodedPem = headers.get(AuthConstants.ENCODED_PEM).toString(); if (log.isDebugEnabled()) { @@ -178,8 +199,13 @@ public class AuthenticationHandler extends AbstractHandler { } catch (APIMCertificateMGTException e) { log.error("Error while processing certificate.", e); return false; + } catch (CertificateException e) { + log.error("Certificate issue occurred when generating converting PEM to x509Certificate", e); + return false; + } catch (CertificateEncodingException e) { + log.error("Error while attempting to encode certificate.", e); + return false; } - } @Override @@ -205,4 +231,4 @@ public class AuthenticationHandler extends AbstractHandler { map.put(CONTENT_TYPE, "application/json"); return map; } -} +} \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/DCR.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/DCR.java index 4091afcb9e..ae5e42b59a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/DCR.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/DCR.java @@ -24,14 +24,12 @@ package org.wso2.carbon.apimgt.handlers.beans; */ public class DCR { - // Owner of the application + private String callbackUrl; private String owner; - // Client name private String clientName; - // Oauth Grant type private String grantType; - // Scope of the token private String tokenScope; + private boolean isSaasApp; public String getOwner() { return owner; @@ -64,5 +62,27 @@ public class DCR { public void setTokenScope(String tokenScope) { this.tokenScope = tokenScope; } + + public boolean getIsSaasApp() { + return isSaasApp; + } + + public void setIsSaasApp(boolean isSaasApp) { + this.isSaasApp = isSaasApp; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public String toJSON() { + return "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + "\", \"tokenScope\": " + + "\"" + tokenScope + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + + "\", \"saasApp\" :" + isSaasApp + " }\n"; + } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/AuthConstants.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/AuthConstants.java index 531c7c11d5..74870c131f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/AuthConstants.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/AuthConstants.java @@ -35,5 +35,17 @@ public class AuthConstants { // public static final String ANDROID_VERIFY_ENDPOINT = "android-verify-endpoint"; public static final String MDM_SIGNATURE = "mdm-signature"; public static final String PROXY_MUTUAL_AUTH_HEADER = "proxy-mutual-auth-header"; + public static final String MUTUAL_AUTH_HEADER = "mutual-auth-header"; public static final String ENCODED_PEM = "encoded-pem"; + public static final String CALLBACK_URL = ""; + public static final String CLIENT_NAME = "IOT-API-MANAGER"; + public static final String GRANT_TYPE = "refresh_token password client_credentials"; + public static final String TOKEN_SCOPE = "default"; + public static final String CONTENT_TYPE_HEADER = "Content-Type"; + public static final String CONTENT_TYPE = "application/json"; + public static final String AUTHORIZATION_HEADER = "Authorization"; + public static final String BASIC_AUTH_PREFIX = "Basic "; + public static final String CLIENT_ID = "clientId"; + public static final String CLIENT_SECRET = "clientSecret"; + public static final String CLIENT_CERTIFICATE = "ssl.client.auth.cert.X509"; } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/Utils.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/Utils.java index 3e66ed7edd..d3c8ad3a9f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/Utils.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/Utils.java @@ -19,7 +19,6 @@ package org.wso2.carbon.apimgt.handlers.utils; -import com.google.gson.Gson; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.ws.security.util.Base64; @@ -118,8 +117,7 @@ public class Utils { tokenHeaders.put("Content-Type", "application/x-www-form-urlencoded"); RESTInvoker restInvoker = new RESTInvoker(); - RESTResponse response = restInvoker.invokePOST(tokenUrl, tokenHeaders, null, - null, tokenContent); + RESTResponse response = restInvoker.invokePOST(tokenUrl, tokenHeaders, null, null, tokenContent); if(log.isDebugEnabled()) { log.debug("Token response:" + response.getContent()); } @@ -144,31 +142,32 @@ public class Utils { private static void getClientSecretes(IOTServerConfiguration iotServerConfiguration) throws APIMCertificateMGTException { try { + String username = iotServerConfiguration.getUsername(); + String password = iotServerConfiguration.getPassword(); DCR dcr = new DCR(); dcr.setOwner(iotServerConfiguration.getUsername()); - dcr.setClientName("IOT-API-MANAGER"); - dcr.setGrantType("refresh_token password client_credentials"); - dcr.setTokenScope("default"); - Gson gson = new Gson(); - String dcrContent = gson.toJson(dcr); - Map drcHeaders = new HashMap(); - drcHeaders.put("Content-Type", "application/json"); + dcr.setClientName(AuthConstants.CLIENT_NAME); + dcr.setGrantType(AuthConstants.GRANT_TYPE); + dcr.setTokenScope(AuthConstants.TOKEN_SCOPE); + dcr.setCallbackUrl(AuthConstants.CALLBACK_URL); + dcr.setIsSaasApp(true); + String dcrContent = dcr.toJSON(); + Map dcrHeaders = new HashMap(); + String basicAuth = Base64.encode((username + ":" + password).getBytes()); + dcrHeaders.put(AuthConstants.CONTENT_TYPE_HEADER, AuthConstants.CONTENT_TYPE); + dcrHeaders.put(AuthConstants.AUTHORIZATION_HEADER, AuthConstants.BASIC_AUTH_PREFIX + basicAuth); URI dcrUrl = new URI(iotServerConfiguration.getDynamicClientRegistrationEndpoint()); RESTInvoker restInvoker = new RESTInvoker(); - RESTResponse response = restInvoker.invokePOST(dcrUrl, drcHeaders, null, - null, dcrContent); - + RESTResponse response = restInvoker.invokePOST(dcrUrl, dcrHeaders, null, null, dcrContent); if (log.isDebugEnabled()) { log.debug("DCR response :" + response.getContent()); } JSONObject jsonResponse = new JSONObject(response.getContent()); - clientId = jsonResponse.getString("client_id"); - clientSecret = jsonResponse.getString("client_secret"); + clientId = jsonResponse.getString(AuthConstants.CLIENT_ID); + clientSecret = jsonResponse.getString(AuthConstants.CLIENT_SECRET); } catch (JSONException e) { throw new APIMCertificateMGTException("Error occurred while converting the json to object", e); - } catch (IOException e) { - throw new APIMCertificateMGTException("Error occurred while trying to call DCR endpoint", e); - } catch (URISyntaxException e) { + } catch (IOException | URISyntaxException e) { throw new APIMCertificateMGTException("Error occurred while trying to call DCR endpoint", e); } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index b2d292e654..e90752fba8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -13,13 +13,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java index 9c12b0cdaa..19633fa009 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java @@ -19,7 +19,9 @@ package org.wso2.carbon.apimgt.integration.client.store; import feign.Feign; import feign.Logger; +import feign.Request; import feign.RequestInterceptor; +import feign.Retryer; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.slf4j.Slf4jLogger; @@ -28,6 +30,8 @@ import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; import org.wso2.carbon.apimgt.integration.generated.client.store.api.*; import org.wso2.carbon.core.util.Utils; +import java.util.concurrent.TimeUnit; + /** * API Store client, created using swagger gen. */ @@ -62,8 +66,10 @@ public class StoreClient { individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath); subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath); tags = builder.target(TagCollectionApi.class, basePath); - tiers = builder.target(ThrottlingTierCollectionApi.class, basePath); individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath); + tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1)) + .options(new Request.Options(10000, 5000)) + .target(ThrottlingTierCollectionApi.class, basePath); } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index 6ba32f2671..6b85588bb4 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml @@ -13,13 +13,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.generated.client - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT bundle WSO2 Carbon - API Management Integration Generated Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 408c29e00d..7b1f639ddc 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT bundle WSO2 Carbon - API Management Webapp Publisher WSO2 Carbon - API Management Webapp Publisher diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 9ba0dc3827..b57f64e0db 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT pom WSO2 Carbon - API Management Extensions Component http://wso2.org diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml similarity index 98% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/pom.xml rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml index ab6f88a5e3..40747d1341 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml @@ -22,12 +22,13 @@ application-mgt org.wso2.carbon.devicemgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.api + 2.0.63-SNAPSHOT war WSO2 Carbon - Mobile Application Management API WSO2 Carbon - Mobile Application Management API @@ -46,7 +47,7 @@ maven-war-plugin WEB-INF/lib/*cxf*.jar - api#application-mgt#v2.0 + api#application-mgt#v1.0 diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/beans/ErrorListItem.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorListItem.java similarity index 97% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/beans/ErrorListItem.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorListItem.java index b120f18156..e69f62c2ca 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/beans/ErrorListItem.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorListItem.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.api.v2.beans; +package org.wso2.carbon.device.application.mgt.api.beans; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/beans/ErrorResponse.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorResponse.java similarity index 98% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/beans/ErrorResponse.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorResponse.java index 253c848e02..0b648b52c6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/beans/ErrorResponse.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorResponse.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.api.v2.beans; +package org.wso2.carbon.device.application.mgt.api.beans; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/ErrorHandler.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/ErrorHandler.java similarity index 95% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/ErrorHandler.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/ErrorHandler.java index 9564d90f09..0b921d5ec1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/ErrorHandler.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/ErrorHandler.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.application.mgt.api.v2.common; +package org.wso2.carbon.device.application.mgt.api.common; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/ErrorMessage.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/ErrorMessage.java similarity index 94% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/ErrorMessage.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/ErrorMessage.java index 42cfb1f4d2..1856305ab6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/ErrorMessage.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/ErrorMessage.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.application.mgt.api.v2.common; +package org.wso2.carbon.device.application.mgt.api.common; public class ErrorMessage { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/GsonMessageBodyHandler.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/GsonMessageBodyHandler.java similarity index 98% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/GsonMessageBodyHandler.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/GsonMessageBodyHandler.java index ef8c4a8c70..8789e25a3d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/GsonMessageBodyHandler.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/GsonMessageBodyHandler.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.application.mgt.api.v2.common; +package org.wso2.carbon.device.application.mgt.api.common; import com.google.gson.Gson; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/MDMAPIException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/MDMAPIException.java similarity index 95% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/MDMAPIException.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/MDMAPIException.java index def0093863..4637c6f3ec 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/common/MDMAPIException.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/MDMAPIException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.application.mgt.api.v2.common; +package org.wso2.carbon.device.application.mgt.api.common; /** * Custom exception class for handling CDM API related exceptions. diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/apis/ApplicationManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java similarity index 92% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/apis/ApplicationManagementAPI.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java index 7087d9da36..54af6d1cfe 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/apis/ApplicationManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java @@ -16,11 +16,11 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.api.v2.apis; +package org.wso2.carbon.device.application.mgt.api.services; import io.swagger.annotations.*; -import org.wso2.carbon.device.application.mgt.api.v2.beans.ErrorResponse; -import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList; +import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse; +import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -30,7 +30,7 @@ import javax.ws.rs.core.Response; "such as get all the available devices, etc.") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -public interface ApplicationManagementAPI { +public interface ApplicationManagementService { public final static String SCOPE = "scope"; @@ -90,4 +90,5 @@ public interface ApplicationManagementAPI { ); + } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/apis/impl/ApplicationManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementServiceImpl.java similarity index 94% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/apis/impl/ApplicationManagementAPIImpl.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementServiceImpl.java index 49f8de3f8a..bf86b93a48 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/java/org/wso2/carbon/device/application/mgt/api/v2/apis/impl/ApplicationManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementServiceImpl.java @@ -16,25 +16,25 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.api.v2.apis.impl; +package org.wso2.carbon.device.application.mgt.api.services.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList; import org.wso2.carbon.device.application.mgt.core.dto.Filter; -import org.wso2.carbon.device.application.mgt.core.services.ApplicationManager; +import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList; import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUtil; +import org.wso2.carbon.device.application.mgt.core.services.ApplicationManager; import javax.ws.rs.*; import javax.ws.rs.core.Response; @Produces({ "application/json"}) @Consumes({ "application/json"}) -public class ApplicationManagementAPIImpl { +public class ApplicationManagementServiceImpl { public static final int DEFAULT_LIMIT = 20; - private static Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class); + private static Log log = LogFactory.getLog(ApplicationManagementServiceImpl.class); @GET @@ -43,7 +43,6 @@ public class ApplicationManagementAPIImpl { public Response getApplications(@QueryParam("offset") int offset, @QueryParam("limit") int limit, @QueryParam("q") String searchQuery) { ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagementService(); - try { if(limit == 0){ @@ -57,7 +56,6 @@ public class ApplicationManagementAPIImpl { ApplicationList applications = applicationManager.getApplications(filter); return Response.status(Response.Status.OK).entity(applications).build(); - } catch (Exception e) { String msg = "Error occurred while getting the application list"; log.error(msg, e); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/webapp/META-INF/permissions.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/webapp/META-INF/permissions.xml rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/webapp/META-INF/webapp-classloading.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/webapp/META-INF/webapp-classloading.xml rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 85% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 8cb974f518..65b5a921e7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -16,7 +16,7 @@ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> - - + + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/webapp/WEB-INF/web.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api.v2/src/main/webapp/WEB-INF/web.xml rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml index 5a7933cd2d..46a9c6e7dc 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt application-mgt - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.core - 2.0.45-SNAPSHOT + 2.0.63-SNAPSHOT bundle WSO2 Carbon - Application Management Core WSO2 Carbon - Application Management Core diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationList.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationList.java new file mode 100644 index 0000000000..c089cbb388 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationList.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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. + * + */ +package org.wso2.carbon.device.application.mgt.core.dto; + +import java.util.List; + +public class ApplicationList { + + private List applications; + + private Pagination pagination; + + public List getApplications() { + return applications; + } + + public void setApplications(List applications) { + this.applications = applications; + } + + public Pagination getPagination() { + return pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationType.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationType.java new file mode 100644 index 0000000000..c6a9bb25ee --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationType.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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. + * + */ +package org.wso2.carbon.device.application.mgt.core.dto; + +import org.wso2.carbon.device.application.mgt.core.jaxrs.Exclude; + +public class ApplicationType { + + @Exclude + private int id; + + private String name; + + private String code; + + private String parameters; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getParameters() { + return parameters; + } + + public void setParameters(String parameters) { + this.parameters = parameters; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/log4j.properties b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/log4j.properties new file mode 100644 index 0000000000..e415fd607d --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/log4j.properties @@ -0,0 +1,34 @@ +# +# Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. 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. +# + +# +# This is the log4j configuration file used by WSO2 Carbon +# +# IMPORTANT : Please do not remove or change the names of any +# of the Appender defined here. The layout pattern & log file +# can be changed using the WSO2 Carbon Management Console, and those +# settings will override the settings in this file. +# + +log4j.rootLogger=DEBUG, STD_OUT + +# Redirect log messages to console +log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender +log4j.appender.STD_OUT.Target=System.out +log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout +log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/testng.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/testng.xml new file mode 100644 index 0000000000..0af96a3777 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/testng.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/pom.xml new file mode 100644 index 0000000000..f3401922bf --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/pom.xml @@ -0,0 +1,62 @@ + + + + + + + application-mgt + org.wso2.carbon.devicemgt + 2.0.63-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.application.mgt.ui + pom + 2.0.63-SNAPSHOT + WSO2 Carbon - Application Management Base UI + WSO2 Carbon - Application Management Base UI + http://wso2.org + + + + + maven-assembly-plugin + 2.5.5 + + ${project.artifactId}-${carbon.device.mgt.version} + false + + src/assembly/src.xml + + + + + create-archive + package + + single + + + + + + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/assembly/src.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/assembly/src.xml new file mode 100644 index 0000000000..86251cba50 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/assembly/src.xml @@ -0,0 +1,48 @@ + + + + src + + zip + + false + ${basedir}/src + + + + ${basedir}/src/main/resources/jaggeryapps/application-mgt + /jaggeryapps/application-mgt/ + true + + + + ${basedir}/src/main/resources/jaggeryapps/uuf-template-app + /jaggeryapps/appmgt-uuf-template-app/ + true + + + ${basedir}/src/main/resources/jaggery-modules + /jaggery-modules/ + true + + + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/module.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/module.xml new file mode 100644 index 0000000000..485112332c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/module.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/exception/exception.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/exception/exception.js new file mode 100644 index 0000000000..a80361dec0 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/exception/exception.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) WSO2 Inc. (http://wso2.com) All Rights Reserved. + * + * Licensed 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. + */ + +/** + * Description: The response of the currently invoked api enpoint is organized + */ + +var exception = {}; +var log = new Log('exception_module'); + +(function(exception) { + /** + * + * @param message The exception description + * @param code HTTP STATUS CODE related to the exception + * @return The error object + */ + exception.buildExceptionObject = function(message, code) { + var error = {}; + error.message = message; + error.code = code; + return error; + }; + + exception.handleError = function (exception, type, code){ + var constants = require('rxt').constants; + + if (type == constants.THROW_EXCEPTION_TO_CLIENT) { + log.debug(exception); + var e = exceptionModule.buildExceptionObject(exception, code); + throw e; + } else if (type == constants.LOG_AND_THROW_EXCEPTION) { + log.error(exception); + throw exception; + } else if (type == constants.LOG_EXCEPTION_AND_TERMINATE) { + log.error(exception); + var msg = 'An error occurred while serving the request!'; + var e = exceptionModule.buildExceptionObject(msg, constants.STATUS_CODES.INTERNAL_SERVER_ERROR); + throw e; + } else if (type == constants.LOG_EXCEPTION_AND_CONTINUE) { + log.debug(exception); + } + else { + log.error(exception); + throw e; + } + }; +}(exception)) + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/file/file.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/file/file.js new file mode 100644 index 0000000000..f3aa6578f5 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/file/file.js @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 file = {}; +(function() { + var log = new Log('utils-file'); + var CONTENT_MAP = { + 'js': 'application/javascript', + 'css': 'text/css', + 'csv': 'text/csv', + 'html': 'text/html', + 'json': 'application/json', + 'png': 'image/png', + 'jpeg': 'image/jpeg', + 'gif': 'image/gif', + 'svg': 'image/svg+xml', + 'ttf': 'application/x-font-ttf', + 'eot': 'application/vnd.ms-fontobject', + 'woff': 'application/font-woff', + 'otf': 'application/x-font-otf', + 'zip': 'application/zip', + 'xml': 'text/xml', + 'xhtml': 'application/xhtml+xml', + 'pdf': 'application/pdf' + }; + /** + * The function checks whether a directory contains a particular file + * @param dir The directory in which the file must be checked + * @param file A File object if the file exists,else null + */ + file.getFileInDir = function(dir, fileName) { + var isFilePresent = false; + var files = dir.listFiles(); + for (var index in files) { + if (files[index].getName() == fileName) { + return files[index]; + } + } + return null; + }; + /** + * The function returns the file extension of a filename + * @param file + * @return: The extension of the file + */ + file.getExtension = function(file) { + var baseFileName = file.getName(); + //Break up the name by . + var baseNameComponents = baseFileName.split('.'); + var extension = baseNameComponents[baseNameComponents.length - 1]; + return extension; + }; + /** + * The function obtains the MIME type based on the extension + * @param The extension + * @return The mime type + */ + file.getMimeType = function(extension) { + return CONTENT_MAP[extension]; + }; + /** + * The function returns the name of the file without the file extension + * @param file A file object + * @return: The name of the file without the extension + */ + file.getFileName = function(file) { + //Get the name of the file + var baseFileName = file.getName(); + //Break up the name by . + var baseNameComponents = baseFileName.split('.'); + //Get all of the components except the last one + baseNameComponents.splice(baseNameComponents.length - 1, 1); + return baseNameComponents.join('.'); + }; + /** + * The function returns the contents of a directory as a JSON object.The name of the + * file is used as the property names without the extensions. + * NOTE: The method will not traverse sub folders. + * @param The directory to be inspected + * @return A JSON object which contains the files in the directory + */ + file.getDirectoryContents = function(dir) { + var dirContents = {}; + //Check if it is a directory + if (!dir.isDirectory()) { + log.info('Not a directory'); + return dirContents; + } + //Obtain a list of all files + var files = this.getAllFiles(dir); + var name; + log.info('Files: ' + files); + //Create the directory object with each file been a property + for (var index in files) { + dirContents[this.getFileName(files[index])] = files[index]; + } + return dirContents; + }; + /** + * The function obtains a list of files that are not directories + * @param dir The directory to be inspected + * @return An array with all of the files in the directory + */ + file.getAllFiles = function(dir) { + var filesInDir = []; + if (!dir.isDirectory()) { + return filesInDir; + } + //Obtain a list of all files + var files = dir.listFiles(); + for (var index in files) { + log.info('Checking file: ' + files[index].getName()); + //Check if the file is a directory + if (!files[index].isDirectory()) { + filesInDir.push(files[index]); + } + } + return filesInDir; + }; + /** + * The function returns a list of all file names in a directory + * @param dir The directory to be inspected + * @return {An array containing the name of all files in a directory + */ + file.getAllFileNames = function(dir) { + var files = dir.listFiles(); + var list = []; + var fileName; + for (var index in files) { + if (files[index].isDirectory()) { + fileName=this.getFileName(files[index].getName()); + list.push(fileName); + } + } + return list; + }; + /** + * The function returns a list of all sub directories in a given directory + * @param dir The root directory + * @return: An array containing all sub directories + */ + file.getAllSubDirs = function(dir) { + var files = dir.listFiles(); + var subDirs = []; + for (var index in files) { + if (files[index].isDirectory()) { + subDirs.push(files[index]); + } + } + return subDirs; + }; +}()); \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/patterns/patterns.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/patterns/patterns.js new file mode 100644 index 0000000000..f0e55bb254 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/patterns/patterns.js @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 patterns = {}; + +(function () { + + var DEF_ERR_ARITY = 3; + var DEF_HANDLE_ARITY = 2; + var log = new Log('utils.patterns.GenericPipe'); + + function GenericPipe(options) { + this.errHandlerArity = DEF_ERR_ARITY || options.errArity; + this.handlerArity = DEF_HANDLE_ARITY || options.handlerArity; + this.plugins = []; + this.finalHandler = function () { + }; + } + + + /** + *The function registers the provided plugin + */ + GenericPipe.prototype.plug = function (plugin, options) { + var options = options || {}; + //Only a function + if (plugin instanceof Function) { + this.plugins.push({ + handle: plugin, + options: options + }); + } + //Is it a plugin object + else if (plugin instanceof Object) { + plugin.options = options; + this.plugins.push(plugin); + } + + return this; + }; + + GenericPipe.prototype.finally = function (plugin) { + this.finalHandler = plugin; + return this; + }; + + GenericPipe.prototype.resolve = function (data, req, res, session) { + var context = {}; + context.req = req; + context.res = res; + context.session = session; + context.data = data; + handle(context, this.plugins, this.errHandlerArity, this.handlerArity, this.finalHandler); + }; + + var handle = function (context, plugins, errArity, handlerArity, finallyHandler) { + var index = 0; + var currentPlugin; + + var recursiveHandle = function (err) { + + currentPlugin = plugins[index]; + + index++; + + //Check if there is a plugin + if (!currentPlugin) { + //log.warn('No plugin found at index: ' + index); + return; + } + + //Populate the options object for the plugin + context.options=currentPlugin.options;; + + //Check if an error has been provided + if (err) { + //Can the current plugin handle the err + if (currentPlugin.handle.length == errArity) { + try { + currentPlugin.handle(err, context,recursiveHandle); + } + catch (e) { + recursiveHandle(e); + } + } + else { + recursiveHandle(err); + } + } + //There is no error so try to invoke the current plugin + else { + if (currentPlugin.handle.length == handlerArity) { + try { + + + currentPlugin.handle(context,recursiveHandle); + } catch (e) { + recursiveHandle(e); + } + } + else { + recursiveHandle(); + } + } + }; + + recursiveHandle(); + finallyHandler(context); + }; + + patterns.GenericPipe = GenericPipe; + +}()); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/reflection/reflection.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/reflection/reflection.js new file mode 100644 index 0000000000..77ff58d49e --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/reflection/reflection.js @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 reflection = {}; +/** + * Description: The script encapsulates any reflection related utility functions + */ +(function() { + var log = new Log('utils-reflection'); + reflection.copyPropKeys = function(from, to) { + for (var key in from) { + if (from.hasOwnProperty(key)) { + to[key] = ''; + } + } + return to; + }; + /** + * The function recursively copies all property keys in an object + * @param from + * @param to + */ + reflection.copyAllPropKeys = function(from, to) { + recurse(from, to, function(from, to, key) { + if (from[key] instanceof Object) { + to[key] = from[key]; + } else { + to[key] = null; + } + }); + }; + reflection.copyAllPropValues = function(from, to) { + recurse(from, to, function(from, to, key) { + //Create an instance if the property does not exist + if (!to[key]) { + to[key] = {}; + } + //Copy the values over + if (!(from[key] instanceof Object)) { + to[key] = from[key]; + } else { + log.debug('Not copying values of key: ' + key); + } + }); + }; + /** + * The function will only copy public properties + * @param from + * @param to + */ + reflection.copyPublicPropValues = function(from, to) { + recurse(from, to, function(from, to, key) { + //Ignore any hidden properties + if (key.charAt(0) == '_') { + log.warn('Drop key: ' + key); + return; + } + //Create an instance if the property does not exist + if (!to[key]) { + to[key] = {}; + } + //Copy the values over + if (!(from[key] instanceof Object)) { + to[key] = from[key]; + } else { + log.warn('Not copying values of key: ' + key); + } + }); + }; + reflection.inspect = function(from, to, cb) { + recurse(from, to, cb); + }; + /** + * The function recursively traverses an object and then invokes the provided + * callback + * @param root + * @param clone + * @param cb + */ + var recurse = function(root, clone, cb) { + var key; + //Check if the root is an object + if (!(root instanceof Object)) { + return; + } else { + var keys = Object.keys(root); + //Go through all the other keys in the current root + for (var index in keys) { + key = keys[index]; + cb(root, clone, key); + recurse(root[key], clone[key], cb); + } + } + }; + reflection.copyProps = function(from, to) { + for (var key in from) { + if (from.hasOwnProperty(key)) { + to[key] = from[key]; + } + } + return to; + }; + reflection.getProps = function(obj) { + var props = {}; + for (var key in obj) { + if (!(obj[key] instanceof Function)) { + props[key] = obj[key]; + } + } + return props; + }; + reflection.printProps = function(obj) { + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + log.info('key: ' + key); + } + } + }; + /** + * The function determines if a property is hidden based on _ + * @param key + * @returns {boolean} + */ + reflection.isHiddenProp = function(key) { + if (key == '') { + return false; + } + return (key.charAt(0) == '_') ? true : false; + }; + var getDiff = function(a, b, diff) {}; + /** + * The function calculates the differences between two simple JSON objects + * @param a The object with which b is compared + * @param b The target of the comparison + * @return An object which records the differences between the two objects + */ + reflection.diff = function(a, b) {}; + /** + * The function merges the two provided objects to create a new + * object.In the case where b has the same property as a; the property of b + * will have precedence + * @param {[type]} a [description] + * @param {[type]} b [description] + * @return A new object having the properties of both object a and b + */ + reflection.merge = function(a, b) { + var newObj = {}; + //Copy the properties of a first + for (var key in a) { + newObj[key] = b[key]; + } + //Override with the properties of b + for (var key in b) { + newObj[key] = b[key]; + } + return newObj; + }; + /** + * The function allows a child class to override a select set of methods of + * a parent class.The original methods of the parent can be accessed + * using the this._super keyword + * @param {[type]} parent The parent class instance to be overriden + * @param {[type]} child The child class instance containing methods which will override the parent + */ + reflection.override = function(parent, child) { + //Make a clone of the parent + var super = parse(stringify(parent)); + for (var childKey in child) { + for (var parentKey in parent) { + //Only override those methods that are common + if (childKey === parentKey) { + var parentPtr = parent[parentKey]; + var childPtr = child[childKey]; + //Update the clone with the old parent method + super[parentKey] = parentPtr; + parent[parentKey] = childPtr; + /*parent[parentKey] = function() { + var result=childPtr.apply(this, arguments)||null; + return result; + };*/ + } + } + } + //Allow the child object to call methods of the parent + parent._super = super; + }; + reflection.overrideAll=function(parent,child){ + //Make a clone of the parent + var super = parse(stringify(parent)); + for (var childKey in child) { + for (var parentKey in parent) { + //Only override those methods that are common + if ( (child.hasOwnProperty(childKey))&&(parent.hasOwnProperty(parentKey)) ) { + var parentPtr = parent[parentKey]; + var childPtr = child[childKey]; + //Update the clone with the old parent method + super[parentKey] = parentPtr; + parent[parentKey] = childPtr; + /*parent[parentKey] = function() { + var result=childPtr.apply(this, arguments)||null; + return result; + };*/ + } + } + } + //Allow the child object to call methods of the parent + parent._super = super; + }; + reflection.isArray = function(object) { + if (Object.prototype.toString.call(object) === '[object Array]') { + return true; + } + return false; + }; +}()); \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/request/request.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/request/request.js new file mode 100644 index 0000000000..4218da70fd --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/request/request.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 request = {}; +(function(request) { + var hasOwnProperty = function(obj, element) { + return Object.prototype.hasOwnProperty.call(obj, element); + }; + var isObject = function(object) {; + return typeof object === 'object'; + }; + /* + * ECMA Standard (ECMA-262 : 5.1 Edition)*/ + var decodes = function(encodedURI) { + return decodeURIComponent(encodedURI); + }; + request.getQueryOptions = function(queryString) { + var opt={}; + var sep = opt.sep || '&', + assign = opt.assign || '=', + compoArray = []; + var obj = {}; + var decodedURI = decodes(queryString); + decodedURI.split(sep).forEach(function(comp) { + comp.split(assign).some(function(element, index, array) { + if (hasOwnProperty(obj, element.toString())) { + compoArray.push(obj[element]); + compoArray.push(array[1]); + obj[element] = compoArray; + } else { + Object.defineProperty(obj, element, { + enumerable: true, + writable: true, + value: array[1] + }); + } + return true; + }); + }); + return obj; + }; +}(request)) \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/response/response.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/response/response.js new file mode 100644 index 0000000000..a8dae44247 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/response/response.js @@ -0,0 +1,96 @@ +/* + * Copyright (c) WSO2 Inc. (http://wso2.com) All Rights Reserved. + * + * Licensed 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. + */ + +/** + * Description: The response of the currently invoked api endpoint is organized + */ + +var response = {}; +var log = new Log("response"); + +(function(response) { + + /** + * Build Error response + * @param resp jaggery-response object to retrieve to client + * @param code status code + * @param message message to the client side + * @return return response + */ + response.buildErrorResponse = function(resp,code,message) { + var content={}; + content.error = message; + resp = processResponse(resp,code,content); + return resp; + }; + + /** + * Build success response + * @param resp jaggery response object + * @param code status code + * @param data the result to client + * @return return response + */ + response.buildSuccessResponse= function(resp, code, data){ + var content={}; + content.data = data; + resp = processResponse(resp,code,content); + return resp; + }; + + /** + * process General response + * @param resp jaggery response + * @param code status code + * @param data success result + * @return resp jaggery response + */ + response.buildSuccessResponseForRxt= function(resp, code, data){ + resp.status = code; + resp.content = data; + return resp; + }; + + /** + * General response builder + * @param resp jaggery response + * @param code status code + * @param content what ever the content to be sent as response + * @return resp jaggery response + */ + function processResponse(resp, code, content){ + resp.status = code; + resp.contentType = 'application/json'; + resp.content = content; + return resp; + + }; + + /** + * + * @param resp + * @param code + * @param data + * @return The http response + */ + response.buildSuccessResponseForRxt= function(resp, code, data){ + resp.contentType = 'application/json'; + resp.status = code; + resp.content = data; + return resp; + }; + +}(response)) \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/time/time.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/time/time.js new file mode 100644 index 0000000000..142d4fa73c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/time/time.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 time = {}; +(function(time) { + time.getCurrentTime = function(dateLength) { + var dateLength=dateLength||20; + var now = new String(new Date().valueOf()); + var length = now.length; + var prefix = dateLength; + var onsetVal = ''; + if (length != prefix) { + var onset = prefix - length; + for (var i = 0; i < onset; i++) { + onsetVal += '0'; + } + } + return onsetVal + now; + }; +}(time)); \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/url/url.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/url/url.js new file mode 100644 index 0000000000..5f8154607a --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/url/url.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 url = {}; +(function() { + var log=new Log('utils-url'); + url.popServerDetails = function(obj) { + var process = require('process'); + var localIP = process.getProperty('server.host'); + var httpPort = process.getProperty('http.port'); + var httpsPort = process.getProperty('https.port'); + var value = ''; + var carbonLocalIP = process.getProperty('carbon.local.ip'); + + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + value = obj[key]; + if ((typeof value === 'string') && value.indexOf('%https.host%') > -1) { + value=value.replace('%https.host%', 'https://' + localIP + ':' + httpsPort); + } else if ((typeof value === 'string') && value.indexOf('%http.host%') > -1) { + value=value.replace('%http.host%', 'http://' + localIP + ':' + httpPort); + } else if ((typeof value === 'string') && value.indexOf('%https.carbon.local.ip%') > -1) { + value=value.replace('%https.carbon.local.ip%', 'https://' + carbonLocalIP + ':' + httpsPort); + } else if ((typeof value === 'string') && value.indexOf('%http.carbon.local.ip%') > -1) { + value=value.replace('%http.carbon.local.ip%', 'http://' + carbonLocalIP + ':' + httpPort); + } + obj[key] = value; + } + } + return obj; + }; +}(url)); \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/xml/xml.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/xml/xml.js new file mode 100644 index 0000000000..7caefe9d07 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggery-modules/utils/scripts/xml/xml.js @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 xml = {}; + +(function () { + + var log=new Log('util.xml') + + /* + The method is used to create a JSON object using + an xml object. + @xmlElement: An xml element object to be processed + @return: A pseudo object containing the properties of the + xml element. + */ + var createJSONObject = function (xmlElement) { + + var pseudo = {}; + + //Extract all attributes + var attributes = xmlElement.@*; + + //Fill the pseudo object with the attributes of the element + for (var attributeKey in attributes) { + var attribute = attributes[attributeKey]; + pseudo[attribute.localName()] = attribute.toString(); + } + + return pseudo; + }; + + /* + The function converts an E4X Xml object to a JSON object + This function has been adapted from the work of Oleg Podsechin available at + https://gist.github.com/olegp/642667 + It uses a slightly modified version of his algorithm , therefore + all credit should be attributed to Oleg Podsechin. + IMPORTANT: + 1. It does not create a 1..1 mapping due to the differences + between Xml and JSON.It is IMPORTANT that you verify the structure + of the object generated before using it. + 2. The input xml object must not contain the xml header information + This is a known bug 336551 (Mozilla Developer Network) + Source: https://developer.mozilla.org/en/docs/E4X + Please remove the header prior to sending the xml object for processing. + @root: A starting element in an E4X Xml object + @return: A JSON object mirroring the provided Xml object + */ + var recursiveConvertE4XtoJSON = function (root) { + + log.debug('Root: ' + root.localName()); + + //Obtain child nodes + var children = root.*; + + //The number of children + var numChildren = children.length(); + + //No children + if (numChildren == 0) { + + //Extract contents + return createJSONObject(root); + } + else { + + //Create an empty object + var rootObject = createJSONObject(root); + + //Could be multiple children + for (var childElementKey in children) { + + var child = children[childElementKey]; + + log.debug('Examining child: ' + child.localName()); + + //If the child just contains a single value then stop + if (child.localName() == undefined) { + + log.debug('Child is undefined: ' + child.toString()); + + //Change the object to just a key value pair + rootObject[root.localName()] = child.toString(); + return rootObject; + } + + //Make a recursive call to construct the child element + var createdObject = recursiveConvertE4XtoJSON(child); + + log.debug('Converted object: ' + stringify(createdObject)); + + //Check if the root object has the property + if (rootObject.hasOwnProperty(child.localName())) { + + log.debug('key: ' + child.localName() + ' already present.'); + rootObject[child.localName()].push(createdObject); + } + else { + + log.debug('key: ' + child.localName() + ' not present.'); + rootObject[child.localName()] = []; + rootObject[child.localName()].push(createdObject); + + } + } + + log.debug('root: ' + root.localName()); + + return rootObject; + } + }; + + /** + * The function is used to convert an E4X xml to JSON + * @param root + */ + xml.convertE4XtoJSON = function (root) { + return recursiveConvertE4XtoJSON(root); + }; + + +}()); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error400-cloud.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error400-cloud.html new file mode 100644 index 0000000000..3007e7d0be --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error400-cloud.html @@ -0,0 +1,30 @@ + + + + + + + + +
+
+
+ +
+
+

Oops something went wrong

+

400 - Bad request

+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error400.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error400.html new file mode 100644 index 0000000000..3b0349ef37 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error400.html @@ -0,0 +1,33 @@ + + + + + + + Bad request - Error 400 + + + + + + +

Error 400

+

We are unable to understand the request and process it. Please re-check your request.

+ + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error401-cloud.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error401-cloud.html new file mode 100644 index 0000000000..8c195bd0f0 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error401-cloud.html @@ -0,0 +1,30 @@ + + + + + + + + +
+
+
+ +
+
+

Oops something went wrong

+

401 - Unauthorized

+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error401.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error401.html new file mode 100644 index 0000000000..0502d8fda6 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error401.html @@ -0,0 +1,33 @@ + + + + + + + Unauthorized - Error 401 + + + + + + +

Error 401

+

You do not have permission to access this page.Please contact your administrator and request permission.

+ + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error403-cloud.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error403-cloud.html new file mode 100644 index 0000000000..d9d7d00b0c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error403-cloud.html @@ -0,0 +1,30 @@ + + + + + + + + +
+
+
+ +
+
+

Oops something went wrong

+

403 - Forbidden

+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error403.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error403.html new file mode 100644 index 0000000000..b4fbfdaceb --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error403.html @@ -0,0 +1,34 @@ + + + + + + + Forbidden - Error 403 + + + + + + + +

Error 403

+

We cannot process this request.

+ + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error404-cloud.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error404-cloud.html new file mode 100644 index 0000000000..897eeb4821 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error404-cloud.html @@ -0,0 +1,30 @@ + + + + + + + + +
+
+
+ +
+
+

Oops something went wrong

+

404 - Page Not Found

+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error404.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error404.html new file mode 100644 index 0000000000..d2a9cd0365 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error404.html @@ -0,0 +1,33 @@ + + + + + + + Page not found - Error 404 + + + + + + +

Error 404

+

We can't find what you are looking for.

+ + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error405-cloud.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error405-cloud.html new file mode 100644 index 0000000000..bc3d5bdd57 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error405-cloud.html @@ -0,0 +1,30 @@ + + + + + + + + +
+
+
+ +
+
+

Oops something went wrong

+

405 - Method Not Allowed

+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error405.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error405.html new file mode 100644 index 0000000000..dd1b781246 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error405.html @@ -0,0 +1,33 @@ + + + + + + + Method not allowed - Error 405 + + + + + + +

Error 405

+

Method not allowed.

+ + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error500-cloud.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error500-cloud.html new file mode 100644 index 0000000000..1ece4cc29d --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error500-cloud.html @@ -0,0 +1,30 @@ + + + + + + + + +
+
+
+ +
+
+

Oops something went wrong

+

500 - Internal Server Error

+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error500.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error500.html new file mode 100644 index 0000000000..4ec7b17228 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/error-pages/error500.html @@ -0,0 +1,32 @@ + + + + + + + Internal Server Error - Error 500 + + + + + +

Error 500

+

Something went wrong and we're trying to fix it.

+ + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/jaggery.conf b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/jaggery.conf new file mode 100644 index 0000000000..12f3796fec --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/application-mgt/jaggery.conf @@ -0,0 +1,101 @@ +{ + "displayName": "Carbon Application Management App", + "logLevel": "info", + "initScripts": ["/app/modules/init.js"], + "urlMappings": [ + { + "url": "/uuf/login", + "path": "/lib/modules/auth/login.jag" + }, + { + "url": "/uuf/logout", + "path": "/lib/modules/auth/logout.jag" + }, + { + "url": "/uuf/sso/acs", + "path": "/lib/modules/auth/acs.jag" + }, + { + "url": "/public/*", + "path": "/lib/static-files.jag" + }, + { + "url": "/unit/*", + "path": "/lib/units.jag" + }, + { + "url": "/*", + "path": "/lib/pages.jag" + } + ], + "errorPages": { + "500": "/error-pages/error500.html", + "404": "/error-pages/error404.html", + "401": "/error-pages/error401.html", + "405": "/error-pages/error405.html", + "403": "/error-pages/error403.html", + "400": "/error-pages/error400.html" + }, + "filters": [ + { + "name": "ContentTypeBasedCachePreventionFilter", + "class": "org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter", + "params" : [ + {"name" : "patterns", "value" : "text/html\" ,application/json\" ,text/plain"}, + {"name" : "filterAction", "value" : "enforce"}, + {"name" : "httpHeaders", "value" : "Cache-Control: no-store, no-cache, must-revalidate, private"} + ] + }, + { + "name":"HttpHeaderSecurityFilter", + "class":"org.apache.catalina.filters.HttpHeaderSecurityFilter", + "params" : [{"name" : "hstsEnabled", "value" : "false"}] + }, + { + "name" : "CSRFGuard", + "class" : "org.owasp.csrfguard.CsrfGuardFilter" + } + + ], + "filterMappings": [ + { + "name":"HttpHeaderSecurityFilter", + "url":"*" + }, + { + "name" : "CSRFGuard", + "url" : "/*" + }, + { + "name":"ContentTypeBasedCachePreventionFilter", + "url":"*" + } + + ], + "listeners" : [ + { + "class" : "org.owasp.csrfguard.CsrfGuardServletContextListener" + }, + { + "class" : "org.owasp.csrfguard.CsrfGuardHttpSessionListener" + } + ], + "servlets" : [ + { + "name" : "JavaScriptServlet", + "class" : "org.owasp.csrfguard.servlet.JavaScriptServlet" + } + ], + "servletMappings" : [ + { + "name" : "JavaScriptServlet", + "url" : "/csrf.js" + } + ], + "contextParams" : [ + { + "name" : "Owasp.CsrfGuard.Config", + "value" : "repository/conf/security/Owasp.CsrfGuard.dashboard.properties" + } + ] +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/conf/app-conf.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/conf/app-conf.json new file mode 100644 index 0000000000..63bcd3f5f1 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/conf/app-conf.json @@ -0,0 +1,45 @@ +{ + "appName": "UUF Template App", + "cachingEnabled": false, + "debuggingEnabled": false, + "permissionRoot": "/", + "loginPage": "uuf.page.sign-in", + "adminServicesUrl": "https://${server.ip}:${server.https_port}/admin/services/", + "authModule": { + "enabled": true, + "login": { + "onSuccess": { + "script": "/app/modules/login.js", + "page": "uuf.page.home" + }, + "onFail": { + "script": "/app/modules/login.js", + "page": "uuf.page.sign-in" + } + }, + "logout": { + "onSuccess": { + "script": "/app/modules/logout.js", + "page": "uuf.page.sign-in" + }, + "onFail": { + "script": "/app/modules/logout.js", + "page": "uuf.page.home" + } + }, + "sso": { + "enabled": false, + "issuer": "uuf", + "responseSigningEnabled": true, + "keyStoreName": "repository/resources/security/wso2carbon.jks", + "keyStorePassword": "wso2carbon", + "identityProviderAlias": "wso2carbon", + "identityProviderUrl": "https://${server.ip}:${server.https_port}/samlsso", + "intermediatePage": "uuf.page.sso-intermediate" + } + }, + "errorPages": { + "404": "uuf.page.error", + "default": "uuf.page.error" + } +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/conf/uuf-conf.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/conf/uuf-conf.json new file mode 100644 index 0000000000..72d2df1edf --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/conf/uuf-conf.json @@ -0,0 +1,4 @@ +{ + "displayName": "UUF Template App", + "logLevel": "debug" +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/layouts/uuf.layout.default.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/layouts/uuf.layout.default.hbs new file mode 100644 index 0000000000..a67a3e63eb --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/layouts/uuf.layout.default.hbs @@ -0,0 +1,67 @@ +{{!-- +* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. 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. +--}} + + + + + + + + + {{#defineZone "title"}}WSO2 Template{{/defineZone}} + {{defineZone "favicon"}} + {{defineZone "topCss"}} + {{defineZone "topJs"}} + + + +{{defineZone "header"}} + + + + + + + +{{defineZone "sidePanes"}} + + + +
+ {{defineZone "contentTitle"}} +
+
+ {{defineZone "content"}} +
+
+
+ + + +
+
+ {{defineZone "footer"}} +
+
+ + +{{defineZone "bottomJs"}} + + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/layouts/uuf.layout.sign-in.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/layouts/uuf.layout.sign-in.hbs new file mode 100644 index 0000000000..3283927e56 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/layouts/uuf.layout.sign-in.hbs @@ -0,0 +1,56 @@ +{{!-- +* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. 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. +--}} + + + + + + + + + {{#defineZone "title"}}WSO2 Template{{/defineZone}} + {{defineZone "favicon"}} + {{defineZone "topCss"}} + {{defineZone "topJs"}} + + + +{{defineZone "header"}} + + + +
+
+
+ {{defineZone "content"}} +
+
+
+ + + +
+
+ {{defineZone "footer"}} +
+
+ + +{{defineZone "bottomJs"}} + + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.error/error.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.error/error.hbs new file mode 100644 index 0000000000..a4a31d008c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.error/error.hbs @@ -0,0 +1,38 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{#zone "title"}}Error | {{@app.conf.appName}}{{/zone}} + +{{#zone "breadcrumbs"}} +
  • + + + +
  • +{{/zone}} + +{{#zone "content"}} +
    +

    An Error Occurred!

    + +
    +
    HTTP Status : {{@page.params.status}}
    + +

    {{@page.params.message}}

    +
    +
    +{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.error/error.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.error/error.json new file mode 100644 index 0000000000..c60eb52075 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.error/error.json @@ -0,0 +1,6 @@ +{ + "version": "1.0.0", + "uri": "/error/default", + "layout": "uuf.layout.default", + "isAnonymous": true +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/public/js/sign-in-validations.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/public/js/sign-in-validations.js new file mode 100644 index 0000000000..2db2c795f7 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/public/js/sign-in-validations.js @@ -0,0 +1,24 @@ +$(document).ready(function(){ + $("#signInForm").validate({ + rules: { + username: { + required: true, + minlength: 3 + }, + password: { + required: true, + minlength: 3 + } + }, + messages: { + username: { + required: "Please enter a username", + minlength: "Your username must consist of at least 3 characters" + }, + password: { + required: "Please provide a password", + minlength: "Your password must be at least 3 characters long" + } + } + }); +}); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.hbs new file mode 100644 index 0000000000..ba781f71b3 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.hbs @@ -0,0 +1,63 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{#zone "title"}}Sign In | {{@app.conf.appName}}{{/zone}} + +{{~#zone "content"}} +
    +
    +
    +

    + {{#defineZone "signIn-title" scope="protected"}}Sign In to UUF Template App{{/defineZone}} +

    +
    +
    + {{#if message}} +
    + {{message}}! +
    + {{/if}} +
    +
    + +
    +
    + +
    + {{#if referer}} + + {{/if}} +
    + +
    + {{defineZone "signInForm-below" scope="protected"}} +
    +
    +
    +
    +{{/zone}} + +{{! sign-in form validation}} +{{~unit "uuf.unit.lib.form-validation"}} +{{~#zone "bottomJs"}} + {{~js "js/sign-in-validations.js"}} +{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.js new file mode 100644 index 0000000000..939e7c82b0 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.js @@ -0,0 +1,30 @@ +function onRequest(context) { + var authModuleConfigs = context.app.conf["authModule"]; + if (authModuleConfigs && (authModuleConfigs["enabled"].toString() == "true")) { + // Auth module is enabled. + if (context.user) { + // User is already logged in. + response.sendRedirect(context.app.context + "/"); + exit(); + } else { + // User is not logged in. + var ssoConfigs = authModuleConfigs["sso"]; + if (ssoConfigs && (ssoConfigs["enabled"].toString() == "true")) { + // SSO is enabled in Auth module. + var redirectUri = context.app.context + "/uuf/login"; + var queryString = request.getQueryString(); + if (queryString && (queryString.length > 0)) { + redirectUri = redirectUri + "?" + queryString; + } + response.sendRedirect(encodeURI(redirectUri)); + exit(); + } else { + // Generic login process is enabled. + return { + message: request.getParameter("error"), + referer: request.getParameter("referer") + }; + } + } + } +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.json new file mode 100644 index 0000000000..4bafc2dbb9 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.json @@ -0,0 +1,6 @@ +{ + "version": "1.0.0", + "uri": "/signin", + "layout": "uuf.layout.sign-in", + "isAnonymous": true +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-out/sign-out.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-out/sign-out.hbs new file mode 100644 index 0000000000..23e70695fc --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-out/sign-out.hbs @@ -0,0 +1,18 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{! This template won't be rendered. So nothing is here }} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-out/sign-out.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-out/sign-out.js new file mode 100644 index 0000000000..527c977335 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-out/sign-out.js @@ -0,0 +1,16 @@ +function onRequest(context) { + var authModuleConfigs = context.app.conf["authModule"]; + if (authModuleConfigs && (authModuleConfigs["enabled"].toString() == "true")) { + // Auth module is enabled. + if (context.user) { + // User is logged in. + response.sendRedirect(context.app.context + "/uuf/logout"); + exit(); + } else { + // User is already logged out. + response.sendRedirect(context.app.context + "/"); + exit(); + } + } + +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-out/sign-out.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-out/sign-out.json new file mode 100644 index 0000000000..0667f6f06d --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-out/sign-out.json @@ -0,0 +1,5 @@ +{ + "version": "1.0.0", + "uri": "/signout", + "layout": "uuf.layout.sign-in" +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sso-intermediate/sso-intermediate.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sso-intermediate/sso-intermediate.hbs new file mode 100644 index 0000000000..73de91e94d --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sso-intermediate/sso-intermediate.hbs @@ -0,0 +1,45 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{#zone "title"}}Sign In | {{@app.conf.appName}}{{/zone}} + +{{unit "uuf.unit.theme"}} +{{unit "uuf.unit.header.logo"}}{{unit "uuf.unit.header"}} +{{unit "uuf.unit.footer"}} + +{{#zone "content"}} +
    +

    + You are now being redirected to Identity Server. If the redirection fails, please click + on the button below. +

    + +
    +
    + + + + +
    +
    +
    +{{/zone}} + +{{#zone "bottomJs"}} + +{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sso-intermediate/sso-intermediate.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sso-intermediate/sso-intermediate.json new file mode 100644 index 0000000000..e3c6cdde28 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sso-intermediate/sso-intermediate.json @@ -0,0 +1,6 @@ +{ + "version": "1.0.0", + "uri": "//", + "layout": "uuf.layout.sign-in", + "isAnonymous": true +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.alert/alert.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.alert/alert.hbs new file mode 100644 index 0000000000..51a365f77e --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.alert/alert.hbs @@ -0,0 +1,27 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.alert/alert.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.alert/alert.js new file mode 100644 index 0000000000..aa4e1482f4 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.alert/alert.js @@ -0,0 +1,15 @@ +function onRequest(context) { + var type = context.unit.params.type; + switch (type) { + case "success": + return {icon: "ok"}; + case "info": + return {icon: "info"}; + case "warning": + return {icon: "warning"}; + case "danger": + return {icon: "error"}; + default: + return {icon: "ok"}; + } +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.alert/alert.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.alert/alert.json new file mode 100644 index 0000000000..f2f22da9a9 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.alert/alert.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "isAnonymous": true +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/favicon.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/favicon.hbs new file mode 100644 index 0000000000..4e56417553 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/favicon.hbs @@ -0,0 +1,24 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{#zone "favicon"}} + {{#if isCloud}} + + {{else}} + + {{/if}} +{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/favicon.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/favicon.js new file mode 100644 index 0000000000..76da4c18f0 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/favicon.js @@ -0,0 +1,8 @@ +function onRequest(context) { + + var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + var viewModel = {}; + viewModel.isCloud = deviceMgtProps.isCloud; + return viewModel; + +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/favicon.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/favicon.json new file mode 100644 index 0000000000..6e8b1666ca --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/favicon.json @@ -0,0 +1,8 @@ +{ + "version": "1.0.0", + "pushedUris": [ + "/", + "/{+any}" + ], + "isAnonymous": true +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/public/img/cloud-favicon.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/public/img/cloud-favicon.png new file mode 100644 index 0000000000..e9d327e613 Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/public/img/cloud-favicon.png differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/public/img/favicon.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/public/img/favicon.png new file mode 100644 index 0000000000..a1deab3581 Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.favicon/public/img/favicon.png differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.hbs new file mode 100644 index 0000000000..e726ab6dd7 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.hbs @@ -0,0 +1,23 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{#zone "footer"}} +

    + WSO2 | © 2015 + Inc. +

    +{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.json new file mode 100644 index 0000000000..6e8b1666ca --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.json @@ -0,0 +1,8 @@ +{ + "version": "1.0.0", + "pushedUris": [ + "/", + "/{+any}" + ], + "isAnonymous": true +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.logo/logo.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.logo/logo.hbs new file mode 100644 index 0000000000..4ce5f300d4 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.logo/logo.hbs @@ -0,0 +1,27 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{#zone "brand"}} + + +

    + 
 + {{#defineZone "productNameResponsive"}}UUI Tmpl. App{{/defineZone}} +

    +
    +{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.logo/logo.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.logo/logo.json new file mode 100644 index 0000000000..38acf5dc9c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.logo/logo.json @@ -0,0 +1,9 @@ +{ + "version": "1.0.0", + "index": 9100, + "pushedUris": [ + "/", + "/{+any}" + ], + "isAnonymous": true +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.logo/public/img/logo.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.logo/public/img/logo.png new file mode 100644 index 0000000000..8fc1947a6a Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.logo/public/img/logo.png differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.user-menu/user-menu.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.user-menu/user-menu.hbs new file mode 100644 index 0000000000..d14d5dfed6 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.user-menu/user-menu.hbs @@ -0,0 +1,39 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{#zone "userMenu"}} + +{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.user-menu/user-menu.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.user-menu/user-menu.json new file mode 100644 index 0000000000..614b0890bd --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header.user-menu/user-menu.json @@ -0,0 +1,8 @@ +{ + "version": "1.0.0", + "index": 9110, + "pushedUris": [ + "/", + "/{+any}" + ] +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.hbs new file mode 100644 index 0000000000..af3e248189 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.hbs @@ -0,0 +1,32 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{#zone "header"}} +
    +
    +
    + {{defineZone "brand"}} +
    +
    + {{defineZone "cloudMenu"}} +
    +
    + {{defineZone "userMenu"}} +
    +
    +
    +{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.json new file mode 100644 index 0000000000..8a3fe9c7c8 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.json @@ -0,0 +1,9 @@ +{ + "version": "1.0.0", + "index": 9199, + "pushedUris": [ + "/", + "/{+any}" + ], + "isAnonymous": true +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/data-table.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/data-table.hbs new file mode 100644 index 0000000000..e2e188f5a2 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/data-table.hbs @@ -0,0 +1,27 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. 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. +}} +{{#zone "topCss"}} + {{~css "data-tables_1.10.7/extensions/Bootstrap/css/dataTables.bootstrap.css"}} + {{~css "data-tables_1.10.7/extensions/Responsive/css/dataTables.responsive.css"}} +{{/zone}} + +{{~#zone "bottomJs"}} + {{~js "data-tables_1.10.7/media/js/jquery.dataTables.min.js"}} + {{~js "data-tables_1.10.7/extensions/Bootstrap/js/dataTables.bootstrap.js"}} + {{~js "data-tables_1.10.7/extensions/Responsive/js/dataTables.responsive.js"}} +{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/data-table.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/data-table.json new file mode 100644 index 0000000000..f2f22da9a9 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/data-table.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "isAnonymous": true +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/css/dataTables.autoFill.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/css/dataTables.autoFill.css new file mode 100644 index 0000000000..cab59b3a05 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/css/dataTables.autoFill.css @@ -0,0 +1,24 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * AutoFill styles + */ + +div.AutoFill_filler { + display: none; + position: absolute; + height: 14px; + width: 14px; + background: url(../images/filler.png) no-repeat center center; + z-index: 1002; +} + +div.AutoFill_border { + display: none; + position: absolute; + background-color: #0063dc; + z-index: 1001; + + box-shadow: 0px 0px 5px #76b4ff; + -moz-box-shadow: 0px 0px 5px #76b4ff; + -webkit-box-shadow: 0px 0px 5px #76b4ff; +} + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/css/dataTables.autoFill.min.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/css/dataTables.autoFill.min.css new file mode 100644 index 0000000000..b485f2163f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/css/dataTables.autoFill.min.css @@ -0,0 +1 @@ +div.AutoFill_filler{display:none;position:absolute;height:14px;width:14px;background:url(../images/filler.png) no-repeat center center;z-index:1002}div.AutoFill_border{display:none;position:absolute;background-color:#0063dc;z-index:1001;box-shadow:0px 0px 5px #76b4ff;-moz-box-shadow:0px 0px 5px #76b4ff;-webkit-box-shadow:0px 0px 5px #76b4ff} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/images/filler.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/images/filler.png new file mode 100644 index 0000000000..f2af65d8c3 Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/images/filler.png differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/js/dataTables.autoFill.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/js/dataTables.autoFill.js new file mode 100644 index 0000000000..6bbfa35b93 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/AutoFill/js/dataTables.autoFill.js @@ -0,0 +1,855 @@ +/*! AutoFill 1.2.1 + * ©2008-2014 SpryMedia Ltd - datatables.net/license + */ + +/** + * @summary AutoFill + * @description Add Excel like click and drag auto-fill options to DataTables + * @version 1.2.1 + * @file dataTables.autoFill.js + * @author SpryMedia Ltd (www.sprymedia.co.uk) + * @contact www.sprymedia.co.uk/contact + * @copyright Copyright 2010-2014 SpryMedia Ltd. + * + * This source file is free software, available under the following license: + * MIT license - http://datatables.net/license/mit + * + * This source file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. + * + * For details please refer to: http://www.datatables.net + */ + +(function( window, document, undefined ) { + +var factory = function( $, DataTable ) { +"use strict"; + +/** + * AutoFill provides Excel like auto-fill features for a DataTable + * + * @class AutoFill + * @constructor + * @param {object} oTD DataTables settings object + * @param {object} oConfig Configuration object for AutoFill + */ +var AutoFill = function( oDT, oConfig ) +{ + /* Sanity check that we are a new instance */ + if ( ! (this instanceof AutoFill) ) { + throw( "Warning: AutoFill must be initialised with the keyword 'new'" ); + } + + if ( ! $.fn.dataTableExt.fnVersionCheck('1.7.0') ) { + throw( "Warning: AutoFill requires DataTables 1.7 or greater"); + } + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Public class variables + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + this.c = {}; + + /** + * @namespace Settings object which contains customisable information for AutoFill instance + */ + this.s = { + /** + * @namespace Cached information about the little dragging icon (the filler) + */ + "filler": { + "height": 0, + "width": 0 + }, + + /** + * @namespace Cached information about the border display + */ + "border": { + "width": 2 + }, + + /** + * @namespace Store for live information for the current drag + */ + "drag": { + "startX": -1, + "startY": -1, + "startTd": null, + "endTd": null, + "dragging": false + }, + + /** + * @namespace Data cache for information that we need for scrolling the screen when we near + * the edges + */ + "screen": { + "interval": null, + "y": 0, + "height": 0, + "scrollTop": 0 + }, + + /** + * @namespace Data cache for the position of the DataTables scrolling element (when scrolling + * is enabled) + */ + "scroller": { + "top": 0, + "bottom": 0 + }, + + /** + * @namespace Information stored for each column. An array of objects + */ + "columns": [] + }; + + + /** + * @namespace Common and useful DOM elements for the class instance + */ + this.dom = { + "table": null, + "filler": null, + "borderTop": null, + "borderRight": null, + "borderBottom": null, + "borderLeft": null, + "currentTarget": null + }; + + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Public class methods + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /** + * Retreieve the settings object from an instance + * @method fnSettings + * @returns {object} AutoFill settings object + */ + this.fnSettings = function () { + return this.s; + }; + + + /* Constructor logic */ + this._fnInit( oDT, oConfig ); + return this; +}; + + + +AutoFill.prototype = { + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Private methods (they are of course public in JS, but recommended as private) + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /** + * Initialisation + * @method _fnInit + * @param {object} dt DataTables settings object + * @param {object} config Configuration object for AutoFill + * @returns void + */ + "_fnInit": function ( dt, config ) + { + var + that = this, + i, iLen; + + // Use DataTables API to get the settings allowing selectors, instances + // etc to be used, or for backwards compatibility get from the old + // fnSettings method + this.s.dt = DataTable.Api ? + new DataTable.Api( dt ).settings()[0] : + dt.fnSettings(); + this.s.init = config || {}; + this.dom.table = this.s.dt.nTable; + + $.extend( true, this.c, AutoFill.defaults, config ); + + /* Add and configure the columns */ + this._initColumns(); + + /* Auto Fill click and drag icon */ + var filler = $('
    ', { + 'class': 'AutoFill_filler' + } ) + .appendTo( 'body' ); + this.dom.filler = filler[0]; + + // Get the height / width of the click element + this.s.filler.height = filler.height(); + this.s.filler.width = filler.width(); + filler[0].style.display = "none"; + + /* Border display - one div for each side. We can't just use a single + * one with a border, as we want the events to effectively pass through + * the transparent bit of the box + */ + var border; + var appender = document.body; + if ( that.s.dt.oScroll.sY !== "" ) { + that.s.dt.nTable.parentNode.style.position = "relative"; + appender = that.s.dt.nTable.parentNode; + } + + border = $('
    ', { + "class": "AutoFill_border" + } ); + this.dom.borderTop = border.clone().appendTo( appender )[0]; + this.dom.borderRight = border.clone().appendTo( appender )[0]; + this.dom.borderBottom = border.clone().appendTo( appender )[0]; + this.dom.borderLeft = border.clone().appendTo( appender )[0]; + + /* Events */ + filler.on( 'mousedown.DTAF', function (e) { + this.onselectstart = function() { return false; }; + that._fnFillerDragStart.call( that, e ); + return false; + } ); + + $('tbody', this.dom.table).on( + 'mouseover.DTAF mouseout.DTAF', + '>tr>td, >tr>th', + function (e) { + that._fnFillerDisplay.call( that, e ); + } + ); + + $(this.dom.table).on( 'destroy.dt.DTAF', function () { + filler.off( 'mousedown.DTAF' ).remove(); + $('tbody', this.dom.table).off( 'mouseover.DTAF mouseout.DTAF' ); + } ); + }, + + + _initColumns: function ( ) + { + var that = this; + var i, ien; + var dt = this.s.dt; + var config = this.s.init; + + for ( i=0, ien=dt.aoColumns.length ; i offsetEnd.left) { + x1 = offsetEnd.left - border; + x2 = offsetStart.left + $(nStart).outerWidth(); + width = offsetStart.left + $(nStart).outerWidth() - offsetEnd.left + (2*border); + } + + if ( this.s.dt.oScroll.sY !== "" ) + { + /* The border elements are inside the DT scroller - so position relative to that */ + var + offsetScroll = $(this.s.dt.nTable.parentNode).offset(), + scrollTop = $(this.s.dt.nTable.parentNode).scrollTop(), + scrollLeft = $(this.s.dt.nTable.parentNode).scrollLeft(); + + x1 -= offsetScroll.left - scrollLeft; + x2 -= offsetScroll.left - scrollLeft; + y1 -= offsetScroll.top - scrollTop; + y2 -= offsetScroll.top - scrollTop; + } + + /* Top */ + oStyle = this.dom.borderTop.style; + oStyle.top = y1+"px"; + oStyle.left = x1+"px"; + oStyle.height = this.s.border.width+"px"; + oStyle.width = width+"px"; + + /* Bottom */ + oStyle = this.dom.borderBottom.style; + oStyle.top = y2+"px"; + oStyle.left = x1+"px"; + oStyle.height = this.s.border.width+"px"; + oStyle.width = width+"px"; + + /* Left */ + oStyle = this.dom.borderLeft.style; + oStyle.top = y1+"px"; + oStyle.left = x1+"px"; + oStyle.height = height+"px"; + oStyle.width = this.s.border.width+"px"; + + /* Right */ + oStyle = this.dom.borderRight.style; + oStyle.top = y1+"px"; + oStyle.left = x2+"px"; + oStyle.height = height+"px"; + oStyle.width = this.s.border.width+"px"; + }, + + + /** + * Mouse down event handler for starting a drag + * @method _fnFillerDragStart + * @param {Object} e Event object + * @returns void + */ + "_fnFillerDragStart": function (e) + { + var that = this; + var startingTd = this.dom.currentTarget; + + this.s.drag.dragging = true; + + that.dom.borderTop.style.display = "block"; + that.dom.borderRight.style.display = "block"; + that.dom.borderBottom.style.display = "block"; + that.dom.borderLeft.style.display = "block"; + + var coords = this._fnTargetCoords( startingTd ); + this.s.drag.startX = coords.x; + this.s.drag.startY = coords.y; + + this.s.drag.startTd = startingTd; + this.s.drag.endTd = startingTd; + + this._fnUpdateBorder( startingTd, startingTd ); + + $(document).bind('mousemove.AutoFill', function (e) { + that._fnFillerDragMove.call( that, e ); + } ); + + $(document).bind('mouseup.AutoFill', function (e) { + that._fnFillerFinish.call( that, e ); + } ); + + /* Scrolling information cache */ + this.s.screen.y = e.pageY; + this.s.screen.height = $(window).height(); + this.s.screen.scrollTop = $(document).scrollTop(); + + if ( this.s.dt.oScroll.sY !== "" ) + { + this.s.scroller.top = $(this.s.dt.nTable.parentNode).offset().top; + this.s.scroller.bottom = this.s.scroller.top + $(this.s.dt.nTable.parentNode).height(); + } + + /* Scrolling handler - we set an interval (which is cancelled on mouse up) which will fire + * regularly and see if we need to do any scrolling + */ + this.s.screen.interval = setInterval( function () { + var iScrollTop = $(document).scrollTop(); + var iScrollDelta = iScrollTop - that.s.screen.scrollTop; + that.s.screen.y += iScrollDelta; + + if ( that.s.screen.height - that.s.screen.y + iScrollTop < 50 ) + { + $('html, body').animate( { + "scrollTop": iScrollTop + 50 + }, 240, 'linear' ); + } + else if ( that.s.screen.y - iScrollTop < 50 ) + { + $('html, body').animate( { + "scrollTop": iScrollTop - 50 + }, 240, 'linear' ); + } + + if ( that.s.dt.oScroll.sY !== "" ) + { + if ( that.s.screen.y > that.s.scroller.bottom - 50 ) + { + $(that.s.dt.nTable.parentNode).animate( { + "scrollTop": $(that.s.dt.nTable.parentNode).scrollTop() + 50 + }, 240, 'linear' ); + } + else if ( that.s.screen.y < that.s.scroller.top + 50 ) + { + $(that.s.dt.nTable.parentNode).animate( { + "scrollTop": $(that.s.dt.nTable.parentNode).scrollTop() - 50 + }, 240, 'linear' ); + } + } + }, 250 ); + }, + + + /** + * Mouse move event handler for during a move. See if we want to update the display based on the + * new cursor position + * @method _fnFillerDragMove + * @param {Object} e Event object + * @returns void + */ + "_fnFillerDragMove": function (e) + { + if ( e.target && e.target.nodeName.toUpperCase() == "TD" && + e.target != this.s.drag.endTd ) + { + var coords = this._fnTargetCoords( e.target ); + + if ( this.c.mode == "y" && coords.x != this.s.drag.startX ) + { + e.target = $('tbody>tr:eq('+coords.y+')>td:eq('+this.s.drag.startX+')', this.dom.table)[0]; + } + if ( this.c.mode == "x" && coords.y != this.s.drag.startY ) + { + e.target = $('tbody>tr:eq('+this.s.drag.startY+')>td:eq('+coords.x+')', this.dom.table)[0]; + } + + if ( this.c.mode == "either") + { + if(coords.x != this.s.drag.startX ) + { + e.target = $('tbody>tr:eq('+this.s.drag.startY+')>td:eq('+coords.x+')', this.dom.table)[0]; + } + else if ( coords.y != this.s.drag.startY ) { + e.target = $('tbody>tr:eq('+coords.y+')>td:eq('+this.s.drag.startX+')', this.dom.table)[0]; + } + } + + // update coords + if ( this.c.mode !== "both" ) { + coords = this._fnTargetCoords( e.target ); + } + + var drag = this.s.drag; + drag.endTd = e.target; + + if ( coords.y >= this.s.drag.startY ) { + this._fnUpdateBorder( drag.startTd, drag.endTd ); + } + else { + this._fnUpdateBorder( drag.endTd, drag.startTd ); + } + this._fnFillerPosition( e.target ); + } + + /* Update the screen information so we can perform scrolling */ + this.s.screen.y = e.pageY; + this.s.screen.scrollTop = $(document).scrollTop(); + + if ( this.s.dt.oScroll.sY !== "" ) + { + this.s.scroller.scrollTop = $(this.s.dt.nTable.parentNode).scrollTop(); + this.s.scroller.top = $(this.s.dt.nTable.parentNode).offset().top; + this.s.scroller.bottom = this.s.scroller.top + $(this.s.dt.nTable.parentNode).height(); + } + }, + + + /** + * Mouse release handler - end the drag and take action to update the cells with the needed values + * @method _fnFillerFinish + * @param {Object} e Event object + * @returns void + */ + "_fnFillerFinish": function (e) + { + var that = this, i, iLen, j; + + $(document).unbind('mousemove.AutoFill mouseup.AutoFill'); + + this.dom.borderTop.style.display = "none"; + this.dom.borderRight.style.display = "none"; + this.dom.borderBottom.style.display = "none"; + this.dom.borderLeft.style.display = "none"; + + this.s.drag.dragging = false; + + clearInterval( this.s.screen.interval ); + + var cells = []; + var table = this.dom.table; + var coordsStart = this._fnTargetCoords( this.s.drag.startTd ); + var coordsEnd = this._fnTargetCoords( this.s.drag.endTd ); + var columnIndex = function ( visIdx ) { + return that.s.dt.oApi._fnVisibleToColumnIndex( that.s.dt, visIdx ); + }; + + // xxx - urgh - there must be a way of reducing this... + if ( coordsStart.y <= coordsEnd.y ) { + for ( i=coordsStart.y ; i<=coordsEnd.y ; i++ ) { + if ( coordsStart.x <= coordsEnd.x ) { + for ( j=coordsStart.x ; j<=coordsEnd.x ; j++ ) { + cells.push( { + node: $('tbody>tr:eq('+i+')>td:eq('+j+')', table)[0], + x: j - coordsStart.x, + y: i - coordsStart.y, + colIdx: columnIndex( j ) + } ); + } + } + else { + for ( j=coordsStart.x ; j>=coordsEnd.x ; j-- ) { + cells.push( { + node: $('tbody>tr:eq('+i+')>td:eq('+j+')', table)[0], + x: j - coordsStart.x, + y: i - coordsStart.y, + colIdx: columnIndex( j ) + } ); + } + } + } + } + else { + for ( i=coordsStart.y ; i>=coordsEnd.y ; i-- ) { + if ( coordsStart.x <= coordsEnd.x ) { + for ( j=coordsStart.x ; j<=coordsEnd.x ; j++ ) { + cells.push( { + node: $('tbody>tr:eq('+i+')>td:eq('+j+')', table)[0], + x: j - coordsStart.x, + y: i - coordsStart.y, + colIdx: columnIndex( j ) + } ); + } + } + else { + for ( j=coordsStart.x ; j>=coordsEnd.x ; j-- ) { + cells.push( { + node: $('tbody>tr:eq('+i+')>td:eq('+j+')', table)[0], + x: coordsStart.x - j, + y: coordsStart.y - i, + colIdx: columnIndex( j ) + } ); + } + } + } + } + + // An auto-fill requires 2 or more cells + if ( cells.length <= 1 ) { + return; + } + + var edited = []; + var previous; + + for ( i=0, iLen=cells.length ; i",{"class":"AutoFill_filler"}).appendTo("body");this.dom.filler=e[0];this.s.filler.height=e.height();this.s.filler.width=e.width();e[0].style.display= +"none";var g,f=j.body;""!==a.s.dt.oScroll.sY&&(a.s.dt.nTable.parentNode.style.position="relative",f=a.s.dt.nTable.parentNode);g=c("
    ",{"class":"AutoFill_border"});this.dom.borderTop=g.clone().appendTo(f)[0];this.dom.borderRight=g.clone().appendTo(f)[0];this.dom.borderBottom=g.clone().appendTo(f)[0];this.dom.borderLeft=g.clone().appendTo(f)[0];e.on("mousedown.DTAF",function(b){this.onselectstart=function(){return false};a._fnFillerDragStart.call(a,b);return false});c("tbody",this.dom.table).on("mouseover.DTAF mouseout.DTAF", +">tr>td, >tr>th",function(b){a._fnFillerDisplay.call(a,b)});c(this.dom.table).on("destroy.dt.DTAF",function(){e.off("mousedown.DTAF").remove();c("tbody",this.dom.table).off("mouseover.DTAF mouseout.DTAF")})},_initColumns:function(){var d=this,b,a,e=this.s.dt,g=this.s.init;b=0;for(a=e.aoColumns.length;bg.left&&(f=g.left-a,i=e.left+c(d).outerWidth(),j=e.left+c(d).outerWidth()-g.left+2*a);""!==this.s.dt.oScroll.sY&&(a=c(this.s.dt.nTable.parentNode).offset(),e=c(this.s.dt.nTable.parentNode).scrollTop(), +g=c(this.s.dt.nTable.parentNode).scrollLeft(),f-=a.left-g,i-=a.left-g,n-=a.top-e,h-=a.top-e);a=this.dom.borderTop.style;a.top=n+"px";a.left=f+"px";a.height=this.s.border.width+"px";a.width=j+"px";a=this.dom.borderBottom.style;a.top=h+"px";a.left=f+"px";a.height=this.s.border.width+"px";a.width=j+"px";a=this.dom.borderLeft.style;a.top=n+"px";a.left=f+"px";a.height=k+"px";a.width=this.s.border.width+"px";a=this.dom.borderRight.style;a.top=n+"px";a.left=i+"px";a.height=k+"px";a.width=this.s.border.width+ +"px"},_fnFillerDragStart:function(d){var b=this,a=this.dom.currentTarget;this.s.drag.dragging=!0;b.dom.borderTop.style.display="block";b.dom.borderRight.style.display="block";b.dom.borderBottom.style.display="block";b.dom.borderLeft.style.display="block";var e=this._fnTargetCoords(a);this.s.drag.startX=e.x;this.s.drag.startY=e.y;this.s.drag.startTd=a;this.s.drag.endTd=a;this._fnUpdateBorder(a,a);c(j).bind("mousemove.AutoFill",function(a){b._fnFillerDragMove.call(b,a)});c(j).bind("mouseup.AutoFill", +function(a){b._fnFillerFinish.call(b,a)});this.s.screen.y=d.pageY;this.s.screen.height=c(o).height();this.s.screen.scrollTop=c(j).scrollTop();""!==this.s.dt.oScroll.sY&&(this.s.scroller.top=c(this.s.dt.nTable.parentNode).offset().top,this.s.scroller.bottom=this.s.scroller.top+c(this.s.dt.nTable.parentNode).height());this.s.screen.interval=setInterval(function(){var a=c(j).scrollTop();b.s.screen.y=b.s.screen.y+(a-b.s.screen.scrollTop);b.s.screen.height-b.s.screen.y+a<50?c("html, body").animate({scrollTop:a+ +50},240,"linear"):b.s.screen.y-a<50&&c("html, body").animate({scrollTop:a-50},240,"linear");b.s.dt.oScroll.sY!==""&&(b.s.screen.y>b.s.scroller.bottom-50?c(b.s.dt.nTable.parentNode).animate({scrollTop:c(b.s.dt.nTable.parentNode).scrollTop()+50},240,"linear"):b.s.screen.ytr:eq("+b.y+")>td:eq("+this.s.drag.startX+")",this.dom.table)[0]);"x"==this.c.mode&&b.y!=this.s.drag.startY&&(d.target=c("tbody>tr:eq("+this.s.drag.startY+")>td:eq("+b.x+")",this.dom.table)[0]);"either"==this.c.mode&&(b.x!=this.s.drag.startX?d.target=c("tbody>tr:eq("+this.s.drag.startY+")>td:eq("+b.x+")",this.dom.table)[0]:b.y!=this.s.drag.startY&&(d.target=c("tbody>tr:eq("+b.y+")>td:eq("+this.s.drag.startX+ +")",this.dom.table)[0]));"both"!==this.c.mode&&(b=this._fnTargetCoords(d.target));var a=this.s.drag;a.endTd=d.target;b.y>=this.s.drag.startY?this._fnUpdateBorder(a.startTd,a.endTd):this._fnUpdateBorder(a.endTd,a.startTd);this._fnFillerPosition(d.target)}this.s.screen.y=d.pageY;this.s.screen.scrollTop=c(j).scrollTop();""!==this.s.dt.oScroll.sY&&(this.s.scroller.scrollTop=c(this.s.dt.nTable.parentNode).scrollTop(),this.s.scroller.top=c(this.s.dt.nTable.parentNode).offset().top,this.s.scroller.bottom= +this.s.scroller.top+c(this.s.dt.nTable.parentNode).height())},_fnFillerFinish:function(){var d=this,b,a;c(j).unbind("mousemove.AutoFill mouseup.AutoFill");this.dom.borderTop.style.display="none";this.dom.borderRight.style.display="none";this.dom.borderBottom.style.display="none";this.dom.borderLeft.style.display="none";this.s.drag.dragging=!1;clearInterval(this.s.screen.interval);var e=[],g=this.dom.table,f=this._fnTargetCoords(this.s.drag.startTd),i=this._fnTargetCoords(this.s.drag.endTd),h=function(a){return d.s.dt.oApi._fnVisibleToColumnIndex(d.s.dt, +a)};if(f.y<=i.y)for(b=f.y;b<=i.y;b++)if(f.x<=i.x)for(a=f.x;a<=i.x;a++)e.push({node:c("tbody>tr:eq("+b+")>td:eq("+a+")",g)[0],x:a-f.x,y:b-f.y,colIdx:h(a)});else for(a=f.x;a>=i.x;a--)e.push({node:c("tbody>tr:eq("+b+")>td:eq("+a+")",g)[0],x:a-f.x,y:b-f.y,colIdx:h(a)});else for(b=f.y;b>=i.y;b--)if(f.x<=i.x)for(a=f.x;a<=i.x;a++)e.push({node:c("tbody>tr:eq("+b+")>td:eq("+a+")",g)[0],x:a-f.x,y:b-f.y,colIdx:h(a)});else for(a=f.x;a>=i.x;a--)e.push({node:c("tbody>tr:eq("+b+")>td:eq("+a+")",g)[0],x:f.x-a,y:f.y- +b,colIdx:h(a)});if(!(1>=e.length)){var g=[],m;b=0;for(a=e.length;bg||0>f?-1:1)):a===m?b:a}}};return h};"function"===typeof define&&define.amd? +define(["jquery","datatables"],l):"object"===typeof exports?l(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.AutoFill&&l(jQuery,jQuery.fn.dataTable)})(window,document); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/Bootstrap/css/dataTables.bootstrap.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/Bootstrap/css/dataTables.bootstrap.css new file mode 100644 index 0000000000..2ccacaff89 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/Bootstrap/css/dataTables.bootstrap.css @@ -0,0 +1,372 @@ +div.dataTables_length label { + font-weight: normal; + text-align: left; + white-space: nowrap; +} + +div.dataTables_length select { + width: 75px; + display: inline-block; +} + +div.dataTables_filter { + text-align: right; +} + +div.dataTables_filter label { + font-weight: normal; + white-space: nowrap; + text-align: left; +} + +div.dataTables_filter input { + margin-left: 0.5em; + display: inline-block; + width: auto; +} + +div.dataTables_info { + padding-top: 8px; + white-space: nowrap; +} + +div.dataTables_paginate { + margin: 0; + white-space: nowrap; + text-align: right; +} + +div.dataTables_paginate ul.pagination { + margin: 2px 0; + white-space: nowrap; +} + +@media screen and (max-width: 767px) { + div.dataTables_wrapper > div.row > div, + div.dataTables_length, + div.dataTables_filter, + div.dataTables_info, + div.dataTables_paginate { + text-align: center; + } + + div.DTTT { + margin-bottom: 0.5em; + } +} + + +table.dataTable td, +table.dataTable th { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + + +table.dataTable { + clear: both; + margin-top: 6px !important; + margin-bottom: 6px !important; + max-width: none !important; +} + +table.dataTable thead .sorting, +table.dataTable thead .sorting_asc, +table.dataTable thead .sorting_desc, +table.dataTable thead .sorting_asc_disabled, +table.dataTable thead .sorting_desc_disabled { + cursor: pointer; + position: relative; +} + +table.dataTable thead .sorting:after, +table.dataTable thead .sorting_asc:after, +table.dataTable thead .sorting_desc:after { + position: absolute; + top: 8px; + right: 8px; + display: block; + font-family: 'Glyphicons Halflings'; + opacity: 0.5; +} +table.dataTable thead .sorting:after { + opacity: 0.2; + content: "\e150"; /* sort */ +} +table.dataTable thead .sorting_asc:after { + content: "\e155"; /* sort-by-attributes */ +} +table.dataTable thead .sorting_desc:after { + content: "\e156"; /* sort-by-attributes-alt */ +} +div.dataTables_scrollBody table.dataTable thead .sorting:after, +div.dataTables_scrollBody table.dataTable thead .sorting_asc:after, +div.dataTables_scrollBody table.dataTable thead .sorting_desc:after { + display: none; +} + +table.dataTable thead .sorting_asc_disabled:after, +table.dataTable thead .sorting_desc_disabled:after { + color: #eee; +} + +table.dataTable thead > tr > th { + padding-right: 30px; +} + +table.dataTable th:active { + outline: none; +} + + +/* Condensed */ +table.dataTable.table-condensed thead > tr > th { + padding-right: 20px; +} + +table.dataTable.table-condensed thead .sorting:after, +table.dataTable.table-condensed thead .sorting_asc:after, +table.dataTable.table-condensed thead .sorting_desc:after { + top: 6px; + right: 6px; +} + +/* Scrolling */ +div.dataTables_scrollHead table { + margin-bottom: 0 !important; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +div.dataTables_scrollHead table thead tr:last-child th:first-child, +div.dataTables_scrollHead table thead tr:last-child td:first-child { + border-bottom-left-radius: 0 !important; + border-bottom-right-radius: 0 !important; +} + +div.dataTables_scrollBody table { + border-top: none; + margin-top: 0 !important; + margin-bottom: 0 !important; +} + +div.dataTables_scrollBody tbody tr:first-child th, +div.dataTables_scrollBody tbody tr:first-child td { + border-top: none; +} + +div.dataTables_scrollFoot table { + margin-top: 0 !important; + border-top: none; +} + +/* Frustratingly the border-collapse:collapse used by Bootstrap makes the column + width calculations when using scrolling impossible to align columns. We have + to use separate + */ +table.table-bordered.dataTable { + border-collapse: separate !important; +} +table.table-bordered thead th, +table.table-bordered thead td { + border-left-width: 0; + border-top-width: 0; +} +table.table-bordered tbody th, +table.table-bordered tbody td { + border-left-width: 0; + border-bottom-width: 0; +} +table.table-bordered tfoot th, +table.table-bordered tfoot td { + border-left-width: 0; + border-bottom-width: 0; +} +table.table-bordered th:last-child, +table.table-bordered td:last-child { + border-right-width: 0; +} +div.dataTables_scrollHead table.table-bordered { + border-bottom-width: 0; +} + + + + +/* + * TableTools styles + */ +.table.dataTable tbody tr.active td, +.table.dataTable tbody tr.active th { + background-color: #08C; + color: white; +} + +.table.dataTable tbody tr.active:hover td, +.table.dataTable tbody tr.active:hover th { + background-color: #0075b0 !important; +} + +.table.dataTable tbody tr.active th > a, +.table.dataTable tbody tr.active td > a { + color: white; +} + +.table-striped.dataTable tbody tr.active:nth-child(odd) td, +.table-striped.dataTable tbody tr.active:nth-child(odd) th { + background-color: #017ebc; +} + +table.DTTT_selectable tbody tr { + cursor: pointer; +} + +div.DTTT .btn:hover { + text-decoration: none !important; +} + +ul.DTTT_dropdown.dropdown-menu { + z-index: 2003; +} + +ul.DTTT_dropdown.dropdown-menu a { + color: #333 !important; /* needed only when demo_page.css is included */ +} + +ul.DTTT_dropdown.dropdown-menu li { + position: relative; +} + +ul.DTTT_dropdown.dropdown-menu li:hover a { + background-color: #0088cc; + color: white !important; +} + +div.DTTT_collection_background { + z-index: 2002; +} + +/* TableTools information display */ +div.DTTT_print_info { + position: fixed; + top: 50%; + left: 50%; + width: 400px; + height: 150px; + margin-left: -200px; + margin-top: -75px; + text-align: center; + color: #333; + padding: 10px 30px; + opacity: 0.95; + + background-color: white; + border: 1px solid rgba(0, 0, 0, 0.2); + border-radius: 6px; + + -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.5); + box-shadow: 0 3px 7px rgba(0, 0, 0, 0.5); +} + +div.DTTT_print_info h6 { + font-weight: normal; + font-size: 28px; + line-height: 28px; + margin: 1em; +} + +div.DTTT_print_info p { + font-size: 14px; + line-height: 20px; +} + +div.dataTables_processing { + position: absolute; + top: 50%; + left: 50%; + width: 100%; + height: 60px; + margin-left: -50%; + margin-top: -25px; + padding-top: 20px; + padding-bottom: 20px; + text-align: center; + font-size: 1.2em; + background-color: white; + background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255,255,255,0)), color-stop(25%, rgba(255,255,255,0.9)), color-stop(75%, rgba(255,255,255,0.9)), color-stop(100%, rgba(255,255,255,0))); + background: -webkit-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); + background: -moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); + background: -ms-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); + background: -o-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); + background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); +} + + + +/* + * FixedColumns styles + */ +div.DTFC_LeftHeadWrapper table, +div.DTFC_LeftFootWrapper table, +div.DTFC_RightHeadWrapper table, +div.DTFC_RightFootWrapper table, +table.DTFC_Cloned tr.even { + background-color: white; + margin-bottom: 0; +} + +div.DTFC_RightHeadWrapper table , +div.DTFC_LeftHeadWrapper table { + border-bottom: none !important; + margin-bottom: 0 !important; + border-top-right-radius: 0 !important; + border-bottom-left-radius: 0 !important; + border-bottom-right-radius: 0 !important; +} + +div.DTFC_RightHeadWrapper table thead tr:last-child th:first-child, +div.DTFC_RightHeadWrapper table thead tr:last-child td:first-child, +div.DTFC_LeftHeadWrapper table thead tr:last-child th:first-child, +div.DTFC_LeftHeadWrapper table thead tr:last-child td:first-child { + border-bottom-left-radius: 0 !important; + border-bottom-right-radius: 0 !important; +} + +div.DTFC_RightBodyWrapper table, +div.DTFC_LeftBodyWrapper table { + border-top: none; + margin: 0 !important; +} + +div.DTFC_RightBodyWrapper tbody tr:first-child th, +div.DTFC_RightBodyWrapper tbody tr:first-child td, +div.DTFC_LeftBodyWrapper tbody tr:first-child th, +div.DTFC_LeftBodyWrapper tbody tr:first-child td { + border-top: none; +} + +div.DTFC_RightFootWrapper table, +div.DTFC_LeftFootWrapper table { + border-top: none; + margin-top: 0 !important; +} + + +div.DTFC_LeftBodyWrapper table.dataTable thead .sorting:after, +div.DTFC_LeftBodyWrapper table.dataTable thead .sorting_asc:after, +div.DTFC_LeftBodyWrapper table.dataTable thead .sorting_desc:after, +div.DTFC_RightBodyWrapper table.dataTable thead .sorting:after, +div.DTFC_RightBodyWrapper table.dataTable thead .sorting_asc:after, +div.DTFC_RightBodyWrapper table.dataTable thead .sorting_desc:after { + display: none; +} + + +/* + * FixedHeader styles + */ +div.FixedHeader_Cloned table { + margin: 0 !important +} + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/Bootstrap/js/dataTables.bootstrap.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/Bootstrap/js/dataTables.bootstrap.js new file mode 100644 index 0000000000..dcc561fcfd --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/Bootstrap/js/dataTables.bootstrap.js @@ -0,0 +1,206 @@ +/*! DataTables Bootstrap 3 integration + * ©2011-2014 SpryMedia Ltd - datatables.net/license + */ + +/** + * DataTables integration for Bootstrap 3. This requires Bootstrap 3 and + * DataTables 1.10 or newer. + * + * This file sets the defaults and adds options to DataTables to style its + * controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap + * for further information. + */ +(function(window, document, undefined){ + +var factory = function( $, DataTable ) { +"use strict"; + + +/* Set the defaults for DataTables initialisation */ +$.extend( true, DataTable.defaults, { + dom: + "<'row'<'col-sm-6'l><'col-sm-6'f>>" + + "<'row'<'col-sm-12'tr>>" + + "<'row'<'col-sm-5'i><'col-sm-7'p>>", + renderer: 'bootstrap' +} ); + + +/* Default class modification */ +$.extend( DataTable.ext.classes, { + sWrapper: "dataTables_wrapper form-inline dt-bootstrap", + sFilterInput: "form-control input-sm", + sLengthSelect: "form-control input-sm" +} ); + + +/* Bootstrap paging button renderer */ +DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) { + var api = new DataTable.Api( settings ); + var classes = settings.oClasses; + var lang = settings.oLanguage.oPaginate; + var btnDisplay, btnClass, counter=0; + + var attach = function( container, buttons ) { + var i, ien, node, button; + var clickHandler = function ( e ) { + e.preventDefault(); + if ( !$(e.currentTarget).hasClass('disabled') ) { + api.page( e.data.action ).draw( false ); + } + }; + + for ( i=0, ien=buttons.length ; i 0 ? + '' : ' disabled'); + break; + + case 'previous': + btnDisplay = lang.sPrevious; + btnClass = button + (page > 0 ? + '' : ' disabled'); + break; + + case 'next': + btnDisplay = lang.sNext; + btnClass = button + (page < pages-1 ? + '' : ' disabled'); + break; + + case 'last': + btnDisplay = lang.sLast; + btnClass = button + (page < pages-1 ? + '' : ' disabled'); + break; + + default: + btnDisplay = button + 1; + btnClass = page === button ? + 'active' : ''; + break; + } + + if ( btnDisplay ) { + node = $('
  • ', { + 'class': classes.sPageButton+' '+btnClass, + 'id': idx === 0 && typeof button === 'string' ? + settings.sTableId +'_'+ button : + null + } ) + .append( $('', { + 'href': '#', + 'aria-controls': settings.sTableId, + 'data-dt-idx': counter, + 'tabindex': settings.iTabIndex + } ) + .html( btnDisplay ) + ) + .appendTo( container ); + + settings.oApi._fnBindAction( + node, {action: button}, clickHandler + ); + + counter++; + } + } + } + }; + + // IE9 throws an 'unknown error' if document.activeElement is used + // inside an iframe or frame. + var activeEl; + + try { + // Because this approach is destroying and recreating the paging + // elements, focus is lost on the select button which is bad for + // accessibility. So we want to restore focus once the draw has + // completed + activeEl = $(document.activeElement).data('dt-idx'); + } + catch (e) {} + + attach( + $(host).empty().html('
      ').children('ul'), + buttons + ); + + if ( activeEl ) { + $(host).find( '[data-dt-idx='+activeEl+']' ).focus(); + } +}; + + +/* + * TableTools Bootstrap compatibility + * Required TableTools 2.1+ + */ +if ( DataTable.TableTools ) { + // Set the classes that TableTools uses to something suitable for Bootstrap + $.extend( true, DataTable.TableTools.classes, { + "container": "DTTT btn-group", + "buttons": { + "normal": "btn btn-default", + "disabled": "disabled" + }, + "collection": { + "container": "DTTT_dropdown dropdown-menu", + "buttons": { + "normal": "", + "disabled": "disabled" + } + }, + "print": { + "info": "DTTT_print_info" + }, + "select": { + "row": "active" + } + } ); + + // Have the collection use a bootstrap compatible drop down + $.extend( true, DataTable.TableTools.DEFAULTS.oTags, { + "collection": { + "container": "ul", + "button": "li", + "liner": "a" + } + } ); +} + +}; // /factory + + +// Define as an AMD module if possible +if ( typeof define === 'function' && define.amd ) { + define( ['jquery', 'datatables'], factory ); +} +else if ( typeof exports === 'object' ) { + // Node/CommonJS + factory( require('jquery'), require('datatables') ); +} +else if ( jQuery ) { + // Otherwise simply initialise as normal, stopping multiple evaluation + factory( jQuery, jQuery.fn.dataTable ); +} + + +})(window, document); + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/css/dataTables.colReorder.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/css/dataTables.colReorder.css new file mode 100644 index 0000000000..bdd6aa0b9a --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/css/dataTables.colReorder.css @@ -0,0 +1,14 @@ +/* + * Namespace DTCR - "DataTables ColReorder" plug-in + */ + +table.DTCR_clonedTable { + background-color: rgba(255, 255, 255, 0.7); + z-index: 202; +} + +div.DTCR_pointer { + width: 1px; + background-color: #0259C4; + z-index: 201; +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/css/dataTables.colReorder.min.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/css/dataTables.colReorder.min.css new file mode 100644 index 0000000000..77b230e013 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/css/dataTables.colReorder.min.css @@ -0,0 +1 @@ +table.DTCR_clonedTable{background-color:rgba(255,255,255,0.7);z-index:202}div.DTCR_pointer{width:1px;background-color:#0259C4;z-index:201} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/images/insert.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/images/insert.png new file mode 100644 index 0000000000..15d5522da6 Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/images/insert.png differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/js/dataTables.colReorder.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/js/dataTables.colReorder.js new file mode 100644 index 0000000000..c3b2f1e2ad --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.lib.data-table/public/data-tables_1.10.7/extensions/ColReorder/js/dataTables.colReorder.js @@ -0,0 +1,1372 @@ +/*! ColReorder 1.1.3 + * ©2010-2014 SpryMedia Ltd - datatables.net/license + */ + +/** + * @summary ColReorder + * @description Provide the ability to reorder columns in a DataTable + * @version 1.1.3 + * @file dataTables.colReorder.js + * @author SpryMedia Ltd (www.sprymedia.co.uk) + * @contact www.sprymedia.co.uk/contact + * @copyright Copyright 2010-2014 SpryMedia Ltd. + * + * This source file is free software, available under the following license: + * MIT license - http://datatables.net/license/mit + * + * This source file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. + * + * For details please refer to: http://www.datatables.net + */ + +(function(window, document, undefined) { + + +/** + * Switch the key value pairing of an index array to be value key (i.e. the old value is now the + * key). For example consider [ 2, 0, 1 ] this would be returned as [ 1, 2, 0 ]. + * @method fnInvertKeyValues + * @param array aIn Array to switch around + * @returns array + */ +function fnInvertKeyValues( aIn ) +{ + var aRet=[]; + for ( var i=0, iLen=aIn.length ; i= iCols ) + { + this.oApi._fnLog( oSettings, 1, "ColReorder 'from' index is out of bounds: "+iFrom ); + return; + } + + if ( iTo < 0 || iTo >= iCols ) + { + this.oApi._fnLog( oSettings, 1, "ColReorder 'to' index is out of bounds: "+iTo ); + return; + } + + /* + * Calculate the new column array index, so we have a mapping between the old and new + */ + var aiMapping = []; + for ( i=0, iLen=iCols ; i this.s.fixed-1 && i < iLen - this.s.fixedRight ) + { + this._fnMouseListener( i, this.s.dt.aoColumns[i].nTh ); + } + + /* Mark the original column order for later reference */ + this.s.dt.aoColumns[i]._ColReorder_iOrigCol = i; + } + + /* State saving */ + this.s.dt.oApi._fnCallbackReg( this.s.dt, 'aoStateSaveParams', function (oS, oData) { + that._fnStateSave.call( that, oData ); + }, "ColReorder_State" ); + + /* An initial column order has been specified */ + var aiOrder = null; + if ( this.s.init.aiOrder ) + { + aiOrder = this.s.init.aiOrder.slice(); + } + + /* State loading, overrides the column order given */ + if ( this.s.dt.oLoadedState && typeof this.s.dt.oLoadedState.ColReorder != 'undefined' && + this.s.dt.oLoadedState.ColReorder.length == this.s.dt.aoColumns.length ) + { + aiOrder = this.s.dt.oLoadedState.ColReorder; + } + + /* If we have an order to apply - do so */ + if ( aiOrder ) + { + /* We might be called during or after the DataTables initialisation. If before, then we need + * to wait until the draw is done, if after, then do what we need to do right away + */ + if ( !that.s.dt._bInitComplete ) + { + var bDone = false; + this.s.dt.aoDrawCallback.push( { + "fn": function () { + if ( !that.s.dt._bInitComplete && !bDone ) + { + bDone = true; + var resort = fnInvertKeyValues( aiOrder ); + that._fnOrderColumns.call( that, resort ); + } + }, + "sName": "ColReorder_Pre" + } ); + } + else + { + var resort = fnInvertKeyValues( aiOrder ); + that._fnOrderColumns.call( that, resort ); + } + } + else { + this._fnSetColumnIndexes(); + } + }, + + + /** + * Set the column order from an array + * @method _fnOrderColumns + * @param array a An array of integers which dictate the column order that should be applied + * @returns void + * @private + */ + "_fnOrderColumns": function ( a ) + { + if ( a.length != this.s.dt.aoColumns.length ) + { + this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+ + "match known number of columns. Skipping." ); + return; + } + + for ( var i=0, iLen=a.length ; i
  • ') + .addClass( 'DTCR_pointer' ) + .css( { + position: 'absolute', + top: scrolling ? + $('div.dataTables_scroll', this.s.dt.nTableWrapper).offset().top : + $(this.s.dt.nTable).offset().top, + height : scrolling ? + $('div.dataTables_scroll', this.s.dt.nTableWrapper).height() : + $(this.s.dt.nTable).height() + } ) + .appendTo( 'body' ); + }, + + /** + * Clean up ColReorder memory references and event handlers + * @method _fnDestroy + * @returns void + * @private + */ + "_fnDestroy": function () + { + var i, iLen; + + for ( i=0, iLen=this.s.dt.aoDrawCallback.length ; ib||b>=n)this.oApi._fnLog(a,1,"ColReorder 'from' index is out of bounds: "+b);else if(0>e||e>=n)this.oApi._fnLog(a,1,"ColReorder 'to' index is out of bounds: "+e);else{f=[];c=0;for(g=n;cthis.s.fixed-1&&eMath.pow(Math.pow(a.pageX-this.s.mouse.startX,2)+Math.pow(a.pageY-this.s.mouse.startY,2),0.5))return;this._fnCreateDragNode()}this.dom.drag.css({left:a.pageX-this.s.mouse.offsetX,top:a.pageY-this.s.mouse.offsetY});for(var b=!1,e=this.s.mouse.toIndex,d=1,c=this.s.aoTargets.length;d
    ").addClass("DTCR_pointer").css({position:"absolute",top:a?d("div.dataTables_scroll",this.s.dt.nTableWrapper).offset().top:d(this.s.dt.nTable).offset().top,height:a?d("div.dataTables_scroll",this.s.dt.nTableWrapper).height(): +d(this.s.dt.nTable).height()}).appendTo("body")},_fnDestroy:function(){var a,b;a=0;for(b=this.s.dt.aoDrawCallback.length;a
    ')[0], +g=c.childNodes[0],f=c.childNodes[1];this.dom.grid.dt.parentNode.insertBefore(c,this.dom.grid.dt);c.appendChild(this.dom.grid.dt);this.dom.grid.wrapper=c;0b.clientWidth&&(c.x=!0);a.offsetHeight>b.clientHeight&&(c.y=!0);return c},_fnDraw:function(a){this._fnGridLayout();this._fnCloneLeft(a);this._fnCloneRight(a);null!==this.s.fnDrawCallback&&this.s.fnDrawCallback.call(this,this.dom.clone.left,this.dom.clone.right);d(this).trigger("draw.dtfc",{leftClone:this.dom.clone.left,rightClone:this.dom.clone.right})},_fnCloneRight:function(a){if(!(0>= +this.s.iRightColumns)){var b,c=[];for(b=this.s.iTableColumns-this.s.iRightColumns;b=this.s.iLeftColumns)){var b,c=[];for(b=0;bthead",a.header);k.empty();e=0;for(h=n.length;ethead",a.header)[0]);e=0;for(h=n.length;etbody>tr",f.dom.body).css("height","auto");null!==a.body&&(a.body.parentNode.removeChild(a.body),a.body=null);a.body=d(this.dom.body).clone(!0)[0];a.body.className+=" DTFC_Cloned";a.body.style.paddingBottom=l.oScroll.iBarWidth+"px";a.body.style.marginBottom=2*l.oScroll.iBarWidth+"px";null!==a.body.getAttribute("id")&&a.body.removeAttribute("id");d(">thead>tr",a.body).empty();d(">tfoot", +a.body).remove();var p=d("tbody",a.body)[0];d(p).empty();if(0thead>tr",a.body)[0];for(o=0;otbody>tr",f.dom.body).each(function(a){var b=this.cloneNode(false);b.removeAttribute("id");a=f.s.dt.aoData[f.s.dt.oFeatures.bServerSide===false?f.s.dt.aiDisplay[f.s.dt._iDisplayStart+ +a]:a].anCells||d(this).children("td, th");for(o=0;o0){m=d(a[j]).clone(true,true)[0];b.appendChild(m)}}p.appendChild(b)})}else d(">tbody>tr",f.dom.body).each(function(){m=this.cloneNode(true);m.className=m.className+" DTFC_NoData";d("td",m).html("");p.appendChild(m)});a.body.style.width="100%";a.body.style.margin="0";a.body.style.padding="0";l.oScroller!==t&&(h=l.oScroller.dom.force,b.forcer?b.forcer.style.height=h.style.height:(b.forcer=h.cloneNode(!0),b.liner.appendChild(b.forcer))); +b.liner.appendChild(a.body);this._fnEqualiseHeights("tbody",f.dom.body,a.body);if(null!==l.nTFoot){if(g){null!==a.footer&&a.footer.parentNode.removeChild(a.footer);a.footer=d(this.dom.footer).clone(!0,!0)[0];a.footer.className+=" DTFC_Cloned";a.footer.style.width="100%";b.foot.appendChild(a.footer);n=this._fnCopyLayout(l.aoFooter,c);b=d(">tfoot",a.footer);b.empty();e=0;for(h=n.length;etfoot",a.footer)[0]);e=0;for(h=n.length;ethead",a.header)[0]);d(b).each(function(a){j=c[a];this.style.width=f.s.aiInnerWidths[j]+"px"});null!==f.s.dt.nTFoot&&(b=l.oApi._fnGetUniqueThs(l,d(">tfoot",a.footer)[0]),d(b).each(function(a){j=c[a];this.style.width=f.s.aiInnerWidths[j]+"px"}))},_fnGetTrNodes:function(a){for(var b= +[],c=0,d=a.childNodes.length;c"+a+">tr:eq(0)",b).children(":first");a.outerHeight();a.height();for(var e=this._fnGetTrNodes(e),b=this._fnGetTrNodes(c),h=[],c=0,a=b.length;cg?f:g,"semiauto"==this.s.sHeightMatch&& +(e[c]._DTTC_iHeight=g),h.push(g);c=0;for(a=b.length;ctfoot', s.nTable).length > 0) ? true : false; + + /* Add the 'sides' that are fixed */ + if ( s.oSides.top ) + { + s.aoCache.push( that._fnCloneTable( "fixedHeader", "FixedHeader_Header", that._fnCloneThead ) ); + } + if ( s.oSides.bottom ) + { + s.aoCache.push( that._fnCloneTable( "fixedFooter", "FixedHeader_Footer", that._fnCloneTfoot ) ); + } + if ( s.oSides.left ) + { + s.aoCache.push( that._fnCloneTable( "fixedLeft", "FixedHeader_Left", that._fnCloneTLeft, s.oSides.left ) ); + } + if ( s.oSides.right ) + { + s.aoCache.push( that._fnCloneTable( "fixedRight", "FixedHeader_Right", that._fnCloneTRight, s.oSides.right ) ); + } + + /* Event listeners for window movement */ + FixedHeader.afnScroll.push( function () { + that._fnUpdatePositions.call(that); + } ); + + $(window).resize( function () { + FixedHeader.fnMeasure(); + that._fnUpdateClones.call(that); + that._fnUpdatePositions.call(that); + } ); + + $(s.nTable) + .on('column-reorder.dt', function () { + FixedHeader.fnMeasure(); + that._fnUpdateClones( true ); + that._fnUpdatePositions(); + } ) + .on('column-visibility.dt', function () { + FixedHeader.fnMeasure(); + that._fnUpdateClones( true ); + that._fnUpdatePositions(); + } ); + + /* Get things right to start with */ + FixedHeader.fnMeasure(); + that._fnUpdateClones(); + that._fnUpdatePositions(); + + s.bInitComplete = true; + }, + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Support functions + */ + + /* + * Function: fnInitSettings + * Purpose: Take the user's settings and copy them to our local store + * Returns: - + * Inputs: object:s - the local settings object + * object:oInit - the user's settings object + */ + fnInitSettings: function ( s, oInit ) + { + if ( oInit !== undefined ) + { + if ( oInit.top !== undefined ) { + s.oSides.top = oInit.top; + } + if ( oInit.bottom !== undefined ) { + s.oSides.bottom = oInit.bottom; + } + if ( typeof oInit.left == 'boolean' ) { + s.oSides.left = oInit.left ? 1 : 0; + } + else if ( oInit.left !== undefined ) { + s.oSides.left = oInit.left; + } + if ( typeof oInit.right == 'boolean' ) { + s.oSides.right = oInit.right ? 1 : 0; + } + else if ( oInit.right !== undefined ) { + s.oSides.right = oInit.right; + } + + if ( oInit.zTop !== undefined ) { + s.oZIndexes.top = oInit.zTop; + } + if ( oInit.zBottom !== undefined ) { + s.oZIndexes.bottom = oInit.zBottom; + } + if ( oInit.zLeft !== undefined ) { + s.oZIndexes.left = oInit.zLeft; + } + if ( oInit.zRight !== undefined ) { + s.oZIndexes.right = oInit.zRight; + } + + if ( oInit.offsetTop !== undefined ) { + s.oOffset.top = oInit.offsetTop; + } + if ( oInit.alwaysCloneTop !== undefined ) { + s.oCloneOnDraw.top = oInit.alwaysCloneTop; + } + if ( oInit.alwaysCloneBottom !== undefined ) { + s.oCloneOnDraw.bottom = oInit.alwaysCloneBottom; + } + if ( oInit.alwaysCloneLeft !== undefined ) { + s.oCloneOnDraw.left = oInit.alwaysCloneLeft; + } + if ( oInit.alwaysCloneRight !== undefined ) { + s.oCloneOnDraw.right = oInit.alwaysCloneRight; + } + } + }, + + /* + * Function: _fnCloneTable + * Purpose: Clone the table node and do basic initialisation + * Returns: - + * Inputs: - + */ + _fnCloneTable: function ( sType, sClass, fnClone, iCells ) + { + var s = this.fnGetSettings(); + var nCTable; + + /* We know that the table _MUST_ has a DIV wrapped around it, because this is simply how + * DataTables works. Therefore, we can set this to be relatively position (if it is not + * alreadu absolute, and use this as the base point for the cloned header + */ + if ( $(s.nTable.parentNode).css('position') != "absolute" ) + { + s.nTable.parentNode.style.position = "relative"; + } + + /* Just a shallow clone will do - we only want the table node */ + nCTable = s.nTable.cloneNode( false ); + nCTable.removeAttribute( 'id' ); + + var nDiv = document.createElement( 'div' ); + nDiv.style.position = "absolute"; + nDiv.style.top = "0px"; + nDiv.style.left = "0px"; + nDiv.className += " FixedHeader_Cloned "+sType+" "+sClass; + + /* Set the zIndexes */ + if ( sType == "fixedHeader" ) + { + nDiv.style.zIndex = s.oZIndexes.top; + } + if ( sType == "fixedFooter" ) + { + nDiv.style.zIndex = s.oZIndexes.bottom; + } + if ( sType == "fixedLeft" ) + { + nDiv.style.zIndex = s.oZIndexes.left; + } + else if ( sType == "fixedRight" ) + { + nDiv.style.zIndex = s.oZIndexes.right; + } + + /* remove margins since we are going to position it absolutely */ + nCTable.style.margin = "0"; + + /* Insert the newly cloned table into the DOM, on top of the "real" header */ + nDiv.appendChild( nCTable ); + document.body.appendChild( nDiv ); + + return { + "nNode": nCTable, + "nWrapper": nDiv, + "sType": sType, + "sPosition": "", + "sTop": "", + "sLeft": "", + "fnClone": fnClone, + "iCells": iCells + }; + }, + + /* + * Function: _fnMeasure + * Purpose: Get the current positioning of the table in the DOM + * Returns: - + * Inputs: - + */ + _fnMeasure: function () + { + var + s = this.fnGetSettings(), + m = s.oMes, + jqTable = $(s.nTable), + oOffset = jqTable.offset(), + iParentScrollTop = this._fnSumScroll( s.nTable.parentNode, 'scrollTop' ), + iParentScrollLeft = this._fnSumScroll( s.nTable.parentNode, 'scrollLeft' ); + + m.iTableWidth = jqTable.outerWidth(); + m.iTableHeight = jqTable.outerHeight(); + m.iTableLeft = oOffset.left + s.nTable.parentNode.scrollLeft; + m.iTableTop = oOffset.top + iParentScrollTop; + m.iTableRight = m.iTableLeft + m.iTableWidth; + m.iTableRight = FixedHeader.oDoc.iWidth - m.iTableLeft - m.iTableWidth; + m.iTableBottom = FixedHeader.oDoc.iHeight - m.iTableTop - m.iTableHeight; + }, + + /* + * Function: _fnSumScroll + * Purpose: Sum node parameters all the way to the top + * Returns: int: sum + * Inputs: node:n - node to consider + * string:side - scrollTop or scrollLeft + */ + _fnSumScroll: function ( n, side ) + { + var i = n[side]; + while ( n = n.parentNode ) + { + if ( n.nodeName == 'HTML' || n.nodeName == 'BODY' ) + { + break; + } + i = n[side]; + } + return i; + }, + + /* + * Function: _fnUpdatePositions + * Purpose: Loop over the fixed elements for this table and update their positions + * Returns: - + * Inputs: - + */ + _fnUpdatePositions: function () + { + var s = this.fnGetSettings(); + this._fnMeasure(); + + for ( var i=0, iLen=s.aoCache.length ; i oWin.iScrollTop + s.oOffset.top ) + { + /* Above the table */ + this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style ); + this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style ); + this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style ); + } + else if ( oWin.iScrollTop + s.oOffset.top > oMes.iTableTop+iTbodyHeight ) + { + /* At the bottom of the table */ + this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style ); + this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop+iTbodyHeight)+"px", 'top', nTable.style ); + this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style ); + } + else + { + /* In the middle of the table */ + this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style ); + this._fnUpdateCache( oCache, 'sTop', s.oOffset.top+"px", 'top', nTable.style ); + this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft-oWin.iScrollLeft)+"px", 'left', nTable.style ); + } + }, + + /* + * Function: _fnUpdateCache + * Purpose: Check the cache and update cache and value if needed + * Returns: - + * Inputs: object:oCache - local cache object + * string:sCache - cache property + * string:sSet - value to set + * string:sProperty - object property to set + * object:oObj - object to update + */ + _fnUpdateCache: function ( oCache, sCache, sSet, sProperty, oObj ) + { + if ( oCache[sCache] != sSet ) + { + oObj[sProperty] = sSet; + oCache[sCache] = sSet; + } + }, + + + + /** + * Copy the classes of all child nodes from one element to another. This implies + * that the two have identical structure - no error checking is performed to that + * fact. + * @param {element} source Node to copy classes from + * @param {element} dest Node to copy classes too + */ + _fnClassUpdate: function ( source, dest ) + { + var that = this; + + if ( source.nodeName.toUpperCase() === "TR" || source.nodeName.toUpperCase() === "TH" || + source.nodeName.toUpperCase() === "TD" || source.nodeName.toUpperCase() === "SPAN" ) + { + dest.className = source.className; + } + + $(source).children().each( function (i) { + that._fnClassUpdate( $(source).children()[i], $(dest).children()[i] ); + } ); + }, + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Cloning functions + */ + + /* + * Function: _fnCloneThead + * Purpose: Clone the thead element + * Returns: - + * Inputs: object:oCache - the cached values for this fixed element + */ + _fnCloneThead: function ( oCache ) + { + var s = this.fnGetSettings(); + var nTable = oCache.nNode; + + if ( s.bInitComplete && !s.oCloneOnDraw.top ) + { + this._fnClassUpdate( $('thead', s.nTable)[0], $('thead', nTable)[0] ); + return; + } + + /* Set the wrapper width to match that of the cloned table */ + var iDtWidth = $(s.nTable).outerWidth(); + oCache.nWrapper.style.width = iDtWidth+"px"; + nTable.style.width = iDtWidth+"px"; + + /* Remove any children the cloned table has */ + while ( nTable.childNodes.length > 0 ) + { + $('thead th', nTable).unbind( 'click' ); + nTable.removeChild( nTable.childNodes[0] ); + } + + /* Clone the DataTables header */ + var nThead = $('thead', s.nTable).clone(true)[0]; + nTable.appendChild( nThead ); + + /* Copy the widths across - apparently a clone isn't good enough for this */ + var a = []; + var b = []; + + $("thead>tr th", s.nTable).each( function (i) { + a.push( $(this).width() ); + } ); + + $("thead>tr td", s.nTable).each( function (i) { + b.push( $(this).width() ); + } ); + + $("thead>tr th", s.nTable).each( function (i) { + $("thead>tr th:eq("+i+")", nTable).width( a[i] ); + $(this).width( a[i] ); + } ); + + $("thead>tr td", s.nTable).each( function (i) { + $("thead>tr td:eq("+i+")", nTable).width( b[i] ); + $(this).width( b[i] ); + } ); + + // Stop DataTables 1.9 from putting a focus ring on the headers when + // clicked to sort + $('th.sorting, th.sorting_desc, th.sorting_asc', nTable).bind( 'click', function () { + this.blur(); + } ); + }, + + /* + * Function: _fnCloneTfoot + * Purpose: Clone the tfoot element + * Returns: - + * Inputs: object:oCache - the cached values for this fixed element + */ + _fnCloneTfoot: function ( oCache ) + { + var s = this.fnGetSettings(); + var nTable = oCache.nNode; + + /* Set the wrapper width to match that of the cloned table */ + oCache.nWrapper.style.width = $(s.nTable).outerWidth()+"px"; + + /* Remove any children the cloned table has */ + while ( nTable.childNodes.length > 0 ) + { + nTable.removeChild( nTable.childNodes[0] ); + } + + /* Clone the DataTables footer */ + var nTfoot = $('tfoot', s.nTable).clone(true)[0]; + nTable.appendChild( nTfoot ); + + /* Copy the widths across - apparently a clone isn't good enough for this */ + $("tfoot:eq(0)>tr th", s.nTable).each( function (i) { + $("tfoot:eq(0)>tr th:eq("+i+")", nTable).width( $(this).width() ); + } ); + + $("tfoot:eq(0)>tr td", s.nTable).each( function (i) { + $("tfoot:eq(0)>tr td:eq("+i+")", nTable).width( $(this).width() ); + } ); + }, + + /* + * Function: _fnCloneTLeft + * Purpose: Clone the left column(s) + * Returns: - + * Inputs: object:oCache - the cached values for this fixed element + */ + _fnCloneTLeft: function ( oCache ) + { + var s = this.fnGetSettings(); + var nTable = oCache.nNode; + var nBody = $('tbody', s.nTable)[0]; + + /* Remove any children the cloned table has */ + while ( nTable.childNodes.length > 0 ) + { + nTable.removeChild( nTable.childNodes[0] ); + } + + /* Is this the most efficient way to do this - it looks horrible... */ + nTable.appendChild( $("thead", s.nTable).clone(true)[0] ); + nTable.appendChild( $("tbody", s.nTable).clone(true)[0] ); + if ( s.bFooter ) + { + nTable.appendChild( $("tfoot", s.nTable).clone(true)[0] ); + } + + /* Remove unneeded cells */ + var sSelector = 'gt(' + (oCache.iCells - 1) + ')'; + $('thead tr', nTable).each( function (k) { + $('th:' + sSelector, this).remove(); + } ); + + $('tfoot tr', nTable).each( function (k) { + $('th:' + sSelector, this).remove(); + } ); + + $('tbody tr', nTable).each( function (k) { + $('td:' + sSelector, this).remove(); + } ); + + this.fnEqualiseHeights( 'thead', nBody.parentNode, nTable ); + this.fnEqualiseHeights( 'tbody', nBody.parentNode, nTable ); + this.fnEqualiseHeights( 'tfoot', nBody.parentNode, nTable ); + + var iWidth = 0; + for (var i = 0; i < oCache.iCells; i++) { + iWidth += $('thead tr th:eq(' + i + ')', s.nTable).outerWidth(); + } + nTable.style.width = iWidth+"px"; + oCache.nWrapper.style.width = iWidth+"px"; + }, + + /* + * Function: _fnCloneTRight + * Purpose: Clone the right most column(s) + * Returns: - + * Inputs: object:oCache - the cached values for this fixed element + */ + _fnCloneTRight: function ( oCache ) + { + var s = this.fnGetSettings(); + var nBody = $('tbody', s.nTable)[0]; + var nTable = oCache.nNode; + var iCols = $('tbody tr:eq(0) td', s.nTable).length; + + /* Remove any children the cloned table has */ + while ( nTable.childNodes.length > 0 ) + { + nTable.removeChild( nTable.childNodes[0] ); + } + + /* Is this the most efficient way to do this - it looks horrible... */ + nTable.appendChild( $("thead", s.nTable).clone(true)[0] ); + nTable.appendChild( $("tbody", s.nTable).clone(true)[0] ); + if ( s.bFooter ) + { + nTable.appendChild( $("tfoot", s.nTable).clone(true)[0] ); + } + $('thead tr th:lt('+(iCols-oCache.iCells)+')', nTable).remove(); + $('tfoot tr th:lt('+(iCols-oCache.iCells)+')', nTable).remove(); + + /* Remove unneeded cells */ + $('tbody tr', nTable).each( function (k) { + $('td:lt('+(iCols-oCache.iCells)+')', this).remove(); + } ); + + this.fnEqualiseHeights( 'thead', nBody.parentNode, nTable ); + this.fnEqualiseHeights( 'tbody', nBody.parentNode, nTable ); + this.fnEqualiseHeights( 'tfoot', nBody.parentNode, nTable ); + + var iWidth = 0; + for (var i = 0; i < oCache.iCells; i++) { + iWidth += $('thead tr th:eq('+(iCols-1-i)+')', s.nTable).outerWidth(); + } + nTable.style.width = iWidth+"px"; + oCache.nWrapper.style.width = iWidth+"px"; + }, + + + /** + * Equalise the heights of the rows in a given table node in a cross browser way. Note that this + * is more or less lifted as is from FixedColumns + * @method fnEqualiseHeights + * @returns void + * @param {string} parent Node type - thead, tbody or tfoot + * @param {element} original Original node to take the heights from + * @param {element} clone Copy the heights to + * @private + */ + "fnEqualiseHeights": function ( parent, original, clone ) + { + var that = this; + var originals = $(parent +' tr', original); + var height; + + $(parent+' tr', clone).each( function (k) { + height = originals.eq( k ).css('height'); + + // This is nasty :-(. IE has a sub-pixel error even when setting + // the height below (the Firefox fix) which causes the fixed column + // to go out of alignment. Need to add a pixel before the assignment + // Can this be feature detected? Not sure how... + if ( navigator.appName == 'Microsoft Internet Explorer' ) { + height = parseInt( height, 10 ) + 1; + } + + $(this).css( 'height', height ); + + // For Firefox to work, we need to also set the height of the + // original row, to the value that we read from it! Otherwise there + // is a sub-pixel rounding error + originals.eq( k ).css( 'height', height ); + } ); + } +}; + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Static properties and methods + * We use these for speed! This information is common to all instances of FixedHeader, so no + * point if having them calculated and stored for each different instance. + */ + +/* + * Variable: oWin + * Purpose: Store information about the window positioning + * Scope: FixedHeader + */ +FixedHeader.oWin = { + "iScrollTop": 0, + "iScrollRight": 0, + "iScrollBottom": 0, + "iScrollLeft": 0, + "iHeight": 0, + "iWidth": 0 +}; + +/* + * Variable: oDoc + * Purpose: Store information about the document size + * Scope: FixedHeader + */ +FixedHeader.oDoc = { + "iHeight": 0, + "iWidth": 0 +}; + +/* + * Variable: afnScroll + * Purpose: Array of functions that are to be used for the scrolling components + * Scope: FixedHeader + */ +FixedHeader.afnScroll = []; + +/* + * Function: fnMeasure + * Purpose: Update the measurements for the window and document + * Returns: - + * Inputs: - + */ +FixedHeader.fnMeasure = function () +{ + var + jqWin = $(window), + jqDoc = $(document), + oWin = FixedHeader.oWin, + oDoc = FixedHeader.oDoc; + + oDoc.iHeight = jqDoc.height(); + oDoc.iWidth = jqDoc.width(); + + oWin.iHeight = jqWin.height(); + oWin.iWidth = jqWin.width(); + oWin.iScrollTop = jqWin.scrollTop(); + oWin.iScrollLeft = jqWin.scrollLeft(); + oWin.iScrollRight = oDoc.iWidth - oWin.iScrollLeft - oWin.iWidth; + oWin.iScrollBottom = oDoc.iHeight - oWin.iScrollTop - oWin.iHeight; +}; + + +FixedHeader.version = "2.1.2"; + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Global processing + */ + +/* + * Just one 'scroll' event handler in FixedHeader, which calls the required components. This is + * done as an optimisation, to reduce calculation and proagation time + */ +$(window).scroll( function () { + FixedHeader.fnMeasure(); + + for ( var i=0, iLen=FixedHeader.afnScroll.length ; itfoot",c.nTable).length?!0:!1,c.oSides.top&&c.aoCache.push(d._fnCloneTable("fixedHeader","FixedHeader_Header",d._fnCloneThead)),c.oSides.bottom&&c.aoCache.push(d._fnCloneTable("fixedFooter","FixedHeader_Footer",d._fnCloneTfoot)),c.oSides.left&&c.aoCache.push(d._fnCloneTable("fixedLeft","FixedHeader_Left",d._fnCloneTLeft,c.oSides.left)), +c.oSides.right&&c.aoCache.push(d._fnCloneTable("fixedRight","FixedHeader_Right",d._fnCloneTRight,c.oSides.right)),FixedHeader.afnScroll.push(function(){d._fnUpdatePositions.call(d)}),e(j).resize(function(){FixedHeader.fnMeasure();d._fnUpdateClones.call(d);d._fnUpdatePositions.call(d)}),e(c.nTable).on("column-reorder.dt",function(){FixedHeader.fnMeasure();d._fnUpdateClones(!0);d._fnUpdatePositions()}).on("column-visibility.dt",function(){FixedHeader.fnMeasure();d._fnUpdateClones(!0);d._fnUpdatePositions()}), +FixedHeader.fnMeasure(),d._fnUpdateClones(),d._fnUpdatePositions(),c.bInitComplete=!0)},fnInitSettings:function(a,b){if(b!==h&&(b.top!==h&&(a.oSides.top=b.top),b.bottom!==h&&(a.oSides.bottom=b.bottom),"boolean"==typeof b.left?a.oSides.left=b.left?1:0:b.left!==h&&(a.oSides.left=b.left),"boolean"==typeof b.right?a.oSides.right=b.right?1:0:b.right!==h&&(a.oSides.right=b.right),b.zTop!==h&&(a.oZIndexes.top=b.zTop),b.zBottom!==h&&(a.oZIndexes.bottom=b.zBottom),b.zLeft!==h&&(a.oZIndexes.left=b.zLeft),b.zRight!== +h&&(a.oZIndexes.right=b.zRight),b.offsetTop!==h&&(a.oOffset.top=b.offsetTop),b.alwaysCloneTop!==h&&(a.oCloneOnDraw.top=b.alwaysCloneTop),b.alwaysCloneBottom!==h&&(a.oCloneOnDraw.bottom=b.alwaysCloneBottom),b.alwaysCloneLeft!==h&&(a.oCloneOnDraw.left=b.alwaysCloneLeft),b.alwaysCloneRight!==h))a.oCloneOnDraw.right=b.alwaysCloneRight},_fnCloneTable:function(a,b,c,d){var f=this.fnGetSettings(),g;"absolute"!=e(f.nTable.parentNode).css("position")&&(f.nTable.parentNode.style.position="relative");g=f.nTable.cloneNode(!1); +g.removeAttribute("id");var i=k.createElement("div");i.style.position="absolute";i.style.top="0px";i.style.left="0px";i.className+=" FixedHeader_Cloned "+a+" "+b;"fixedHeader"==a&&(i.style.zIndex=f.oZIndexes.top);"fixedFooter"==a&&(i.style.zIndex=f.oZIndexes.bottom);"fixedLeft"==a?i.style.zIndex=f.oZIndexes.left:"fixedRight"==a&&(i.style.zIndex=f.oZIndexes.right);g.style.margin="0";i.appendChild(g);k.body.appendChild(i);return{nNode:g,nWrapper:i,sType:a,sPosition:"",sTop:"",sLeft:"",fnClone:c,iCells:d}}, +_fnMeasure:function(){var a=this.fnGetSettings(),b=a.oMes,c=e(a.nTable),d=c.offset(),f=this._fnSumScroll(a.nTable.parentNode,"scrollTop");this._fnSumScroll(a.nTable.parentNode,"scrollLeft");b.iTableWidth=c.outerWidth();b.iTableHeight=c.outerHeight();b.iTableLeft=d.left+a.nTable.parentNode.scrollLeft;b.iTableTop=d.top+f;b.iTableRight=b.iTableLeft+b.iTableWidth;b.iTableRight=FixedHeader.oDoc.iWidth-b.iTableLeft-b.iTableWidth;b.iTableBottom=FixedHeader.oDoc.iHeight-b.iTableTop-b.iTableHeight},_fnSumScroll:function(a, +b){for(var c=a[b];(a=a.parentNode)&&!("HTML"==a.nodeName||"BODY"==a.nodeName);)c=a[b];return c},_fnUpdatePositions:function(){var a=this.fnGetSettings();this._fnMeasure();for(var b=0,c=a.aoCache.length;bd.iScrollTop+b.oOffset.top?(this._fnUpdateCache(a,"sPosition","absolute","position",e.style),this._fnUpdateCache(a,"sTop",c.iTableTop+"px","top",e.style),this._fnUpdateCache(a,"sLeft",c.iTableLeft+"px","left",e.style)):d.iScrollTop+b.oOffset.top>c.iTableTop+ +g?(this._fnUpdateCache(a,"sPosition","absolute","position",e.style),this._fnUpdateCache(a,"sTop",c.iTableTop+g+"px","top",e.style),this._fnUpdateCache(a,"sLeft",c.iTableLeft+"px","left",e.style)):(this._fnUpdateCache(a,"sPosition","fixed","position",e.style),this._fnUpdateCache(a,"sTop",b.oOffset.top+"px","top",e.style),this._fnUpdateCache(a,"sLeft",c.iTableLeft-d.iScrollLeft+"px","left",e.style))},_fnUpdateCache:function(a,b,c,d,e){a[b]!=c&&(e[d]=c,a[b]=c)},_fnClassUpdate:function(a,b){var c=this; +if("TR"===a.nodeName.toUpperCase()||"TH"===a.nodeName.toUpperCase()||"TD"===a.nodeName.toUpperCase()||"SPAN"===a.nodeName.toUpperCase())b.className=a.className;e(a).children().each(function(d){c._fnClassUpdate(e(a).children()[d],e(b).children()[d])})},_fnCloneThead:function(a){var b=this.fnGetSettings(),c=a.nNode;if(b.bInitComplete&&!b.oCloneOnDraw.top)this._fnClassUpdate(e("thead",b.nTable)[0],e("thead",c)[0]);else{var d=e(b.nTable).outerWidth();a.nWrapper.style.width=d+"px";for(c.style.width=d+ +"px";0tr th",b.nTable).each(function(){f.push(e(this).width())});e("thead>tr td",b.nTable).each(function(){g.push(e(this).width())});e("thead>tr th",b.nTable).each(function(a){e("thead>tr th:eq("+a+")",c).width(f[a]);e(this).width(f[a])});e("thead>tr td",b.nTable).each(function(a){e("thead>tr td:eq("+a+")",c).width(g[a]);e(this).width(g[a])}); +e("th.sorting, th.sorting_desc, th.sorting_asc",c).bind("click",function(){this.blur()})}},_fnCloneTfoot:function(a){var b=this.fnGetSettings(),c=a.nNode;for(a.nWrapper.style.width=e(b.nTable).outerWidth()+"px";0tr th",b.nTable).each(function(a){e("tfoot:eq(0)>tr th:eq("+a+")",c).width(e(this).width())});e("tfoot:eq(0)>tr td",b.nTable).each(function(a){e("tfoot:eq(0)>tr td:eq("+ +a+")",c).width(e(this).width())})},_fnCloneTLeft:function(a){for(var b=this.fnGetSettings(),c=a.nNode,d=e("tbody",b.nTable)[0];0= oSettings.fnDisplayEnd() ) + { + if ( oSettings._iDisplayLength >= 0 ) + { + /* Make sure we are not over running the display array */ + if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() ) + { + oSettings._iDisplayStart += oSettings._iDisplayLength; + } + } + else + { + oSettings._iDisplayStart = 0; + } + _oDatatable.oApi._fnCalculateEnd( oSettings ); + } + + /* Page backwards */ + while ( iRow < oSettings._iDisplayStart ) + { + oSettings._iDisplayStart = oSettings._iDisplayLength>=0 ? + oSettings._iDisplayStart - oSettings._iDisplayLength : + 0; + + if ( oSettings._iDisplayStart < 0 ) + { + oSettings._iDisplayStart = 0; + } + _oDatatable.oApi._fnCalculateEnd( oSettings ); + } + + /* Re-draw the table */ + _oDatatable.oApi._fnDraw( oSettings ); + + /* Restore the key capture */ + _bKeyCapture = bKeyCaptureCache; + } + + /* Cache the information that we are interested in */ + var aNewPos = _fnCoordsFromCell( nTarget ); + _nOldFocus = nTarget; + _iOldX = aNewPos[0]; + _iOldY = aNewPos[1]; + + var iViewportHeight, iViewportWidth, iScrollTop, iScrollLeft, iHeight, iWidth, aiPos; + if ( bAutoScroll ) + { + /* Scroll the viewport such that the new cell is fully visible in the rendered window */ + iViewportHeight = $(window).height(); + iViewportWidth = $(window).width(); + iScrollTop = $(document).scrollTop(); + iScrollLeft = $(document).scrollLeft(); + iHeight = nTarget.offsetHeight; + iWidth = nTarget.offsetWidth; + aiPos = _fnGetPos( nTarget ); + + /* Take account of scrolling in DataTables 1.7 - remove scrolling since that would add to + * the positioning calculation + */ + if ( _oDatatable && typeof oSettings.oScroll != 'undefined' && + (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) + { + aiPos[1] -= $(oSettings.nTable.parentNode).scrollTop(); + aiPos[0] -= $(oSettings.nTable.parentNode).scrollLeft(); + } + + /* Correct viewport positioning for vertical scrolling */ + if ( aiPos[1]+iHeight > iScrollTop+iViewportHeight ) + { + /* Displayed element if off the bottom of the viewport */ + _fnSetScrollTop( aiPos[1]+iHeight - iViewportHeight ); + } + else if ( aiPos[1] < iScrollTop ) + { + /* Displayed element if off the top of the viewport */ + _fnSetScrollTop( aiPos[1] ); + } + + /* Correct viewport positioning for horizontal scrolling */ + if ( aiPos[0]+iWidth > iScrollLeft+iViewportWidth ) + { + /* Displayed element is off the bottom of the viewport */ + _fnSetScrollLeft( aiPos[0]+iWidth - iViewportWidth ); + } + else if ( aiPos[0] < iScrollLeft ) + { + /* Displayed element if off the Left of the viewport */ + _fnSetScrollLeft( aiPos[0] ); + } + } + + /* Take account of scrolling in DataTables 1.7 */ + if ( _oDatatable && typeof oSettings.oScroll != 'undefined' && + (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) + { + var dtScrollBody = oSettings.nTable.parentNode; + iViewportHeight = dtScrollBody.clientHeight; + iViewportWidth = dtScrollBody.clientWidth; + iScrollTop = dtScrollBody.scrollTop; + iScrollLeft = dtScrollBody.scrollLeft; + iHeight = nTarget.offsetHeight; + iWidth = nTarget.offsetWidth; + + /* Correct for vertical scrolling */ + if ( nTarget.offsetTop + iHeight > iViewportHeight+iScrollTop ) + { + dtScrollBody.scrollTop = (nTarget.offsetTop + iHeight) - iViewportHeight; + } + else if ( nTarget.offsetTop < iScrollTop ) + { + dtScrollBody.scrollTop = nTarget.offsetTop; + } + + /* Correct for horizontal scrolling */ + if ( nTarget.offsetLeft + iWidth > iViewportWidth+iScrollLeft ) + { + dtScrollBody.scrollLeft = (nTarget.offsetLeft + iWidth) - iViewportWidth; + } + else if ( nTarget.offsetLeft < iScrollLeft ) + { + dtScrollBody.scrollLeft = nTarget.offsetLeft; + } + } + + /* Focused - so we want to capture the keys */ + _fnCaptureKeys(); + + /* Fire of the focus event if there is one */ + _fnEventFire( "focus", _iOldX, _iOldY ); + } + + + /* + * Function: _fnBlur + * Purpose: Blur focus from the whole table + * Returns: - + * Inputs: - + */ + function _fnBlur() + { + _fnRemoveFocus( _nOldFocus ); + _iOldX = null; + _iOldY = null; + _nOldFocus = null; + _fnReleaseKeys(); + } + + + /* + * Function: _fnRemoveFocus + * Purpose: Remove focus from a cell and fire any blur events which are attached + * Returns: - + * Inputs: node:nTarget - cell of interest + */ + function _fnRemoveFocus( nTarget ) + { + $(nTarget).removeClass( _sFocusClass ); + $(nTarget).parent().removeClass( _sFocusClass ); + _fnEventFire( "blur", _iOldX, _iOldY ); + } + + + /* + * Function: _fnClick + * Purpose: Focus on the element that has been clicked on by the user + * Returns: - + * Inputs: event:e - click event + */ + function _fnClick ( e ) + { + var nTarget = this; + while ( nTarget.nodeName != "TD" ) + { + nTarget = nTarget.parentNode; + } + + _fnSetFocus( nTarget ); + _fnCaptureKeys(); + } + + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Key events + */ + + /* + * Function: _fnKey + * Purpose: Deal with a key events, be it moving the focus or return etc. + * Returns: bool: - allow browser default action + * Inputs: event:e - key event + */ + function _fnKey ( e ) + { + /* If user or system has blocked KeyTable from doing anything, just ignore this event */ + if ( _that.block || !_bKeyCapture ) + { + return true; + } + + /* If a modifier key is pressed (exapct shift), ignore the event */ + if ( e.metaKey || e.altKey || e.ctrlKey ) + { + return true; + } + var + x, y, + iTableWidth = _nBody.getElementsByTagName('tr')[0].getElementsByTagName('td').length, + iTableHeight; + + /* Get table height and width - done here so as to be dynamic (if table is updated) */ + if ( _oDatatable ) + { + /* + * Locate the current node in the DataTable overriding the old positions - the reason for + * is is that there might have been some DataTables interaction between the last focus and + * now + */ + iTableHeight = _oDatatable.aiDisplay.length; + + var aDtPos = _fnFindDtCell( _nOldFocus ); + if ( aDtPos === null ) + { + /* If the table has been updated such that the focused cell can't be seen - do nothing */ + return; + } + _iOldX = aDtPos[ 0 ]; + _iOldY = aDtPos[ 1 ]; + } + else + { + iTableHeight = _nBody.getElementsByTagName('tr').length; + } + + /* Capture shift+tab to match the left arrow key */ + var iKey = (e.keyCode == 9 && e.shiftKey) ? -1 : e.keyCode; + + switch( iKey ) + { + case 13: /* return */ + e.preventDefault(); + e.stopPropagation(); + _fnEventFire( "action", _iOldX, _iOldY ); + return true; + + case 27: /* esc */ + if ( !_fnEventFire( "esc", _iOldX, _iOldY ) ) + { + /* Only lose focus if there isn't an escape handler on the cell */ + _fnBlur(); + return; + } + x = _iOldX; + y = _iOldY; + break; + + case -1: + case 37: /* left arrow */ + if ( _iOldX > 0 ) { + x = _iOldX - 1; + y = _iOldY; + } else if ( _iOldY > 0 ) { + x = iTableWidth-1; + y = _iOldY - 1; + } else { + /* at start of table */ + if ( iKey == -1 && _bForm ) + { + /* If we are in a form, return focus to the 'input' element such that tabbing will + * follow correctly in the browser + */ + _bInputFocused = true; + _nInput.focus(); + + /* This timeout is a little nasty - but IE appears to have some asyhnc behaviour for + * focus + */ + setTimeout( function(){ _bInputFocused = false; }, 0 ); + _bKeyCapture = false; + _fnBlur(); + return true; + } + else + { + return false; + } + } + break; + + case 38: /* up arrow */ + if ( _iOldY > 0 ) { + x = _iOldX; + y = _iOldY - 1; + } else { + return false; + } + break; + + case 36: /* home */ + x = _iOldX; + y = 0; + break; + + case 33: /* page up */ + x = _iOldX; + y = _iOldY - 10; + if (y < 0) { + y = 0; + } + break; + + case 9: /* tab */ + case 39: /* right arrow */ + if ( _iOldX < iTableWidth-1 ) { + x = _iOldX + 1; + y = _iOldY; + } else if ( _iOldY < iTableHeight-1 ) { + x = 0; + y = _iOldY + 1; + } else { + /* at end of table */ + if ( iKey == 9 && _bForm ) + { + /* If we are in a form, return focus to the 'input' element such that tabbing will + * follow correctly in the browser + */ + _bInputFocused = true; + _nInput.focus(); + + /* This timeout is a little nasty - but IE appears to have some asyhnc behaviour for + * focus + */ + setTimeout( function(){ _bInputFocused = false; }, 0 ); + _bKeyCapture = false; + _fnBlur(); + return true; + } + else + { + return false; + } + } + break; + + case 40: /* down arrow */ + if ( _iOldY < iTableHeight-1 ) { + x = _iOldX; + y = _iOldY + 1; + } else { + return false; + } + break; + + case 35: /* end */ + x = _iOldX; + y = iTableHeight-1; + break; + + case 34: /* page down */ + x = _iOldX; + y = _iOldY+10; + if (y > iTableHeight-1) { + y = iTableHeight-1; + } + break; + + default: /* Nothing we are interested in */ + return true; + } + + _fnSetFocus( _fnCellFromCoords(x, y) ); + return false; + } + + + /* + * Function: _fnCaptureKeys + * Purpose: Start capturing key events for this table + * Returns: - + * Inputs: - + */ + function _fnCaptureKeys( ) + { + if ( !_bKeyCapture ) + { + _bKeyCapture = true; + } + } + + + /* + * Function: _fnReleaseKeys + * Purpose: Stop capturing key events for this table + * Returns: - + * Inputs: - + */ + function _fnReleaseKeys( ) + { + _bKeyCapture = false; + } + + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Support functions + */ + + /* + * Function: _fnCellFromCoords + * Purpose: Calulate the target TD cell from x and y coordinates + * Returns: node: - TD target + * Inputs: int:x - x coordinate + * int:y - y coordinate + */ + function _fnCellFromCoords( x, y ) + { + if ( _oDatatable ) + { + if ( typeof _oDatatable.aoData[ _oDatatable.aiDisplay[ y ] ] != 'undefined' ) + { + return _oDatatable.aoData[ _oDatatable.aiDisplay[ y ] ].nTr.getElementsByTagName('td')[x]; + } + else + { + return null; + } + } + else + { + return $('tr:eq('+y+')>td:eq('+x+')', _nBody )[0]; + } + } + + + /* + * Function: _fnCoordsFromCell + * Purpose: Calculate the x and y position in a table from a TD cell + * Returns: array[2] int: [x, y] + * Inputs: node:n - TD cell of interest + * Notes: Not actually interested in this for DataTables since it might go out of date + */ + function _fnCoordsFromCell( n ) + { + if ( _oDatatable ) + { + return [ + $('td', n.parentNode).index(n), + $('tr', n.parentNode.parentNode).index(n.parentNode) + _oDatatable._iDisplayStart + ]; + } + else + { + return [ + $('td', n.parentNode).index(n), + $('tr', n.parentNode.parentNode).index(n.parentNode) + ]; + } + } + + + /* + * Function: _fnSetScrollTop + * Purpose: Set the vertical scrolling position + * Returns: - + * Inputs: int:iPos - scrolltop + * Notes: This is so nasty, but without browser detection you can't tell which you should set + * So on browsers that support both, the scroll top will be set twice. I can live with + * that :-) + */ + function _fnSetScrollTop( iPos ) + { + document.documentElement.scrollTop = iPos; + document.body.scrollTop = iPos; + } + + + /* + * Function: _fnSetScrollLeft + * Purpose: Set the horizontal scrolling position + * Returns: - + * Inputs: int:iPos - scrollleft + */ + function _fnSetScrollLeft( iPos ) + { + document.documentElement.scrollLeft = iPos; + document.body.scrollLeft = iPos; + } + + + /* + * Function: _fnGetPos + * Purpose: Get the position of an object on the rendered page + * Returns: array[2] int: [left, right] + * Inputs: node:obj - element of interest + */ + function _fnGetPos ( obj ) + { + var iLeft = 0; + var iTop = 0; + + if (obj.offsetParent) + { + iLeft = obj.offsetLeft; + iTop = obj.offsetTop; + obj = obj.offsetParent; + while (obj) + { + iLeft += obj.offsetLeft; + iTop += obj.offsetTop; + obj = obj.offsetParent; + } + } + return [iLeft,iTop]; + } + + + /* + * Function: _fnFindDtCell + * Purpose: Get the coords. of a cell from the DataTables internal information + * Returns: array[2] int: [x, y] coords. or null if not found + * Inputs: node:nTarget - the node of interest + */ + function _fnFindDtCell( nTarget ) + { + for ( var i=0, iLen=_oDatatable.aiDisplay.length ; i