diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/conf.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/conf.json deleted file mode 100644 index 4da39ae5c..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/conf.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "provider-conf": { - "streamName": "org.wso2.iot.android.gyroscope:1.0.0", - "provider-name": "realtime" - }, - "chart-conf": { - "x": "TIMESTAMP", - "xType": "time", - "y": "value", - "yType": "number", - "color": "axis", - "maxLength": "30", - "gadget-name": "ANDROID_GYROSCOPE_GADGET", - "chart-name": "line-chart" - } -} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/gadget-controller.jag b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/gadget-controller.jag deleted file mode 100644 index f84538a40..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/gadget-controller.jag +++ /dev/null @@ -1,42 +0,0 @@ -<% -/** - * 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. - * - */ -(function () { - - response.contentType = 'application/json'; - var PROVIDER_CONF = 'provider-conf'; - var PROVIDER_NAME = 'provider-name'; - - var action = request.getParameter("action"); - var data = request.getContent(); - var providerConf = data[PROVIDER_CONF]; - var providerAPI = require('js/core/' + providerConf[PROVIDER_NAME] + '-provider-api.js'); - - if (action === 'getSchema') { - print(providerAPI.getSchema(providerConf)); - return; - } else if(action === 'getData'){ - print(providerAPI.getData(providerConf)); - return; - } - -}()); - - -%> diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/gadget.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/gadget.json deleted file mode 100644 index dd6ccb149..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/gadget.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "ANDROID_GYROSCOPE_GADGET", - "title": "ANDROID_GYROSCOPE_GADGET", - "type": "gadget", - "thumbnail": "gadget/ANDROID_GYROSCOPE_GADGET/thumbnail.png", - "data": { - "url": "gadget/ANDROID_GYROSCOPE_GADGET/gadget.xml" - } -} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/gadget.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/gadget.xml deleted file mode 100644 index f2dc17a74..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/gadget.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - ]]> -
-
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/gadget-core.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/gadget-core.js deleted file mode 100644 index 8bfc5f742..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/gadget-core.js +++ /dev/null @@ -1,64 +0,0 @@ -/* -* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. -*/ -$(function () { - var gadgetLocation; - var conf; - var schema; - var pref = new gadgets.Prefs(); - - var CHART_CONF = 'chart-conf'; - var PROVIDER_CONF = 'provider-conf'; - -var init = function () { - $.ajax({ - url: gadgetLocation + '/conf.json', - method: "GET", - contentType: "application/json", - async: false, - success: function (data) { - conf = JSON.parse(data); - $.ajax({ - url: gadgetLocation + '/gadget-controller.jag?action=getSchema', - method: "POST", - data: JSON.stringify(conf), - contentType: "application/json", - async: false, - success: function (data) { - schema = data; - } - }); - - } - }); -}; - - -var drawGadget = function (){ - - draw('#canvas', conf[CHART_CONF], schema, null); - registerCallBackforPush(conf[PROVIDER_CONF], schema, function(providerData) { - update(providerData); - }); - -}; - -getGadgetLocation(function (gadget_Location) { - gadgetLocation = gadget_Location; - init(); - drawGadget(); - -}); -}); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/gadget-util.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/gadget-util.js deleted file mode 100644 index 77f1a1ffe..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/gadget-util.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getGadgetLocation = function (callback) { - var gadgetLocation = "/portal/store/carbon.super/fs/gadget/ANDROID_GYROSCOPE_GADGET"; - var PATH_SEPERATOR = "/"; - if (gadgetLocation.search("store") != -1) { - wso2.gadgets.identity.getTenantDomain(function (tenantDomain) { - var gadgetPath = gadgetLocation.split(PATH_SEPERATOR); - var modifiedPath = ''; - for (var i = 1; i < gadgetPath.length; i++) { - if (i === 3) { - modifiedPath = modifiedPath.concat(PATH_SEPERATOR, tenantDomain); - } else { - modifiedPath = modifiedPath.concat(PATH_SEPERATOR, gadgetPath[i]) - } - } - callback(modifiedPath); - }); - } else { - callback(gadgetLocation); - } -} \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/line-chart-api.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/line-chart-api.js deleted file mode 100644 index 18f363a32..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/line-chart-api.js +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getConfig, validate, isProviderRequired, draw, update; - -(function() { - - var CHART_LOCATION = '/extensions/chart-templates/'; - - /** - * return the config to be populated in the chart configuration UI - * @param schema - */ - getConfig = function(schema) { - var chartConf = require(CHART_LOCATION + '/line-chart/config.json').config; - /* - dynamic logic goes here - */ - - var columns = []; - - columns.push("None"); - for(var i=0; i < schema.length; i++) { - columns.push(schema[i]["fieldName"]); - } - - for(var i=0; i < chartConf.length; i++) { - if (chartConf[i]["fieldName"] == "color") { - chartConf[i]["valueSet"] = columns; - break; - } - } - - return chartConf; - }; - - /** - * validate the user inout for the chart configuration - * @param chartConfig - */ - validate = function(chartConfig) { - return true; - }; - - /** - * TO be used when provider configuration steps need to be skipped - */ - isProviderRequired = function() { - - } - - - /** - * return the gadget content - * @param chartConfig - * @param schema - * @param data - */ - draw = function(placeholder, chartConfig, _schema, data) { - _schema = updateUserPrefXYTypes(_schema, chartConfig); - var schema = toVizGrammarSchema(_schema); - - var view = { - id: "chart-0", - schema: schema, - chartConfig: buildChartConfig(chartConfig), - data: function() { - if(data) { - var result = []; - console.log(data); - data.forEach(function(item) { - var row = []; - schema[0].metadata.names.forEach(function(name) { - row.push(item[name]); - }); - result.push(row); - }); - console.log(result); - wso2gadgets.onDataReady(result); - } - } - - }; - - try { - wso2gadgets.init(placeholder, view); - var view = wso2gadgets.load("chart-0"); - } catch (e) { - console.error(e); - } - - }; - - /** - * - * @param data - */ - update = function(data) { - wso2gadgets.onDataReady(data,"append"); - }; - - buildChartConfig = function (_chartConfig) { - var conf = {}; - conf.x = _chartConfig.x; - conf.xType = _chartConfig.xType; - conf.yType = _chartConfig.yType; - conf.maxLength = _chartConfig.maxLength; - conf.charts = []; - conf.charts[0] = { - type : "line", - y: _chartConfig.y - }; - - if (_chartConfig.color != "None") { - conf.charts[0].color = _chartConfig.color; - } - - return conf; - }; - - -}()); \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/provider-client.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/provider-client.js deleted file mode 100644 index 6196677f6..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/provider-client.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -// var registerCallBackforPush; - -(function() { - - var callback; - - /** - * TODO Need to read hostname,port, and tenantId from providerConfig - * @param providerConfig - * @param schema - */ - registerCallBackforPush = function(providerConfig, schema, _callback) { - var streamId = providerConfig['streamName']; - var hostname = window.parent.location.hostname; - var port = window.parent.location.port; - - subscribe(streamId.split(":")[0], streamId.split(":")[1], - '10', - onData, onError, - hostname, - port, - 'WEBSOCKET' - ); - callback = _callback; - }; - - function onData(streamId, data) { - callback(data); - }; - - function onError(error) { - console.error(error); - }; - -}()); - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/realtime-provider-api.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/realtime-provider-api.js deleted file mode 100644 index 7cf59af77..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/core/realtime-provider-api.js +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; - -(function() { - - var PROVIDERS_LOCATION = '/extensions/providers/'; - var PROVIDER_NAME = 'realtime'; - - var log = new Log(); - var utils = require('/modules/utils.js'); - var carbon = require("carbon"); - var EventPublisherConstants = Packages.org.wso2.carbon.event.publisher.core.config.EventPublisherConstants; - var eventPublisherService = carbon.server.osgiService('org.wso2.carbon.event.publisher.core.EventPublisherService'); - var eventStreamService = carbon.server.osgiService('org.wso2.carbon.event.stream.core.EventStreamService'); - - var typeMap = { - "bool": "string", - "boolean": "string", - "string": "string", - "int": "number", - "integer": "number", - "long": "number", - "double": "number", - "float": "number", - "time": "time" - }; - - getConfig = function() { - var formConfig = require(PROVIDERS_LOCATION + '/' + PROVIDER_NAME + '/config.json'); - var datasources = []; - try { - var eventPublisherConfigurationList = eventPublisherService.getAllActiveEventPublisherConfigurations(); - for (var i = 0; i < eventPublisherConfigurationList.size(); i++) { - var eventPublisherConfiguration = eventPublisherService.getActiveEventPublisherConfiguration( - eventPublisherConfigurationList.get(i).getEventPublisherName());; - - var mappingTypeIsWso2 = eventPublisherConfiguration.getOutputMapping() - .getMappingType().equals(EventPublisherConstants.EF_WSO2EVENT_MAPPING_TYPE); - - var adapterType = null; - if (eventPublisherConfiguration.getToAdapterConfiguration() != null) { - adapterType = eventPublisherConfiguration.getToAdapterConfiguration().getType(); - } - if (mappingTypeIsWso2 && adapterType.trim() == "ui") { - var streamName = eventPublisherConfiguration.getFromStreamName(); - var streamVersion = eventPublisherConfiguration.getFromStreamVersion(); - var streamId = streamName + ":" + streamVersion; - datasources.push(streamId); - } - } - var datasourceCfg = { - "fieldLabel": "Event Stream", - "fieldName": "streamName", - "fieldType": "dropDown" - }; - datasourceCfg['valueSet'] = datasources; - } catch (e) { - log.error(e); - } - formConfig.config.push(datasourceCfg); - return formConfig; - }; - - /** - * validate the user input of provider configuration - * @param providerConfig - */ - validate = function(providerConfig) { - /* - validate the form and return - - */ - return true; - }; - - /** - * returns the data mode either push or pull - */ - getMode = function() { - return 'push'; - }; - - /** - * returns an array of column names & types - * @param providerConfig - */ - getSchema = function(providerConfig) { - var streamId = providerConfig["streamName"]; - var output = []; - - output.push({ - fieldName: "TIMESTAMP", - fieldType: "time" - }); - - if (eventStreamService != null) { - var eventStreamConfiguration = eventStreamService.getEventStreamConfiguration(streamId); - if (eventStreamConfiguration != null) { - var metaData = eventStreamConfiguration.getStreamDefinition().getMetaData(); - var correlationData = eventStreamConfiguration.getStreamDefinition().getCorrelationData(); - var payloadData = eventStreamConfiguration.getStreamDefinition().getPayloadData(); - if (metaData != null) { - for (var i = 0; i < metaData.size(); i++) { - var type = metaData.get(i).getType().toString().toLowerCase(); - output.push({ - fieldName: metaData.get(i).getName(), - fieldType: typeMap[type.toLowerCase()] - }); - } - } - if (correlationData != null) { - for (var i = 0; i < correlationData.size(); i++) { - var type = correlationData.get(i).getType().toString().toLowerCase(); - output.push({ - fieldName: correlationData.get(i).getName(), - fieldType: typeMap[type.toLowerCase()] - }); - } - } - if (payloadData != null) { - for (var i = 0; i < payloadData.size(); i++) { - var type = payloadData.get(i).getType().toString().toLowerCase(); - output.push({ - fieldName: payloadData.get(i).getName(), - fieldType: typeMap[type.toLowerCase()] - }); - } - } - } - } - return output; - }; - - getData = function(providerConfig,limit) { - var data = []; - return data; - }; - - -}()); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/provider-libs/ws-client.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/provider-libs/ws-client.js deleted file mode 100644 index 760ecf951..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_gadget/ANDROID_GYROSCOPE_GADGET/js/provider-libs/ws-client.js +++ /dev/null @@ -1,286 +0,0 @@ -/* - * 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. - */ - -var CONSTANTS = { - urlSeperator: '/', - queryParamStreamName : '?streamname=', - queryParamStreamVersion : '&version=', - queryParamLastUpdatedTime : '&lastUpdatedTime=', - urlSecureTransportWebsocket : 'wss://', - urlSecureTransportHttp : 'https://', - colon : ':', - defaultIntervalTime : 10 * 1000, - defaultHostName : 'localhost', - defaultSecurePortNumber : '9443', - defaultMode : 'AUTO', - processModeHTTP : 'HTTP', - processModeWebSocket : 'WEBSOCKET', - processModeAuto : 'AUTO', - numThousand : 1000, - websocketTimeAppender : 400, - websocketSubscriptionEndpoint : 'portal/uipublisher/websocketSubscriptionEndpoint.jag', - httpEventRetrievalEndpoint : 'portal/uipublisher/httpEventRetrievalEndpoint.jag' -}; - -var websocket = null; -var webSocketUrl; -var httpUrl; -var cepHostName; -var cepPortNumber; -var isErrorOccured = false; -var lastUpdatedtime = -1; -var polingInterval; -var stream; -var streamVersion; -var firstPollingAttempt; -var processMode; -var onSuccessFunction; -var onErrorFunction; -var terminateWebsocketInstance = false; -var pollingContinue = true; - -function subscribe(streamName,version,intervalTime, - listeningFuncSuccessData,listeningFuncErrorData,cepHost,cepPort,mode){ - stopPollingProcesses(); - stream = streamName; - streamVersion = version; - onSuccessFunction = listeningFuncSuccessData; - onErrorFunction = listeningFuncErrorData; - - if(intervalTime == null || intervalTime == ""){ - polingInterval = CONSTANTS.defaultIntervalTime; - } else{ - polingInterval = intervalTime * CONSTANTS.numThousand; - } - - if(cepHost == null || cepHost == ""){ - cepHostName = CONSTANTS.defaultHostName; - } else{ - cepHostName = cepHost; - } - - if(cepPort == null || cepPort == ""){ - cepPortNumber = CONSTANTS.defaultSecurePortNumber; - } else{ - cepPortNumber = cepPort; - } - - if(mode == null || mode == ""){ - processMode = CONSTANTS.defaultMode; - } else{ - processMode = mode; - } - - webSocketUrl = CONSTANTS.urlSecureTransportWebsocket + cepHostName + CONSTANTS.colon + cepPortNumber + - CONSTANTS.urlSeperator + CONSTANTS.websocketSubscriptionEndpoint; - - if(processMode == CONSTANTS.processModeHTTP){ - firstPollingAttempt = true; - pollingContinue = true; - startPoll(); - } else{ - initializeWebSocket(webSocketUrl); - } -} - -/** - * Initializing Web Socket - */ -function initializeWebSocket(webSocketUrl){ - websocket = new WebSocket(webSocketUrl); - websocket.onopen = webSocketOnOpen; - websocket.onmessage = webSocketOnMessage; - websocket.onclose = webSocketOnClose; - websocket.onerror = webSocketOnError; -} - -function getWebsocketSubscriptionMessage(streamName, streamVersion, streamProperties, streamValues) { - if (streamProperties.length === streamValues.length) { - var message = {}; - message.streamName = streamName; - message.streamVersion = streamVersion; - var i; - for (i = 0; i < streamProperties.length; i++) { - message.filterProps = []; - message.filterProps.push({ - 'name': streamProperties[i], - 'value': streamValues[i] - }); - } - return JSON.stringify(message); - } else { - console.log('stream properties and values are not in equal size'); - } -} - -/** - * Get the parameters as query parameters. - * This method parses those parameters and returns. - * */ -function getAllQueryParamsFromURL() { - var queryParamList = {}, qParam; - var urlQueryString = decodeURIComponent(window.top.location.search.substring(1)); - - if (urlQueryString) { - var queryStringPairs = urlQueryString.split('&'); - for (var i = 0; i < queryStringPairs.length; i++) { - qParam = queryStringPairs[i].split('='); - queryParamList[qParam[0]] = qParam[1]; - } - return queryParamList; - - } else { - return null; - } -} - -/** - * Web socket On Open - */ -var webSocketOnOpen = function () { - var params = getAllQueryParamsFromURL(); - var deviceId; - var owner; - if (params) { - owner = params["owner"]; - deviceId = params["deviceId"]; - } - var filterPropNames = ["meta_owner", "meta_deviceId"]; - var filterPropVals = [owner, deviceId]; - var data = getWebsocketSubscriptionMessage(stream, streamVersion, filterPropNames, filterPropVals); - websocket.send(data); -}; - -/** - * On server sends a message - */ -var webSocketOnMessage = function (evt) { - var event = evt.data; - var array = JSON.parse(event); - constructPayload(array); -}; - -/** - * On server close - */ -var webSocketOnClose =function (e) { - - if(isErrorOccured){ - if(processMode != CONSTANTS.processModeWebSocket){ - firstPollingAttempt = true; - pollingContinue = true; - startPoll(); - } - } else{ - if(!terminateWebsocketInstance){ - waitForSocketConnection(websocket); - } else{ - terminateWebsocketInstance = false; - } - - } -}; - -/** - * On server Error - */ -var webSocketOnError = function (err) { - var error = "Error: Cannot connect to Websocket URL:" + webSocketUrl + " .Hence closing the connection!"; - - onErrorFunction(error); - isErrorOccured = true; - -}; - -/** - * Gracefully increments the connection retry - */ -var waitTime = CONSTANTS.numThousand; -function waitForSocketConnection(socket, callback){ - setTimeout( - function () { - if (socket.readyState === 1) { - initializeWebSocket(webSocketUrl); - console.log("Connection is made"); - if(callback != null){ - callback(); - } - return; - } else { - websocket = new WebSocket(webSocketUrl); - waitTime += CONSTANTS.websocketTimeAppender; - waitForSocketConnection(websocket, callback); - } - }, waitTime); -} - -/** - * Polling to retrieve events from http request periodically - */ -function startPoll(){ - - (function poll(){ - setTimeout(function(){ - httpUrl = CONSTANTS.urlSecureTransportHttp + cepHostName + CONSTANTS.colon + cepPortNumber + - CONSTANTS.urlSeperator + CONSTANTS.httpEventRetrievalEndpoint + CONSTANTS.queryParamStreamName + stream + - CONSTANTS.queryParamStreamVersion + streamVersion + CONSTANTS.queryParamLastUpdatedTime + lastUpdatedtime;; - $.getJSON(httpUrl, function(responseText) { - if(firstPollingAttempt){ - /*var data = $("textarea#idConsole").val(); - $("textarea#idConsole").val(data + "Successfully connected to HTTP.");*/ - firstPollingAttempt = false; - } - var eventList = $.parseJSON(responseText.events); - if(eventList.length != 0){ - lastUpdatedtime = responseText.lastEventTime; - for(var i=0;i - - - - ANDROID_GYROSCOPE_GADGET - - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_ui_event_publisher/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_ui_event_publisher/artifact.xml deleted file mode 100644 index 0e0fd9182..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_ui_event_publisher/artifact.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - org.wso2.iot.android.gyroscope.ui.publisher.xml - - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_ui_event_publisher/org.wso2.iot.android.gyroscope.ui.publisher.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_ui_event_publisher/org.wso2.iot.android.gyroscope.ui.publisher.xml deleted file mode 100644 index 2cd783def..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_ui_event_publisher/org.wso2.iot.android.gyroscope.ui.publisher.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/conf.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/conf.json deleted file mode 100644 index 53199e326..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/conf.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "provider-conf": { - "streamName": "org.wso2.iot.android.magnetic:1.0.0", - "provider-name": "realtime" - }, - "chart-conf": { - "x": "TIMESTAMP", - "xType": "time", - "y": "value", - "yType": "number", - "color": "axis", - "maxLength": "30", - "gadget-name": "ANDROID_MAGNETIC_GADGET", - "chart-name": "line-chart" - } -} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/gadget-controller.jag b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/gadget-controller.jag deleted file mode 100644 index f84538a40..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/gadget-controller.jag +++ /dev/null @@ -1,42 +0,0 @@ -<% -/** - * 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. - * - */ -(function () { - - response.contentType = 'application/json'; - var PROVIDER_CONF = 'provider-conf'; - var PROVIDER_NAME = 'provider-name'; - - var action = request.getParameter("action"); - var data = request.getContent(); - var providerConf = data[PROVIDER_CONF]; - var providerAPI = require('js/core/' + providerConf[PROVIDER_NAME] + '-provider-api.js'); - - if (action === 'getSchema') { - print(providerAPI.getSchema(providerConf)); - return; - } else if(action === 'getData'){ - print(providerAPI.getData(providerConf)); - return; - } - -}()); - - -%> diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/gadget.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/gadget.json deleted file mode 100644 index 93efa3813..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/gadget.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "ANDROID_MAGNETIC_GADGET", - "title": "ANDROID_MAGNETIC_GADGET", - "type": "gadget", - "thumbnail": "gadget/ANDROID_MAGNETIC_GADGET/thumbnail.png", - "data": { - "url": "gadget/ANDROID_MAGNETIC_GADGET/gadget.xml" - } -} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/gadget.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/gadget.xml deleted file mode 100644 index e3a632324..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/gadget.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - ]]> -
-
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/gadget-core.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/gadget-core.js deleted file mode 100644 index 8bfc5f742..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/gadget-core.js +++ /dev/null @@ -1,64 +0,0 @@ -/* -* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. -*/ -$(function () { - var gadgetLocation; - var conf; - var schema; - var pref = new gadgets.Prefs(); - - var CHART_CONF = 'chart-conf'; - var PROVIDER_CONF = 'provider-conf'; - -var init = function () { - $.ajax({ - url: gadgetLocation + '/conf.json', - method: "GET", - contentType: "application/json", - async: false, - success: function (data) { - conf = JSON.parse(data); - $.ajax({ - url: gadgetLocation + '/gadget-controller.jag?action=getSchema', - method: "POST", - data: JSON.stringify(conf), - contentType: "application/json", - async: false, - success: function (data) { - schema = data; - } - }); - - } - }); -}; - - -var drawGadget = function (){ - - draw('#canvas', conf[CHART_CONF], schema, null); - registerCallBackforPush(conf[PROVIDER_CONF], schema, function(providerData) { - update(providerData); - }); - -}; - -getGadgetLocation(function (gadget_Location) { - gadgetLocation = gadget_Location; - init(); - drawGadget(); - -}); -}); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/gadget-util.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/gadget-util.js deleted file mode 100644 index 426dae39b..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/gadget-util.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getGadgetLocation = function (callback) { - var gadgetLocation = "/portal/store/carbon.super/fs/gadget/ANDROID_MAGNETIC_GADGET"; - var PATH_SEPERATOR = "/"; - if (gadgetLocation.search("store") != -1) { - wso2.gadgets.identity.getTenantDomain(function (tenantDomain) { - var gadgetPath = gadgetLocation.split(PATH_SEPERATOR); - var modifiedPath = ''; - for (var i = 1; i < gadgetPath.length; i++) { - if (i === 3) { - modifiedPath = modifiedPath.concat(PATH_SEPERATOR, tenantDomain); - } else { - modifiedPath = modifiedPath.concat(PATH_SEPERATOR, gadgetPath[i]) - } - } - callback(modifiedPath); - }); - } else { - callback(gadgetLocation); - } -} \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/line-chart-api.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/line-chart-api.js deleted file mode 100644 index 18f363a32..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/line-chart-api.js +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getConfig, validate, isProviderRequired, draw, update; - -(function() { - - var CHART_LOCATION = '/extensions/chart-templates/'; - - /** - * return the config to be populated in the chart configuration UI - * @param schema - */ - getConfig = function(schema) { - var chartConf = require(CHART_LOCATION + '/line-chart/config.json').config; - /* - dynamic logic goes here - */ - - var columns = []; - - columns.push("None"); - for(var i=0; i < schema.length; i++) { - columns.push(schema[i]["fieldName"]); - } - - for(var i=0; i < chartConf.length; i++) { - if (chartConf[i]["fieldName"] == "color") { - chartConf[i]["valueSet"] = columns; - break; - } - } - - return chartConf; - }; - - /** - * validate the user inout for the chart configuration - * @param chartConfig - */ - validate = function(chartConfig) { - return true; - }; - - /** - * TO be used when provider configuration steps need to be skipped - */ - isProviderRequired = function() { - - } - - - /** - * return the gadget content - * @param chartConfig - * @param schema - * @param data - */ - draw = function(placeholder, chartConfig, _schema, data) { - _schema = updateUserPrefXYTypes(_schema, chartConfig); - var schema = toVizGrammarSchema(_schema); - - var view = { - id: "chart-0", - schema: schema, - chartConfig: buildChartConfig(chartConfig), - data: function() { - if(data) { - var result = []; - console.log(data); - data.forEach(function(item) { - var row = []; - schema[0].metadata.names.forEach(function(name) { - row.push(item[name]); - }); - result.push(row); - }); - console.log(result); - wso2gadgets.onDataReady(result); - } - } - - }; - - try { - wso2gadgets.init(placeholder, view); - var view = wso2gadgets.load("chart-0"); - } catch (e) { - console.error(e); - } - - }; - - /** - * - * @param data - */ - update = function(data) { - wso2gadgets.onDataReady(data,"append"); - }; - - buildChartConfig = function (_chartConfig) { - var conf = {}; - conf.x = _chartConfig.x; - conf.xType = _chartConfig.xType; - conf.yType = _chartConfig.yType; - conf.maxLength = _chartConfig.maxLength; - conf.charts = []; - conf.charts[0] = { - type : "line", - y: _chartConfig.y - }; - - if (_chartConfig.color != "None") { - conf.charts[0].color = _chartConfig.color; - } - - return conf; - }; - - -}()); \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/provider-client.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/provider-client.js deleted file mode 100644 index 6196677f6..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/provider-client.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -// var registerCallBackforPush; - -(function() { - - var callback; - - /** - * TODO Need to read hostname,port, and tenantId from providerConfig - * @param providerConfig - * @param schema - */ - registerCallBackforPush = function(providerConfig, schema, _callback) { - var streamId = providerConfig['streamName']; - var hostname = window.parent.location.hostname; - var port = window.parent.location.port; - - subscribe(streamId.split(":")[0], streamId.split(":")[1], - '10', - onData, onError, - hostname, - port, - 'WEBSOCKET' - ); - callback = _callback; - }; - - function onData(streamId, data) { - callback(data); - }; - - function onError(error) { - console.error(error); - }; - -}()); - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/realtime-provider-api.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/realtime-provider-api.js deleted file mode 100644 index 7cf59af77..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/core/realtime-provider-api.js +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; - -(function() { - - var PROVIDERS_LOCATION = '/extensions/providers/'; - var PROVIDER_NAME = 'realtime'; - - var log = new Log(); - var utils = require('/modules/utils.js'); - var carbon = require("carbon"); - var EventPublisherConstants = Packages.org.wso2.carbon.event.publisher.core.config.EventPublisherConstants; - var eventPublisherService = carbon.server.osgiService('org.wso2.carbon.event.publisher.core.EventPublisherService'); - var eventStreamService = carbon.server.osgiService('org.wso2.carbon.event.stream.core.EventStreamService'); - - var typeMap = { - "bool": "string", - "boolean": "string", - "string": "string", - "int": "number", - "integer": "number", - "long": "number", - "double": "number", - "float": "number", - "time": "time" - }; - - getConfig = function() { - var formConfig = require(PROVIDERS_LOCATION + '/' + PROVIDER_NAME + '/config.json'); - var datasources = []; - try { - var eventPublisherConfigurationList = eventPublisherService.getAllActiveEventPublisherConfigurations(); - for (var i = 0; i < eventPublisherConfigurationList.size(); i++) { - var eventPublisherConfiguration = eventPublisherService.getActiveEventPublisherConfiguration( - eventPublisherConfigurationList.get(i).getEventPublisherName());; - - var mappingTypeIsWso2 = eventPublisherConfiguration.getOutputMapping() - .getMappingType().equals(EventPublisherConstants.EF_WSO2EVENT_MAPPING_TYPE); - - var adapterType = null; - if (eventPublisherConfiguration.getToAdapterConfiguration() != null) { - adapterType = eventPublisherConfiguration.getToAdapterConfiguration().getType(); - } - if (mappingTypeIsWso2 && adapterType.trim() == "ui") { - var streamName = eventPublisherConfiguration.getFromStreamName(); - var streamVersion = eventPublisherConfiguration.getFromStreamVersion(); - var streamId = streamName + ":" + streamVersion; - datasources.push(streamId); - } - } - var datasourceCfg = { - "fieldLabel": "Event Stream", - "fieldName": "streamName", - "fieldType": "dropDown" - }; - datasourceCfg['valueSet'] = datasources; - } catch (e) { - log.error(e); - } - formConfig.config.push(datasourceCfg); - return formConfig; - }; - - /** - * validate the user input of provider configuration - * @param providerConfig - */ - validate = function(providerConfig) { - /* - validate the form and return - - */ - return true; - }; - - /** - * returns the data mode either push or pull - */ - getMode = function() { - return 'push'; - }; - - /** - * returns an array of column names & types - * @param providerConfig - */ - getSchema = function(providerConfig) { - var streamId = providerConfig["streamName"]; - var output = []; - - output.push({ - fieldName: "TIMESTAMP", - fieldType: "time" - }); - - if (eventStreamService != null) { - var eventStreamConfiguration = eventStreamService.getEventStreamConfiguration(streamId); - if (eventStreamConfiguration != null) { - var metaData = eventStreamConfiguration.getStreamDefinition().getMetaData(); - var correlationData = eventStreamConfiguration.getStreamDefinition().getCorrelationData(); - var payloadData = eventStreamConfiguration.getStreamDefinition().getPayloadData(); - if (metaData != null) { - for (var i = 0; i < metaData.size(); i++) { - var type = metaData.get(i).getType().toString().toLowerCase(); - output.push({ - fieldName: metaData.get(i).getName(), - fieldType: typeMap[type.toLowerCase()] - }); - } - } - if (correlationData != null) { - for (var i = 0; i < correlationData.size(); i++) { - var type = correlationData.get(i).getType().toString().toLowerCase(); - output.push({ - fieldName: correlationData.get(i).getName(), - fieldType: typeMap[type.toLowerCase()] - }); - } - } - if (payloadData != null) { - for (var i = 0; i < payloadData.size(); i++) { - var type = payloadData.get(i).getType().toString().toLowerCase(); - output.push({ - fieldName: payloadData.get(i).getName(), - fieldType: typeMap[type.toLowerCase()] - }); - } - } - } - } - return output; - }; - - getData = function(providerConfig,limit) { - var data = []; - return data; - }; - - -}()); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/provider-libs/ws-client.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/provider-libs/ws-client.js deleted file mode 100644 index 760ecf951..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_gadget/ANDROID_MAGNETIC_GADGET/js/provider-libs/ws-client.js +++ /dev/null @@ -1,286 +0,0 @@ -/* - * 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. - */ - -var CONSTANTS = { - urlSeperator: '/', - queryParamStreamName : '?streamname=', - queryParamStreamVersion : '&version=', - queryParamLastUpdatedTime : '&lastUpdatedTime=', - urlSecureTransportWebsocket : 'wss://', - urlSecureTransportHttp : 'https://', - colon : ':', - defaultIntervalTime : 10 * 1000, - defaultHostName : 'localhost', - defaultSecurePortNumber : '9443', - defaultMode : 'AUTO', - processModeHTTP : 'HTTP', - processModeWebSocket : 'WEBSOCKET', - processModeAuto : 'AUTO', - numThousand : 1000, - websocketTimeAppender : 400, - websocketSubscriptionEndpoint : 'portal/uipublisher/websocketSubscriptionEndpoint.jag', - httpEventRetrievalEndpoint : 'portal/uipublisher/httpEventRetrievalEndpoint.jag' -}; - -var websocket = null; -var webSocketUrl; -var httpUrl; -var cepHostName; -var cepPortNumber; -var isErrorOccured = false; -var lastUpdatedtime = -1; -var polingInterval; -var stream; -var streamVersion; -var firstPollingAttempt; -var processMode; -var onSuccessFunction; -var onErrorFunction; -var terminateWebsocketInstance = false; -var pollingContinue = true; - -function subscribe(streamName,version,intervalTime, - listeningFuncSuccessData,listeningFuncErrorData,cepHost,cepPort,mode){ - stopPollingProcesses(); - stream = streamName; - streamVersion = version; - onSuccessFunction = listeningFuncSuccessData; - onErrorFunction = listeningFuncErrorData; - - if(intervalTime == null || intervalTime == ""){ - polingInterval = CONSTANTS.defaultIntervalTime; - } else{ - polingInterval = intervalTime * CONSTANTS.numThousand; - } - - if(cepHost == null || cepHost == ""){ - cepHostName = CONSTANTS.defaultHostName; - } else{ - cepHostName = cepHost; - } - - if(cepPort == null || cepPort == ""){ - cepPortNumber = CONSTANTS.defaultSecurePortNumber; - } else{ - cepPortNumber = cepPort; - } - - if(mode == null || mode == ""){ - processMode = CONSTANTS.defaultMode; - } else{ - processMode = mode; - } - - webSocketUrl = CONSTANTS.urlSecureTransportWebsocket + cepHostName + CONSTANTS.colon + cepPortNumber + - CONSTANTS.urlSeperator + CONSTANTS.websocketSubscriptionEndpoint; - - if(processMode == CONSTANTS.processModeHTTP){ - firstPollingAttempt = true; - pollingContinue = true; - startPoll(); - } else{ - initializeWebSocket(webSocketUrl); - } -} - -/** - * Initializing Web Socket - */ -function initializeWebSocket(webSocketUrl){ - websocket = new WebSocket(webSocketUrl); - websocket.onopen = webSocketOnOpen; - websocket.onmessage = webSocketOnMessage; - websocket.onclose = webSocketOnClose; - websocket.onerror = webSocketOnError; -} - -function getWebsocketSubscriptionMessage(streamName, streamVersion, streamProperties, streamValues) { - if (streamProperties.length === streamValues.length) { - var message = {}; - message.streamName = streamName; - message.streamVersion = streamVersion; - var i; - for (i = 0; i < streamProperties.length; i++) { - message.filterProps = []; - message.filterProps.push({ - 'name': streamProperties[i], - 'value': streamValues[i] - }); - } - return JSON.stringify(message); - } else { - console.log('stream properties and values are not in equal size'); - } -} - -/** - * Get the parameters as query parameters. - * This method parses those parameters and returns. - * */ -function getAllQueryParamsFromURL() { - var queryParamList = {}, qParam; - var urlQueryString = decodeURIComponent(window.top.location.search.substring(1)); - - if (urlQueryString) { - var queryStringPairs = urlQueryString.split('&'); - for (var i = 0; i < queryStringPairs.length; i++) { - qParam = queryStringPairs[i].split('='); - queryParamList[qParam[0]] = qParam[1]; - } - return queryParamList; - - } else { - return null; - } -} - -/** - * Web socket On Open - */ -var webSocketOnOpen = function () { - var params = getAllQueryParamsFromURL(); - var deviceId; - var owner; - if (params) { - owner = params["owner"]; - deviceId = params["deviceId"]; - } - var filterPropNames = ["meta_owner", "meta_deviceId"]; - var filterPropVals = [owner, deviceId]; - var data = getWebsocketSubscriptionMessage(stream, streamVersion, filterPropNames, filterPropVals); - websocket.send(data); -}; - -/** - * On server sends a message - */ -var webSocketOnMessage = function (evt) { - var event = evt.data; - var array = JSON.parse(event); - constructPayload(array); -}; - -/** - * On server close - */ -var webSocketOnClose =function (e) { - - if(isErrorOccured){ - if(processMode != CONSTANTS.processModeWebSocket){ - firstPollingAttempt = true; - pollingContinue = true; - startPoll(); - } - } else{ - if(!terminateWebsocketInstance){ - waitForSocketConnection(websocket); - } else{ - terminateWebsocketInstance = false; - } - - } -}; - -/** - * On server Error - */ -var webSocketOnError = function (err) { - var error = "Error: Cannot connect to Websocket URL:" + webSocketUrl + " .Hence closing the connection!"; - - onErrorFunction(error); - isErrorOccured = true; - -}; - -/** - * Gracefully increments the connection retry - */ -var waitTime = CONSTANTS.numThousand; -function waitForSocketConnection(socket, callback){ - setTimeout( - function () { - if (socket.readyState === 1) { - initializeWebSocket(webSocketUrl); - console.log("Connection is made"); - if(callback != null){ - callback(); - } - return; - } else { - websocket = new WebSocket(webSocketUrl); - waitTime += CONSTANTS.websocketTimeAppender; - waitForSocketConnection(websocket, callback); - } - }, waitTime); -} - -/** - * Polling to retrieve events from http request periodically - */ -function startPoll(){ - - (function poll(){ - setTimeout(function(){ - httpUrl = CONSTANTS.urlSecureTransportHttp + cepHostName + CONSTANTS.colon + cepPortNumber + - CONSTANTS.urlSeperator + CONSTANTS.httpEventRetrievalEndpoint + CONSTANTS.queryParamStreamName + stream + - CONSTANTS.queryParamStreamVersion + streamVersion + CONSTANTS.queryParamLastUpdatedTime + lastUpdatedtime;; - $.getJSON(httpUrl, function(responseText) { - if(firstPollingAttempt){ - /*var data = $("textarea#idConsole").val(); - $("textarea#idConsole").val(data + "Successfully connected to HTTP.");*/ - firstPollingAttempt = false; - } - var eventList = $.parseJSON(responseText.events); - if(eventList.length != 0){ - lastUpdatedtime = responseText.lastEventTime; - for(var i=0;i - - - - ANDROID_MAGNETIC_GADGET - - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_ui_event_publisher/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_ui_event_publisher/artifact.xml deleted file mode 100644 index b34157e4b..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_ui_event_publisher/artifact.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - org.wso2.iot.android.magnetic.ui.publisher.xml - - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_ui_event_publisher/org.wso2.iot.android.magnetic.ui.publisher.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_ui_event_publisher/org.wso2.iot.android.magnetic.ui.publisher.xml deleted file mode 100644 index 2c8af401c..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_ui_event_publisher/org.wso2.iot.android.magnetic.ui.publisher.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/conf.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/conf.json deleted file mode 100644 index 849f327b9..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/conf.json +++ /dev/null @@ -1 +0,0 @@ -{"provider-conf" : {"tableName" : "ORG_WSO2_IOT_ANDROID_PRESSURE_STATS", "query" : "", "limit" : "", "provider-name" : "batch"}, "chart-conf" : {"x" : "pressure", "title" : "PRESSURE", "maxLength" : "30", "gadget-name" : "PROXIMITY", "chart-name" : "number-chart"}} \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/css/number-chart.css b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/css/number-chart.css deleted file mode 100644 index 5dde0413a..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/css/number-chart.css +++ /dev/null @@ -1,35 +0,0 @@ -#canvas { - height: 100%; - width: 100%; -} - -p { - margin: 0; - display: block; - text-align: center; - font-weight: bold; -} - -.titlecanvasContent { - color:steelblue; - font-size:18px; - font-weight: normal; - padding: 10px 0; -} - -.valcanvasContent { - color:#438CAD; - font-size:50px; - font-weight: normal; -} - - -.diffcanvasContent { - color:#438CAD; - font-size:14px; -} - -.diffPercentagecanvasContent { - color:#ff944d; - font-size:14px; -} \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/gadget-controller.jag b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/gadget-controller.jag deleted file mode 100644 index f84538a40..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/gadget-controller.jag +++ /dev/null @@ -1,42 +0,0 @@ -<% -/** - * 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. - * - */ -(function () { - - response.contentType = 'application/json'; - var PROVIDER_CONF = 'provider-conf'; - var PROVIDER_NAME = 'provider-name'; - - var action = request.getParameter("action"); - var data = request.getContent(); - var providerConf = data[PROVIDER_CONF]; - var providerAPI = require('js/core/' + providerConf[PROVIDER_NAME] + '-provider-api.js'); - - if (action === 'getSchema') { - print(providerAPI.getSchema(providerConf)); - return; - } else if(action === 'getData'){ - print(providerAPI.getData(providerConf)); - return; - } - -}()); - - -%> diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/gadget.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/gadget.json deleted file mode 100644 index 43b51c3b6..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/gadget.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "PROXIMITY", - "title": "PROXIMITY", - "type": "gadget", - "thumbnail": "gadget/PROXIMITY/thumbnail.png", - "data": { - "url": "gadget/PROXIMITY/gadget.xml" - } -} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/gadget.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/gadget.xml deleted file mode 100644 index de27540da..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/gadget.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - ]]> -
-
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/batch-provider-api.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/batch-provider-api.js deleted file mode 100644 index 30c96902a..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/batch-provider-api.js +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; - -(function() { - - var PROVIDERS_LOCATION = '/extensions/providers/'; - - var PROVIDER_NAME = 'batch'; - var TYPE = "type"; - var TABLE_NAME = "tableName"; - var HTTPS_TRANSPORT = "https"; - var CONTENT_TYPE_JSON = "application/json"; - var AUTHORIZATION_HEADER = "Authorization"; - var USER_TOKEN = "user"; - var TENANT_DOMAIN = "domain"; - var CONST_AT = "@"; - var USERNAME = "username"; - var HTTP_USER_NOT_AUTHENTICATED = 403; - var JS_MAX_VALUE = "9007199254740992"; - var JS_MIN_VALUE = "-9007199254740992"; - - var typeMap = { - "bool" : "string", - "boolean" : "string", - "string" : "string", - "int" : "number", - "integer" : "number", - "long" : "number", - "double" : "number", - "float" : "number", - "time": "time" - }; - - var log = new Log(); - var carbon = require('carbon'); - var configs = require('/configs/designer.json'); - var utils = require('/modules/utils.js'); - var JSUtils = Packages.org.wso2.carbon.analytics.jsservice.Utils; - var AnalyticsCachedJSServiceConnector = Packages.org.wso2.carbon.analytics.jsservice.AnalyticsCachedJSServiceConnector; - var AnalyticsCache = Packages.org.wso2.carbon.analytics.jsservice.AnalyticsCachedJSServiceConnector.AnalyticsCache; - var cacheTimeoutSeconds = 5; - var loggedInUser = null; - - if (configs.cacheTimeoutSeconds) { - cacheTimeoutSeconds = parseInt(configs.cacheTimeoutSeconds); - } - var cacheSizeBytes = 1024 * 1024 * 1024; // 1GB - if (configs.cacheSizeBytes) { - cacheSizeBytes = parseInt(configs.cacheSizeBytes); - } - response.contentType = CONTENT_TYPE_JSON; - - var authParam = request.getHeader(AUTHORIZATION_HEADER); - if (authParam != null) { - credentials = JSUtils.authenticate(authParam); - loggedInUser = credentials[0]; - } else { - var token = session.get(USER_TOKEN); - if (token != null) { - loggedInUser = token[USERNAME] + CONST_AT + token[TENANT_DOMAIN]; - } else { - log.error("user is not authenticated!"); - response.status = HTTP_USER_NOT_AUTHENTICATED; - print('{ "status": "Failed", "message": "User is not authenticated." }'); - return; - } - } - - var cache = application.get("AnalyticsWebServiceCache"); - if (cache == null) { - cache = new AnalyticsCache(cacheTimeoutSeconds, cacheSizeBytes); - application.put("AnalyticsWebServiceCache", cache); - } - var connector = new AnalyticsCachedJSServiceConnector(cache); - - /** - * require the existing config.json and push any dynamic fields that needs to be populated in the UI - */ - getConfig = function() { - var formConfig = require(PROVIDERS_LOCATION + '/' + PROVIDER_NAME + '/config.json'); - var tables; - try { - tables = JSON.parse(connector.getTableList(loggedInUser).getMessage()); - } catch (e) { - log.error(e); - } - var configs = formConfig.config; - configs.forEach(function(config) { - if (config.fieldName === TABLE_NAME) { - config.valueSet = tables; - } - }); - return formConfig; - } - - /** - * validate the user input of provider configuration - * @param providerConfig - */ - validate = function(providerConfig) { - /* - validate the form and return - - */ - return true; - } - - /** - * returns the data mode either push or pull - */ - getMode = function() { - return "PULL"; - } - - /** - * returns an array of column names & types - * @param providerConfig - */ - getSchema = function(providerConfig) { - var schema = []; - var tableName = providerConfig["tableName"]; - var result = connector.getTableSchema(loggedInUser, tableName).getMessage(); - result = JSON.parse(result); - - var columns = result.columns; - Object.getOwnPropertyNames(columns).forEach(function(name, idx, array) { - var type = "ordinal"; - if(columns[name]['type']) { - type = columns[name]['type']; - } - schema.push({ - fieldName: name, - fieldType: typeMap[type.toLowerCase()] - }); - }); - // log.info(schema); - return schema; - }; - - /** - * returns the actual data - * @param providerConfig - * @param limit - */ - getData = function(providerConfig, limit) { - var tableName = providerConfig.tableName; - var query = providerConfig.query; - var limit = 100; - if (providerConfig.limit) { - limit = providerConfig.limit; - } - var result; - //if there's a filter present, we should perform a Lucene search instead of reading the table - if (query) { - var filter = { - "query": query, - "start": 0, - "count": limit - }; - result = connector.search(loggedInUser, tableName, stringify(filter)).getMessage(); - } else { - var from = JS_MIN_VALUE; - var to = JS_MAX_VALUE; - result = connector.getRecordsByRange(loggedInUser, tableName, from, to, 0, limit, null).getMessage(); - - } - result = JSON.parse(result); - var data = []; - for (var i = 0; i < result.length; i++) { - var values = result[i].values; - data.push(values); - } - return data; - }; - -}()); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/gadget-core.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/gadget-core.js deleted file mode 100644 index 9dfe8683b..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/gadget-core.js +++ /dev/null @@ -1,85 +0,0 @@ -/* -* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. -*/ -$(function () { - var gadgetLocation; - var conf; - var schema; - var pref = new gadgets.Prefs(); - - var refreshInterval; - var providerData; - - var CHART_CONF = 'chart-conf'; - var PROVIDER_CONF = 'provider-conf'; - - var REFRESH_INTERVAL = 'refreshInterval'; - -var init = function () { - $.ajax({ - url: gadgetLocation + '/conf.json', - method: "GET", - contentType: "application/json", - async: false, - success: function (data) { - conf = JSON.parse(data); - $.ajax({ - url: gadgetLocation + '/gadget-controller.jag?action=getSchema', - method: "POST", - data: JSON.stringify(conf), - contentType: "application/json", - async: false, - success: function (data) { - schema = data; - } - }); - - getProviderData(); - - } - }); -}; - -var getProviderData = function (){ - $.ajax({ - url: gadgetLocation + '/gadget-controller.jag?action=getData', - method: "POST", - data: JSON.stringify(conf), - contentType: "application/json", - async: false, - success: function (data) { - providerData = data; - } - }); - return providerData; -}; - - -var drawGadget = function (){ - - draw('#canvas', conf[CHART_CONF], schema, providerData); - setInterval(function() { - draw('#canvas', conf[CHART_CONF], schema, getProviderData()); - },pref.getInt(REFRESH_INTERVAL)); - -}; - -getGadgetLocation(function (gadget_Location) { - gadgetLocation = gadget_Location; - init(); - drawGadget(); - -}); -}); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/gadget-util.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/gadget-util.js deleted file mode 100644 index 13f2120f1..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/gadget-util.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getGadgetLocation = function (callback) { - var gadgetLocation = "/portal/store/carbon.super/fs/gadget/PROXIMITY"; - var PATH_SEPERATOR = "/"; - if (gadgetLocation.search("store") != -1) { - wso2.gadgets.identity.getTenantDomain(function (tenantDomain) { - var gadgetPath = gadgetLocation.split(PATH_SEPERATOR); - var modifiedPath = ''; - for (var i = 1; i < gadgetPath.length; i++) { - if (i === 3) { - modifiedPath = modifiedPath.concat(PATH_SEPERATOR, tenantDomain); - } else { - modifiedPath = modifiedPath.concat(PATH_SEPERATOR, gadgetPath[i]) - } - } - callback(modifiedPath); - }); - } else { - callback(gadgetLocation); - } -} \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/number-chart-api.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/number-chart-api.js deleted file mode 100644 index ef2c5da98..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/js/core/number-chart-api.js +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getConfig, validate, isProviderRequired, draw, update; - -(function() { - - var CHART_LOCATION = '/extensions/chart-templates/'; - - /** - * return the config to be populated in the chart configuration UI - * @param schema - */ - getConfig = function(schema) { - var chartConf = require(CHART_LOCATION + '/number-chart/config.json').config; - /* - dynamic logic goes here - */ - return chartConf; - - }; - - /** - * validate the user inout for the chart configurationx - * @param chartConfig - */ - validate = function(chartConfig) { - return true; - }; - - /** - * TO be used when provider configuration steps need to be skipped - */ - isProviderRequired = function() { - - } - - - /** - * return the gadget content - * @param chartConfig - * @param schema - * @param data - */ - draw = function(placeholder, chartConfig, _schema, data) { - var schema = toVizGrammarSchema(_schema); - var view = { - id: "chart-0", - schema: schema, - chartConfig: buildChartConfig(chartConfig), - data: function() { - if(data) { - var result = []; - console.log(data); - data.forEach(function(item) { - var row = []; - schema[0].metadata.names.forEach(function(name) { - row.push(item[name]); - }); - result.push(row); - }); - console.log(result); - wso2gadgets.onDataReady(result); - } - } - - }; - - try { - wso2gadgets.init(placeholder, view); - var view = wso2gadgets.load("chart-0"); - } catch (e) { - console.error(e); - } - - }; - - /** - * - * @param data - */ - update = function(data) { - wso2gadgets.onDataReady(data,"append"); - } - - buildChartConfig = function (_chartConfig) { - var conf = {}; - conf.x = _chartConfig.x; - conf.maxLength = _chartConfig.maxLength; - conf.charts = []; - conf.charts[0] = { - type : "number", - title : _chartConfig.title - }; - return conf; - }; - - -}()); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/thumbnail.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/thumbnail.png deleted file mode 100644 index 8b3f43540..000000000 Binary files a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/PROXIMITY/thumbnail.png and /dev/null differ diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/artifact.xml deleted file mode 100644 index 50d606102..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_gadget/artifact.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - PROXIMITY - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_ui_event_publisher/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_ui_event_publisher/artifact.xml deleted file mode 100644 index dbdeeb073..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_ui_event_publisher/artifact.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - org.wso2.iot.android.proximity.ui.publisher.xml - - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_ui_event_publisher/org.wso2.iot.android.proximity.ui.publisher.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_ui_event_publisher/org.wso2.iot.android.proximity.ui.publisher.xml deleted file mode 100644 index 4d689764f..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_ui_event_publisher/org.wso2.iot.android.proximity.ui.publisher.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/conf.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/conf.json deleted file mode 100644 index 254c66d67..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/conf.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "provider-conf": { - "streamName": "org.wso2.iot.android.battery:1.0.0", - "provider-name": "realtime" - }, - "chart-conf": { - "key": "timestamp", - "color": "status", - "grid": "on", - "maxLength": "15", - "gadget-name": "Android Realtime Battery", - "chart-name": "table-chart" - } -} \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/css/dataTables.bootstrap.min.css b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/css/dataTables.bootstrap.min.css deleted file mode 100644 index 745f2996f..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/css/dataTables.bootstrap.min.css +++ /dev/null @@ -1 +0,0 @@ -table.dataTable{clear:both;margin-top:6px !important;margin-bottom:6px !important;max-width:none !important}table.dataTable td,table.dataTable th{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}table.dataTable td.dataTables_empty,table.dataTable th.dataTables_empty{text-align:center}table.dataTable.nowrap th,table.dataTable.nowrap td{white-space:nowrap}div.dataTables_wrapper div.dataTables_length label{font-weight:normal;text-align:left;white-space:nowrap}div.dataTables_wrapper div.dataTables_length select{width:75px;display:inline-block}div.dataTables_wrapper div.dataTables_filter{text-align:right}div.dataTables_wrapper div.dataTables_filter label{font-weight:normal;white-space:nowrap;text-align:left}div.dataTables_wrapper div.dataTables_filter input{margin-left:0.5em;display:inline-block;width:auto}div.dataTables_wrapper div.dataTables_info{padding-top:8px;white-space:nowrap}div.dataTables_wrapper div.dataTables_paginate{margin:0;white-space:nowrap;text-align:right}div.dataTables_wrapper div.dataTables_paginate ul.pagination{margin:2px 0;white-space:nowrap}div.dataTables_wrapper div.dataTables_processing{position:absolute;top:50%;left:50%;width:200px;margin-left:-100px;margin-top:-26px;text-align:center;padding:1em 0}table.dataTable thead>tr>th.sorting_asc,table.dataTable thead>tr>th.sorting_desc,table.dataTable thead>tr>th.sorting,table.dataTable thead>tr>td.sorting_asc,table.dataTable thead>tr>td.sorting_desc,table.dataTable thead>tr>td.sorting{padding-right:30px}table.dataTable thead>tr>th:active,table.dataTable thead>tr>td:active{outline:none}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,table.dataTable thead .sorting_asc_disabled:after,table.dataTable thead .sorting_desc_disabled:after{position:absolute;bottom:8px;right:8px;display:block;font-family:'Glyphicons Halflings';opacity:0.5}table.dataTable thead .sorting:after{opacity:0.2;content:"\e150"}table.dataTable thead .sorting_asc:after{content:"\e155"}table.dataTable thead .sorting_desc:after{content:"\e156"}table.dataTable thead .sorting_asc_disabled:after,table.dataTable thead .sorting_desc_disabled:after{color:#eee}div.dataTables_scrollHead table.dataTable{margin-bottom:0 !important}div.dataTables_scrollBody table{border-top:none;margin-top:0 !important;margin-bottom:0 !important}div.dataTables_scrollBody table thead .sorting:after,div.dataTables_scrollBody table thead .sorting_asc:after,div.dataTables_scrollBody table thead .sorting_desc:after{display:none}div.dataTables_scrollBody table tbody tr:first-child th,div.dataTables_scrollBody table tbody tr:first-child td{border-top:none}div.dataTables_scrollFoot table{margin-top:0 !important;border-top:none}@media screen and (max-width: 767px){div.dataTables_wrapper div.dataTables_length,div.dataTables_wrapper div.dataTables_filter,div.dataTables_wrapper div.dataTables_info,div.dataTables_wrapper div.dataTables_paginate{text-align:center}}table.dataTable.table-condensed>thead>tr>th{padding-right:20px}table.dataTable.table-condensed .sorting:after,table.dataTable.table-condensed .sorting_asc:after,table.dataTable.table-condensed .sorting_desc:after{top:6px;right:6px}table.table-bordered.dataTable{border-collapse:separate !important}table.table-bordered.dataTable th,table.table-bordered.dataTable td{border-left-width:0}table.table-bordered.dataTable th:last-child,table.table-bordered.dataTable th:last-child,table.table-bordered.dataTable td:last-child,table.table-bordered.dataTable td:last-child{border-right-width:0}table.table-bordered.dataTable tbody th,table.table-bordered.dataTable tbody td{border-bottom-width:0}div.dataTables_scrollHead table.table-bordered{border-bottom-width:0}div.table-responsive>div.dataTables_wrapper>div.row{margin:0}div.table-responsive>div.dataTables_wrapper>div.row>div[class^="col-"]:first-child{padding-left:0}div.table-responsive>div.dataTables_wrapper>div.row>div[class^="col-"]:last-child{padding-right:0} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/gadget-controller.jag b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/gadget-controller.jag deleted file mode 100644 index f84538a40..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/gadget-controller.jag +++ /dev/null @@ -1,42 +0,0 @@ -<% -/** - * 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. - * - */ -(function () { - - response.contentType = 'application/json'; - var PROVIDER_CONF = 'provider-conf'; - var PROVIDER_NAME = 'provider-name'; - - var action = request.getParameter("action"); - var data = request.getContent(); - var providerConf = data[PROVIDER_CONF]; - var providerAPI = require('js/core/' + providerConf[PROVIDER_NAME] + '-provider-api.js'); - - if (action === 'getSchema') { - print(providerAPI.getSchema(providerConf)); - return; - } else if(action === 'getData'){ - print(providerAPI.getData(providerConf)); - return; - } - -}()); - - -%> diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/gadget.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/gadget.json deleted file mode 100644 index 19f480e19..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/gadget.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "Android_Realtime_Battery", - "title": "Android Realtime Battery", - "type": "gadget", - "thumbnail": "gadget/Android_Realtime_Battery/thumbnail.png", - "data": { - "url": "gadget/Android_Realtime_Battery/gadget.xml" - } -} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/gadget.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/gadget.xml deleted file mode 100644 index 334d78791..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/gadget.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - ]]> -
-
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/gadget-core.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/gadget-core.js deleted file mode 100644 index 2b1e3f717..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/gadget-core.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. -*/ -$(function () { - var gadgetLocation; - var conf; - var schema; - var pref = new gadgets.Prefs(); - - var CHART_CONF = 'chart-conf'; - var PROVIDER_CONF = 'provider-conf'; - -var init = function () { - $.ajax({ - url: gadgetLocation + '/conf.json', - method: "GET", - contentType: "application/json", - async: false, - success: function (data) { - conf = JSON.parse(data); - $.ajax({ - url: gadgetLocation + '/gadget-controller.jag?action=getSchema', - method: "POST", - data: JSON.stringify(conf), - contentType: "application/json", - async: false, - success: function (data) { - schema = data; - } - }); - - } - }); -}; - - -var drawGadget = function (){ - draw('#canvas', conf[CHART_CONF], schema, null); - registerCallBackforPush(conf[PROVIDER_CONF], schema, function(providerData) { - update(providerData); - }); - -}; - -getGadgetLocation(function (gadget_Location) { - gadgetLocation = gadget_Location; - init(); - drawGadget(); -}); -}); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/gadget-util.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/gadget-util.js deleted file mode 100644 index 3ef89ba43..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/gadget-util.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getGadgetLocation = function (callback) { - var gadgetLocation = "/portal/store/carbon.super/fs/gadget/Android_Realtime_Battery"; - var PATH_SEPERATOR = "/"; - if (gadgetLocation.search("store") != -1) { - wso2.gadgets.identity.getTenantDomain(function (tenantDomain) { - var gadgetPath = gadgetLocation.split(PATH_SEPERATOR); - var modifiedPath = ''; - for (var i = 1; i < gadgetPath.length; i++) { - if (i === 3) { - modifiedPath = modifiedPath.concat(PATH_SEPERATOR, tenantDomain); - } else { - modifiedPath = modifiedPath.concat(PATH_SEPERATOR, gadgetPath[i]) - } - } - callback(modifiedPath); - }); - } else { - callback(gadgetLocation); - } -}; \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/provider-client.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/provider-client.js deleted file mode 100644 index 6196677f6..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/provider-client.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -// var registerCallBackforPush; - -(function() { - - var callback; - - /** - * TODO Need to read hostname,port, and tenantId from providerConfig - * @param providerConfig - * @param schema - */ - registerCallBackforPush = function(providerConfig, schema, _callback) { - var streamId = providerConfig['streamName']; - var hostname = window.parent.location.hostname; - var port = window.parent.location.port; - - subscribe(streamId.split(":")[0], streamId.split(":")[1], - '10', - onData, onError, - hostname, - port, - 'WEBSOCKET' - ); - callback = _callback; - }; - - function onData(streamId, data) { - callback(data); - }; - - function onError(error) { - console.error(error); - }; - -}()); - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/realtime-provider-api.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/realtime-provider-api.js deleted file mode 100644 index 7cf59af77..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/realtime-provider-api.js +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; - -(function() { - - var PROVIDERS_LOCATION = '/extensions/providers/'; - var PROVIDER_NAME = 'realtime'; - - var log = new Log(); - var utils = require('/modules/utils.js'); - var carbon = require("carbon"); - var EventPublisherConstants = Packages.org.wso2.carbon.event.publisher.core.config.EventPublisherConstants; - var eventPublisherService = carbon.server.osgiService('org.wso2.carbon.event.publisher.core.EventPublisherService'); - var eventStreamService = carbon.server.osgiService('org.wso2.carbon.event.stream.core.EventStreamService'); - - var typeMap = { - "bool": "string", - "boolean": "string", - "string": "string", - "int": "number", - "integer": "number", - "long": "number", - "double": "number", - "float": "number", - "time": "time" - }; - - getConfig = function() { - var formConfig = require(PROVIDERS_LOCATION + '/' + PROVIDER_NAME + '/config.json'); - var datasources = []; - try { - var eventPublisherConfigurationList = eventPublisherService.getAllActiveEventPublisherConfigurations(); - for (var i = 0; i < eventPublisherConfigurationList.size(); i++) { - var eventPublisherConfiguration = eventPublisherService.getActiveEventPublisherConfiguration( - eventPublisherConfigurationList.get(i).getEventPublisherName());; - - var mappingTypeIsWso2 = eventPublisherConfiguration.getOutputMapping() - .getMappingType().equals(EventPublisherConstants.EF_WSO2EVENT_MAPPING_TYPE); - - var adapterType = null; - if (eventPublisherConfiguration.getToAdapterConfiguration() != null) { - adapterType = eventPublisherConfiguration.getToAdapterConfiguration().getType(); - } - if (mappingTypeIsWso2 && adapterType.trim() == "ui") { - var streamName = eventPublisherConfiguration.getFromStreamName(); - var streamVersion = eventPublisherConfiguration.getFromStreamVersion(); - var streamId = streamName + ":" + streamVersion; - datasources.push(streamId); - } - } - var datasourceCfg = { - "fieldLabel": "Event Stream", - "fieldName": "streamName", - "fieldType": "dropDown" - }; - datasourceCfg['valueSet'] = datasources; - } catch (e) { - log.error(e); - } - formConfig.config.push(datasourceCfg); - return formConfig; - }; - - /** - * validate the user input of provider configuration - * @param providerConfig - */ - validate = function(providerConfig) { - /* - validate the form and return - - */ - return true; - }; - - /** - * returns the data mode either push or pull - */ - getMode = function() { - return 'push'; - }; - - /** - * returns an array of column names & types - * @param providerConfig - */ - getSchema = function(providerConfig) { - var streamId = providerConfig["streamName"]; - var output = []; - - output.push({ - fieldName: "TIMESTAMP", - fieldType: "time" - }); - - if (eventStreamService != null) { - var eventStreamConfiguration = eventStreamService.getEventStreamConfiguration(streamId); - if (eventStreamConfiguration != null) { - var metaData = eventStreamConfiguration.getStreamDefinition().getMetaData(); - var correlationData = eventStreamConfiguration.getStreamDefinition().getCorrelationData(); - var payloadData = eventStreamConfiguration.getStreamDefinition().getPayloadData(); - if (metaData != null) { - for (var i = 0; i < metaData.size(); i++) { - var type = metaData.get(i).getType().toString().toLowerCase(); - output.push({ - fieldName: metaData.get(i).getName(), - fieldType: typeMap[type.toLowerCase()] - }); - } - } - if (correlationData != null) { - for (var i = 0; i < correlationData.size(); i++) { - var type = correlationData.get(i).getType().toString().toLowerCase(); - output.push({ - fieldName: correlationData.get(i).getName(), - fieldType: typeMap[type.toLowerCase()] - }); - } - } - if (payloadData != null) { - for (var i = 0; i < payloadData.size(); i++) { - var type = payloadData.get(i).getType().toString().toLowerCase(); - output.push({ - fieldName: payloadData.get(i).getName(), - fieldType: typeMap[type.toLowerCase()] - }); - } - } - } - } - return output; - }; - - getData = function(providerConfig,limit) { - var data = []; - return data; - }; - - -}()); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/table-chart-api.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/table-chart-api.js deleted file mode 100644 index a71cd548b..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/core/table-chart-api.js +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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. - */ -var getConfig, validate, isProviderRequired, draw, update; - -(function () { - - var CHART_LOCATION = '/extensions/chart-templates/'; - - var tableFieldsOrder = ['timestamp', 'level', 'status', 'state', 'temperature']; - - /** - * return the config to be populated in the chart configuration UI - * @param schema - */ - getConfig = function (schema) { - var chartConf = require(CHART_LOCATION + '/table-chart/config.json').config; - /* - dynamic logic goes here - */ - - var columns = []; - - columns.push("None"); - columns.push("All"); - for (var i = 0; i < schema.length; i++) { - columns.push(schema[i]["fieldName"]); - } - - for (var i = 0; i < chartConf.length; i++) { - if (chartConf[i]["fieldName"] == "color") { - chartConf[i]["valueSet"] = columns; - break; - } - } - - return chartConf; - }; - - /** - * validate the user inout for the chart configuration - * @param chartConfig - */ - validate = function (chartConfig) { - return true; - }; - - /** - * TO be used when provider configuration steps need to be skipped - */ - isProviderRequired = function () { - - } - - - /** - * return the gadget content - * @param chartConfig - * @param schema - * @param data - */ - draw = function (placeholder, chartConfig, _schema, data) { - var schema = toVizGrammarSchema(_schema); - var grid = chartConfig.grid; - var columns = []; - - for (var i = 0; i < _schema.length; i++) { - columns.push(_schema[i]["fieldName"]); - } - // console.log(schema); - chartConfig.columns = tableFieldsOrder; - - - var view = { - id: "chart-0", - schema: schema, - chartConfig: buildChartConfig(chartConfig), - data: function () { - if (data) { - var result = []; - data.forEach(function (item) { - var row = []; - schema[0].metadata.names.forEach(function (name) { - row.push(item[name]); - }); - result.push(row); - }); - wso2gadgets.onDataReady(result); - } - } - - }; - - try { - wso2gadgets.init(placeholder, view); - var view = wso2gadgets.load("chart-0"); - if (grid) { - $(document).ready(function () { - $('#table').DataTable(); - }); - } - } catch (e) { - console.error(e); - } - - }; - - /** - * - * @param data - */ - update = function (data) { - //Change the timestamp field in Datetime format. - data[0][3] = getDateString(data[0][3]); - wso2gadgets.onDataReady(data, "append"); - }; - - buildChartConfig = function (_chartConfig) { - var conf = {}; - conf.charts = []; - conf.charts[0] = { - type: "table", - key: _chartConfig.key, - grid: _chartConfig.grid - }; - conf.maxLength = _chartConfig.maxLength; - - if (_chartConfig.color == "All") { - conf.charts[0].color = "*"; - } else if (_chartConfig.color != "None") { - conf.charts[0].color = _chartConfig.color; - } - - conf.charts[0].columns = _chartConfig.columns; - conf.columnTitles = ['Time', 'Remaining Charge','Health', 'State', 'Temperature']; - return conf; - }; - - -}()); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/jquery.dataTables.min.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/jquery.dataTables.min.js deleted file mode 100644 index d87780456..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/jquery.dataTables.min.js +++ /dev/null @@ -1,164 +0,0 @@ -/*! - DataTables 1.10.10 - ©2008-2015 SpryMedia Ltd - datatables.net/license -*/ -(function(h){"function"===typeof define&&define.amd?define(["jquery"],function(E){return h(E,window,document)}):"object"===typeof exports?module.exports=function(E,H){E||(E=window);H||(H="undefined"!==typeof window?require("jquery"):require("jquery")(E));return h(H,E,E.document)}:h(jQuery,window,document)})(function(h,E,H,k){function Y(a){var b,c,d={};h.each(a,function(e){if((b=e.match(/^([^A-Z]+?)([A-Z])/))&&-1!=="a aa ai ao as b fn i m o s ".indexOf(b[1]+" "))c=e.replace(b[0],b[2].toLowerCase()), -d[c]=e,"o"===b[1]&&Y(a[e])});a._hungarianMap=d}function J(a,b,c){a._hungarianMap||Y(a);var d;h.each(b,function(e){d=a._hungarianMap[e];if(d!==k&&(c||b[d]===k))"o"===d.charAt(0)?(b[d]||(b[d]={}),h.extend(!0,b[d],b[e]),J(a[d],b[d],c)):b[d]=b[e]})}function Fa(a){var b=m.defaults.oLanguage,c=a.sZeroRecords;!a.sEmptyTable&&(c&&"No data available in table"===b.sEmptyTable)&&F(a,a,"sZeroRecords","sEmptyTable");!a.sLoadingRecords&&(c&&"Loading..."===b.sLoadingRecords)&&F(a,a,"sZeroRecords","sLoadingRecords"); -a.sInfoThousands&&(a.sThousands=a.sInfoThousands);(a=a.sDecimal)&&db(a)}function eb(a){A(a,"ordering","bSort");A(a,"orderMulti","bSortMulti");A(a,"orderClasses","bSortClasses");A(a,"orderCellsTop","bSortCellsTop");A(a,"order","aaSorting");A(a,"orderFixed","aaSortingFixed");A(a,"paging","bPaginate");A(a,"pagingType","sPaginationType");A(a,"pageLength","iDisplayLength");A(a,"searching","bFilter");"boolean"===typeof a.sScrollX&&(a.sScrollX=a.sScrollX?"100%":"");"boolean"===typeof a.scrollX&&(a.scrollX= -a.scrollX?"100%":"");if(a=a.aoSearchCols)for(var b=0,c=a.length;b").css({position:"fixed",top:0,left:0,height:1,width:1,overflow:"hidden"}).append(h("
").css({position:"absolute",top:1,left:1, -width:100,overflow:"scroll"}).append(h("
").css({width:"100%",height:10}))).appendTo("body"),d=c.children(),e=d.children();b.barWidth=d[0].offsetWidth-d[0].clientWidth;b.bScrollOversize=100===e[0].offsetWidth&&100!==d[0].clientWidth;b.bScrollbarLeft=1!==Math.round(e.offset().left);b.bBounding=c[0].getBoundingClientRect().width?!0:!1;c.remove()}h.extend(a.oBrowser,m.__browser);a.oScroll.iBarWidth=m.__browser.barWidth}function hb(a,b,c,d,e,f){var g,j=!1;c!==k&&(g=c,j=!0);for(;d!==e;)a.hasOwnProperty(d)&& -(g=j?b(g,a[d],d,a):a[d],j=!0,d+=f);return g}function Ga(a,b){var c=m.defaults.column,d=a.aoColumns.length,c=h.extend({},m.models.oColumn,c,{nTh:b?b:H.createElement("th"),sTitle:c.sTitle?c.sTitle:b?b.innerHTML:"",aDataSort:c.aDataSort?c.aDataSort:[d],mData:c.mData?c.mData:d,idx:d});a.aoColumns.push(c);c=a.aoPreSearchCols;c[d]=h.extend({},m.models.oSearch,c[d]);la(a,d,h(b).data())}function la(a,b,c){var b=a.aoColumns[b],d=a.oClasses,e=h(b.nTh);if(!b.sWidthOrig){b.sWidthOrig=e.attr("width")||null;var f= -(e.attr("style")||"").match(/width:\s*(\d+[pxem%]+)/);f&&(b.sWidthOrig=f[1])}c!==k&&null!==c&&(fb(c),J(m.defaults.column,c),c.mDataProp!==k&&!c.mData&&(c.mData=c.mDataProp),c.sType&&(b._sManualType=c.sType),c.className&&!c.sClass&&(c.sClass=c.className),h.extend(b,c),F(b,c,"sWidth","sWidthOrig"),c.iDataSort!==k&&(b.aDataSort=[c.iDataSort]),F(b,c,"aDataSort"));var g=b.mData,j=Q(g),i=b.mRender?Q(b.mRender):null,c=function(a){return"string"===typeof a&&-1!==a.indexOf("@")};b._bAttrSrc=h.isPlainObject(g)&& -(c(g.sort)||c(g.type)||c(g.filter));b.fnGetData=function(a,b,c){var d=j(a,b,k,c);return i&&b?i(d,b,a,c):d};b.fnSetData=function(a,b,c){return R(g)(a,b,c)};"number"!==typeof g&&(a._rowReadObject=!0);a.oFeatures.bSort||(b.bSortable=!1,e.addClass(d.sSortableNone));a=-1!==h.inArray("asc",b.asSorting);c=-1!==h.inArray("desc",b.asSorting);!b.bSortable||!a&&!c?(b.sSortingClass=d.sSortableNone,b.sSortingClassJUI=""):a&&!c?(b.sSortingClass=d.sSortableAsc,b.sSortingClassJUI=d.sSortJUIAscAllowed):!a&&c?(b.sSortingClass= -d.sSortableDesc,b.sSortingClassJUI=d.sSortJUIDescAllowed):(b.sSortingClass=d.sSortable,b.sSortingClassJUI=d.sSortJUI)}function U(a){if(!1!==a.oFeatures.bAutoWidth){var b=a.aoColumns;Ha(a);for(var c=0,d=b.length;cq[f])d(l.length+q[f],o);else if("string"===typeof q[f]){j=0;for(i=l.length;jb&&a[e]--; -1!=d&&c===k&&a.splice(d,1)}function ea(a,b,c,d){var e=a.aoData[b],f,g=function(c,d){for(;c.childNodes.length;)c.removeChild(c.firstChild);c.innerHTML=B(a,b,d,"display")};if("dom"===c||(!c||"auto"===c)&&"dom"===e.src)e._aData= -Ka(a,e,d,d===k?k:e._aData).data;else{var j=e.anCells;if(j)if(d!==k)g(j[d],d);else{c=0;for(f=j.length;c").appendTo(g));b=0;for(c=l.length;btr").attr("role","row");h(g).find(">tr>th, >tr>td").addClass(o.sHeaderTH);h(j).find(">tr>th, >tr>td").addClass(o.sFooterTH);if(null!==j){a=a.aoFooter[0];b=0;for(c=a.length;b=a.fnRecordsDisplay()?0:g,a.iInitDisplayStart=-1);var g=a._iDisplayStart,o=a.fnDisplayEnd();if(a.bDeferLoading)a.bDeferLoading=!1,a.iDraw++,C(a,!1);else if(j){if(!a.bDestroying&& -!lb(a))return}else a.iDraw++;if(0!==i.length){f=j?a.aoData.length:o;for(j=j?0:g;j",{"class":e?d[0]:""}).append(h("",{valign:"top",colSpan:ca(a), -"class":a.oClasses.sRowEmpty}).html(c))[0];v(a,"aoHeaderCallback","header",[h(a.nTHead).children("tr")[0],Ma(a),g,o,i]);v(a,"aoFooterCallback","footer",[h(a.nTFoot).children("tr")[0],Ma(a),g,o,i]);d=h(a.nTBody);d.children().detach();d.append(h(b));v(a,"aoDrawCallback","draw",[a]);a.bSorted=!1;a.bFiltered=!1;a.bDrawing=!1}}function T(a,b){var c=a.oFeatures,d=c.bFilter;c.bSort&&mb(a);d?ha(a,a.oPreviousSearch):a.aiDisplay=a.aiDisplayMaster.slice();!0!==b&&(a._iDisplayStart=0);a._drawHold=b;O(a);a._drawHold= -!1}function nb(a){var b=a.oClasses,c=h(a.nTable),c=h("
").insertBefore(c),d=a.oFeatures,e=h("
",{id:a.sTableId+"_wrapper","class":b.sWrapper+(a.nTFoot?"":" "+b.sNoFooter)});a.nHolding=c[0];a.nTableWrapper=e[0];a.nTableReinsertBefore=a.nTable.nextSibling;for(var f=a.sDom.split(""),g,j,i,o,l,q,u=0;u")[0];o=f[u+1];if("'"==o||'"'==o){l="";for(q=2;f[u+q]!=o;)l+=f[u+q],q++;"H"==l?l=b.sJUIHeader:"F"==l&&(l=b.sJUIFooter);-1!=l.indexOf(".")?(o=l.split("."), -i.id=o[0].substr(1,o[0].length-1),i.className=o[1]):"#"==l.charAt(0)?i.id=l.substr(1,l.length-1):i.className=l;u+=q}e.append(i);e=h(i)}else if(">"==j)e=e.parent();else if("l"==j&&d.bPaginate&&d.bLengthChange)g=ob(a);else if("f"==j&&d.bFilter)g=pb(a);else if("r"==j&&d.bProcessing)g=qb(a);else if("t"==j)g=rb(a);else if("i"==j&&d.bInfo)g=sb(a);else if("p"==j&&d.bPaginate)g=tb(a);else if(0!==m.ext.feature.length){i=m.ext.feature;q=0;for(o=i.length;q',j=d.sSearch,j=j.match(/_INPUT_/)?j.replace("_INPUT_",g):j+g,b=h("
",{id:!f.f?c+"_filter":null,"class":b.sFilter}).append(h("
").addClass(b.sLength); -a.aanFeatures.l||(i[0].id=c+"_length");i.children().append(a.oLanguage.sLengthMenu.replace("_MENU_",e[0].outerHTML));h("select",i).val(a._iDisplayLength).bind("change.DT",function(){Ra(a,h(this).val());O(a)});h(a.nTable).bind("length.dt.DT",function(b,c,d){a===c&&h("select",i).val(d)});return i[0]}function tb(a){var b=a.sPaginationType,c=m.ext.pager[b],d="function"===typeof c,e=function(a){O(a)},b=h("
").addClass(a.oClasses.sPaging+b)[0],f=a.aanFeatures;d||c.fnInit(a,b,e);f.p||(b.id=a.sTableId+ -"_paginate",a.aoDrawCallback.push({fn:function(a){if(d){var b=a._iDisplayStart,i=a._iDisplayLength,h=a.fnRecordsDisplay(),l=-1===i,b=l?0:Math.ceil(b/i),i=l?1:Math.ceil(h/i),h=c(b,i),k,l=0;for(k=f.p.length;lf&&(d=0)):"first"==b?d=0:"previous"==b?(d=0<=e?d-e:0,0>d&&(d=0)):"next"== -b?d+e",{id:!a.aanFeatures.r?a.sTableId+"_processing":null,"class":a.oClasses.sProcessing}).html(a.oLanguage.sProcessing).insertBefore(a.nTable)[0]}function C(a,b){a.oFeatures.bProcessing&&h(a.aanFeatures.r).css("display",b?"block":"none");v(a,null,"processing",[a,b])}function rb(a){var b=h(a.nTable);b.attr("role", -"grid");var c=a.oScroll;if(""===c.sX&&""===c.sY)return a.nTable;var d=c.sX,e=c.sY,f=a.oClasses,g=b.children("caption"),j=g.length?g[0]._captionSide:null,i=h(b[0].cloneNode(!1)),o=h(b[0].cloneNode(!1)),l=b.children("tfoot");l.length||(l=null);i=h("
",{"class":f.sScrollWrapper}).append(h("
",{"class":f.sScrollHead}).css({overflow:"hidden",position:"relative",border:0,width:d?!d?null:w(d):"100%"}).append(h("
",{"class":f.sScrollHeadInner}).css({"box-sizing":"content-box",width:c.sXInner|| -"100%"}).append(i.removeAttr("id").css("margin-left",0).append("top"===j?g:null).append(b.children("thead"))))).append(h("
",{"class":f.sScrollBody}).css({position:"relative",overflow:"auto",width:!d?null:w(d)}).append(b));l&&i.append(h("
",{"class":f.sScrollFoot}).css({overflow:"hidden",border:0,width:d?!d?null:w(d):"100%"}).append(h("
",{"class":f.sScrollFootInner}).append(o.removeAttr("id").css("margin-left",0).append("bottom"===j?g:null).append(b.children("tfoot")))));var b=i.children(), -k=b[0],f=b[1],u=l?b[2]:null;if(d)h(f).on("scroll.DT",function(){var a=this.scrollLeft;k.scrollLeft=a;l&&(u.scrollLeft=a)});h(f).css(e&&c.bCollapse?"max-height":"height",e);a.nScrollHead=k;a.nScrollBody=f;a.nScrollFoot=u;a.aoDrawCallback.push({fn:Z,sName:"scrolling"});return i[0]}function Z(a){var b=a.oScroll,c=b.sX,d=b.sXInner,e=b.sY,b=b.iBarWidth,f=h(a.nScrollHead),g=f[0].style,j=f.children("div"),i=j[0].style,o=j.children("table"),j=a.nScrollBody,l=h(j),q=j.style,u=h(a.nScrollFoot).children("div"), -m=u.children("table"),n=h(a.nTHead),p=h(a.nTable),t=p[0],v=t.style,r=a.nTFoot?h(a.nTFoot):null,Eb=a.oBrowser,Ua=Eb.bScrollOversize,s,L,P,x,y=[],z=[],A=[],B,C=function(a){a=a.style;a.paddingTop="0";a.paddingBottom="0";a.borderTopWidth="0";a.borderBottomWidth="0";a.height=0};L=j.scrollHeight>j.clientHeight;if(a.scrollBarVis!==L&&a.scrollBarVis!==k)a.scrollBarVis=L,U(a);else{a.scrollBarVis=L;p.children("thead, tfoot").remove();x=n.clone().prependTo(p);n=n.find("tr");L=x.find("tr");x.find("th, td").removeAttr("tabindex"); -r&&(P=r.clone().prependTo(p),s=r.find("tr"),P=P.find("tr"));c||(q.width="100%",f[0].style.width="100%");h.each(qa(a,x),function(b,c){B=$(a,b);c.style.width=a.aoColumns[B].sWidth});r&&I(function(a){a.style.width=""},P);f=p.outerWidth();if(""===c){v.width="100%";if(Ua&&(p.find("tbody").height()>j.offsetHeight||"scroll"==l.css("overflow-y")))v.width=w(p.outerWidth()-b);f=p.outerWidth()}else""!==d&&(v.width=w(d),f=p.outerWidth());I(C,L);I(function(a){A.push(a.innerHTML);y.push(w(h(a).css("width")))}, -L);I(function(a,b){a.style.width=y[b]},n);h(L).height(0);r&&(I(C,P),I(function(a){z.push(w(h(a).css("width")))},P),I(function(a,b){a.style.width=z[b]},s),h(P).height(0));I(function(a,b){a.innerHTML='
'+A[b]+"
";a.style.width=y[b]},L);r&&I(function(a,b){a.innerHTML="";a.style.width=z[b]},P);if(p.outerWidth()j.offsetHeight||"scroll"==l.css("overflow-y")?f+b:f;if(Ua&&(j.scrollHeight>j.offsetHeight||"scroll"==l.css("overflow-y")))v.width= -w(s-b);(""===c||""!==d)&&K(a,1,"Possible column misalignment",6)}else s="100%";q.width=w(s);g.width=w(s);r&&(a.nScrollFoot.style.width=w(s));!e&&Ua&&(q.height=w(t.offsetHeight+b));c=p.outerWidth();o[0].style.width=w(c);i.width=w(c);d=p.height()>j.clientHeight||"scroll"==l.css("overflow-y");e="padding"+(Eb.bScrollbarLeft?"Left":"Right");i[e]=d?b+"px":"0px";r&&(m[0].style.width=w(c),u[0].style.width=w(c),u[0].style[e]=d?b+"px":"0px");l.scroll();if((a.bSorted||a.bFiltered)&&!a._drawHold)j.scrollTop= -0}}function I(a,b,c){for(var d=0,e=0,f=b.length,g,j;e").appendTo(j.find("tbody"));j.find("thead, tfoot").remove();j.append(h(a.nTHead).clone()).append(h(a.nTFoot).clone());j.find("tfoot th, tfoot td").css("width","");o=qa(a,j.find("thead")[0]);for(m=0;m").css({width:n.sWidthOrig,margin:0,padding:0,border:0,height:1}));if(a.aoData.length)for(m=0;m").css(f||e?{position:"absolute",top:0,left:0,height:1,right:0,overflow:"hidden"}:{}).append(j).appendTo(k);f&&g?j.width(g):f?(j.css("width","auto"),j.removeAttr("width"),j.width()").css("width",w(a)).appendTo(b||H.body),d=c[0].offsetWidth;c.remove();return d}function Gb(a,b){var c=Hb(a,b);if(0>c)return null;var d=a.aoData[c];return!d.nTr?h("").html(B(a,c,b,"display"))[0]:d.anCells[b]}function Hb(a,b){for(var c,d=-1,e=-1,f=0,g=a.aoData.length;fd&&(d=c.length,e=f);return e}function w(a){return null=== -a?"0px":"number"==typeof a?0>a?"0px":a+"px":a.match(/\d$/)?a+"px":a}function W(a){var b,c,d=[],e=a.aoColumns,f,g,j,i;b=a.aaSortingFixed;c=h.isPlainObject(b);var o=[];f=function(a){a.length&&!h.isArray(a[0])?o.push(a):h.merge(o,a)};h.isArray(b)&&f(b);c&&b.pre&&f(b.pre);f(a.aaSorting);c&&b.post&&f(b.post);for(a=0;ae?1:0,0!==c)return"asc"===j.dir?c:-c;c=d[a];e=d[b]; -return ce?1:0}):i.sort(function(a,b){var c,g,j,i,k=h.length,m=f[a]._aSortData,p=f[b]._aSortData;for(j=0;jg?1:0})}a.bSorted=!0}function Jb(a){for(var b,c,d=a.aoColumns,e=W(a),a=a.oLanguage.oAria,f=0,g=d.length;f/g,"");var i=c.nTh;i.removeAttribute("aria-sort");c.bSortable&&(0e?e+1:3));e=0;for(f=d.length;ee?e+1:3))}a.aLastSort=d}function Ib(a,b){var c=a.aoColumns[b],d=m.ext.order[c.sSortDataType],e;d&&(e=d.call(a.oInstance,a,b,ba(a,b)));for(var f,g=m.ext.type.order[c.sType+"-pre"],j=0,i=a.aoData.length;j=d.length?[0,c[1]]:c)}));e.search!==k&&h.extend(a.oPreviousSearch,Bb(e.search));b=0;for(c=e.columns.length;b=c&&(b=c-d);b-=b%d;if(-1===d||0>b)b=0;a._iDisplayStart=b}function Pa(a,b){var c= -a.renderer,d=m.ext.renderer[b];return h.isPlainObject(c)&&c[b]?d[c[b]]||d._:"string"===typeof c?d[c]||d._:d._}function y(a){return a.oFeatures.bServerSide?"ssp":a.ajax||a.sAjaxSource?"ajax":"dom"}function Aa(a,b){var c=[],c=Mb.numbers_length,d=Math.floor(c/2);b<=c?c=X(0,b):a<=d?(c=X(0,c-2),c.push("ellipsis"),c.push(b-1)):(a>=b-1-d?c=X(b-(c-2),b):(c=X(a-d+2,a+d-1),c.push("ellipsis"),c.push(b-1)),c.splice(0,0,"ellipsis"),c.splice(0,0,0));c.DT_el="span";return c}function db(a){h.each({num:function(b){return Ba(b, -a)},"num-fmt":function(b){return Ba(b,a,Xa)},"html-num":function(b){return Ba(b,a,Ca)},"html-num-fmt":function(b){return Ba(b,a,Ca,Xa)}},function(b,c){s.type.order[b+a+"-pre"]=c;b.match(/^html\-/)&&(s.type.search[b+a]=s.type.search.html)})}function Nb(a){return function(){var b=[za(this[m.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return m.ext.internal[a].apply(this,b)}}var m,s,t,p,r,Ya={},Ob=/[\r\n]/g,Ca=/<.*?>/g,ac=/^[\w\+\-]/,bc=/[\w\+\-]$/,Yb=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^|\\-)", -"g"),Xa=/[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi,M=function(a){return!a||!0===a||"-"===a?!0:!1},Pb=function(a){var b=parseInt(a,10);return!isNaN(b)&&isFinite(a)?b:null},Qb=function(a,b){Ya[b]||(Ya[b]=RegExp(va(b),"g"));return"string"===typeof a&&"."!==b?a.replace(/\./g,"").replace(Ya[b],"."):a},Za=function(a,b,c){var d="string"===typeof a;if(M(a))return!0;b&&d&&(a=Qb(a,b));c&&d&&(a=a.replace(Xa,""));return!isNaN(parseFloat(a))&&isFinite(a)},Rb=function(a,b,c){return M(a)?!0:!(M(a)||"string"=== -typeof a)?null:Za(a.replace(Ca,""),b,c)?!0:null},D=function(a,b,c){var d=[],e=0,f=a.length;if(c!==k)for(;e")[0],Zb=wa.textContent!==k,$b=/<.*?>/g;m=function(a){this.$=function(a,b){return this.api(!0).$(a,b)};this._=function(a,b){return this.api(!0).rows(a,b).data()};this.api=function(a){return a?new t(za(this[s.iApiIndex])):new t(this)};this.fnAddData=function(a,b){var c=this.api(!0), -d=h.isArray(a)&&(h.isArray(a[0])||h.isPlainObject(a[0]))?c.rows.add(a):c.row.add(a);(b===k||b)&&c.draw();return d.flatten().toArray()};this.fnAdjustColumnSizing=function(a){var b=this.api(!0).columns.adjust(),c=b.settings()[0],d=c.oScroll;a===k||a?b.draw(!1):(""!==d.sX||""!==d.sY)&&Z(c)};this.fnClearTable=function(a){var b=this.api(!0).clear();(a===k||a)&&b.draw()};this.fnClose=function(a){this.api(!0).row(a).child.hide()};this.fnDeleteRow=function(a,b,c){var d=this.api(!0),a=d.rows(a),e=a.settings()[0], -h=e.aoData[a[0][0]];a.remove();b&&b.call(this,e,h);(c===k||c)&&d.draw();return h};this.fnDestroy=function(a){this.api(!0).destroy(a)};this.fnDraw=function(a){this.api(!0).draw(a)};this.fnFilter=function(a,b,c,d,e,h){e=this.api(!0);null===b||b===k?e.search(a,c,d,h):e.column(b).search(a,c,d,h);e.draw()};this.fnGetData=function(a,b){var c=this.api(!0);if(a!==k){var d=a.nodeName?a.nodeName.toLowerCase():"";return b!==k||"td"==d||"th"==d?c.cell(a,b).data():c.row(a).data()||null}return c.data().toArray()}; -this.fnGetNodes=function(a){var b=this.api(!0);return a!==k?b.row(a).node():b.rows().nodes().flatten().toArray()};this.fnGetPosition=function(a){var b=this.api(!0),c=a.nodeName.toUpperCase();return"TR"==c?b.row(a).index():"TD"==c||"TH"==c?(a=b.cell(a).index(),[a.row,a.columnVisible,a.column]):null};this.fnIsOpen=function(a){return this.api(!0).row(a).child.isShown()};this.fnOpen=function(a,b,c){return this.api(!0).row(a).child(b,c).show().child()[0]};this.fnPageChange=function(a,b){var c=this.api(!0).page(a); -(b===k||b)&&c.draw(!1)};this.fnSetColumnVis=function(a,b,c){a=this.api(!0).column(a).visible(b);(c===k||c)&&a.columns.adjust().draw()};this.fnSettings=function(){return za(this[s.iApiIndex])};this.fnSort=function(a){this.api(!0).order(a).draw()};this.fnSortListener=function(a,b,c){this.api(!0).order.listener(a,b,c)};this.fnUpdate=function(a,b,c,d,e){var h=this.api(!0);c===k||null===c?h.row(b).data(a):h.cell(b,c).data(a);(e===k||e)&&h.columns.adjust();(d===k||d)&&h.draw();return 0};this.fnVersionCheck= -s.fnVersionCheck;var b=this,c=a===k,d=this.length;c&&(a={});this.oApi=this.internal=s.internal;for(var e in m.ext.internal)e&&(this[e]=Nb(e));this.each(function(){var e={},e=1t<"F"ip>'),n.renderer)?h.isPlainObject(n.renderer)&&!n.renderer.header&&(n.renderer.header="jqueryui"):n.renderer="jqueryui":h.extend(i,m.ext.classes,e.oClasses);q.addClass(i.sTable);n.iInitDisplayStart===k&&(n.iInitDisplayStart=e.iDisplayStart,n._iDisplayStart=e.iDisplayStart);null!==e.iDeferLoading&&(n.bDeferLoading=!0,g=h.isArray(e.iDeferLoading), -n._iRecordsDisplay=g?e.iDeferLoading[0]:e.iDeferLoading,n._iRecordsTotal=g?e.iDeferLoading[1]:e.iDeferLoading);var t=n.oLanguage;h.extend(!0,t,e.oLanguage);""!==t.sUrl&&(h.ajax({dataType:"json",url:t.sUrl,success:function(a){Fa(a);J(l.oLanguage,a);h.extend(true,t,a);ia(n)},error:function(){ia(n)}}),o=!0);null===e.asStripeClasses&&(n.asStripeClasses=[i.sStripeOdd,i.sStripeEven]);var g=n.asStripeClasses,r=q.children("tbody").find("tr").eq(0);-1!==h.inArray(!0,h.map(g,function(a){return r.hasClass(a)}))&& -(h("tbody tr",this).removeClass(g.join(" ")),n.asDestroyStripes=g.slice());u=[];g=this.getElementsByTagName("thead");0!==g.length&&(fa(n.aoHeader,g[0]),u=qa(n));if(null===e.aoColumns){p=[];g=0;for(j=u.length;g").appendTo(this));n.nTHead=j[0];j=q.children("tbody");0===j.length&&(j=h("").appendTo(this));n.nTBody=j[0];j=q.children("tfoot");if(0===j.length&&0").appendTo(this); -0===j.length||0===j.children().length?q.addClass(i.sNoFooter):0a?new t(b[a],this[a]):null},filter:function(a){var b=[];if(x.filter)b=x.filter.call(this,a,this);else for(var c=0,d=this.length;c").addClass(b),h("td",c).addClass(b).html(a)[0].colSpan=ca(d),e.push(c[0]))};f(a,b);c._details&&c._details.remove();c._details=h(e);c._detailsShow&&c._details.insertAfter(c.nTr)}return this});p(["row().child.show()","row().child().show()"],function(){Vb(this, -!0);return this});p(["row().child.hide()","row().child().hide()"],function(){Vb(this,!1);return this});p(["row().child.remove()","row().child().remove()"],function(){cb(this);return this});p("row().child.isShown()",function(){var a=this.context;return a.length&&this.length?a[0].aoData[this[0]]._detailsShow||!1:!1});var dc=/^(.+):(name|visIdx|visible)$/,Wb=function(a,b,c,d,e){for(var c=[],d=0,f=e.length;d=0?b:g.length+b];if(typeof a==="function"){var e=Da(c,f);return h.map(g,function(b,f){return a(f,Wb(c,f,0,0,e),i[f])?f:null})}var k=typeof a==="string"?a.match(dc):"";if(k)switch(k[2]){case "visIdx":case "visible":b=parseInt(k[1],10);if(b<0){var m=h.map(g,function(a,b){return a.bVisible?b:null}); -return[m[m.length+b]]}return[$(c,b)];case "name":return h.map(j,function(a,b){return a===k[1]?b:null})}else return h(i).filter(a).map(function(){return h.inArray(this,i)}).toArray()},c,f)},1);c.selector.cols=a;c.selector.opts=b;return c});r("columns().header()","column().header()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTh},1)});r("columns().footer()","column().footer()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTf},1)});r("columns().data()", -"column().data()",function(){return this.iterator("column-rows",Wb,1)});r("columns().dataSrc()","column().dataSrc()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].mData},1)});r("columns().cache()","column().cache()",function(a){return this.iterator("column-rows",function(b,c,d,e,f){return ja(b.aoData,f,"search"===a?"_aFilterData":"_aSortData",c)},1)});r("columns().nodes()","column().nodes()",function(){return this.iterator("column-rows",function(a,b,c,d,e){return ja(a.aoData, -e,"anCells",b)},1)});r("columns().visible()","column().visible()",function(a,b){return this.iterator("column",function(c,d){if(a===k)return c.aoColumns[d].bVisible;var e=c.aoColumns,f=e[d],g=c.aoData,j,i,m;if(a!==k&&f.bVisible!==a){if(a){var l=h.inArray(!0,D(e,"bVisible"),d+1);j=0;for(i=g.length;jd;return!0};m.isDataTable=m.fnIsDataTable=function(a){var b=h(a).get(0),c=!1;h.each(m.settings,function(a,e){var f=e.nScrollHead?h("table",e.nScrollHead)[0]:null,g=e.nScrollFoot?h("table",e.nScrollFoot)[0]: -null;if(e.nTable===b||f===b||g===b)c=!0});return c};m.tables=m.fnTables=function(a){var b=!1;h.isPlainObject(a)&&(b=a.api,a=a.visible);var c=h.map(m.settings,function(b){if(!a||a&&h(b.nTable).is(":visible"))return b.nTable});return b?new t(c):c};m.util={throttle:ua,escapeRegex:va};m.camelToHungarian=J;p("$()",function(a,b){var c=this.rows(b).nodes(),c=h(c);return h([].concat(c.filter(a).toArray(),c.find(a).toArray()))});h.each(["on","one","off"],function(a,b){p(b+"()",function(){var a=Array.prototype.slice.call(arguments); -a[0].match(/\.dt\b/)||(a[0]+=".dt");var d=h(this.tables().nodes());d[b].apply(d,a);return this})});p("clear()",function(){return this.iterator("table",function(a){na(a)})});p("settings()",function(){return new t(this.context,this.context)});p("init()",function(){var a=this.context;return a.length?a[0].oInit:null});p("data()",function(){return this.iterator("table",function(a){return D(a.aoData,"_aData")}).flatten()});p("destroy()",function(a){a=a||!1;return this.iterator("table",function(b){var c= -b.nTableWrapper.parentNode,d=b.oClasses,e=b.nTable,f=b.nTBody,g=b.nTHead,j=b.nTFoot,i=h(e),f=h(f),k=h(b.nTableWrapper),l=h.map(b.aoData,function(a){return a.nTr}),p;b.bDestroying=!0;v(b,"aoDestroyCallback","destroy",[b]);a||(new t(b)).columns().visible(!0);k.unbind(".DT").find(":not(tbody *)").unbind(".DT");h(E).unbind(".DT-"+b.sInstance);e!=g.parentNode&&(i.children("thead").detach(),i.append(g));j&&e!=j.parentNode&&(i.children("tfoot").detach(),i.append(j));b.aaSorting=[];b.aaSortingFixed=[];xa(b); -h(l).removeClass(b.asStripeClasses.join(" "));h("th, td",g).removeClass(d.sSortable+" "+d.sSortableAsc+" "+d.sSortableDesc+" "+d.sSortableNone);b.bJUI&&(h("th span."+d.sSortIcon+", td span."+d.sSortIcon,g).detach(),h("th, td",g).each(function(){var a=h("div."+d.sSortJUIWrapper,this);h(this).append(a.contents());a.detach()}));f.children().detach();f.append(l);g=a?"remove":"detach";i[g]();k[g]();!a&&c&&(c.insertBefore(e,b.nTableReinsertBefore),i.css("width",b.sDestroyWidth).removeClass(d.sTable),(p= -b.asDestroyStripes.length)&&f.children().each(function(a){h(this).addClass(b.asDestroyStripes[a%p])}));c=h.inArray(b,m.settings);-1!==c&&m.settings.splice(c,1)})});h.each(["column","row","cell"],function(a,b){p(b+"s().every()",function(a){var d=this.selector.opts,e=this;return this.iterator(b,function(f,g,h,i,m){a.call(e[b](g,"cell"===b?h:d,"cell"===b?d:k),g,h,i,m)})})});p("i18n()",function(a,b,c){var d=this.context[0],a=Q(a)(d.oLanguage);a===k&&(a=b);c!==k&&h.isPlainObject(a)&&(a=a[c]!==k?a[c]:a._); -return a.replace("%d",c)});m.version="1.10.10";m.settings=[];m.models={};m.models.oSearch={bCaseInsensitive:!0,sSearch:"",bRegex:!1,bSmart:!0};m.models.oRow={nTr:null,anCells:null,_aData:[],_aSortData:null,_aFilterData:null,_sFilterRow:null,_sRowStripe:"",src:null,idx:-1};m.models.oColumn={idx:null,aDataSort:null,asSorting:null,bSearchable:null,bSortable:null,bVisible:null,_sManualType:null,_bAttrSrc:!1,fnCreatedCell:null,fnGetData:null,fnSetData:null,mData:null,mRender:null,nTh:null,nTf:null,sClass:null, -sContentPadding:null,sDefaultContent:null,sName:null,sSortDataType:"std",sSortingClass:null,sSortingClassJUI:null,sTitle:null,sType:null,sWidth:null,sWidthOrig:null};m.defaults={aaData:null,aaSorting:[[0,"asc"]],aaSortingFixed:[],ajax:null,aLengthMenu:[10,25,50,100],aoColumns:null,aoColumnDefs:null,aoSearchCols:[],asStripeClasses:null,bAutoWidth:!0,bDeferRender:!1,bDestroy:!1,bFilter:!0,bInfo:!0,bJQueryUI:!1,bLengthChange:!0,bPaginate:!0,bProcessing:!1,bRetrieve:!1,bScrollCollapse:!1,bServerSide:!1, -bSort:!0,bSortMulti:!0,bSortCellsTop:!1,bSortClasses:!0,bStateSave:!1,fnCreatedRow:null,fnDrawCallback:null,fnFooterCallback:null,fnFormatNumber:function(a){return a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,this.oLanguage.sThousands)},fnHeaderCallback:null,fnInfoCallback:null,fnInitComplete:null,fnPreDrawCallback:null,fnRowCallback:null,fnServerData:null,fnServerParams:null,fnStateLoadCallback:function(a){try{return JSON.parse((-1===a.iStateDuration?sessionStorage:localStorage).getItem("DataTables_"+ -a.sInstance+"_"+location.pathname))}catch(b){}},fnStateLoadParams:null,fnStateLoaded:null,fnStateSaveCallback:function(a,b){try{(-1===a.iStateDuration?sessionStorage:localStorage).setItem("DataTables_"+a.sInstance+"_"+location.pathname,JSON.stringify(b))}catch(c){}},fnStateSaveParams:null,iStateDuration:7200,iDeferLoading:null,iDisplayLength:10,iDisplayStart:0,iTabIndex:0,oClasses:{},oLanguage:{oAria:{sSortAscending:": activate to sort column ascending",sSortDescending:": activate to sort column descending"}, -oPaginate:{sFirst:"First",sLast:"Last",sNext:"Next",sPrevious:"Previous"},sEmptyTable:"No data available in table",sInfo:"Showing _START_ to _END_ of _TOTAL_ entries",sInfoEmpty:"Showing 0 to 0 of 0 entries",sInfoFiltered:"(filtered from _MAX_ total entries)",sInfoPostFix:"",sDecimal:"",sThousands:",",sLengthMenu:"Show _MENU_ entries",sLoadingRecords:"Loading...",sProcessing:"Processing...",sSearch:"Search:",sSearchPlaceholder:"",sUrl:"",sZeroRecords:"No matching records found"},oSearch:h.extend({}, -m.models.oSearch),sAjaxDataProp:"data",sAjaxSource:null,sDom:"lfrtip",searchDelay:null,sPaginationType:"simple_numbers",sScrollX:"",sScrollXInner:"",sScrollY:"",sServerMethod:"GET",renderer:null,rowId:"DT_RowId"};Y(m.defaults);m.defaults.column={aDataSort:null,iDataSort:-1,asSorting:["asc","desc"],bSearchable:!0,bSortable:!0,bVisible:!0,fnCreatedCell:null,mData:null,mRender:null,sCellType:"td",sClass:"",sContentPadding:"",sDefaultContent:null,sName:"",sSortDataType:"std",sTitle:null,sType:null,sWidth:null}; -Y(m.defaults.column);m.models.oSettings={oFeatures:{bAutoWidth:null,bDeferRender:null,bFilter:null,bInfo:null,bLengthChange:null,bPaginate:null,bProcessing:null,bServerSide:null,bSort:null,bSortMulti:null,bSortClasses:null,bStateSave:null},oScroll:{bCollapse:null,iBarWidth:0,sX:null,sXInner:null,sY:null},oLanguage:{fnInfoCallback:null},oBrowser:{bScrollOversize:!1,bScrollbarLeft:!1,bBounding:!1,barWidth:0},ajax:null,aanFeatures:[],aoData:[],aiDisplay:[],aiDisplayMaster:[],aIds:{},aoColumns:[],aoHeader:[], -aoFooter:[],oPreviousSearch:{},aoPreSearchCols:[],aaSorting:null,aaSortingFixed:[],asStripeClasses:null,asDestroyStripes:[],sDestroyWidth:0,aoRowCallback:[],aoHeaderCallback:[],aoFooterCallback:[],aoDrawCallback:[],aoRowCreatedCallback:[],aoPreDrawCallback:[],aoInitComplete:[],aoStateSaveParams:[],aoStateLoadParams:[],aoStateLoaded:[],sTableId:"",nTable:null,nTHead:null,nTFoot:null,nTBody:null,nTableWrapper:null,bDeferLoading:!1,bInitialised:!1,aoOpenRows:[],sDom:null,searchDelay:null,sPaginationType:"two_button", -iStateDuration:0,aoStateSave:[],aoStateLoad:[],oSavedState:null,oLoadedState:null,sAjaxSource:null,sAjaxDataProp:null,bAjaxDataGet:!0,jqXHR:null,json:k,oAjaxData:k,fnServerData:null,aoServerParams:[],sServerMethod:null,fnFormatNumber:null,aLengthMenu:null,iDraw:0,bDrawing:!1,iDrawError:-1,_iDisplayLength:10,_iDisplayStart:0,_iRecordsTotal:0,_iRecordsDisplay:0,bJUI:null,oClasses:{},bFiltered:!1,bSorted:!1,bSortCellsTop:null,oInit:null,aoDestroyCallback:[],fnRecordsTotal:function(){return"ssp"==y(this)? -1*this._iRecordsTotal:this.aiDisplayMaster.length},fnRecordsDisplay:function(){return"ssp"==y(this)?1*this._iRecordsDisplay:this.aiDisplay.length},fnDisplayEnd:function(){var a=this._iDisplayLength,b=this._iDisplayStart,c=b+a,d=this.aiDisplay.length,e=this.oFeatures,f=e.bPaginate;return e.bServerSide?!1===f||-1===a?b+d:Math.min(b+a,this._iRecordsDisplay):!f||c>d||-1===a?d:c},oInstance:null,sInstance:null,iTabIndex:0,nScrollHead:null,nScrollFoot:null,aLastSort:[],oPlugins:{},rowIdFn:null,rowId:null}; -m.ext=s={buttons:{},classes:{},builder:"-source-",errMode:"alert",feature:[],search:[],selector:{cell:[],column:[],row:[]},internal:{},legacy:{ajax:null},pager:{},renderer:{pageButton:{},header:{}},order:{},type:{detect:[],search:{},order:{}},_unique:0,fnVersionCheck:m.fnVersionCheck,iApiIndex:0,oJUIClasses:{},sVersion:m.version};h.extend(s,{afnFiltering:s.search,aTypes:s.type.detect,ofnSearch:s.type.search,oSort:s.type.order,afnSortData:s.order,aoFeatures:s.feature,oApi:s.internal,oStdClasses:s.classes, -oPagination:s.pager});h.extend(m.ext.classes,{sTable:"dataTable",sNoFooter:"no-footer",sPageButton:"paginate_button",sPageButtonActive:"current",sPageButtonDisabled:"disabled",sStripeOdd:"odd",sStripeEven:"even",sRowEmpty:"dataTables_empty",sWrapper:"dataTables_wrapper",sFilter:"dataTables_filter",sInfo:"dataTables_info",sPaging:"dataTables_paginate paging_",sLength:"dataTables_length",sProcessing:"dataTables_processing",sSortAsc:"sorting_asc",sSortDesc:"sorting_desc",sSortable:"sorting",sSortableAsc:"sorting_asc_disabled", -sSortableDesc:"sorting_desc_disabled",sSortableNone:"sorting_disabled",sSortColumn:"sorting_",sFilterInput:"",sLengthSelect:"",sScrollWrapper:"dataTables_scroll",sScrollHead:"dataTables_scrollHead",sScrollHeadInner:"dataTables_scrollHeadInner",sScrollBody:"dataTables_scrollBody",sScrollFoot:"dataTables_scrollFoot",sScrollFootInner:"dataTables_scrollFootInner",sHeaderTH:"",sFooterTH:"",sSortJUIAsc:"",sSortJUIDesc:"",sSortJUI:"",sSortJUIAscAllowed:"",sSortJUIDescAllowed:"",sSortJUIWrapper:"",sSortIcon:"", -sJUIHeader:"",sJUIFooter:""});var Ea="",Ea="",G=Ea+"ui-state-default",ka=Ea+"css_right ui-icon ui-icon-",Xb=Ea+"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix";h.extend(m.ext.oJUIClasses,m.ext.classes,{sPageButton:"fg-button ui-button "+G,sPageButtonActive:"ui-state-disabled",sPageButtonDisabled:"ui-state-disabled",sPaging:"dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_",sSortAsc:G+" sorting_asc",sSortDesc:G+" sorting_desc",sSortable:G+" sorting", -sSortableAsc:G+" sorting_asc_disabled",sSortableDesc:G+" sorting_desc_disabled",sSortableNone:G+" sorting_disabled",sSortJUIAsc:ka+"triangle-1-n",sSortJUIDesc:ka+"triangle-1-s",sSortJUI:ka+"carat-2-n-s",sSortJUIAscAllowed:ka+"carat-1-n",sSortJUIDescAllowed:ka+"carat-1-s",sSortJUIWrapper:"DataTables_sort_wrapper",sSortIcon:"DataTables_sort_icon",sScrollHead:"dataTables_scrollHead "+G,sScrollFoot:"dataTables_scrollFoot "+G,sHeaderTH:G,sFooterTH:G,sJUIHeader:Xb+" ui-corner-tl ui-corner-tr",sJUIFooter:Xb+ -" ui-corner-bl ui-corner-br"});var Mb=m.ext.pager;h.extend(Mb,{simple:function(){return["previous","next"]},full:function(){return["first","previous","next","last"]},numbers:function(a,b){return[Aa(a,b)]},simple_numbers:function(a,b){return["previous",Aa(a,b),"next"]},full_numbers:function(a,b){return["first","previous",Aa(a,b),"next","last"]},_numbers:Aa,numbers_length:7});h.extend(!0,m.ext.renderer,{pageButton:{_:function(a,b,c,d,e,f){var g=a.oClasses,j=a.oLanguage.oPaginate,i=a.oLanguage.oAria.paginate|| -{},k,l,m=0,p=function(b,d){var n,r,t,s,v=function(b){Ta(a,b.data.action,true)};n=0;for(r=d.length;n").appendTo(b);p(t,s)}else{k=null;l="";switch(s){case "ellipsis":b.append('');break;case "first":k=j.sFirst;l=s+(e>0?"":" "+g.sPageButtonDisabled);break;case "previous":k=j.sPrevious;l=s+(e>0?"":" "+g.sPageButtonDisabled);break;case "next":k=j.sNext;l=s+(e",{"class":g.sPageButton+" "+l,"aria-controls":a.sTableId,"aria-label":i[s],"data-dt-idx":m,tabindex:a.iTabIndex,id:c===0&&typeof s==="string"?a.sTableId+"_"+s:null}).html(k).appendTo(b);Wa(t,{action:s},v);m++}}}},r;try{r=h(b).find(H.activeElement).data("dt-idx")}catch(n){}p(h(b).empty(),d);r&&h(b).find("[data-dt-idx="+r+"]").focus()}}});h.extend(m.ext.type.detect,[function(a,b){var c= -b.oLanguage.sDecimal;return Za(a,c)?"num"+c:null},function(a){if(a&&!(a instanceof Date)&&(!ac.test(a)||!bc.test(a)))return null;var b=Date.parse(a);return null!==b&&!isNaN(b)||M(a)?"date":null},function(a,b){var c=b.oLanguage.sDecimal;return Za(a,c,!0)?"num-fmt"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Rb(a,c)?"html-num"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Rb(a,c,!0)?"html-num-fmt"+c:null},function(a){return M(a)||"string"===typeof a&&-1!==a.indexOf("<")?"html": -null}]);h.extend(m.ext.type.search,{html:function(a){return M(a)?a:"string"===typeof a?a.replace(Ob," ").replace(Ca,""):""},string:function(a){return M(a)?a:"string"===typeof a?a.replace(Ob," "):a}});var Ba=function(a,b,c,d){if(0!==a&&(!a||"-"===a))return-Infinity;b&&(a=Qb(a,b));a.replace&&(c&&(a=a.replace(c,"")),d&&(a=a.replace(d,"")));return 1*a};h.extend(s.type.order,{"date-pre":function(a){return Date.parse(a)||0},"html-pre":function(a){return M(a)?"":a.replace?a.replace(/<.*?>/g,"").toLowerCase(): -a+""},"string-pre":function(a){return M(a)?"":"string"===typeof a?a.toLowerCase():!a.toString?"":a.toString()},"string-asc":function(a,b){return ab?1:0},"string-desc":function(a,b){return ab?-1:0}});db("");h.extend(!0,m.ext.renderer,{header:{_:function(a,b,c,d){h(a.nTable).on("order.dt.DT",function(e,f,g,h){if(a===f){e=c.idx;b.removeClass(c.sSortingClass+" "+d.sSortAsc+" "+d.sSortDesc).addClass(h[e]=="asc"?d.sSortAsc:h[e]=="desc"?d.sSortDesc:c.sSortingClass)}})},jqueryui:function(a, -b,c,d){h("
").addClass(d.sSortJUIWrapper).append(b.contents()).append(h("").addClass(d.sSortIcon+" "+c.sSortingClassJUI)).appendTo(b);h(a.nTable).on("order.dt.DT",function(e,f,g,h){if(a===f){e=c.idx;b.removeClass(d.sSortAsc+" "+d.sSortDesc).addClass(h[e]=="asc"?d.sSortAsc:h[e]=="desc"?d.sSortDesc:c.sSortingClass);b.find("span."+d.sSortIcon).removeClass(d.sSortJUIAsc+" "+d.sSortJUIDesc+" "+d.sSortJUI+" "+d.sSortJUIAscAllowed+" "+d.sSortJUIDescAllowed).addClass(h[e]=="asc"?d.sSortJUIAsc: -h[e]=="desc"?d.sSortJUIDesc:c.sSortingClassJUI)}})}}});m.render={number:function(a,b,c,d,e){return{display:function(f){if("number"!==typeof f&&"string"!==typeof f)return f;var g=0>f?"-":"",h=parseFloat(f);if(isNaN(h))return f;f=Math.abs(h);h=parseInt(f,10);f=c?b+(f-h).toFixed(c).substring(2):"";return g+(d||"")+h.toString().replace(/\B(?=(\d{3})+(?!\d))/g,a)+f+(e||"")}}},text:function(){return{display:function(a){return"string"===typeof a?a.replace(//g,">").replace(/"/g,"""): -a}}}};h.extend(m.ext.internal,{_fnExternApiFunc:Nb,_fnBuildAjax:ra,_fnAjaxUpdate:lb,_fnAjaxParameters:ub,_fnAjaxUpdateDraw:vb,_fnAjaxDataSrc:sa,_fnAddColumn:Ga,_fnColumnOptions:la,_fnAdjustColumnSizing:U,_fnVisibleToColumnIndex:$,_fnColumnIndexToVisible:ba,_fnVisbleColumns:ca,_fnGetColumns:aa,_fnColumnTypes:Ia,_fnApplyColumnDefs:ib,_fnHungarianMap:Y,_fnCamelToHungarian:J,_fnLanguageCompat:Fa,_fnBrowserDetect:gb,_fnAddData:N,_fnAddTr:ma,_fnNodeToDataIndex:function(a,b){return b._DT_RowIndex!==k?b._DT_RowIndex: -null},_fnNodeToColumnIndex:function(a,b,c){return h.inArray(c,a.aoData[b].anCells)},_fnGetCellData:B,_fnSetCellData:jb,_fnSplitObjNotation:La,_fnGetObjectDataFn:Q,_fnSetObjectDataFn:R,_fnGetDataMaster:Ma,_fnClearTable:na,_fnDeleteIndex:oa,_fnInvalidate:ea,_fnGetRowElements:Ka,_fnCreateTr:Ja,_fnBuildHead:kb,_fnDrawHead:ga,_fnDraw:O,_fnReDraw:T,_fnAddOptionsHtml:nb,_fnDetectHeader:fa,_fnGetUniqueThs:qa,_fnFeatureHtmlFilter:pb,_fnFilterComplete:ha,_fnFilterCustom:yb,_fnFilterColumn:xb,_fnFilter:wb,_fnFilterCreateSearch:Qa, -_fnEscapeRegex:va,_fnFilterData:zb,_fnFeatureHtmlInfo:sb,_fnUpdateInfo:Cb,_fnInfoMacros:Db,_fnInitialise:ia,_fnInitComplete:ta,_fnLengthChange:Ra,_fnFeatureHtmlLength:ob,_fnFeatureHtmlPaginate:tb,_fnPageChange:Ta,_fnFeatureHtmlProcessing:qb,_fnProcessingDisplay:C,_fnFeatureHtmlTable:rb,_fnScrollDraw:Z,_fnApplyToChildren:I,_fnCalculateColumnWidths:Ha,_fnThrottle:ua,_fnConvertToWidth:Fb,_fnGetWidestNode:Gb,_fnGetMaxLenString:Hb,_fnStringToCss:w,_fnSortFlatten:W,_fnSort:mb,_fnSortAria:Jb,_fnSortListener:Va, -_fnSortAttachListener:Oa,_fnSortingClasses:xa,_fnSortData:Ib,_fnSaveState:ya,_fnLoadState:Kb,_fnSettingsFromNode:za,_fnLog:K,_fnMap:F,_fnBindAction:Wa,_fnCallbackReg:z,_fnCallbackFire:v,_fnLengthOverflow:Sa,_fnRenderer:Pa,_fnDataSource:y,_fnRowAttributes:Na,_fnCalculateEnd:function(){}});h.fn.dataTable=m;m.$=h;h.fn.dataTableSettings=m.settings;h.fn.dataTableExt=m.ext;h.fn.DataTable=function(a){return h(this).dataTable(a).api()};h.each(m,function(a,b){h.fn.DataTable[a]=b});return h.fn.dataTable}); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/provider-libs/ws-client.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/provider-libs/ws-client.js deleted file mode 100644 index ab7263155..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_realtime_battery_gadget/Android_Realtime_Battery/js/provider-libs/ws-client.js +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 2015, 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 CONSTANTS = { - urlSeperator: '/', - queryParamStreamName : '?streamname=', - queryParamStreamVersion : '&version=', - queryParamLastUpdatedTime : '&lastUpdatedTime=', - urlSecureTransportWebsocket : 'wss://', - urlSecureTransportHttp : 'https://', - colon : ':', - defaultIntervalTime : 10 * 1000, - defaultHostName : 'localhost', - defaultSecurePortNumber : '9443', - defaultMode : 'AUTO', - processModeHTTP : 'HTTP', - processModeWebSocket : 'WEBSOCKET', - processModeAuto : 'AUTO', - numThousand : 1000, - websocketTimeAppender : 400, - websocketSubscriptionEndpoint : 'portal/uipublisher/websocketSubscriptionEndpoint.jag', - httpEventRetrievalEndpoint : 'portal/uipublisher/httpEventRetrievalEndpoint.jag' -}; - - -var websocket = null; -var webSocketUrl; -var httpUrl; -var cepHostName; -var cepPortNumber; -var isErrorOccured = false; -var lastUpdatedtime = -1; -var polingInterval; -var stream; -var streamVersion; -var firstPollingAttempt; -var processMode; -var onSuccessFunction; -var onErrorFunction; -var terminateWebsocketInstance = false; -var pollingContinue = true; - -function subscribe(streamName,version,intervalTime, - listeningFuncSuccessData,listeningFuncErrorData,cepHost,cepPort,mode){ - stopPollingProcesses(); - stream = streamName; - streamVersion = version; - onSuccessFunction = listeningFuncSuccessData; - onErrorFunction = listeningFuncErrorData; - - if(intervalTime == null || intervalTime == ""){ - polingInterval = CONSTANTS.defaultIntervalTime; - } else{ - polingInterval = intervalTime * CONSTANTS.numThousand; - } - - if(cepHost == null || cepHost == ""){ - cepHostName = CONSTANTS.defaultHostName; - } else{ - cepHostName = cepHost; - } - - if(cepPort == null || cepPort == ""){ - cepPortNumber = CONSTANTS.defaultSecurePortNumber; - } else{ - cepPortNumber = cepPort; - } - - if(mode == null || mode == ""){ - processMode = CONSTANTS.defaultMode; - } else{ - processMode = mode; - } - - webSocketUrl = CONSTANTS.urlSecureTransportWebsocket + cepHostName + CONSTANTS.colon + cepPortNumber + - CONSTANTS.urlSeperator + CONSTANTS.websocketSubscriptionEndpoint; - - if(processMode == CONSTANTS.processModeHTTP){ - firstPollingAttempt = true; - pollingContinue = true; - startPoll(); - } else{ - initializeWebSocket(webSocketUrl); - } -} - - -/** - * Initializing Web Socket - */ -function initializeWebSocket(webSocketUrl){ - websocket = new WebSocket(webSocketUrl); - websocket.onopen = webSocketOnOpen; - websocket.onmessage = webSocketOnMessage; - websocket.onclose = webSocketOnClose; - websocket.onerror = webSocketOnError; -} - -function getWebsocketSubscriptionMessage(streamName, streamVersion, streamProperties, streamValues) { - if (streamProperties.length === streamValues.length) { - var message = {}; - message.streamName = streamName; - message.streamVersion = streamVersion; - var i; - for (i = 0; i < streamProperties.length; i++) { - message.filterProps = []; - message.filterProps.push({ - 'name': streamProperties[i], - 'value': streamValues[i] - }); - } - return JSON.stringify(message); - } else { - console.log('stream properties and values are not in equal size'); - } -} - -/** - * Get the parameters as query parameters. - * This method parses those parameters and returns. - * */ -function getAllQueryParamsFromURL() { - var queryParamList = {}, qParam; - var urlQueryString = decodeURIComponent(window.top.location.search.substring(1)); - - if (urlQueryString) { - var queryStringPairs = urlQueryString.split('&'); - for (var i = 0; i < queryStringPairs.length; i++) { - qParam = queryStringPairs[i].split('='); - queryParamList[qParam[0]] = qParam[1]; - } - return queryParamList; - - } else { - return null; - } -} - -/** - * Web socket On Open - */ -var webSocketOnOpen = function () { - var params = getAllQueryParamsFromURL(); - var deviceId; - var owner; - if (params) { - owner = params["owner"]; - deviceId = params["deviceId"]; - } - var filterPropNames = ["meta_owner", "meta_deviceId"]; - var filterPropVals = [owner, deviceId]; - var data = getWebsocketSubscriptionMessage(stream, streamVersion, filterPropNames, filterPropVals); - websocket.send(data); -}; - -/** - * On server sends a message - */ -var webSocketOnMessage = function (evt) { - var event = evt.data; - var array = JSON.parse(event); - constructPayload(array); -}; - -/** - * On server close - */ -var webSocketOnClose =function (e) { - - if(isErrorOccured){ - if(processMode != CONSTANTS.processModeWebSocket){ - firstPollingAttempt = true; - pollingContinue = true; - startPoll(); - } - } else{ - if(!terminateWebsocketInstance){ - waitForSocketConnection(websocket); - } else{ - terminateWebsocketInstance = false; - } - - } -}; - -/** - * On server Error - */ -var webSocketOnError = function (err) { - var error = "Error: Cannot connect to Websocket URL:" + webSocketUrl + " .Hence closing the connection!"; - - onErrorFunction(error); - isErrorOccured = true; - -}; - -/** - * Gracefully increments the connection retry - */ -var waitTime = CONSTANTS.numThousand; -function waitForSocketConnection(socket, callback){ - setTimeout( - function () { - if (socket.readyState === 1) { - initializeWebSocket(webSocketUrl); - console.log("Connection is made"); - if(callback != null){ - callback(); - } - return; - } else { - websocket = new WebSocket(webSocketUrl); - waitTime += CONSTANTS.websocketTimeAppender; - waitForSocketConnection(websocket, callback); - } - }, waitTime); -} - -/** - * Polling to retrieve events from http request periodically - */ -function startPoll(){ - - (function poll(){ - setTimeout(function(){ - httpUrl = CONSTANTS.urlSecureTransportHttp + cepHostName + CONSTANTS.colon + cepPortNumber + - CONSTANTS.urlSeperator + CONSTANTS.httpEventRetrievalEndpoint + CONSTANTS.queryParamStreamName + stream + - CONSTANTS.queryParamStreamVersion + streamVersion + CONSTANTS.queryParamLastUpdatedTime + lastUpdatedtime;; - $.getJSON(httpUrl, function(responseText) { - if(firstPollingAttempt){ - /*var data = $("textarea#idConsole").val(); - $("textarea#idConsole").val(data + "Successfully connected to HTTP.");*/ - firstPollingAttempt = false; - } - var eventList = $.parseJSON(responseText.events); - if(eventList.length != 0){ - lastUpdatedtime = responseText.lastEventTime; - for(var i=0;i - - - - Android_Realtime_Battery - -