Adding create link option for Raspberry Pi device type

merge-requests/1/head
lasantha 7 years ago
parent 87e7452952
commit afacf9d32a

@ -84,8 +84,8 @@ function attachEvents() {
* on Device Management page in WSO2 DC Console.
*/
$("a.download-link").click(function () {
var sketchType = $(this).data("sketchtype");
var deviceType = $(this).data("devicetype");
var sketchType = $(".deviceType").val();
var deviceType = $(".sketchType").val();
var downloadDeviceAPI = "/devicemgt/api/devices/sketch/generate_link";
var payload = {"sketchType": sketchType, "deviceType": deviceType};
$(modalPopupContent).html($('#download-device-modal-content').html());
@ -100,16 +100,24 @@ function attachEvents() {
$('label[for=deviceName]').remove();
if (deviceName && deviceName.length >= 4) {
payload.deviceName = deviceName;
invokerUtil.post(
downloadDeviceAPI,
payload,
function (data, textStatus, jqxhr) {
doAction(data);
},
function (data) {
doAction(data);
var request = {
url: downloadDeviceAPI,
type: "POST",
contentType: "application/json",
data: JSON.stringify(payload),
accept: "application/json",
async : true,
success: doAction,
error: function (jqXHR) {
if (jqXHR.status == 401) {
$(modalPopupContent).html($("#error-msg").html());
showPopup();
} else {
doAction(jqXHR);
}
}
);
};
$.ajax(request);
}else if(deviceName){
$('.controls').append('<label for="deviceName" generated="true" class="error" ' +
'style="display: inline-block;">Please enter at least 4 ' +
@ -159,10 +167,7 @@ function doAction(data) {
if (data.status == "200") {
$(modalPopupContent).html($('#download-device-modal-content-links').html());
$("input#download-device-url").val(data.responseText);
$("input#download-device-url").focus(function () {
$(this).select();
});
$("#download-device-url").html(data.responseText);
showPopup();
} else if (data.status == "401") {
$(modalPopupContent).html($('#device-401-content').html());

@ -62,7 +62,7 @@
<i class="fw fw-download add-margin-1x"></i>Download Agent
</a>
<p class="doc-link">Click <a href="https://docs.wso2.com/display/IoTS310/Raspberry+Pi"
<p class="doc-link">Click <a href="https://docs.wso2.com/display/IoTS300/Raspberry+Pi"
target="_blank">here</a> for latest instructions and
troubleshooting.</p>
<div id="download-device-modal-content" class="hide">
@ -85,16 +85,16 @@
name="deviceName" size="60" required>
<br/>
<input type="hidden" class="deviceType" name="deviceType"
value="raspberrypi"/>
value="raspberrypi" data-device_type="raspberrypi"/>
<input type="hidden" class="sketchType" name="sketchType"
value="raspberrypi"/>
value="raspberrypi" data-sketch_type="raspberrypi"/>
</div>
</div>
<div class="buttons" style="padding-bottom: 0px">
<a class="btn btn-operations" onclick="downloadAgent()">Download Now</a>
<a href="#" id="download-device-download-link"
class="btn btn-operations hidden"> Copy Link
class="btn btn-operations"> Copy Link
</a>
</div>
@ -112,6 +112,15 @@
</div>
</div>
</div>
<div id="download-device-modal-content-links" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-7 col-centered center-container">
<h4 id="download-device-url"></h4>
</div>
</div>
</div>
</div>
<div id="device-400-content" class="hide">
<div class="modal-content">
<div class="row">

Loading…
Cancel
Save