mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Merge pull request #4 from dulichan/master
UI improvements and backend implementations
This commit is contained in:
commit
4c1d4a01a5
@ -22,13 +22,11 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
/**
|
||||
* Class for holding data source configuration in mobile-config.xml at parsing with JAXB.
|
||||
*/
|
||||
@XmlRootElement(name = "DataSourceConfiguration")
|
||||
public class MobileDataSourceConfig {
|
||||
@XmlRootElement(name = "DataSourceConfiguration") public class MobileDataSourceConfig {
|
||||
|
||||
private JNDILookupDefinition jndiLookupDefinition;
|
||||
|
||||
@XmlElement(name = "JndiLookupDefinition", nillable = true)
|
||||
public JNDILookupDefinition getJndiLookupDefintion() {
|
||||
@XmlElement(name = "JndiLookupDefinition", nillable = true) public JNDILookupDefinition getJndiLookupDefinition() {
|
||||
return jndiLookupDefinition;
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ public class MobileDeviceManagementDAOFactory {
|
||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||
"is null and thus, is not initialized");
|
||||
}
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
|
||||
if (jndiConfig != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||
|
||||
@ -51,7 +51,7 @@ public class MobileDeviceManagementDAOUtil {
|
||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||
"is null and thus, is not initialized");
|
||||
}
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
|
||||
if (jndiConfig != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||
|
||||
1
pom.xml
1
pom.xml
@ -227,6 +227,7 @@
|
||||
<carbon.feature.version>1.1.0</carbon.feature.version>
|
||||
<process.feature.version>1.0.0</process.feature.version>
|
||||
<uuid.feature.version>1.0.0</uuid.feature.version>
|
||||
<sso.feature.version>1.1.0-SNAPSHOT</sso.feature.version>
|
||||
<jaggery-test.feature.version>1.1.0</jaggery-test.feature.version>
|
||||
<!--Testing -->
|
||||
<test.framework.version>4.3.1</test.framework.version>
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
<%
|
||||
/*
|
||||
* 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 verb = request.getMethod();
|
||||
var uri = request.getRequestURI();
|
||||
var callPath=uri.replace("/cdm/api/","");
|
||||
var log = new Log();
|
||||
var deviceModule = require("/modules/device.js");
|
||||
if (uri != null) {
|
||||
var uriMatcher = new URIMatcher(callPath);
|
||||
log.info(callPath);
|
||||
if (uriMatcher.match("devices/mobile/{type}/{deviceid}/")) {
|
||||
var deviceId = uriMatcher.elements().deviceid;
|
||||
var type = uriMatcher.elements().type;
|
||||
var result = deviceModule.viewDevice(type, deviceId);
|
||||
print(result);
|
||||
}
|
||||
if (uriMatcher.match("devices/mobile/")) {
|
||||
var result = deviceModule.listDevices();
|
||||
print(result);
|
||||
}
|
||||
}
|
||||
%>
|
||||
@ -1,6 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
function identifierFormatter(value, row, index) {
|
||||
return [
|
||||
'<a class="like" href="/cdm/devices/'+value+'" title="Like">',
|
||||
value,
|
||||
'</a>'
|
||||
].join('');}
|
||||
'<a class="like" href="/cdm/devices/' + row["deviceType"] + '/' + value + '" title="Like">',
|
||||
value,
|
||||
'</a>'
|
||||
].join('');
|
||||
}
|
||||
@ -1 +1,32 @@
|
||||
//Init js to execute
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
//Init js to execute
|
||||
var logger = new Log();
|
||||
logger.debug("running debug");
|
||||
var app_TENANT_CONFIGS = 'tenant.configs';
|
||||
var app_carbon = require('carbon');
|
||||
var app_configs = {
|
||||
"HTTPS_URL": "https://localhost:9443"
|
||||
};
|
||||
|
||||
var app_server = new app_carbon.server.Server({
|
||||
tenanted: app_configs.tenanted,
|
||||
url: app_configs.HTTPS_URL + '/admin'
|
||||
});
|
||||
application.put("SERVER", app_server);
|
||||
application.put(app_TENANT_CONFIGS, {});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"welcomeFiles": ["pages/dashboard.jag"],
|
||||
"initScripts": ["init.js"],
|
||||
"initScripts": ["/init.js"],
|
||||
"urlMappings": [
|
||||
{
|
||||
"url": "/devices/*",
|
||||
@ -9,12 +9,16 @@
|
||||
{
|
||||
"url": "/dashboard",
|
||||
"path": "/pages/dashboard.jag"
|
||||
},
|
||||
{
|
||||
"url": "/api/devices/mobile/*",
|
||||
"path": "/api/mobile/device-api.jag"
|
||||
}
|
||||
],
|
||||
"errorPages": {
|
||||
"500": "/error500.jag",
|
||||
"404": "/error404.jag",
|
||||
"403": "/error403.jag"
|
||||
"403": "/error403.jag "
|
||||
},
|
||||
"logLevel": "info"
|
||||
"logLevel": "debug"
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 utility = require("/modules/utility.js");
|
||||
var DeviceIdentifier = Packages.org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
var log = new Log();
|
||||
|
||||
var deviceManagementService = utility.getDeviceManagementService();
|
||||
|
||||
var listDevices = function () {
|
||||
var devices = deviceManagementService.getAllDevices("android");
|
||||
var deviceList = [];
|
||||
|
||||
for (i = 0; i < devices.size(); i++) {
|
||||
var device = devices.get(i);
|
||||
deviceList.push({
|
||||
"identifier": device.getDeviceIdentifier(),
|
||||
"name": device.getName(),
|
||||
"ownership": device.getOwnership(),
|
||||
"owner": device.getOwner(),
|
||||
"deviceType": device.getType(),
|
||||
"vendor": device.getProperties().get("vendor"),
|
||||
"model": device.getProperties().get("model"),
|
||||
"osVersion": device.getProperties().get("osVersion")
|
||||
});
|
||||
}
|
||||
return deviceList;
|
||||
}
|
||||
var getDevice = function(type, deviceId){
|
||||
var deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setType(type);
|
||||
deviceIdentifier.setId(deviceId);
|
||||
var device = deviceManagementService.getDevice(deviceIdentifier);
|
||||
return device;
|
||||
}
|
||||
|
||||
var viewDevice = function(type, deviceId){
|
||||
var device = this.getDevice(type, deviceId);
|
||||
|
||||
var entries = device.getProperties().entrySet();
|
||||
var iterator = entries.iterator();
|
||||
var properties = {};
|
||||
while(iterator.hasNext()){
|
||||
var entry = iterator.next();
|
||||
var key = entry.getKey();
|
||||
var value = entry.getValue();
|
||||
properties[key]= value;
|
||||
}
|
||||
return {
|
||||
"identifier": device.getDeviceIdentifier(),
|
||||
"name": device.getName(),
|
||||
"ownership": device.getOwnership(),
|
||||
"owner": device.getOwner(),
|
||||
"deviceType": device.getType(),
|
||||
"vendor": device.getProperties().get("vendor"),
|
||||
"model": device.getProperties().get("model"),
|
||||
"osVersion": device.getProperties().get("osVersion"),
|
||||
"properties": properties
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//temporary
|
||||
|
||||
var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext,
|
||||
Class = java.lang.Class;
|
||||
|
||||
osgiService = function (clazz) {
|
||||
return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(Class.forName(clazz));
|
||||
};
|
||||
var getDeviceManagementService= function(){
|
||||
//server.authenticate("admin", "admin");
|
||||
var realmService = osgiService('org.wso2.carbon.device.mgt.core.service.DeviceManagementService');
|
||||
//var realmService = null;
|
||||
return realmService;
|
||||
}
|
||||
@ -1,5 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<%
|
||||
<%
|
||||
/*
|
||||
* 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 title="WSO2 CDM";
|
||||
%>
|
||||
<html lang="en">
|
||||
@ -14,25 +31,43 @@ var title="WSO2 CDM";
|
||||
<div class="row">
|
||||
<div class="col-sm-9 main col-centered">
|
||||
<h2 class="sub-header">Devices list</h2>
|
||||
<!--
|
||||
<div class="row">
|
||||
<div class="col-md-1"><button type="button" class="btn btn-primary">Execute</button></div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table id="table-pagination" data-toggle="table" data-url="data2.json" data-query-params="queryParams" data-height="400" data-pagination="true" data-search="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-field="state" data-checkbox="true"></th>
|
||||
<th data-field="identifier" data-align="right" data-sortable="true" data-formatter="identifierFormatter">Identifier</th>
|
||||
<th data-field="name" data-align="center" data-sortable="true">Name</th>
|
||||
<th data-field="owner" data-align="center" data-sortable="true">Owner</th>
|
||||
<th data-field="ownership" data-align="center" data-sortable="true">Ownership</th>
|
||||
<th data-field="deviceType" data-align="center" data-sortable="true">Device Type</th>
|
||||
<th data-field="vendor" data-align="center" data-sortable="true">Vendor</th>
|
||||
<th data-field="model" data-align="center" data-sortable="true">Model</th>
|
||||
<th data-field="osVersion" data-align="center" data-sortable="true">OS Version</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
-->
|
||||
<div role="devicepanel">
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="active"><a href="#mobile" aria-controls="home" role="tab" data-toggle="tab">Mobile</a></li>
|
||||
<li role="presentation"><a href="#raspberrypi" aria-controls="profile" role="tab" data-toggle="tab">RaspberryPi</a></li>
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div role="devicepanel" class="tab-pane active" id="mobile">
|
||||
<div class="table-responsive">
|
||||
<table id="table-pagination" data-toggle="table" data-url="/cdm/api/devices/mobile" data-query-params="queryParams" data-height="400" data-pagination="true" data-search="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-field="state" data-checkbox="true"></th>
|
||||
<th data-field="identifier" data-align="right" data-sortable="true" data-formatter="identifierFormatter">Identifier</th>
|
||||
<th data-field="name" data-align="center" data-sortable="true">Name</th>
|
||||
<th data-field="owner" data-align="center" data-sortable="true">Owner</th>
|
||||
<th data-field="ownership" data-align="center" data-sortable="true">Ownership</th>
|
||||
<th data-field="deviceType" data-align="center" data-sortable="true">Device Type</th>
|
||||
<th data-field="vendor" data-align="center" data-sortable="true">Vendor</th>
|
||||
<th data-field="model" data-align="center" data-sortable="true">Model</th>
|
||||
<th data-field="osVersion" data-align="center" data-sortable="true">OS Version</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div role="devicepanel" class="tab-pane" id="raspberrypi">sdfweroiweuroi</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<%
|
||||
<%
|
||||
/*
|
||||
* 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 title="WSO2 CDM";
|
||||
%>
|
||||
<html lang="en">
|
||||
@ -9,11 +26,20 @@ var title="WSO2 CDM";
|
||||
<body>
|
||||
<%
|
||||
include("/includes/header.jag");
|
||||
|
||||
var deviceModule = require("/modules/device.js");
|
||||
var uri = request.getRequestURI();
|
||||
var callPath=uri.replace("/cdm/","");
|
||||
var uriMatcher = new URIMatcher(callPath);
|
||||
uriMatcher.match("devices/{type}/{deviceid}/");
|
||||
var deviceId = uriMatcher.elements().deviceid;
|
||||
var type = uriMatcher.elements().type;
|
||||
var device = deviceModule.viewDevice(type, deviceId);
|
||||
%>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-sm-9 main col-centered">
|
||||
<h2 class="sub-header">Dulitha's iPhone</h2>
|
||||
<h2 class="sub-header"><%=device.name%></h2>
|
||||
<div class="row">
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -33,36 +59,44 @@ var title="WSO2 CDM";
|
||||
<div class="col-md-8">
|
||||
<div class="row">
|
||||
<div class="col-md-12 well well-lg device-static-data">
|
||||
<p>Model: <span>GT-I9500</span> </p>
|
||||
<p>IMSI : <span>GT-I9500</span> </p>
|
||||
<p>IMEI : <span>GT-I9500</span> </p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 well well-lg device-static-data">
|
||||
<p>Model: <span>GT-I9500</span> </p>
|
||||
<p>IMSI : <span>GT-I9500</span> </p>
|
||||
<p>IMEI : <span>GT-I9500</span> </p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 well well-lg device-static-data">
|
||||
<table id="table-pagination" data-toggle="table" data-url="/cdm/data3.json" data-query-params="queryParams" data-height="300" data-pagination="true" data-search="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-field="appName" data-align="right" data-sortable="true">App name</th>
|
||||
<th data-field="packageName" data-align="center" data-sortable="true">Package name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%
|
||||
for (var property in device.properties) {
|
||||
if (device.properties.hasOwnProperty(property)) {
|
||||
var value = device.properties[property];
|
||||
%>
|
||||
<p><%=property %>: <span><%=value %></span> </p>
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 well well-lg device-static-data">
|
||||
<p>Model: <span>GT-I9500</span> </p>
|
||||
<p>IMSI : <span>GT-I9500</span> </p>
|
||||
<p>IMEI : <span>GT-I9500</span> </p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 well well-lg device-static-data">
|
||||
<table id="table-pagination" data-toggle="table" data-url="/cdm/data3.json" data-query-params="queryParams" data-height="300" data-pagination="true" data-search="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-field="appName" data-align="right" data-sortable="true">App name</th>
|
||||
<th data-field="packageName" data-align="center" data-sortable="true">Package name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
include("/includes/layout-footer.jag");
|
||||
%>
|
||||
</body>
|
||||
|
||||
@ -127,6 +127,9 @@
|
||||
<featureArtifactDef>
|
||||
org.jaggeryjs.modules:uuid.feature:${uuid.feature.version}
|
||||
</featureArtifactDef>
|
||||
<featureArtifactDef>
|
||||
org.jaggeryjs.modules:sso.feature:${sso.feature.version}
|
||||
</featureArtifactDef>
|
||||
<featureArtifactDef>
|
||||
org.jaggeryjs.modules:jaggery-test.feature:${jaggery-test.feature.version}
|
||||
</featureArtifactDef>
|
||||
@ -284,6 +287,10 @@
|
||||
<id>org.jaggeryjs.modules.uuid.feature.group</id>
|
||||
<version>${uuid.feature.version}</version>
|
||||
</feature>
|
||||
<feature>
|
||||
<id>org.jaggeryjs.modules.sso.feature.group</id>
|
||||
<version>${sso.feature.version}</version>
|
||||
</feature>
|
||||
<feature>
|
||||
<id>org.jaggeryjs.modules.jaggery-test.feature.group</id>
|
||||
<version>${jaggery-test.feature.version}</version>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user