From afacf9d32aff66183ba1067457472e282f2e06c2 Mon Sep 17 00:00:00 2001 From: lasantha Date: Thu, 3 Aug 2017 20:28:02 +0530 Subject: [PATCH 1/2] Adding create link option for Raspberry Pi device type --- .../public/js/download.js | 35 +++++++++++-------- .../type-view.hbs | 17 ++++++--- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js index aced9b532..3b2a740bb 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js @@ -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('