forked from community/device-mgt-plugins
parent
86018fddf1
commit
562ac197af
@ -0,0 +1,51 @@
|
|||||||
|
{{!
|
||||||
|
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.
|
||||||
|
}}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div id="general-config-heading" class="panel-heading" role="tab">
|
||||||
|
<h2 class="sub-title panel-title">
|
||||||
|
Android Sense Endpoint Configuration
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div id="android_sense-config-body" class="panel-collapse panel-body"
|
||||||
|
role="tabpanel">
|
||||||
|
<div id="android_sense-config-error-msg"
|
||||||
|
class="alert alert-danger hidden" role="alert">
|
||||||
|
<i class="icon fw fw-error"></i><span></span>
|
||||||
|
</div>
|
||||||
|
<div class="wr-input-control">
|
||||||
|
<label class="wr-input-label" for="email-config-host">
|
||||||
|
Mqtt Endpoint
|
||||||
|
<span class="helper" title="SMTP Server Host">
|
||||||
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</label>
|
||||||
|
<input id="mqtt-endpoint" type="text" class="form-control"
|
||||||
|
placeholder="[ Required Field ]">
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div class="wr-input-control wr-btn-grp">
|
||||||
|
<button id="save-general-btn" class="wr-btn" onclick="addConfiguration();">
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{#zone "bottomJs"}}
|
||||||
|
{{js "js/platform-configuration.js"}}
|
||||||
|
{{/zone}}
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"version" : "1.0.0"
|
||||||
|
}
|
@ -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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
invokerUtil.get(
|
||||||
|
"/devicemgt_admin/configuration",
|
||||||
|
function (data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data && data.configuration) {
|
||||||
|
for (var i = 0; i < data.configuration.length; i++) {
|
||||||
|
var config = data.configuration[i];
|
||||||
|
if (config.name == "ARDUINO_HTTP_IP") {
|
||||||
|
$("input#http-endpoint").val(config.value);
|
||||||
|
} else if (config.name == "ARDUINO_HTTP_PORT") {
|
||||||
|
$("input#https-endpoint").val(config.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function (data) {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Start of HTML embedded invoke methods
|
||||||
|
var showAdvanceOperation = function (operation, button) {
|
||||||
|
$(button).addClass('selected');
|
||||||
|
$(button).siblings().removeClass('selected');
|
||||||
|
var hiddenOperation = ".wr-hidden-operations-content > div";
|
||||||
|
$(hiddenOperation + '[data-operation="' + operation + '"]').show();
|
||||||
|
$(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Start of HTML embedded invoke methods
|
||||||
|
var addConfiguration = function () {
|
||||||
|
var errorMsgWrapper = "#android_sense-config-error-msg";
|
||||||
|
var errorMsg = "#android_sense-config-error-msg span";
|
||||||
|
var addConfigFormData = {};
|
||||||
|
var configList = new Array();
|
||||||
|
var mqttEp = $("input#mqtt-endpoint").val();
|
||||||
|
var mqttConfig = {
|
||||||
|
"name": "ANDROID_SENSE_MQTT_EP",
|
||||||
|
"value": String(mqttEp),
|
||||||
|
"contentType": "text"
|
||||||
|
};
|
||||||
|
|
||||||
|
configList.push(mqttConfig);
|
||||||
|
addConfigFormData.type = "android_sense"
|
||||||
|
addConfigFormData.configuration = configList;
|
||||||
|
|
||||||
|
var addConfigAPI = "/devicemgt_admin/configuration";
|
||||||
|
invokerUtil.post(
|
||||||
|
addConfigAPI,
|
||||||
|
addConfigFormData,
|
||||||
|
function (data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data.statusCode == 201) {
|
||||||
|
$("#config-save-form").addClass("hidden");
|
||||||
|
$("#record-created-msg").removeClass("hidden");
|
||||||
|
} else if (data == 500) {
|
||||||
|
$(errorMsg).text("Exception occurred at backend.");
|
||||||
|
} else if (data == 403) {
|
||||||
|
$(errorMsg).text("Action was not permitted.");
|
||||||
|
} else {
|
||||||
|
$(errorMsg).text("An unexpected error occurred.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
}, function (data) {
|
||||||
|
data = data.status;
|
||||||
|
if (data == 500) {
|
||||||
|
$(errorMsg).text("Exception occurred at backend.");
|
||||||
|
} else if (data == 403) {
|
||||||
|
$(errorMsg).text("Action was not permitted.");
|
||||||
|
} else {
|
||||||
|
$(errorMsg).text("An unexpected error occurred.");
|
||||||
|
}
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
@ -0,0 +1,62 @@
|
|||||||
|
{{!
|
||||||
|
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.
|
||||||
|
}}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div id="general-config-heading" class="panel-heading" role="tab">
|
||||||
|
<h2 class="sub-title panel-title">
|
||||||
|
Arduino Endpoint Configuration
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div id="arduino-config-body" class="panel-collapse panel-body"
|
||||||
|
role="tabpanel">
|
||||||
|
<div id="arduino-config-error-msg"
|
||||||
|
class="alert alert-danger hidden" role="alert">
|
||||||
|
<i class="icon fw fw-error"></i><span></span>
|
||||||
|
</div>
|
||||||
|
<div class="wr-input-control">
|
||||||
|
<label class="wr-input-label" for="email-config-host">
|
||||||
|
Http Server IP
|
||||||
|
<span class="helper" title="SMTP Server Host">
|
||||||
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</label>
|
||||||
|
<input id="http-endpoint" type="text" class="form-control"
|
||||||
|
placeholder="[ Required Field ]">
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<label class="wr-input-label" for="email-config-host">
|
||||||
|
Http Server Port
|
||||||
|
<span class="helper" title="SMTP Server Host">
|
||||||
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</label>
|
||||||
|
<input id="https-endpoint" type="text" class="form-control"
|
||||||
|
placeholder="[ Required Field ]">
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div class="wr-input-control wr-btn-grp">
|
||||||
|
<button id="save-general-btn" class="wr-btn" onclick="addConfiguration();">
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{#zone "bottomJs"}}
|
||||||
|
{{js "js/platform-configuration.js"}}
|
||||||
|
{{/zone}}
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"version" : "1.0.0"
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
invokerUtil.get(
|
||||||
|
"/devicemgt_admin/configuration",
|
||||||
|
function (data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data && data.configuration) {
|
||||||
|
for (var i = 0; i < data.configuration.length; i++) {
|
||||||
|
var config = data.configuration[i];
|
||||||
|
if (config.name == "ARDUINO_HTTP_IP") {
|
||||||
|
$("input#http-endpoint").val(config.value);
|
||||||
|
} else if (config.name == "ARDUINO_HTTP_PORT") {
|
||||||
|
$("input#https-endpoint").val(config.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function (data) {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Start of HTML embedded invoke methods
|
||||||
|
var showAdvanceOperation = function (operation, button) {
|
||||||
|
$(button).addClass('selected');
|
||||||
|
$(button).siblings().removeClass('selected');
|
||||||
|
var hiddenOperation = ".wr-hidden-operations-content > div";
|
||||||
|
$(hiddenOperation + '[data-operation="' + operation + '"]').show();
|
||||||
|
$(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Start of HTML embedded invoke methods
|
||||||
|
var addConfiguration = function () {
|
||||||
|
var errorMsgWrapper = "#arduino-config-error-msg";
|
||||||
|
var errorMsg = "#arduino-config-error-msg span";
|
||||||
|
var addConfigFormData = {};
|
||||||
|
var configList = new Array();
|
||||||
|
var httpEp = $("input#http-endpoint").val();
|
||||||
|
var httpConfig = {
|
||||||
|
"name": "ARDUINO_HTTP_IP",
|
||||||
|
"value": String(httpEp),
|
||||||
|
"contentType": "text"
|
||||||
|
};
|
||||||
|
|
||||||
|
var httpsEp = $("input#https-endpoint").val();
|
||||||
|
var httpsConfig = {
|
||||||
|
"name": "ARDUINO_HTTP_PORT",
|
||||||
|
"value": String(httpsEp),
|
||||||
|
"contentType": "text"
|
||||||
|
};
|
||||||
|
|
||||||
|
configList.push(httpConfig);
|
||||||
|
configList.push(httpsConfig);
|
||||||
|
addConfigFormData.type = "arduino"
|
||||||
|
addConfigFormData.configuration = configList;
|
||||||
|
|
||||||
|
var addConfigAPI = "/devicemgt_admin/configuration";
|
||||||
|
invokerUtil.post(
|
||||||
|
addConfigAPI,
|
||||||
|
addConfigFormData,
|
||||||
|
function (data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data.statusCode == 201) {
|
||||||
|
$("#config-save-form").addClass("hidden");
|
||||||
|
$("#record-created-msg").removeClass("hidden");
|
||||||
|
} else if (data == 500) {
|
||||||
|
$(errorMsg).text("Exception occurred at backend.");
|
||||||
|
} else if (data == 403) {
|
||||||
|
$(errorMsg).text("Action was not permitted.");
|
||||||
|
} else {
|
||||||
|
$(errorMsg).text("An unexpected error occurred.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
}, function (data) {
|
||||||
|
data = data.status;
|
||||||
|
if (data == 500) {
|
||||||
|
$(errorMsg).text("Exception occurred at backend.");
|
||||||
|
} else if (data == 403) {
|
||||||
|
$(errorMsg).text("Action was not permitted.");
|
||||||
|
} else {
|
||||||
|
$(errorMsg).text("An unexpected error occurred.");
|
||||||
|
}
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
@ -0,0 +1,72 @@
|
|||||||
|
{{!
|
||||||
|
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.
|
||||||
|
}}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div id="general-config-heading" class="panel-heading" role="tab">
|
||||||
|
<h2 class="sub-title panel-title">
|
||||||
|
Raspberrypi Endpoint Configuration
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div id="raspberrypi-config-body" class="panel-collapse panel-body"
|
||||||
|
role="tabpanel">
|
||||||
|
<div id="raspberrypi-config-error-msg"
|
||||||
|
class="alert alert-danger hidden" role="alert">
|
||||||
|
<i class="icon fw fw-error"></i><span></span>
|
||||||
|
</div>
|
||||||
|
<div class="wr-input-control">
|
||||||
|
<label class="wr-input-label" for="email-config-host">
|
||||||
|
Http Endpoint
|
||||||
|
<span class="helper" title="SMTP Server Host">
|
||||||
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</label>
|
||||||
|
<input id="http-endpoint" type="text" class="form-control"
|
||||||
|
placeholder="[ Required Field ]">
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<label class="wr-input-label" for="email-config-host">
|
||||||
|
Https Endpoint
|
||||||
|
<span class="helper" title="SMTP Server Host">
|
||||||
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</label>
|
||||||
|
<input id="https-endpoint" type="text" class="form-control"
|
||||||
|
placeholder="[ Required Field ]">
|
||||||
|
<br>
|
||||||
|
<label class="wr-input-label" for="email-config-host">
|
||||||
|
Mqtt Endpoint
|
||||||
|
<span class="helper" title="SMTP Server Host">
|
||||||
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</label>
|
||||||
|
<input id="mqtt-endpoint" type="text" class="form-control"
|
||||||
|
placeholder="[ Required Field ]">
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div class="wr-input-control wr-btn-grp">
|
||||||
|
<button id="save-general-btn" class="wr-btn" onclick="addConfiguration();">
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{#zone "bottomJs"}}
|
||||||
|
{{js "js/platform-configuration.js"}}
|
||||||
|
{{/zone}}
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"version" : "1.0.0"
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
invokerUtil.get(
|
||||||
|
"/devicemgt_admin/configuration",
|
||||||
|
function (data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data && data.configuration) {
|
||||||
|
for (var i = 0; i < data.configuration.length; i++) {
|
||||||
|
var config = data.configuration[i];
|
||||||
|
if (config.name == "RASPBERRYPI_HTTP_EP") {
|
||||||
|
$("input#http-endpoint").val(config.value);
|
||||||
|
} else if (config.name == "RASPBERRYPI_HTTPS_EP") {
|
||||||
|
$("input#https-endpoint").val(config.value);
|
||||||
|
} else if (config.name == "RASPBERRYPI_MQTT_EP") {
|
||||||
|
$("input#mqtt-endpoint").val(config.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function (data) {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Start of HTML embedded invoke methods
|
||||||
|
var showAdvanceOperation = function (operation, button) {
|
||||||
|
$(button).addClass('selected');
|
||||||
|
$(button).siblings().removeClass('selected');
|
||||||
|
var hiddenOperation = ".wr-hidden-operations-content > div";
|
||||||
|
$(hiddenOperation + '[data-operation="' + operation + '"]').show();
|
||||||
|
$(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Start of HTML embedded invoke methods
|
||||||
|
var addConfiguration = function () {
|
||||||
|
var errorMsgWrapper = "#virtual_firelarm-config-error-msg";
|
||||||
|
var errorMsg = "#virtual_firelarm-config-error-msg span";
|
||||||
|
var addConfigFormData = {};
|
||||||
|
var configList = new Array();
|
||||||
|
var httpEp = $("input#http-endpoint").val();
|
||||||
|
var httpConfig = {
|
||||||
|
"name": "RASPBERRYPI_HTTP_EP",
|
||||||
|
"value": String(httpEp),
|
||||||
|
"contentType": "text"
|
||||||
|
};
|
||||||
|
|
||||||
|
var httpsEp = $("input#https-endpoint").val();
|
||||||
|
var httpsConfig = {
|
||||||
|
"name": "RASPBERRYPI_HTTPS_EP",
|
||||||
|
"value": String(httpsEp),
|
||||||
|
"contentType": "text"
|
||||||
|
};
|
||||||
|
|
||||||
|
var mqttEp = $("input#mqtt-endpoint").val();
|
||||||
|
var mqttConfig = {
|
||||||
|
"name": "RASPBERRYPI_MQTT_EP",
|
||||||
|
"value": String(mqttEp),
|
||||||
|
"contentType": "text"
|
||||||
|
};
|
||||||
|
|
||||||
|
configList.push(httpConfig);
|
||||||
|
configList.push(httpsConfig);
|
||||||
|
configList.push(mqttConfig);
|
||||||
|
addConfigFormData.type = "raspberrypi"
|
||||||
|
addConfigFormData.configuration = configList;
|
||||||
|
|
||||||
|
var addConfigAPI = "/devicemgt_admin/configuration";
|
||||||
|
invokerUtil.post(
|
||||||
|
addConfigAPI,
|
||||||
|
addConfigFormData,
|
||||||
|
function (data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data.statusCode == 201) {
|
||||||
|
$("#config-save-form").addClass("hidden");
|
||||||
|
$("#record-created-msg").removeClass("hidden");
|
||||||
|
} else if (data == 500) {
|
||||||
|
$(errorMsg).text("Exception occurred at backend.");
|
||||||
|
} else if (data == 403) {
|
||||||
|
$(errorMsg).text("Action was not permitted.");
|
||||||
|
} else {
|
||||||
|
$(errorMsg).text("An unexpected error occurred.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
}, function (data) {
|
||||||
|
data = data.status;
|
||||||
|
if (data == 500) {
|
||||||
|
$(errorMsg).text("Exception occurred at backend.");
|
||||||
|
} else if (data == 403) {
|
||||||
|
$(errorMsg).text("Action was not permitted.");
|
||||||
|
} else {
|
||||||
|
$(errorMsg).text("An unexpected error occurred.");
|
||||||
|
}
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
@ -0,0 +1,74 @@
|
|||||||
|
{{!
|
||||||
|
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.
|
||||||
|
}}
|
||||||
|
<!--Virtual Firealarm-->
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div id="general-config-heading" class="panel-heading" role="tab">
|
||||||
|
<h2 class="sub-title panel-title">
|
||||||
|
Virtual Firealarm Endpoint Configuration
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div id="virtual-alarm-config-body" class="panel-collapse panel-body"
|
||||||
|
role="tabpanel">
|
||||||
|
<div id="virtual_firelarm-config-error-msg"
|
||||||
|
class="alert alert-danger hidden" role="alert">
|
||||||
|
<i class="icon fw fw-error"></i><span></span>
|
||||||
|
</div>
|
||||||
|
<div class="wr-input-control">
|
||||||
|
<label class="wr-input-label" for="email-config-host">
|
||||||
|
Http Endpoint
|
||||||
|
<span class="helper" title="SMTP Server Host">
|
||||||
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</label>
|
||||||
|
<input id="http-endpoint" type="text" class="form-control"
|
||||||
|
placeholder="[ Required Field ]">
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<label class="wr-input-label" for="email-config-host">
|
||||||
|
Https Endpoint
|
||||||
|
<span class="helper" title="SMTP Server Host">
|
||||||
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</label>
|
||||||
|
<input id="https-endpoint" type="text" class="form-control"
|
||||||
|
placeholder="[ Required Field ]">
|
||||||
|
<br>
|
||||||
|
<label class="wr-input-label" for="email-config-host">
|
||||||
|
Mqtt Endpoint
|
||||||
|
<span class="helper" title="SMTP Server Host">
|
||||||
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</label>
|
||||||
|
<input id="mqtt-endpoint" type="text" class="form-control"
|
||||||
|
placeholder="[ Required Field ]">
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div class="wr-input-control wr-btn-grp">
|
||||||
|
<button id="save-general-btn-virtualfirealarm" class="wr-btn" onclick="addConfiguration();">
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Virtual Firealarm-->
|
||||||
|
{{#zone "bottomJs"}}
|
||||||
|
{{js "js/platform-configuration.js"}}
|
||||||
|
{{/zone}}
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"version" : "1.0.0"
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
invokerUtil.get(
|
||||||
|
"/devicemgt_admin/configuration",
|
||||||
|
function (data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data && data.configuration) {
|
||||||
|
for (var i = 0; i < data.configuration.length; i++) {
|
||||||
|
var config = data.configuration[i];
|
||||||
|
if (config.name == "VIRTUAL_FIREALARM_HTTP_EP") {
|
||||||
|
$("input#http-endpoint").val(config.value);
|
||||||
|
} else if (config.name == "VIRTUAL_FIREALARM_HTTPS_EP") {
|
||||||
|
$("input#https-endpoint").val(config.value);
|
||||||
|
} else if (config.name == "VIRTUAL_FIREALARM_MQTT_EP") {
|
||||||
|
$("input#mqtt-endpoint").val(config.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function (data) {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Start of HTML embedded invoke methods
|
||||||
|
var showAdvanceOperation = function (operation, button) {
|
||||||
|
$(button).addClass('selected');
|
||||||
|
$(button).siblings().removeClass('selected');
|
||||||
|
var hiddenOperation = ".wr-hidden-operations-content > div";
|
||||||
|
$(hiddenOperation + '[data-operation="' + operation + '"]').show();
|
||||||
|
$(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Start of HTML embedded invoke methods
|
||||||
|
var addConfiguration = function () {
|
||||||
|
var errorMsgWrapper = "#virtual_firelarm-config-error-msg";
|
||||||
|
var errorMsg = "#virtual_firelarm-config-error-msg span";
|
||||||
|
var addConfigFormData = {};
|
||||||
|
var configList = new Array();
|
||||||
|
var httpEp = $("input#http-endpoint").val();
|
||||||
|
var httpConfig = {
|
||||||
|
"name": "VIRTUAL_FIREALARM_HTTP_EP",
|
||||||
|
"value": String(httpEp),
|
||||||
|
"contentType": "text"
|
||||||
|
};
|
||||||
|
|
||||||
|
var httpsEp = $("input#https-endpoint").val();
|
||||||
|
var httpsConfig = {
|
||||||
|
"name": "VIRTUAL_FIREALARM_HTTPS_EP",
|
||||||
|
"value": String(httpsEp),
|
||||||
|
"contentType": "text"
|
||||||
|
};
|
||||||
|
|
||||||
|
var mqttEp = $("input#mqtt-endpoint").val();
|
||||||
|
var mqttConfig = {
|
||||||
|
"name": "VIRTUAL_FIREALARM_MQTT_EP",
|
||||||
|
"value": String(mqttEp),
|
||||||
|
"contentType": "text"
|
||||||
|
};
|
||||||
|
|
||||||
|
configList.push(httpConfig);
|
||||||
|
configList.push(httpsConfig);
|
||||||
|
configList.push(mqttConfig);
|
||||||
|
addConfigFormData.type = "virtual_firealarm"
|
||||||
|
addConfigFormData.configuration = configList;
|
||||||
|
|
||||||
|
var addConfigAPI = "/devicemgt_admin/configuration";
|
||||||
|
invokerUtil.post(
|
||||||
|
addConfigAPI,
|
||||||
|
addConfigFormData,
|
||||||
|
function (data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data.statusCode == 201) {
|
||||||
|
$("#config-save-form").addClass("hidden");
|
||||||
|
$("#record-created-msg").removeClass("hidden");
|
||||||
|
} else if (data == 500) {
|
||||||
|
$(errorMsg).text("Exception occurred at backend.");
|
||||||
|
} else if (data == 403) {
|
||||||
|
$(errorMsg).text("Action was not permitted.");
|
||||||
|
} else {
|
||||||
|
$(errorMsg).text("An unexpected error occurred.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
}, function (data) {
|
||||||
|
data = data.status;
|
||||||
|
if (data == 500) {
|
||||||
|
$(errorMsg).text("Exception occurred at backend.");
|
||||||
|
} else if (data == 403) {
|
||||||
|
$(errorMsg).text("Action was not permitted.");
|
||||||
|
} else {
|
||||||
|
$(errorMsg).text("An unexpected error occurred.");
|
||||||
|
}
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in new issue