diff options
Diffstat (limited to 'openo-portal/portal-common/src/main/webapp/common/js')
5 files changed, 109 insertions, 155 deletions
diff --git a/openo-portal/portal-common/src/main/webapp/common/js/core/const.js b/openo-portal/portal-common/src/main/webapp/common/js/core/const.js index 3e36766c..66bee91a 100644 --- a/openo-portal/portal-common/src/main/webapp/common/js/core/const.js +++ b/openo-portal/portal-common/src/main/webapp/common/js/core/const.js @@ -25,6 +25,7 @@ var IS_V5_TESTVERSION = true; var FrameConst={}; //Ĭϵ¼ɹתҳ FrameConst.DEFAULT_LOGINSKIP_PAGE = "common/main-page.html"; +FrameConst.DEFAULT_PAGE = "default.html"; FrameConst.do_heartbeat = false; FrameConst.change_pass = false; @@ -35,7 +36,6 @@ FrameConst.REST_HEARTBEAT = "../../api/uiframe/v1/heartbeat"; FrameConst.REST_GETLICENSEINFO = "../../api/uiframe/v1/licensevalueinfo"; FrameConst.REST_CHECKRIGHT = "../../api/uiframe/v1/checkRight"; FrameConst.REST_LOGIN = "../../api/uiframe/v1/login"; -FrameConst.REST_LOGOUT = "../../api/uiframe/v1/loginOut?SSOAction=SSOLogout"; FrameConst.REST_GET_FRAME_MENUDIRECTION = "../../api/uiframe/v1/confByKey?key=usf.mainframe.web.navigation.direction"; FrameConst.REST_GET_USERNAME = "../../api/uiframe/v1/userName"; diff --git a/openo-portal/portal-common/src/main/webapp/common/js/core/load_menuList.js b/openo-portal/portal-common/src/main/webapp/common/js/core/load_menuList.js index c56952e5..972e782b 100644 --- a/openo-portal/portal-common/src/main/webapp/common/js/core/load_menuList.js +++ b/openo-portal/portal-common/src/main/webapp/common/js/core/load_menuList.js @@ -39,7 +39,7 @@ var initLeftMenu = function() { "</a>"; var templateChild = "<li>" + - "<a href='{url}' class='iframe'>" + + "<a href='{url}' class='iframe' id='{hrefId}'>" + "<i class='{iconClass}'></i>" + "<span id='{id}' name_i18n='{i18nName}'></span>" + "</a>" + @@ -57,6 +57,7 @@ var initLeftMenu = function() { childMenuContent = childMenuContent + templateChild.replace("{id}", childMenus[j].id) .replace("{url}", childMenus[j].url) .replace("{iconClass}", childMenus[j].iconClass) + .replace("{hrefId}", childMenus[j].id + "_href") .replace("{i18nName}", i18nName); } } diff --git a/openo-portal/portal-common/src/main/webapp/common/js/core/openoFrameWork.js b/openo-portal/portal-common/src/main/webapp/common/js/core/openoFrameWork.js index 267b7219..3b7e4b38 100644 --- a/openo-portal/portal-common/src/main/webapp/common/js/core/openoFrameWork.js +++ b/openo-portal/portal-common/src/main/webapp/common/js/core/openoFrameWork.js @@ -329,14 +329,14 @@ var s=!function(w,d){ purl.jQuery(window.jQuery); return purl; }); -//把框架所有的ajax请求集中到一起,发一条请求,获取所有的配置信息。 +//把框架所有的ajax请求集中到一起,发一条请求,获取所有的配置信息。 openoFrameWork_conf = { - userName:store.get('username'), + userName:store("loginUserName"), changePassItem:FrameConst.change_pass?FrameConst.change_pass:true, helpMenuItem:false, aboutMenuItem:false, flightMenuItem:false, - fullscreenMenuItem:false, + fullscreenMenuItem:true, logoutMenuItem:true, defaultThemeColor:"ztebluelight2", dbType:"other", @@ -344,10 +344,10 @@ openoFrameWork_conf = { }; $("#currentUser").html(openoFrameWork_conf.userName); -$.ajax({ - url : FrameConst.REST_FRAMECOMMIFO, +$.ajax({ + url : FrameConst.REST_FRAMECOMMIFO, type : "GET", - cache:false, + cache:false, contentType : 'application/json; charset=utf-8', success: function(data){ var tempConf = data; @@ -403,51 +403,51 @@ function setThemeColor( configColor ){ }); }; -function setFrameWorkByConf(){ - //设置用户相关的框架下拉菜单是否可用 - var helpMenuItem = openoFrameWork_conf.helpMenuItem; - var aboutMenuItem = openoFrameWork_conf.aboutMenuItem; - var flightMenuItem = openoFrameWork_conf.flightMenuItem; - var fullscreenMenuItem = openoFrameWork_conf.fullscreenMenuItem; - var logoutMenuItem = openoFrameWork_conf.logoutMenuItem; - var changePassMenuItem = openoFrameWork_conf.changePassMenuItem; - if (!helpMenuItem || helpMenuItem === "false") { - $('#uep_ict_help_url').parent('li').remove(); - } - if(!aboutMenuItem|| aboutMenuItem === "false"){ - $('[data-target="#aboutDlg"]').parent('li').remove(); - } - if(!helpMenuItem && !aboutMenuItem){ - $('#uep_ict_help_div').remove(); - } - if (!flightMenuItem|| flightMenuItem === "false") { - $('#header_notification_bar').html("<div>      </div>"); - } - if (!fullscreenMenuItem|| fullscreenMenuItem === "false") { - //$('#trigger_fullscreen').parent().css("display", "none"); - $('#trigger_fullscreen_div').html(""); - } - if (!logoutMenuItem || logoutMenuItem === "false") { - //$('#trigger_logout').parent().css("display", "none"); - $('#trigger_logout_div').html(""); - } - if ((!fullscreenMenuItem && !logoutMenuItem) || (fullscreenMenuItem === "false" && logoutMenuItem === "false")) { - $('#full_logout_divider').css("display", "none"); - } - if (!changePassMenuItem ) { - $('#changePwd_labellink').css('display','none'); - $('#full_logout_divider').css('display','none'); - } - - //设置二次开发者选择的框架皮肤 - var defaultColor = openoFrameWork_conf.defaultThemeColor; - var panel = $('.zte-theme-panel'); - $('ul > li', panel).removeClass("current"); - if (store && !store('style_color')) { // cookie没有才设置默认主题 - setThemeColor(defaultColor); - }else{ - setThemeColor(store('style_color')); - } +function setFrameWorkByConf() { + //设置用户相关的框架下拉菜单是否可用 + var helpMenuItem = openoFrameWork_conf.helpMenuItem; + var aboutMenuItem = openoFrameWork_conf.aboutMenuItem; + var flightMenuItem = openoFrameWork_conf.flightMenuItem; + var fullscreenMenuItem = openoFrameWork_conf.fullscreenMenuItem; + var logoutMenuItem = openoFrameWork_conf.logoutMenuItem; + var changePassMenuItem = openoFrameWork_conf.changePassMenuItem; + if (!helpMenuItem || helpMenuItem === "false") { + $('#uep_ict_help_url').parent('li').remove(); + } + if (!aboutMenuItem|| aboutMenuItem === "false") { + $('[data-target="#aboutDlg"]').parent('li').remove(); + } + if (!helpMenuItem && !aboutMenuItem) { + $('#uep_ict_help_div').remove(); + } + if (!flightMenuItem|| flightMenuItem === "false") { + $('#header_notification_bar').html("<div>      </div>"); + } + if (!fullscreenMenuItem|| fullscreenMenuItem === "false") { + //$('#trigger_fullscreen').parent().css("display", "none"); + $('#trigger_fullscreen_div').html(""); + } + if (!logoutMenuItem || logoutMenuItem === "false") { + //$('#trigger_logout').parent().css("display", "none"); + $('#trigger_logout_div').html(""); + } + if ((!fullscreenMenuItem && !logoutMenuItem) || (fullscreenMenuItem === "false" && logoutMenuItem === "false")) { + $('#full_logout_divider').css("display", "none"); + } + if (!changePassMenuItem ) { + $('#changePwd_labellink').css('display','none'); + $('#full_logout_divider').css('display','none'); + } + + //设置二次开发者选择的框架皮肤 + var defaultColor = openoFrameWork_conf.defaultThemeColor; + var panel = $('.zte-theme-panel'); + $('ul > li', panel).removeClass("current"); + if (store && !store('style_color')) { // cookie没有才设置默认主题 + setThemeColor(defaultColor); + } else { + setThemeColor(store('style_color')); + } }; /*新增的hashtabel实现类,用户后续iframe的缓存,前进后退时打开过的页面的菜单id的缓存等*/ @@ -1269,7 +1269,7 @@ var openoFrameWork = function () { } var pdiv="pdiv_"+miframe; if($("#"+pdiv).length<=0){//检查下,如果该div没有添加过就添加 - pageContentBody.append("<div id='"+pdiv+"'></div>"); + pageContentBody.append("<div id='"+pdiv+"' style='height:800px;overflow:auto'></div>"); } dealstartPageLoading(); pymParent=createIframe(pdiv, url,miframe,miframe,miframe,_xdomain,_iframeAutoScroll); @@ -1952,7 +1952,7 @@ var openoFrameWork = function () { return "Already disabled!"; }; window.doLogout = function(){ - window.location=FrameConst.REST_LOGOUT; + logoutSubmit(); }; //处理ict注销确认 $('#trigger_logout').click(function(){ @@ -3169,7 +3169,6 @@ var openoFrameWork = function () { return null; //返回参数值 } }; - }(); //抽取html片段中任意位置的script标签(包括代码是内嵌的情况)逐个运行(不会在单个script加载不到的时候停下来) diff --git a/openo-portal/portal-common/src/main/webapp/common/js/login.js b/openo-portal/portal-common/src/main/webapp/common/js/login.js index ccc150a4..a5f65a8f 100644 --- a/openo-portal/portal-common/src/main/webapp/common/js/login.js +++ b/openo-portal/portal-common/src/main/webapp/common/js/login.js @@ -17,39 +17,40 @@ String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }; -function loginSubmitHandler(form) { - var params = {}; - params["username"] = $("#openo_input_userName").val().trim(); - var sourcePass = $("#openo_input_password").val(); - var pass = sourcePass; - if (FrameConst.isEncypt === "true") { - pass = ict_framework_func1(pass); +function loginSubmitHandler() { + var loginData = { + "userName": $("#openo_input_userName").val(), + "password": $("#openo_input_password").val() } - params["password"] = pass; - params["isEncypted"] = FrameConst.isEncypt; - saveUserInfo(params); - location.href = FrameConst.DEFAULT_LOGINSKIP_PAGE; -// $.ajax({ -// url : FrameConst.REST_LOGIN, -// type : 'POST', -// data : JSON.stringify(params), -// dataType : 'json', -// contentType : 'application/json; charset=utf-8', -// success : function(data, status, xhr) { -// if (data.result == 0) { -// var epass = CryptoJS.MD5(params.username+sourcePass); -// store("icttka", epass.toLocaleString()); -// } -// processLoginResult(data, params); -// }, -// Error : function(xhr, error, exception) { -// if (console) { -// console.log("login fail:" + error); -// console.log(exception); -// } -// } -// }); + $.ajax({ + url : "/openoapi/auth/v1/tokens", + type : "POST", + contentType : 'application/json; charset=utf-8', + data : JSON.stringify(loginData) + }).done(function(data) { + var topURL = top.window.document.location.href; + if (topURL.indexOf("?service") != -1) { + top.window.document.location.href = decodeURIComponent(topURL.substring(topURL.indexOf("?service") + 9)); + } else { + top.window.document.location.href = "/openoui/common/default.html"; + } + store("loginUserName", $("#openo_input_userName").val()); + }).fail(function(data) { + var tipDivId = $("#loginConnError"); + if (data.status == 401) { + tipDivId = $("#nameOrpwdError"); + } + + tipDivId.addClass('alert-danger'); + if (tipDivId.attr("tipstatus") == "normal") { + tipDivId.show(); + } else if (tipDivId.attr("tipstatus") == "close") { + tipDivId.attr("tipstatus", "normal"); + } + }); + + saveUserInfo(); }; var Login = function () { @@ -103,75 +104,16 @@ var Login = function () { return false; } }); - - $("input[name='remember']").bind("click", function () { - saveUserInfo(); - }); - } - - var handleForgetPassword = function () { - $('.forget-form').validate({ - errorElement: 'span', //default input error message container - errorClass: 'help-block', // default input error message class - focusInvalid: false, // do not focus the last invalid input - ignore: "", - rules: { - email: { - required: true, - email: true - } - }, - messages: { - email: { - required: "Email is required." - } - }, - invalidHandler: function (event, validator) { //display error alert on form submit - }, - highlight: function (element) { // hightlight error inputs - $(element).closest('.form-group').addClass('has-error'); // set error class to the control group - }, - success: function (label) { - label.closest('.form-group').removeClass('has-error'); - label.remove(); - }, - errorPlacement: function (error, element) { - error.insertAfter(element.closest('.input-icon')); - }, - submitHandler: function (form) { - form.submit(); - } - }); - - $('.forget-form input').keypress(function (e) { - if (e.which == 13) { - if ($('.forget-form').validate().form()) { - $('.forget-form').submit(); - } - return false; - } - }); - - $('#forget-password').click(function () { - $('.login-form').hide(); - $('.forget-form').show(); - }); - - $('#back-btn').click(function () { - $('.login-form').show(); - $('.forget-form').hide(); - }); } return { //main function to initiate the module init: function () { handleLogin(); - handleForgetPassword(); $.backstretch([ - "./common/image/integration/openo_bg_1.jpg", - "./common/image/integration//openo_bg_2.jpg", - "./common/image/integration//openo_bg_3.jpg" + "image/integration/openo_bg_1.jpg", + "image/integration//openo_bg_2.jpg", + "image/integration//openo_bg_3.jpg" ], { fade: 500, duration: 15000 @@ -188,17 +130,29 @@ $(document).ready(function() { } }); -function saveUserInfo(params) { +function saveUserInfo() { var rmbcheck = $("input[name='remember']"); if (rmbcheck.attr("checked") == true || rmbcheck.is(':checked')) { - var userName = $("#openo_input_userName").val(); - var passWord = $("#openo_input_password").val(); store("remember", "true"); - store("openo_input_userName", params.username); - store("openo_input_password", passWord); + store("openo_input_userName", $("#openo_input_userName").val()); + store("openo_input_password", $("#openo_input_password").val()); } else { store.remove("remember"); store.remove("openo_input_userName"); store.remove("openo_input_password"); } } + +function logoutSubmit() { + $.ajax({ + url: "/openoapi/auth/v1/tokens" + "?=" + new Date().getTime(), + type: "DELETE", + contentType: "application/json", + dataType: "text", + success: function() { + top.window.location = "/openoui/common/login.html"; + }, + error: function() { + } + }) +} diff --git a/openo-portal/portal-common/src/main/webapp/common/js/security/security.js b/openo-portal/portal-common/src/main/webapp/common/js/security/security.js index 521130c4..f6ae4d05 100644 --- a/openo-portal/portal-common/src/main/webapp/common/js/security/security.js +++ b/openo-portal/portal-common/src/main/webapp/common/js/security/security.js @@ -22,7 +22,7 @@ var ErrResult_LOGIN_SERV_ERROR = -1; function processLoginResult(data,params){ if(data.home="web/res/web-framework/index.html"||data.home.indexOf("index.html")>0){ - data.home=FrameConst.DEFAULT_LOGINSKIP_PAGE; + data.home=FrameConst.DEFAULT_PAGE; //下面这部分是为了演示需要临时增加的自动切换 /*if(params.username=="admin1"){ data.home="/web/res/web-framework/default.html?menu=1"; |