forked from community/device-mgt-plugins
commit
49d81766f6
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.event.streams.battery;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseDataHolder;
|
||||
|
||||
public class BatteryReaderService extends IntentService {
|
||||
|
||||
private Context context;
|
||||
|
||||
public BatteryReaderService() {
|
||||
super("BatteryReaderService");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(Intent.ACTION_BATTERY_LOW);
|
||||
intentFilter.addAction(Intent.ACTION_BATTERY_OKAY);
|
||||
intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
Intent intent1 = registerReceiver(null, intentFilter);
|
||||
|
||||
Log.i("Battery Data", String.valueOf(intent1.getIntExtra(BatteryManager.EXTRA_LEVEL, 0)));
|
||||
if (Intent.ACTION_BATTERY_OKAY.equals(intent.getAction())) {
|
||||
SenseDataHolder.getBatteryDataHolder().add(new BatteryData(BatteryData.State.OK));
|
||||
} else if (Intent.ACTION_BATTERY_LOW.equals(intent.getAction())) {
|
||||
SenseDataHolder.getBatteryDataHolder().add(new BatteryData(BatteryData.State.LOW));
|
||||
} else {
|
||||
SenseDataHolder.getBatteryDataHolder().add(new BatteryData(intent1));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.event.streams.data;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.TrafficStats;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseDataHolder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Class to read data sent and received by the device.
|
||||
*/
|
||||
public class NetworkDataReader extends AsyncTask<Void, Void, Long> {
|
||||
|
||||
private NetworkData networkData;
|
||||
private Context context;
|
||||
private Handler mHandler = new Handler();
|
||||
private long mStartRX = 0;
|
||||
private long mStartTX = 0;
|
||||
private final String WIFI = "WIFI";
|
||||
private final String MOBILE = "MOBILE";
|
||||
private String connectionType;
|
||||
|
||||
public NetworkDataReader(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long doInBackground(Void... voids) {
|
||||
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
networkData = new NetworkData();
|
||||
|
||||
if (getConnectionType(connectivityManager, ConnectivityManager.TYPE_WIFI)) {
|
||||
connectionType = WIFI;
|
||||
} else if (getConnectionType(connectivityManager, ConnectivityManager.TYPE_MOBILE)) {
|
||||
connectionType = MOBILE;
|
||||
}
|
||||
|
||||
mStartRX = TrafficStats.getTotalRxBytes();
|
||||
mStartTX = TrafficStats.getTotalTxBytes();
|
||||
if (mStartRX == TrafficStats.UNSUPPORTED || mStartTX == TrafficStats.UNSUPPORTED) {
|
||||
Log.e("ERROR", "Not connected.");
|
||||
} else {
|
||||
mHandler.postDelayed(mRunnable, 10000);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect data sent and received with in 10 second time frames.
|
||||
*/
|
||||
private final Runnable mRunnable = new Runnable() {
|
||||
public void run() {
|
||||
long rxBytes = TrafficStats.getTotalRxBytes() - mStartRX;
|
||||
long txBytes = TrafficStats.getTotalTxBytes() - mStartTX;
|
||||
Log.i("Usage: ", String.valueOf(rxBytes) + " " + String.valueOf(txBytes) + " " + System.currentTimeMillis());
|
||||
networkData.setType(connectionType);
|
||||
networkData.setTimeStamp(new Date().getTime());
|
||||
networkData.setDataSent(txBytes);
|
||||
networkData.setDataReceived(rxBytes);
|
||||
SenseDataHolder.getNetworkDataHolder().add(networkData);
|
||||
mHandler.postDelayed(mRunnable, 10000);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the type of the connection currently have.
|
||||
*/
|
||||
private boolean getConnectionType(ConnectivityManager manager, Integer type) {
|
||||
NetworkInfo networkInfo = manager.getNetworkInfo(type);
|
||||
return networkInfo.isConnected();
|
||||
}
|
||||
}
|
@ -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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.event.streams.data;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseDataHolder;
|
||||
|
||||
public class NetworkDataReceiver extends BroadcastReceiver{
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
long sent = android.net.TrafficStats.getTotalTxBytes();
|
||||
long received = android.net.TrafficStats.getTotalRxBytes();
|
||||
Log.d("NetworkData :", "Received: " + sent + " Received : " + received);
|
||||
|
||||
NetworkData networkData = new NetworkData(received, sent);
|
||||
|
||||
SenseDataHolder.getNetworkDataHolder().add(networkData);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
@Plan:name('Android-Battery-ExecutionPlan')
|
||||
|
||||
@Plan:description('Find the battery status of the android device.')
|
||||
|
||||
|
||||
@Import('org.wso2.iot.android.battery:1.0.0')
|
||||
define stream BatteryStream (meta_owner string, meta_deviceId string, meta_timestamp long, level int, state string, status string, temperature int);
|
||||
|
||||
|
||||
@Export('org.wso2.iot.android.battery.stats:1.0.0')
|
||||
define stream BatteryStatsStream (meta_owner string, meta_deviceId string, meta_timestamp long, level int, state
|
||||
string, status string, temperature int, year int, month int, day int, hour int, minute int);
|
||||
|
||||
partition with (meta_deviceId of BatteryStream)
|
||||
begin
|
||||
from BatteryStream
|
||||
select meta_owner, meta_deviceId, meta_timestamp, level, state, status, temperature, time:extract(preState.meta_timestamp, 'year') as year, time:extract(preState.meta_timestamp, 'month') as month, time:extract(preState.meta_timestamp, 'day') as day, time:extract(preState.meta_timestamp, 'hour') as hour, time:extract(preState.meta_timestamp, 'minute') as minute
|
||||
insert into BatteryStatsStream;
|
||||
end;
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<artifact name= "android_android_battery_executionplan" version="1.0.0" type="event/execution-plan"
|
||||
serverRole="DataAnalyticsServer">
|
||||
<file>Android-Battery-ExecutionPlan.siddhiql</file>
|
||||
</artifact>
|
||||
|
10
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/conf.json → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/conf.json
10
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/conf.json → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/conf.json
@ -1,17 +1,19 @@
|
||||
{
|
||||
"provider-conf": {
|
||||
"streamName": "org.wso2.iot.android.battery:1.0.0",
|
||||
"provider-name": "realtime"
|
||||
"tableName": "ORG_WSO2_IOT_ANDROID_BATTERY_STATS",
|
||||
"query": "",
|
||||
"limit": "",
|
||||
"provider-name": "batch"
|
||||
},
|
||||
"chart-conf": {
|
||||
"x": "TIMESTAMP",
|
||||
"x": "meta_timestamp",
|
||||
"xType": "time",
|
||||
"y": "level",
|
||||
"yType": "number",
|
||||
"color": "None",
|
||||
"mode": "stack",
|
||||
"maxLength": "30",
|
||||
"gadget-name": "Android Battery Level Chart",
|
||||
"gadget-name": "Battery History",
|
||||
"chart-name": "area-chart"
|
||||
}
|
||||
}
|
0
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/gadget-controller.jag → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/gadget-controller.jag
0
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/gadget-controller.jag → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/gadget-controller.jag
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "Android_Battery_History_Chart",
|
||||
"title": "Battery History",
|
||||
"type": "gadget",
|
||||
"thumbnail": "gadget/Android_Battery_History_Chart/thumbnail.png",
|
||||
"data": {
|
||||
"url": "gadget/Android_Battery_History_Chart/gadget.xml"
|
||||
}
|
||||
}
|
16
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/gadget.xml → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/gadget.xml
16
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/gadget.xml → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/gadget.xml
0
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/js/core/area-chart-api.js → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/js/core/area-chart-api.js
0
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/js/core/area-chart-api.js → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/js/core/area-chart-api.js
@ -0,0 +1,190 @@
|
||||
/*
|
||||
* 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;
|
||||
};
|
||||
|
||||
}());
|
29
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/js/core/gadget-core.js → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/js/core/gadget-core.js
29
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/js/core/gadget-core.js → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/js/core/gadget-core.js
2
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/js/core/gadget-util.js → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/js/core/gadget-util.js
2
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/js/core/gadget-util.js → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/js/core/gadget-util.js
0
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/thumbnail.png → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/thumbnail.png
0
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/Android_Battery_Level_Chart/thumbnail.png → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_history_chart_gadget/Android_Battery_History_Chart/thumbnail.png
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<artifact name= "android_battery_history_chart_gadget" version="1.0.0" type="dashboards/gadget"
|
||||
serverRole="DataAnalyticsServer">
|
||||
<file>Android_Battery_History_Chart</file>
|
||||
</artifact>
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"id": "Android_Battery_Level_Chart",
|
||||
"title": "Android Battery Level Chart",
|
||||
"type": "gadget",
|
||||
"thumbnail": "gadget/Android_Battery_Level_Chart/thumbnail.png",
|
||||
"data": {
|
||||
"url": "gadget/Android_Battery_Level_Chart/gadget.xml"
|
||||
}
|
||||
}
|
@ -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);
|
||||
};
|
||||
|
||||
}());
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
}());
|
@ -1,262 +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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Web socket On Open
|
||||
*/
|
||||
|
||||
var webSocketOnOpen = function () {
|
||||
var filterPropNames = ["meta_deviceId"];
|
||||
var filterPropVals = ["htc"];
|
||||
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<eventList.length;i++){
|
||||
var arr = eventList[i];
|
||||
constructPayload(arr);
|
||||
}
|
||||
}
|
||||
if(pollingContinue){
|
||||
startPoll();
|
||||
}
|
||||
})
|
||||
.fail(function(errorData) {
|
||||
var errorData = JSON.parse(errorData.responseText);
|
||||
onErrorFunction(errorData.error);
|
||||
});
|
||||
}, polingInterval);
|
||||
})()
|
||||
}
|
||||
|
||||
function stopPollingProcesses(){
|
||||
|
||||
//stopping the Websocket
|
||||
if(websocket != null){
|
||||
terminateWebsocketInstance = true;
|
||||
websocket.close();
|
||||
}
|
||||
//stopping the HTTPS Request
|
||||
pollingContinue = false;
|
||||
|
||||
}
|
||||
|
||||
function constructPayload(eventsArray){
|
||||
|
||||
var streamId = stream + CONSTANTS.colon + streamVersion;
|
||||
var twoDimentionalArray = [eventsArray];
|
||||
onSuccessFunction(streamId,twoDimentionalArray);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Analytics>
|
||||
<Editable>true</Editable>
|
||||
<Name>AndriodCallScript</Name>
|
||||
<Script> CREATE TEMPORARY TABLE AndroidBatteryData USING CarbonAnalytics OPTIONS(tableName
|
||||
"ORG_WSO2_IOT_ANDROID_BATTERY_STATS", incrementalParams "ORG_WSO2_IOT_ANDROID_BATTERY_STATS, DAY");
|
||||
|
||||
CREATE TEMPORARY TABLE Android_Battery_Stat_Per_Day USING CarbonAnalytics
|
||||
OPTIONS (tableName "Android_Battery_Stat_Per_Day",
|
||||
schema "owner STRING, deviceId STRING, type STRING, level INT -i, year INT -i, month INT -i, day INT -i,
|
||||
timestamp STRING", primaryKeys "year, month, day, deviceId, owner, type", mergeSchema "false");
|
||||
|
||||
INSERT INTO TABLE Android_Battery_Stat_Per_Day
|
||||
SELECT meta_owner as owner, meta_deviceId as deviceId, type, avg(level) as level, year, month, day,
|
||||
getDateStartingTime(year, month, day) as timestamp
|
||||
FROM AndroidBatteryData
|
||||
GROUP BY year, month, day, meta_deviceId, meta_owner, type ORDER BY timestamp DESC;
|
||||
|
||||
INCREMENTAL_TABLE_COMMIT ORG_WSO2_IOT_ANDROID_BATTERY_STATS;
|
||||
</Script>
|
||||
<CronExpression>0 0/5 * * * ?</CronExpression>
|
||||
</Analytics>
|
4
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/artifact.xml → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/artifact.xml
4
components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_level_chart_gadget/artifact.xml → components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/artifact.xml
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<artifact name= "android_battery_stats_event_sink" version="1.0.0" type="analytics/eventstore"
|
||||
serverRole="DataAnalyticsServer">
|
||||
<file>org_wso2_iot_android_battery_stats.xml</file>
|
||||
</artifact>
|
||||
|
@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<EventStoreConfiguration>
|
||||
<TableSchema>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_owner</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_deviceId</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_timestamp</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>LONG</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>level</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>INTEGER</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>state</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>status</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>LONG</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>temperature</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>INTEGER</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>year</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>INTEGER</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>month</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>INTEGER</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>day</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>INTEGER</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>hour</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>INTEGER</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>minute</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>INTEGER</Type>
|
||||
</ColumnDefinition>
|
||||
</TableSchema>
|
||||
<Source>
|
||||
<StreamId>org.wso2.iot.android.battery.stats:1.0.0</StreamId>
|
||||
</Source>
|
||||
<MergeSchema>false</MergeSchema>
|
||||
<RecordStoreName>PROCESSED_DATA_STORE</RecordStoreName>
|
||||
</EventStoreConfiguration>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<artifact name= "android_battery_stats_streams" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
|
||||
<file>org.wso2.iot.android.battery.stats_1.0.0.json</file>
|
||||
</artifact>
|
||||
|
@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "org.wso2.iot.android.battery.stats",
|
||||
"version": "1.0.0",
|
||||
"nickName": "",
|
||||
"description": "",
|
||||
"metaData": [
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "deviceId",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "timestamp",
|
||||
"type": "LONG"
|
||||
}
|
||||
],
|
||||
"payloadData": [
|
||||
{
|
||||
"name": "level",
|
||||
"type": "INT"
|
||||
},
|
||||
{
|
||||
"name": "state",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "temperature",
|
||||
"type": "INT"
|
||||
},
|
||||
{
|
||||
"name": "year",
|
||||
"type": "INT"
|
||||
},
|
||||
{
|
||||
"name": "month",
|
||||
"type": "INT"
|
||||
},
|
||||
{
|
||||
"name": "day",
|
||||
"type": "INT"
|
||||
},
|
||||
{
|
||||
"name": "hour",
|
||||
"type": "INT"
|
||||
},
|
||||
{
|
||||
"name": "minute",
|
||||
"type": "INT"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<artifact name= "android_battery_stats_ui_event_publisher" version="1.0.0" type="event/publisher"
|
||||
serverRole="DataAnalyticsServer">
|
||||
<file>org.wso2.iot.android.battery.stats.ui.publisher.xml</file>
|
||||
</artifact>
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<eventPublisher name="org.wso2.iot.android.battery.stats.ui.publisher"
|
||||
processing="enable" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
|
||||
<from streamName="org.wso2.iot.android.battery.stats" version="1.0.0"/>
|
||||
<mapping customMapping="disable" type="wso2event"/>
|
||||
<to eventAdapterType="ui"/>
|
||||
</eventPublisher>
|
||||
|
||||
|
Binary file not shown.
@ -0,0 +1,85 @@
|
||||
{{!
|
||||
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
|
||||
WSO2 Inc. licenses this file to you under the Apache License,
|
||||
Version 2.0 (the "License"); you may not use this file except
|
||||
in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
}}
|
||||
{{#zone "topCss"}}
|
||||
<style>
|
||||
.thumbnail.icon:before {
|
||||
padding-top: 0;
|
||||
}
|
||||
</style>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "device-thumbnail"}}
|
||||
<img src="{{@unit.publicUri}}/images/respberry-icon.png"/>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "device-opetations"}}
|
||||
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
|
||||
Operations
|
||||
</div>
|
||||
<div class="add-margin-top-4x">
|
||||
{{unit "iot.unit.device.operation-bar" device=device backendApiUri=backendApiUri autoCompleteParams=autoCompleteParams}}
|
||||
</div>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "device-detail-properties"}}
|
||||
<div class="media">
|
||||
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
|
||||
<ul class="list-group" role="tablist">
|
||||
<li class="active"><a class="list-group-item" href="#device_statistics" role="tab"
|
||||
data-toggle="tab" aria-controls="device_statistics">Device
|
||||
Statistics</a>
|
||||
</li>
|
||||
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab"
|
||||
aria-controls="event_log">Operations Log</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="media-body add-padding-left-5x remove-padding-xs tab-content">
|
||||
<div class="panel-group tab-content">
|
||||
|
||||
<div class="panel panel-default tab-pane active"
|
||||
id="device_statistics" role="tabpanel" aria-labelledby="device_statistics">
|
||||
<div class="panel-heading">Device Statistics</div>
|
||||
{{unit "cdmf.unit.device.type.raspberrypi.realtime.analytics-view" device=device}}
|
||||
</div>
|
||||
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
|
||||
aria-labelledby="event_log">
|
||||
<div class="panel-heading">Operations Log <span><a href="#"
|
||||
id="refresh-operations"><i
|
||||
class="fw fw-refresh"></i></a></span></div>
|
||||
<div class="panel-body">
|
||||
<div id="operations-spinner" class="wr-advance-operations-init hidden">
|
||||
<br>
|
||||
|
||||
<i class="fw fw-settings fw-spin fw-2x"></i>
|
||||
|
||||
Loading Operations Log . . .
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
<div id="operations-log-container">
|
||||
<div class="panel-body">
|
||||
Not available yet
|
||||
</div>
|
||||
<br class="c-both"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
Binary file not shown.
@ -1,32 +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.
|
||||
}}
|
||||
|
||||
{{unit "cdmf.unit.device.type.android.date-range-picker"}}
|
||||
|
||||
{{#zone "content"}}
|
||||
<div id="operations-mod" data-permissions="{{permissions}}" data-device-type="{{deviceType}}" data-ownership="{{ownership}}">
|
||||
{{unit "cdmf.unit.device.type.android.operation-mod"}}
|
||||
</div>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "bottomJs"}}
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<script id="operations-bar" src="{{@unit.publicUri}}/templates/operations.hbs"
|
||||
type="text/x-handlebars-template"></script>
|
||||
{{js "js/operation-bar.js"}}
|
||||
{{/zone}}
|
@ -1,106 +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 onRequest(context) {
|
||||
var log = new Log("cdmf.unit.device.type.android.operation-bar");
|
||||
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
||||
var viewModel = {};
|
||||
var permissions = {};
|
||||
|
||||
// adding android operations related permission checks
|
||||
permissions["android"] = [];
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/ring")) {
|
||||
permissions["android"].push("DEVICE_RING");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/lock")) {
|
||||
permissions["android"].push("DEVICE_LOCK");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/unlock")) {
|
||||
permissions["android"].push("DEVICE_UNLOCK");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/location")) {
|
||||
permissions["android"].push("DEVICE_LOCATION");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/clear-password")) {
|
||||
permissions["android"].push("CLEAR_PASSWORD");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/reboot")) {
|
||||
permissions["android"].push("DEVICE_REBOOT");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/upgrade-firmware")) {
|
||||
permissions["android"].push("UPGRADE_FIRMWARE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/mute")) {
|
||||
permissions["android"].push("DEVICE_MUTE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/send-notification")) {
|
||||
permissions["android"].push("NOTIFICATION");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/change-lock-code")) {
|
||||
permissions["android"].push("CHANGE_LOCK_CODE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/enterprise-wipe")) {
|
||||
permissions["android"].push("ENTERPRISE_WIPE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/wipe")) {
|
||||
permissions["android"].push("WIPE_DATA");
|
||||
}
|
||||
|
||||
// adding ios operations related permission checks
|
||||
permissions["ios"] = [];
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/lock")) {
|
||||
permissions["ios"].push("DEVICE_LOCK");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/location")) {
|
||||
permissions["ios"].push("LOCATION");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/enterprise-wipe")) {
|
||||
permissions["ios"].push("ENTERPRISE_WIPE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/notification")) {
|
||||
permissions["ios"].push("NOTIFICATION");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/ring")) {
|
||||
permissions["ios"].push("RING");
|
||||
}
|
||||
|
||||
// adding windows operations related permission checks
|
||||
permissions["windows"] = [];
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/lock")) {
|
||||
permissions["windows"].push("DEVICE_LOCK");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/disenroll/windows")) {
|
||||
permissions["windows"].push("DISENROLL");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/wipe")) {
|
||||
permissions["windows"].push("WIPE_DATA");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/ring")) {
|
||||
permissions["windows"].push("DEVICE_RING");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/lock-reset")) {
|
||||
permissions["windows"].push("LOCK_RESET");
|
||||
}
|
||||
|
||||
viewModel["permissions"] = stringify(permissions);
|
||||
|
||||
viewModel["deviceType"] = context.unit.params.deviceType;
|
||||
viewModel["ownership"] = context.unit.params.ownership;
|
||||
|
||||
return viewModel;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
@ -1,248 +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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Setting-up global variables.
|
||||
*/
|
||||
|
||||
var operations = '.wr-operations',
|
||||
modalPopup = '.modal',
|
||||
modalPopupContent = modalPopup + ' .modal-content',
|
||||
navHeight = $('#nav').height(),
|
||||
headerHeight = $('header').height(),
|
||||
offset = (headerHeight + navHeight),
|
||||
deviceSelection = '.device-select',
|
||||
platformTypeConstants = {
|
||||
"ANDROID": "android",
|
||||
"IOS": "ios",
|
||||
"WINDOWS": "windows"
|
||||
},
|
||||
ownershipTypeConstants = {
|
||||
"BYOD": "BYOD",
|
||||
"COPE": "COPE"
|
||||
},
|
||||
operationBarModeConstants = {
|
||||
"BULK": "BULK_OPERATION_MODE",
|
||||
"SINGLE": "SINGLE_OPERATION_MODE"
|
||||
};
|
||||
|
||||
/*
|
||||
* Function to get selected devices ID's
|
||||
*/
|
||||
function getSelectedDeviceIds() {
|
||||
var deviceIdentifierList = [];
|
||||
$(deviceSelection).each(function (index) {
|
||||
var device = $(this);
|
||||
var deviceId = device.data('deviceid');
|
||||
var deviceType = device.data('type');
|
||||
deviceIdentifierList.push({
|
||||
"id": deviceId,
|
||||
"type": deviceType
|
||||
});
|
||||
});
|
||||
if (deviceIdentifierList.length == 0) {
|
||||
var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable();
|
||||
thisTable.api().rows().every(function () {
|
||||
if ($(this.node()).hasClass('DTTT_selected')) {
|
||||
var deviceId = $(thisTable.api().row(this).node()).data('deviceid');
|
||||
var deviceType = $(thisTable.api().row(this).node()).data('devicetype');
|
||||
deviceIdentifierList.push({
|
||||
"id": deviceId,
|
||||
"type": deviceType
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return deviceIdentifierList;
|
||||
}
|
||||
|
||||
/*
|
||||
* On operation click function.
|
||||
* @param selection: Selected operation
|
||||
*/
|
||||
function operationSelect(selection) {
|
||||
var deviceIdList = getSelectedDeviceIds();
|
||||
if (deviceIdList == 0) {
|
||||
$(modalPopupContent).html($("#errorOperations").html());
|
||||
} else {
|
||||
$(modalPopupContent).addClass("operation-data");
|
||||
$(modalPopupContent).html($(operations + " .operation[data-operation-code=" + selection + "]").html());
|
||||
$(modalPopupContent).data("operation-code", selection);
|
||||
}
|
||||
showPopup();
|
||||
}
|
||||
|
||||
function getDevicesByTypes(deviceList) {
|
||||
var deviceTypes = {};
|
||||
$.each(deviceList, function (index, item) {
|
||||
if (!deviceTypes[item.type]) {
|
||||
deviceTypes[item.type] = [];
|
||||
}
|
||||
if (item.type == platformTypeConstants.ANDROID ||
|
||||
item.type == platformTypeConstants.IOS || item.type == platformTypeConstants.WINDOWS) {
|
||||
deviceTypes[item.type].push(item.id);
|
||||
}
|
||||
});
|
||||
return deviceTypes;
|
||||
}
|
||||
|
||||
//function unloadOperationBar() {
|
||||
// $("#showOperationsBtn").addClass("hidden");
|
||||
// $(".wr-operations").html("");
|
||||
//}
|
||||
|
||||
function loadOperationBar(deviceType, ownership, mode) {
|
||||
var operationBar = $("#operations-bar");
|
||||
var operationBarSrc = operationBar.attr("src");
|
||||
|
||||
$.template("operations-bar", operationBarSrc, function (template) {
|
||||
var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/*/features";
|
||||
invokerUtil.get(
|
||||
serviceURL,
|
||||
// success callback
|
||||
function (data) {
|
||||
var permittedOperations = [];
|
||||
var i;
|
||||
var permissionList = $("#operations-mod").data("permissions");
|
||||
var totalFeatures = JSON.parse(data);
|
||||
for (i = 0; i < permissionList[deviceType].length; i++) {
|
||||
var j;
|
||||
for (j = 0; j < totalFeatures.length; j++) {
|
||||
if (permissionList[deviceType][i] == totalFeatures[j]["code"]) {
|
||||
if (deviceType == platformTypeConstants.ANDROID) {
|
||||
if (totalFeatures[j]["code"] == "DEVICE_UNLOCK") {
|
||||
if (ownership == ownershipTypeConstants.COPE) {
|
||||
permittedOperations.push(totalFeatures[j]);
|
||||
}
|
||||
} else if (totalFeatures[j]["code"] == "WIPE_DATA") {
|
||||
if (mode == operationBarModeConstants.BULK) {
|
||||
if (ownership == ownershipTypeConstants.COPE) {
|
||||
permittedOperations.push(totalFeatures[j]);
|
||||
}
|
||||
} else {
|
||||
permittedOperations.push(totalFeatures[j]);
|
||||
}
|
||||
} else {
|
||||
permittedOperations.push(totalFeatures[j]);
|
||||
}
|
||||
} else {
|
||||
permittedOperations.push(totalFeatures[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var viewModel = {};
|
||||
permittedOperations = permittedOperations.filter(function (current) {
|
||||
var iconName;
|
||||
switch (deviceType) {
|
||||
case platformTypeConstants.ANDROID:
|
||||
iconName = operationModule.getAndroidIconForFeature(current.code);
|
||||
break;
|
||||
case platformTypeConstants.WINDOWS:
|
||||
iconName = operationModule.getWindowsIconForFeature(current.code);
|
||||
break;
|
||||
case platformTypeConstants.IOS:
|
||||
iconName = operationModule.getIOSIconForFeature(current.code);
|
||||
break;
|
||||
}
|
||||
|
||||
/* adding ownership in addition to device-type
|
||||
as it's vital in cases where UI for the same feature should change
|
||||
according to ownership
|
||||
*/
|
||||
if (ownership) {
|
||||
current.ownership = ownership;
|
||||
}
|
||||
|
||||
if (iconName) {
|
||||
current.icon = iconName;
|
||||
}
|
||||
|
||||
return current;
|
||||
});
|
||||
|
||||
viewModel.features = permittedOperations;
|
||||
var content = template(viewModel);
|
||||
$(".wr-operations").html(content);
|
||||
},
|
||||
// error callback
|
||||
function (message) {
|
||||
$(".wr-operations").html(message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function runOperation(operationName) {
|
||||
var deviceIdList = getSelectedDeviceIds();
|
||||
var list = getDevicesByTypes(deviceIdList);
|
||||
|
||||
var successCallback = function (data) {
|
||||
if (operationName == "NOTIFICATION") {
|
||||
$(modalPopupContent).html($("#messageSuccess").html());
|
||||
} else {
|
||||
$(modalPopupContent).html($("#operationSuccess").html());
|
||||
}
|
||||
showPopup();
|
||||
};
|
||||
var errorCallback = function (data) {
|
||||
$(modalPopupContent).html($("#errorOperationUnexpected").html());
|
||||
showPopup();
|
||||
};
|
||||
|
||||
var payload, serviceEndPoint;
|
||||
if (list[platformTypeConstants.IOS]) {
|
||||
payload =
|
||||
operationModule.generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]);
|
||||
serviceEndPoint = operationModule.getIOSServiceEndpoint(operationName);
|
||||
} else if (list[platformTypeConstants.ANDROID]) {
|
||||
payload = operationModule
|
||||
.generatePayload(platformTypeConstants.ANDROID, operationName, list[platformTypeConstants.ANDROID]);
|
||||
serviceEndPoint = operationModule.getAndroidServiceEndpoint(operationName);
|
||||
} else if (list[platformTypeConstants.WINDOWS]) {
|
||||
payload = operationModule.generatePayload(platformTypeConstants.WINDOWS, operationName,
|
||||
list[platformTypeConstants.WINDOWS]);
|
||||
serviceEndPoint = operationModule.getWindowsServiceEndpoint(operationName);
|
||||
}
|
||||
if (operationName == "NOTIFICATION") {
|
||||
var errorMsgWrapper = "#notification-error-msg";
|
||||
var errorMsg = "#notification-error-msg span";
|
||||
var messageTitle = $("#messageTitle").val();
|
||||
var messageText = $("#messageText").val();
|
||||
if (!(messageTitle && messageText)) {
|
||||
$(errorMsg).text("Enter a message. It cannot be empty.");
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
} else {
|
||||
invokerUtil.post(serviceEndPoint, payload, successCallback, errorCallback);
|
||||
$(modalPopupContent).removeData();
|
||||
hidePopup();
|
||||
}
|
||||
} else {
|
||||
invokerUtil.post(serviceEndPoint, payload, successCallback, errorCallback);
|
||||
$(modalPopupContent).removeData();
|
||||
hidePopup();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* DOM ready functions.
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
$(operations).show();
|
||||
});
|
@ -1,286 +0,0 @@
|
||||
<div class="row no-gutter">
|
||||
<div class="wr-hidden-operations-nav col-lg-4">
|
||||
<a href="javascript:void(0)" onclick="showAdvanceOperation('security', this)" class="selected">
|
||||
<span class="wr-hidden-operations-icon fw-stack">
|
||||
<i class="fw fw-padlock fw-stack-2x"></i>
|
||||
</span>
|
||||
Security
|
||||
</a>
|
||||
<a href="javascript:void(0)" onclick="showAdvanceOperation('restriction', this)">
|
||||
<span class="wr-hidden-operations-icon fw-stack">
|
||||
<i class="fw fw-settings fw-stack-2x"></i>
|
||||
</span>
|
||||
Restrictions
|
||||
</a>
|
||||
<a href="javascript:void(0)" onclick="showAdvanceOperation('application', this)">
|
||||
<span class="wr-hidden-operations-icon fw-stack">
|
||||
<i class="fw fw-padlock fw-stack-2x"></i>
|
||||
</span>
|
||||
Applications
|
||||
</a>
|
||||
<a href="javascript:void(0)" onclick="showAdvanceOperation('wifi', this)">
|
||||
<span class="wr-hidden-operations-icon fw-stack">
|
||||
<i class="fw fw-wifi fw-stack-2x"></i>
|
||||
</span>
|
||||
Wi-fi
|
||||
</a>
|
||||
</div>
|
||||
<div class="wr-hidden-operations-content col-lg-8">
|
||||
|
||||
<!-- security -->
|
||||
<div class="wr-hidden-operation" data-operation="security" style="display: block">
|
||||
<div class="panel panel-default operation-data" data-operation="{{features.ENCRYPT_STORAGE.code}}">
|
||||
<div class="panel-heading" role="tab">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#enableEncryptionTab"
|
||||
aria-expanded="true" aria-controls="enableEncryptionTab">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Encryption Enable/Disable
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="enableEncryptionTab" class="panel-collapse panel-body collapse in" role="tabpanel"
|
||||
aria-labelledby="enableEncryptionTab">
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="enableEncryption"
|
||||
data-key="enableEncryption"/>
|
||||
<span class="helper" title="Enable Encryption">Enable Encryption<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.ENCRYPT_STORAGE.code}}')" class="btn-operations">Configure</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default operation-data" data-operation="{{features.PASSCODE_POLICY.code}}">
|
||||
<div class="panel-heading" role="tab">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#passCodePolicy" aria-expanded="false"
|
||||
aria-controls="passCodePolicy" class="collapsed">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Passcode Policy
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="passCodePolicy" class="panel-collapse panel-body collapse" role="tabpanel"
|
||||
aria-labelledby="passCodePolicy">
|
||||
|
||||
<label class="wr-input-label col-sm-4" for="maxFailedAttempts">Maximum Failed Attempts</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="maxFailedAttempts"
|
||||
data-key="maxFailedAttempts" placeholder="Enter maximum Failed Attempts">
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label col-sm-4" for="minLength">Minimum Length</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="minLength" data-key="minLength"
|
||||
placeholder="Enter minimum Length">
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label col-sm-4" for="pinHistory">PIN History</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="pinHistory" data-key="pinHistory"
|
||||
placeholder="Enter PIN History">
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label col-sm-4" for="minComplexChars">Minimum complex characters</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="minComplexChars"
|
||||
data-key="minComplexChars" placeholder="Enter minimum complex characters">
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label col-sm-4" for="lockcode">Minimum PIN Age in days</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="maxPINAgeInDays"
|
||||
data-key="maxPINAgeInDays" placeholder="Enter minimum PIN age in days">
|
||||
</div>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="requireAlphanumeric"
|
||||
data-key="requireAlphanumeric"/>
|
||||
<span class="helper" title="Require Alphanumeric">Require Alphanumeric<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="allowSimple" data-key="allowSimple"/>
|
||||
<span class="helper" title="Allow simple PIN">Allow simple PIN<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<a href="javascript:runOperation('{{features.PASSCODE_POLICY.code}}')" class="btn-operations">Configure</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /security -->
|
||||
|
||||
<!-- wi-fi -->
|
||||
<div class="wr-hidden-operation panel-body" data-operation="wifi">
|
||||
<div class="operation-data" data-operation="{{features.WIFI.code}}">
|
||||
<label class="wr-input-label" title="Identification of the wireless network to connect to">Service Set
|
||||
Identifier<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Identification of the wireless network to connect to</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="ssid" data-key="ssid"
|
||||
placeholder="Enter SSID"/>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="Password for the wireless network">Password<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Password for the wireless network</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="password" class="form-control operationDataKeys" id="password" data-key="password"
|
||||
placeholder="Password"/>
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.WIFI.code}}')" class="btn-operations">Configure</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /wi-fi -->
|
||||
<!-- application -->
|
||||
<div class="wr-hidden-operation" data-operation="application">
|
||||
<div class="panel panel-default operation-data" data-operation="{{features.INSTALL_APPLICATION.code}}">
|
||||
<div class="panel-heading" role="tab">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#installApp" aria-expanded="true"
|
||||
aria-controls="installApp">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Install App
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="installApp" class="panel-collapse panel-body collapse in" role="tabpanel"
|
||||
aria-labelledby="installApp">
|
||||
<label class="wr-input-label" title="Application Identifier">App Identifier<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="package-name"
|
||||
data-key="packageName" placeholder="Enter App Identifer"/>
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control dropdown">
|
||||
<span class="helper" title="App Type">App Type<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
<select class="form-control col-sm-8 operationDataKeys appTypesInput" id="type"
|
||||
data-key="type">
|
||||
<option>Public</option>
|
||||
<option>Enterprise</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<label class="wr-input-label" title="URL">URL<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="url" data-key="url"
|
||||
placeholder="Enter URL"/>
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.INSTALL_APPLICATION.code}}')" class="btn-operations">Install</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default operation-data" data-operation="{{features.WEBCLIP.code}}">
|
||||
<div class="panel-heading" role="tab">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#installWebClip" aria-expanded="true"
|
||||
aria-controls="installWebClip" class="collapsed">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Install Web Clip
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="installWebClip" class="panel-collapse panel-body collapse" role="tabpanel"
|
||||
aria-labelledby="installWebClip">
|
||||
<label class="wr-input-label" title="Title of the web clip">Title<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="title" data-key="title"
|
||||
placeholder="Enter Title"/>
|
||||
</div>
|
||||
<label class="wr-input-label" title="URL">URL<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="url" data-key="url"
|
||||
placeholder="Enter URL"/>
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.WEBCLIP.code}}')" class="btn-operations">Install</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default operation-data" data-operation="{{features.UNINSTALL_APPLICATION.code}}">
|
||||
<div class="panel-heading" role="tab">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#uninstallApp" aria-expanded="true"
|
||||
aria-controls="uninstallApp" class="collapsed">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Uninstall App
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="uninstallApp" class="panel-collapse panel-body collapse" role="tabpanel"
|
||||
aria-labelledby="uninstallApp">
|
||||
<label class="wr-input-label" title="Application Identifier">App Identifier<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Identification of the wireless network to connect to</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="package-name"
|
||||
data-key="packageName" placeholder="Enter App Identifer"/>
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.UNINSTALL_APPLICATION.code}}')" class="btn-operations">Uninstall</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /application -->
|
||||
|
||||
<!-- Restriction -->
|
||||
<div class="wr-hidden-operation" data-operation="restriction">
|
||||
<div class="panel panel-default operation-data" data-operation="{{features.CAMERA.code}}">
|
||||
<div class="panel-heading" role="tab">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#cameraDisable" aria-expanded="true"
|
||||
aria-controls="cameraDisable">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Camera Enable/Disable
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="cameraDisable" class="panel-collapse panel-body collapse in" role="tabpanel"
|
||||
aria-labelledby="cameraDisable">
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="enableCamera" data-key="enableCamera"
|
||||
checked/>
|
||||
<span class="helper" title="Remove App upon dis-enrollment">Enable Camera<span
|
||||
class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.CAMERA.code}}')" class="btn-operations">Configure</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Restriction -->
|
||||
</div>
|
||||
</div>
|
@ -1,366 +0,0 @@
|
||||
<div class="row no-gutter">
|
||||
<div class="wr-hidden-operations-nav col-lg-4">
|
||||
<a href="javascript:void(0)" onclick="showAdvanceOperation('{{features.WIFI.code}}', this)" class="selected">
|
||||
<span class="wr-hidden-operations-icon fw-stack">
|
||||
<i class="fw fw-wifi fw-stack-2x"></i>
|
||||
</span>
|
||||
Wi-fi
|
||||
</a>
|
||||
<a href="javascript:void(0)" onclick="showAdvanceOperation('application', this)" >
|
||||
<span class="wr-hidden-operations-icon fw-stack">
|
||||
<i class="fw fw-padlock fw-stack-2x"></i>
|
||||
</span>
|
||||
Applications
|
||||
</a>
|
||||
<a href="javascript:void(0)" onclick="showAdvanceOperation('{{features.RESTRICTION.code}}', this)">
|
||||
<span class="wr-hidden-operations-icon fw-stack">
|
||||
<i class="fw fw-settings fw-stack-2x"></i>
|
||||
</span>
|
||||
Restrictions
|
||||
</a>
|
||||
<a href="javascript:void(0)" onclick="showAdvanceOperation('mail', this)">
|
||||
<span class="wr-hidden-operations-icon fw-stack">
|
||||
<i class="fw fw-message fw-stack-2x"></i>
|
||||
</span>
|
||||
Mail
|
||||
</a>
|
||||
<a href="javascript:void(0)" onclick="showAdvanceOperation('{{features.AIR_PLAY.code}}', this)">
|
||||
<span class="wr-hidden-operations-icon fw-stack">
|
||||
<i class="fw fw-service-provider fw-stack-2x"></i>
|
||||
</span>
|
||||
Air Play
|
||||
</a>
|
||||
</div>
|
||||
<div class="wr-hidden-operations-content col-lg-8">
|
||||
|
||||
<!-- application -->
|
||||
<div class="wr-hidden-operation" data-operation="application" style="display: block">
|
||||
<div class="panel panel-default operation-data" data-operation="{{features.INSTALL_STORE_APPLICATION.code}}">
|
||||
<div class="panel-heading" role="tab">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#installPublicAppiOS" aria-expanded="true" aria-controls="installPublicAppiOS">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Install Public App
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="installPublicAppiOS" class="panel-collapse panel-body collapse in" role="tabpanel" aria-labelledby="installPublicAppiOS">
|
||||
<label class="wr-input-label" for="appIdentifier">App identifier</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="appIdentifier" data-key="appIdentifier" placeholder="Enter App Identifier">
|
||||
</div>
|
||||
<label class="wr-input-label col-sm-4" for="ituneID">iTunes store ID</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="ituneID" data-key="ituneID" placeholder="Enter iTunes store ID">
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label col-sm-4" for="bundleId">Bundle ID</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="bundleId" data-key="bundleId" placeholder="Enter Bundle ID">
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="appRemoval" data-key="appRemoval" checked />
|
||||
<span class="helper" title="Remove App upon dis-enrollment">Remove App upon dis-enrollment<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Enable if target network is not open or broadcasting</span-->
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="backupData" data-key="backupData" checked />
|
||||
<span class="helper" title="Prevent backup of App data">Prevent backup of App data<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Enable if target network is not open or broadcasting</span-->
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.INSTALL_STORE_APPLICATION.code}}')" class="btn-operations">Install</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="panel panel-default operation-data" data-operation="{{features.INSTALL_ENTERPRISE_APPLICATION.code}}">
|
||||
<div class="panel-heading" role="tab">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#installEnterpriseAppiOS" aria-expanded="true" aria-controls="installPublicAppiOS" class="collapsed">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Install Enterprise App
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="installEnterpriseAppiOS" class="panel-collapse panel-body collapse" role="tabpanel" aria-labelledby="installEnterpriseAppiOS">
|
||||
<label class="wr-input-label" for="appIdentifier">App identifier</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="appIdentifier" data-key="appIdentifier" placeholder="Enter App Identifier">
|
||||
</div>
|
||||
<label class="wr-input-label col-sm-4" for="manifestURL">Manifest URL</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="manifestURL" data-key="manifestURL" placeholder="Enter manifest URL">
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label col-sm-4" for="bundleId">Bundle ID</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="bundleId" data-key="bundleId" placeholder="Enter Bundle ID">
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="appRemoval" data-key="appRemoval" checked />
|
||||
<span class="helper" title="Remove App upon dis-enrollment">Remove App upon dis-enrollment<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Enable if target network is not open or broadcasting</span-->
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="backupData" data-key="backupData" checked />
|
||||
<span class="helper" title="Prevent backup of App data">Prevent backup of App data<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Enable if target network is not open or broadcasting</span-->
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.INSTALL_ENTERPRISE_APPLICATION.code}}')" class="btn-operations">Install</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default operation-data" data-operation="{{features.REMOVE_APPLICATION.code}}">
|
||||
<div class="panel-heading" role="tab">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#removeApplication" aria-expanded="true" aria-controls="removeApplication" class="collapsed">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Uninstall App
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="removeApplication" class="panel-collapse panel-body collapse" role="tabpanel" aria-labelledby="removeApplication">
|
||||
<label class="wr-input-label col-sm-4" for="bundleId">Bundle ID</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="bundleId" data-key="bundleId" placeholder="Enter Bundle ID">
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.REMOVE_APPLICATION.code}}')" class="btn-operations">Uninstall</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /application -->
|
||||
|
||||
<!-- wi-fi -->
|
||||
<div class="wr-hidden-operation panel-body operation-data" data-operation="{{features.WIFI.code}}">
|
||||
<label class="wr-input-label" title="Identification of the wireless network to connect to">Service Set Identifier<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Identification of the wireless network to connect to</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="ssid" data-key="ssid" placeholder="Enter SSID" />
|
||||
</div>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="hiddenNetwork" data-key="hiddenNetwork" checked />
|
||||
<span class="helper" title="Enable if target network is not open or broadcasting">Hidden Network<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Enable if target network is not open or broadcasting</span-->
|
||||
</div>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="autoJoin" data-key="autoJoin" checked />
|
||||
<span class="helper" title="Automatically join this wireless network">Auto Join<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Automatically join this wireless network</span-->
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="Configures proxies to be used with this network">Proxy Setup<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Configures proxies to be used with this network</span-->
|
||||
<div class="wr-input-control">
|
||||
<select class="form-control">
|
||||
<option>None</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="Wireless network encryption to use when connecting">Security Type<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Wireless network encryption to use when connecting</span-->
|
||||
<div class="wr-input-control">
|
||||
<select class="form-control operationDataKeys" id="encryptionType" data-key="encryptionType">
|
||||
<option data-id="WPA">WPA/WPA2 Personal</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="Password for the wireless network">Password<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Password for the wireless network</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="password" value="" class="operationDataKeys" id="password" data-key="password" placeholder="input text"/>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="Configures network to appear as legacy or Passport">Network Type<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Configures network to appear as legacy or Passport</span-->
|
||||
<div class="wr-input-control">
|
||||
<select class="form-control">
|
||||
<option>Standard</option>
|
||||
</select>
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.WIFI.code}}')" class="btn-operations">Configure</a>
|
||||
</div>
|
||||
<!-- /wi-fi -->
|
||||
|
||||
<!-- mail -->
|
||||
<div class="wr-hidden-operation panel-body" data-operation="mail">
|
||||
<label class="wr-input-label" title="The display name of the account">Account Description<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Identification of the wireless network to connect to</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="text" value="" placeholder="input text"/>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="The protocol for accessing the email account">Account Type<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Configures proxies to be used with this network</span-->
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-25">
|
||||
<select class="form-control">
|
||||
<option>IMAP</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="cus-col-50">
|
||||
<span>Path Prefix</span> <input type="text" value="" placeholder="input text" />
|
||||
</div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="The display name of the user">User Display Name<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Identification of the wireless network to connect to</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="text" value="" placeholder="input text"/>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="The address of the account">Email Address<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Identification of the wireless network to connect to</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="text" value="" placeholder="input text"/>
|
||||
</div>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" checked />
|
||||
<span class="helper" title="Messages can be moved from this account to another">Allow user to move messages from this account<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Enable if target network is not open or broadcasting</span-->
|
||||
</div>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" checked />
|
||||
<span class="helper" title="Include this account in recent address syncing">Allow Recent Address syncing<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Enable if target network is not open or broadcasting</span-->
|
||||
</div>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" checked />
|
||||
<span class="helper" title="Send outgoing mail from this account only from Mail app">Use Only in Mail<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Send outgoing mail from this account only from Mail app</span-->
|
||||
</div>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" checked />
|
||||
<span class="helper" title="Support S/MIME for this account">Enable S/MIME<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Support S/MIME for this account</span-->
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="The protocol for accessing the email account">Mail Server and Port<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>The protocol for accessing the email account</span-->
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-70">
|
||||
<input type="text" value="" placeholder="input text"/>
|
||||
</div>
|
||||
<div class="cus-col-25">
|
||||
<span> : </span><input type="text" value="993" placeholder="input text" />
|
||||
</div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="The username used to connect to the server for incoming mail">Username<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>The Username used to connect to the server for incoming mail</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="text" value="" placeholder="input text"/>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="The autyentication method for the incoming mail server">Authentication Type<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>Wireless network encryption to use when connecting</span-->
|
||||
<div class="wr-input-control">
|
||||
<select class="form-control">
|
||||
<option>Password</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="The password for the incoming mail server">Password<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></label>
|
||||
<!--span>The Username used to connect to the server for incoming mail</span-->
|
||||
<div class="wr-input-control">
|
||||
<input type="text" value="" placeholder="input text"/>
|
||||
</div>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" checked />
|
||||
<span class="helper" title="Retrieve incoming mail through secure socket layer">Use SSL<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
<!--span>Enable if target network is not open or broadcasting</span-->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /mail -->
|
||||
|
||||
<!-- general -->
|
||||
<div class="wr-hidden-operation panel-body operation-data" data-operation="{{features.RESTRICTION.code}}">
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="allowCamera" data-key="allowCamera" checked />
|
||||
<span class="helper" title="Allow Camera">Allow Camera<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="allowCloudBackup" data-key="allowCloudBackup" checked/>
|
||||
<span class="helper" title="Allow Cloud Backup">Allow Cloud Backup<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="allowScreenShot" data-key="allowScreenShot" checked/>
|
||||
<span class="helper" title="Allow Screenshots">Allow Screenshots<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="allowSafari" data-key="allowSafari" checked />
|
||||
<span class="helper" title="Allow Safari Browser">Allow Safari Browser<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control checkbox">
|
||||
<input type="checkbox" class="operationDataKeys" id="allowAirDrop" data-key="allowAirDrop" checked />
|
||||
<span class="helper" title="Allow AirDrop">Allow AirDrop<span class="wr-help-tip glyphicon glyphicon-question-sign"></span></span>
|
||||
</label>
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.RESTRICTION.code}}')" class="btn-operations">Configure</a>
|
||||
</div>
|
||||
<!-- /general -->
|
||||
<!-- air play -->
|
||||
<div class="wr-hidden-operation panel-body operation-data" data-operation="{{features.AIR_PLAY.code}}">
|
||||
<label class="wr-input-label col-sm-4" for="airPlayLocation">Location</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="airPlayLocation" data-key="location" placeholder="Enter location" />
|
||||
</div>
|
||||
<label class="wr-input-label col-sm-4" for="airPlayDeviceName">Device Name</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control operationDataKeys" id="airPlayDeviceName" data-key="deviceName" placeholder="Enter Device Name" />
|
||||
</div
|
||||
<label class="wr-input-label col-sm-4" for="airPlayPassword">AirPlay password</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="password" class="form-control operationDataKeys" id="airPlayPassword" data-key="password" placeholder="Password" />
|
||||
</div>
|
||||
<a href="javascript:runOperation('{{features.AIR_PLAY.code}}')" class="btn-operations">Configure</a>
|
||||
</div>
|
||||
<!-- /air play -->
|
||||
</div>
|
||||
</div>
|
@ -1,249 +0,0 @@
|
||||
<div id="errorOperations" class="operation">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-error fw-stack-1x"></i>
|
||||
</span>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>
|
||||
Please select a device or a list of devices to perform an operation.
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">Ok</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="errorOperationUnexpected" class="operation">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-error fw-stack-1x"></i>
|
||||
</span>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>
|
||||
Unexpected error occurred. Please Try again later.
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">Ok</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="operationSuccess" class="operation">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-check fw-stack-1x"></i>
|
||||
</span>
|
||||
Operation queued successfully !
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>
|
||||
Operation has been queued successfully to be sent to the device.
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">Ok</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="messageSuccess" class="operation">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-check fw-stack-1x"></i>
|
||||
</span>
|
||||
Message sent successfully !
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>Message has been queued to be sent to the device.</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">Ok</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{#each features}}
|
||||
<a href="javascript:operationSelect('{{code}}')" title="{{description}}">
|
||||
<i class="fw {{icon}}"></i>
|
||||
<span>{{name}}</span>
|
||||
</a>
|
||||
<div class="operation" data-operation-code="{{code}}">
|
||||
|
||||
<div class="modal-content clearfix">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw {{icon}} fw-stack-1x"></i>
|
||||
</span>
|
||||
{{name}}
|
||||
<br>
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>
|
||||
{{#equal code "WIPE_DATA"}}
|
||||
{{#equal deviceType "android"}}
|
||||
{{#equal ownership "BYOD"}}
|
||||
Enter PIN code* of the device
|
||||
<br><br>
|
||||
<div>
|
||||
<input id="pin" type="password"
|
||||
class="form-control modal-input operationDataKeys"
|
||||
placeholder="[ Required for a BYOD device ]" data-key="pin" />
|
||||
</div>
|
||||
{{/equal}}
|
||||
{{/equal}}
|
||||
{{/equal}}
|
||||
{{#equal code "NOTIFICATION"}}
|
||||
Type your message below.
|
||||
<br><br>
|
||||
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control modal-input operationDataKeys"
|
||||
id="messageTitle" data-key="messageTitle" placeholder="Title here..." />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<textarea class="form-control modal-input operationDataKeys"
|
||||
id="messageText" data-key="messageText" placeholder="Message here..."></textarea>
|
||||
</div>
|
||||
<br>
|
||||
{{/equal}}
|
||||
{{#equal code "CHANGE_LOCK_CODE"}}
|
||||
Type new lock-code below.
|
||||
<br><br>
|
||||
<input type="password" class="form-control modal-input operationDataKeys" id="lockcode"
|
||||
data-key="lockCode" placeholder="Enter Lockcode"/>
|
||||
<br>
|
||||
{{/equal}}
|
||||
{{#equal code "DEVICE_LOCK"}}
|
||||
{{#equal deviceType "android"}}
|
||||
{{#equal ownership "COPE"}}
|
||||
<label class="wr-input-control checkbox">
|
||||
<input id="hard-lock" type="checkbox" class="form-control operationDataKeys"
|
||||
data-key="hard-lock"/>
|
||||
<span class="helper" title="Once it enables, device will be blocked permanently.">
|
||||
Enable Permanent Lock
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</span>
|
||||
</label>
|
||||
<br><br>
|
||||
{{/equal}}
|
||||
Type your message to be shown in the lock screen
|
||||
<br><br>
|
||||
<div>
|
||||
<textarea id="lock-message" class="form-control modal-input operationDataKeys"
|
||||
data-key="lock-message" placeholder="[ Message content is optional ]"></textarea>
|
||||
</div>
|
||||
{{/equal}}
|
||||
{{/equal}}
|
||||
{{#equal code "UPGRADE_FIRMWARE"}}
|
||||
{{#equal deviceType "android"}}
|
||||
Enter firmware upgrade scheduling information.
|
||||
<br><br>
|
||||
<label class="wr-input-control checkbox">
|
||||
<input id="instant-upgrade" type="checkbox" class="form-control operationDataKeys"
|
||||
data-key="instant-upgrade"/>
|
||||
<span class="helper"
|
||||
title="Once enabled, device firmware upgrade process will start instantly.">
|
||||
Instant Upgrade
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</span>
|
||||
</label>
|
||||
<br><br>
|
||||
<div class='input-group date' id='dateTimePicker'>
|
||||
Enter the date and time to schedule firmware upgrade.
|
||||
<br><br>
|
||||
<div id="firmware-error-msg" class="alert alert-danger hidden" role="alert">
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
<input type='text' class="form-control modal-input operationDataKeys"
|
||||
style="z-index : 900;" name="daterange" id="schedule" data-key="schedule"/>
|
||||
</div>
|
||||
<br><br>
|
||||
<div class='wr-input-control' id='firmwareServerInfo'>
|
||||
Enter firmware upgrade server URL (ie. http://abc.com or http://abc.com/ota)
|
||||
(Optional).
|
||||
<br><br>
|
||||
<input type='text' class="form-control modal-input operationDataKeys" id="server"
|
||||
data-key="server"/>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('.modalpopup-bg').css('z-index', '1000');
|
||||
$('.modalpopup-container').css('z-index', '1200');
|
||||
|
||||
$('input[name="daterange"]').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker: true,
|
||||
showDropdowns: true,
|
||||
timePickerIncrement: 1,
|
||||
locale: {
|
||||
format: 'MM-DD-YYYY hh:mm a'
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#instant-upgrade').change(function () {
|
||||
if ($(this).is(":checked")) {
|
||||
$('#dateTimePicker').addClass("hidden");
|
||||
$("#schedule").val('');
|
||||
|
||||
} else {
|
||||
$('#dateTimePicker').removeClass("hidden");
|
||||
$('input[name="daterange"]').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker: true,
|
||||
showDropdowns: true,
|
||||
timePickerIncrement: 1,
|
||||
locale: {
|
||||
format: 'MM-DD-YYYY hh:mm a'
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<br>
|
||||
{{/equal}}
|
||||
{{/equal}}
|
||||
<br><br>
|
||||
Do you want to perform this operation on selected device(s) ?
|
||||
<br>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:runOperation('{{code}}')" class="btn-operations">Yes</a>
|
||||
<a href="javascript:hidePopup()" class="btn-operations btn-default">No</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{/each}}
|
||||
<br class="c-both"/>
|
File diff suppressed because it is too large
Load Diff
@ -1,111 +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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.windows.api.services;
|
||||
|
||||
import io.swagger.annotations.SwaggerDefinition;
|
||||
import io.swagger.annotations.Info;
|
||||
import io.swagger.annotations.ExtensionProperty;
|
||||
import io.swagger.annotations.Extension;
|
||||
import io.swagger.annotations.Tag;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Windows Device Management REST-API implementation. All end points supports JSON, XMl with content negotiation.
|
||||
*/
|
||||
@Api(value = "Windows Device Management",
|
||||
description = "This carries all the resources related to Windows device management functionalities")
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
version = "1.0.0",
|
||||
title = "",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = "name", value = "Windows Device Management"),
|
||||
@ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/devices"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "devicemgt_windows", description = "")
|
||||
}
|
||||
)
|
||||
@WebService
|
||||
@Path("/devices")
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public interface DeviceManagementService {
|
||||
|
||||
/**
|
||||
* Get all devices.Returns list of Windows devices registered in MDM.
|
||||
*
|
||||
* @return Returns retrieved devices.
|
||||
* @throws WindowsConfigurationException occurred while retrieving all the devices from DB.
|
||||
*/
|
||||
@GET
|
||||
List<Device> getAllDevices() throws WindowsConfigurationException;
|
||||
|
||||
/**
|
||||
* Fetch Windows device details of a given device Id.
|
||||
*
|
||||
* @param deviceId Device Id
|
||||
* @return Returns retrieved device.
|
||||
* @throws WindowsConfigurationException occurred while getting device from DB.
|
||||
*/
|
||||
@GET
|
||||
@Path("{id}")
|
||||
Device getDevice(@PathParam("id") String deviceId) throws WindowsConfigurationException;
|
||||
|
||||
/**
|
||||
* Update Windows device details of given device id.
|
||||
*
|
||||
* @param deviceId Device Id.
|
||||
* @param device Device details to be updated.
|
||||
* @return Returns the message whether device update or not.
|
||||
* @throws WindowsConfigurationException occurred while updating the Device Info.
|
||||
*/
|
||||
@PUT
|
||||
@Path("{id}")
|
||||
Message updateDevice(@PathParam("id") String deviceId, Device device) throws WindowsConfigurationException;
|
||||
|
||||
/**
|
||||
* Fetch the Licence agreement for specific windows platform.
|
||||
*
|
||||
* @return Returns License agreement.
|
||||
* @throws WindowsConfigurationException occurred while getting licence for specific platform and Language.
|
||||
*/
|
||||
@GET
|
||||
@Path("license")
|
||||
@Produces("application/json")
|
||||
License getLicense() throws WindowsConfigurationException;
|
||||
}
|
@ -1,46 +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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.windows.api.services;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.ws.rs.*;
|
||||
|
||||
/**
|
||||
* Endpoint for Enforce Effective Policy.
|
||||
*/
|
||||
@WebService
|
||||
@Produces({ "application/json", "application/xml"})
|
||||
@Consumes({"application/json", "application/xml"})
|
||||
public interface PolicyManagementService {
|
||||
|
||||
/**
|
||||
* Get the applicable effective policy for an enrolled windows device.
|
||||
*
|
||||
* @param deviceId Device Id
|
||||
* @return Returns retrieved devices.
|
||||
* @throws WindowsConfigurationException occurred while retrieving all the devices from DB.
|
||||
*/
|
||||
@GET
|
||||
@Path("{deviceId}")
|
||||
Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader,
|
||||
@PathParam("deviceId") String deviceId) throws WindowsConfigurationException;
|
||||
}
|
@ -1,157 +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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.windows.api.services.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.services.DeviceManagementService;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Windows Device Management REST-API implementation.
|
||||
* All end points supports JSON, XMl with content negotiation.
|
||||
*/
|
||||
@WebService
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
|
||||
|
||||
private static Log log = LogFactory.getLog(
|
||||
org.wso2.carbon.device.mgt.mobile.windows.api.services.impl.DeviceManagementServiceImpl.class);
|
||||
|
||||
/**
|
||||
* Get all devices.Returns list of Windows devices registered in MDM.
|
||||
*
|
||||
* @return Returns retrieved devices.
|
||||
* @throws WindowsConfigurationException occurred while retrieving all the devices from DB.
|
||||
*/
|
||||
@GET
|
||||
public List<Device> getAllDevices() throws WindowsConfigurationException {
|
||||
String msg;
|
||||
List<Device> devices;
|
||||
try {
|
||||
devices = WindowsAPIUtils.getDeviceManagementService().
|
||||
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while fetching the device list.";
|
||||
log.error(msg, e);
|
||||
throw new WindowsConfigurationException(msg, e);
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch Windows device details of a given device Id.
|
||||
*
|
||||
* @param deviceId Device Id
|
||||
* @return Returns retrieved device.
|
||||
* @throws WindowsConfigurationException occurred while getting device from DB.
|
||||
*/
|
||||
@GET
|
||||
@Path("{id}")
|
||||
public Device getDevice(@PathParam("id") String deviceId) throws WindowsConfigurationException {
|
||||
String msg;
|
||||
Device device;
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(deviceId);
|
||||
device = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
if (device == null) {
|
||||
Response.status(Response.Status.NOT_FOUND);
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while fetching the device information.";
|
||||
log.error(msg, e);
|
||||
throw new WindowsConfigurationException(msg, e);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Windows device details of given device id.
|
||||
*
|
||||
* @param deviceId Device Id.
|
||||
* @param device Device details to be updated.
|
||||
* @return Returns the message whether device update or not.
|
||||
* @throws WindowsConfigurationException occurred while updating the Device Info.
|
||||
*/
|
||||
@PUT
|
||||
@Path("{id}")
|
||||
public Message updateDevice(@PathParam("id") String deviceId, Device device) throws WindowsConfigurationException {
|
||||
String msg;
|
||||
Message responseMessage = new Message();
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||
boolean isUpdated;
|
||||
try {
|
||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||
isUpdated = WindowsAPIUtils.getDeviceManagementService().updateDeviceInfo(deviceIdentifier, device);
|
||||
if (isUpdated) {
|
||||
Response.status(Response.Status.ACCEPTED);
|
||||
responseMessage.setResponseMessage("Device information has modified successfully.");
|
||||
} else {
|
||||
Response.status(Response.Status.NOT_MODIFIED);
|
||||
responseMessage.setResponseMessage("Device not found for the update.");
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while modifying the device information.";
|
||||
log.error(msg, e);
|
||||
throw new WindowsConfigurationException(msg, e);
|
||||
}
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the Licence agreement for specific windows platform.
|
||||
*
|
||||
* @return Returns License agreement.
|
||||
* @throws WindowsConfigurationException occurred while getting licence for specific platform and Language.
|
||||
*/
|
||||
@GET
|
||||
@Path("license")
|
||||
@Produces("application/json")
|
||||
public License getLicense() throws WindowsConfigurationException {
|
||||
License license;
|
||||
try {
|
||||
license =
|
||||
WindowsAPIUtils.getDeviceManagementService().getLicense(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS,
|
||||
DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US);
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while retrieving the license configured for Windows device enrollment";
|
||||
log.error(msg, e);
|
||||
throw new WindowsConfigurationException(msg, e);
|
||||
}
|
||||
return license;
|
||||
}
|
||||
}
|
@ -1,71 +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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.windows.api.services.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils;
|
||||
import org.wso2.carbon.device.mgt.mobile.windows.api.services.PolicyManagementService;
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@WebService
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public class PolicyManagementServiceImpl implements PolicyManagementService {
|
||||
private static Log log = LogFactory.getLog(
|
||||
org.wso2.carbon.device.mgt.mobile.windows.api.services.impl.PolicyManagementServiceImpl.class);
|
||||
|
||||
@GET
|
||||
@Path("{deviceId}")
|
||||
public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader,
|
||||
@PathParam("deviceId") String deviceId) throws WindowsConfigurationException {
|
||||
|
||||
DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(deviceId);
|
||||
Message responseMessage = new Message();
|
||||
Policy policy;
|
||||
try {
|
||||
PolicyManagerService policyManagerService = WindowsAPIUtils.getPolicyManagerService();
|
||||
policy = policyManagerService.getEffectivePolicy(deviceIdentifier);
|
||||
if (policy == null) {
|
||||
responseMessage.setResponseCode(Response.Status.NO_CONTENT.toString());
|
||||
responseMessage.setResponseMessage("No effective policy found");
|
||||
return responseMessage;
|
||||
} else {
|
||||
responseMessage.setResponseCode(Response.Status.OK.toString());
|
||||
responseMessage.setResponseMessage("Effective policy added to operation");
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
} catch (PolicyManagementException e) {
|
||||
String msg = "Error occurred while getting the policy.";
|
||||
log.error(msg, e);
|
||||
throw new WindowsConfigurationException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue