Skip to content

Commit

Permalink
RANGER-4833 : Upgrade from Bootbox.js to Bootprompt.js
Browse files Browse the repository at this point in the history
Signed-off-by: Dhaval.Rajpara <[email protected]>
  • Loading branch information
dhavaljrajpara committed Nov 1, 2024
1 parent 2b2da8d commit 03bca8e
Show file tree
Hide file tree
Showing 8 changed files with 1,192 additions and 1,347 deletions.
1,246 changes: 0 additions & 1,246 deletions security-admin/src/main/webapp/libs/bower/bootbox/js/bootbox.js

This file was deleted.

1,138 changes: 1,138 additions & 0 deletions security-admin/src/main/webapp/libs/bower/bootprompt/bootprompt.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions security-admin/src/main/webapp/scripts/Init.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ require.config({
'select2': {
deps: ['jquery', 'bootstrap']
},
'bootbox': {
deps: ['jquery']
},
'esprima': {
'exports': 'esprima'
},
Expand All @@ -95,6 +92,9 @@ require.config({
'Backgrid.ColumnManager' : {
deps: ['backbone', 'backgrid', 'underscore', 'jquery']
},
'bootprompt': {
deps: ['jquery', 'bootstrap']
},
},

paths: {
Expand Down Expand Up @@ -134,7 +134,6 @@ require.config({
'jquery-toggles': '../libs/bower/jquery-toggles/js/toggles.min',
'tag-it': '../libs/bower/tag-it/js/tag-it',
'select2': '../libs/bower/select2/select2',
'bootbox': '../libs/bower/bootbox/js/bootbox',
'visualsearch': '../libs/other/visualsearch/js/visualsearch',
'globalize': '../libs/bower/globalize/lib/globalize',
/* handlebars from the require handlerbars plugin below */
Expand All @@ -145,6 +144,7 @@ require.config({
'esprima': '../libs/bower/esprima/esprima',
'tmpl': '../templates',
'Backgrid.ColumnManager': '../libs/other/backgrid-column-manager/Backgrid.ColumnManager.min',
'bootprompt' : '../libs/bower/bootprompt/bootprompt',
},

hbs: {
Expand Down
41 changes: 24 additions & 17 deletions security-admin/src/main/webapp/scripts/routers/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
'utils/XALangSupport',
'models/VAppState',
'utils/XAUtils',
'bootbox'
'bootprompt'
],
function(Backbone, Marionette, localization, MAppState, XAUtil, bootbox){
function(Backbone, Marionette, localization, MAppState, XAUtil, bootprompt){
'use strict';

return Backbone.Marionette.AppRouter.extend({
Expand Down Expand Up @@ -97,22 +97,29 @@ function(Backbone, Marionette, localization, MAppState, XAUtil, bootbox){
callbackArgs = arguments;
var formStatus = $('.form-horizontal').find('.dirtyField').length > 0 ? true : false
if (window._preventNavigation && formStatus) {
bootbox.dialog(window._preventNavigationMsg, [{
"label": "Stay on this page!",
"class": "btn-success btn-sm",
"callback": function() {
router.navigate(MAppState.get('previousFragment'), {
trigger: false
});
bootprompt.dialog(
{
message: window._preventNavigationMsg,
buttons: {
noclose: {
"label" : localization.tt('btn.stayOnPage'),
"className" : "btn-success btn-sm",
"callback": function() {
router.navigate(MAppState.get('previousFragment'), {
trigger: false
});
}
},
cancel: {
"label" : localization.tt('btn.leavePage'),
"className" : "btn-danger btn-sm",
"callback": function() {
XAUtil.allowNavigation();
proceedWithCallback();
}
}
}
}, {
"label": "Leave this page",
"class": "btn-danger btn-sm",
"callback": function() {
XAUtil.allowNavigation();
proceedWithCallback();
}
}]);
});

} else {
proceedWithCallback();
Expand Down
57 changes: 0 additions & 57 deletions security-admin/src/main/webapp/scripts/utils/XALangSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,63 +81,6 @@ define(['require','modules/Vent','globalize','modules/globalize/message/en'],fun
localization.getDaysOfWeek = function(label){
return Globalize.culture().calendars.standard.days.namesAbbr;
}

localization.chooseCulture = function(culture){
var dfd = $.Deferred();
dfd.done(function(validationMessages){
require([ 'validationEngine'],function(){
setCulture(culture);
validationMessages.setupMessages();
vent.trigger('Layouts:rerender');
});
});
switch(culture){
case "pt-BR" :
require(['gblMessages/message/pt-BR'], function() {
require([ 'validationEngineEn' ],function(validationMessages){
dfd.resolve(validationMessages);
console.log('Language Changed to pt-BR');
});
$.fn.datepicker.dates['pt-BR'] = {
days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
daysMin: ["Do", "Se", "Te", "Qu", "Qu", "Se", "Sa", "Do"],
months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
today: "Hoje",
clear: "Limpar"
};
bootbox.setLocale('pt-BR');
});
break;
case "es" :
require(['gblMessages/message/es'], function() {
require([ 'validationEngineEn' ],function(validationMessages){
dfd.resolve(validationMessages);
console.log('Language Changed to es');
});
$.fn.datepicker.dates['es'] = {
days: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado", "Domingo"],
daysShort: ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb", "Dom"],
daysMin: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"],
months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
today: "Hoy"
};
bootbox.setLocale('es');
});
break;
default :
require(['gblMessages/message/en'], function() {
require([ 'validationEngineEn' ],function(validationMessages){
dfd.resolve(validationMessages);
console.log('Language Changed to en');
});
bootbox.setLocale('en');
});
break;
}
}

localization.formatDate = function(val,format){
if(!val) return "";
Expand Down
26 changes: 13 additions & 13 deletions security-admin/src/main/webapp/scripts/utils/XAUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ define(function(require) {
var localization = require('utils/XALangSupport');
var XAUtils = {};
var notify = require('bootstrap-notify');
var bootbox = require('bootbox');
var bootprompt = require('bootprompt');
var moment = require('moment');

// ///////////////////////////////////////////////////////
Expand Down Expand Up @@ -348,7 +348,7 @@ define(function(require) {

e.preventDefault();
e.stopImmediatePropagation();
bootbox.dialog(
bootprompt.dialog(
{
message: msg,
buttons: {
Expand Down Expand Up @@ -387,35 +387,35 @@ define(function(require) {
};

/**
* Bootbox wrapper for alert
* Bootprompt wrapper for alert
*
* @param {Object}
* params - The params
*/
XAUtils.alertPopup = function(params) {
bootbox.hideAll();
bootprompt.hideAll();
if (params.callback == undefined) {
bootbox.alert(params.msg);
bootprompt.alert(params.msg);
} else {
bootbox.alert(params.msg, params.callback);
bootprompt.alert(params.msg, params.callback);
}
};

//Alert box with time set
XAUtils.alertBoxWithTimeSet = function(msg) {
var alert = bootbox.alert(msg);
var alert = bootprompt.alert(msg);
return(setTimeout(function(){alert.modal('hide'); }, 4000));
}

/**
* Bootbox wrapper for confirm
* Bootprompt wrapper for confirm
*
* @param {Object}
* params - The params
*/
XAUtils.confirmPopup = function(params) {
bootbox.hideAll();
bootbox.confirm(params.msg, function(result) {
bootprompt.hideAll();
bootprompt.confirm(params.msg, function(result) {
if (result) {
params.callback();
}
Expand Down Expand Up @@ -1975,7 +1975,7 @@ define(function(require) {
if (timeLeft == 0 ) {
clearTimeout(timerId);
if (!moment().isAfter(moment(idleTimeVal))) {
bootbox.hideAll()
bootprompt.hideAll()
} else {
localStorage.setItem('idleTimerLoggedOut', 'false');
XAUtils.idleActivityLogout();
Expand All @@ -1987,15 +1987,15 @@ define(function(require) {
localStorage.setItem('idleTimerLoggedOut', 'false');
XAUtils.idleActivityLogout();
} else if (!moment().isAfter(moment(idleTimeVal))) {
bootbox.hideAll()
bootprompt.hideAll()
clearTimeout(timerId);
} else {
$.find('#Timer')[0].innerHTML ='Time left : '+ timeLeft + ' seconds remaining';
timeLeft--;
}
}
}
bootbox.dialog({
bootprompt.dialog({
title: 'Session Expiration Warning',
message: '<span class="inline-block">' + localization.tt('dialogMsg.idleTimeOutMsg') +'<br>'+ $elem + '</span>',
closeButton: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ define(function(require){

require('backgrid-filter');
require('backgrid-paginator');
require('bootbox');

var ModulePermsTableLayout = Backbone.Marionette.Layout.extend(
/** @lends ModulePermsTableLayout */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ define(function(require){
var XAEnums = require('utils/XAEnums');
var XALinks = require('modules/XALinks');
var localization = require('utils/XALangSupport');
var bootbox = require('bootbox');
var bootprompt = require('bootprompt');

var ServiceForm = require('views/service/ServiceForm');
var RangerServiceDef = require('models/RangerServiceDef');
Expand Down Expand Up @@ -249,25 +249,29 @@ define(function(require){
}];
}
var msgHtml = '<b>Connection Failed.</b></br>'+msResponse.msgDesc;
bootbox.dialog({
bootprompt.dialog({
message : msgHtml,
buttons: popupBtnOpts
});
} else {
bootbox.alert("Connection Failed.");
bootprompt.alert("Connection Failed.");
}
} else {
bootbox.alert("Connection Failed.");
bootprompt.alert("Connection Failed.");
}
} else {
bootbox.alert("Connected Successfully.");
bootprompt.alert("Connected Successfully.");
}
},
error: function (msResponse, options) {
if(msResponse.status === 419){
XAUtil.defaultErrorHandler(options , msResponse);
}
bootbox.alert("Connection Failed.");
if(msResponse.status === 419){
XAUtil.defaultErrorHandler(options , msResponse);
}
if(msResponse && msResponse.responseJSON && msResponse.responseJSON.msgDesc) {
bootprompt.alert(msResponse.responseJSON.msgDesc)
} else {
bootprompt.alert("Connection Failed.");
}
}
});
},
Expand Down

0 comments on commit 03bca8e

Please sign in to comment.