From 9fb13e38cf3128152f9c8687f8998ec768297fa1 Mon Sep 17 00:00:00 2001 From: kamidu Date: Tue, 15 Aug 2017 17:43:19 +0530 Subject: [PATCH] enable billing cache invalidation --- .../jaggeryapps/devicemgt/api/user-api.jag | 7 ++++- .../public/js/user-menu.js | 27 +++++++++++++++++++ .../user-menu.hbs | 4 +-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag index 34e4ee14e7..60076acf83 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag @@ -33,8 +33,13 @@ var util = require("/app/modules/oauth/token-handler-utils.js")["utils"]; var responseProcessor = require("utils").response; var result; +if (uriMatcher.match("/{context}/api/user/clearBilling")) { -if (uriMatcher.match("/{context}/api/user/authenticate")) { + carbonUser = session.get(constants.USER_SESSION_KEY); + session.put('BILLING_INFO_' + carbonUser.domain, null); + log.info("billing info cleared for " + carbonUser.domain); + +} else if (uriMatcher.match("/{context}/api/user/authenticate")) { var username = request.getParameter("username"); var password = request.getParameter("password"); //Check if a username and password is provided diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js index edd143481b..9a3459a9a5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js @@ -16,6 +16,33 @@ * under the License. */ $(document).ready(function () { + + $("#expire-upgrade-now-link").click(function() { + $.get("api/user/clearBilling", function(data, status){ + }); + window.location.href = $("#expire-upgrade-now-link").data("url"); + }); + + $("#expire-req-ext-link").click(function() { + $.get("api/user/clearBilling", function(data, status){ + }); + window.location.href = $("#expire-req-ext-link").data("url"); + }); + + $(".expire-upgrade-now-link").parent().click(function(e) { + e.preventDefault(); + $.get("api/user/clearBilling", function(data, status){ + }); + window.location.href = $(this).attr("href"); + }); + + $(".expire-req-ext-link").parent().click(function(e) { + e.preventDefault(); + $.get("api/user/clearBilling", function(data, status){ + }); + window.location.href = $(this).attr("href"); + }); + $('#cloud-menu-popover i.fw-tiles').popover({ html: true, trigger: 'click', diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs index 5b8f29183a..c50ea375eb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs @@ -171,10 +171,10 @@