FBI-2023
FBI-2023: Remove hardcoded values FBI-2023: Code Improvements Code Improvements 2 FBI-2023: Code Improvements 3
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
/*
|
// TODO: Move RCBase64 to an individual file
|
||||||
* @author: Erik A. Ortiz
|
var RCBase64={keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t,r,s,o,i,n,a,h="",c=0;for(e=this.utf8_encode(e);c<e.length;)t=e.charCodeAt(c++),r=e.charCodeAt(c++),s=e.charCodeAt(c++),o=t>>2,i=(3&t)<<4|r>>4,n=(15&r)<<2|s>>6,a=63&s,isNaN(r)?n=a=64:isNaN(s)&&(a=64),h=h+this.keyStr.charAt(o)+this.keyStr.charAt(i)+this.keyStr.charAt(n)+this.keyStr.charAt(a);return h},decode:function(e){var t,r,s,o,i,n,a,h="",c=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");c<e.length;)o=this.keyStr.indexOf(e.charAt(c++)),i=this.keyStr.indexOf(e.charAt(c++)),n=this.keyStr.indexOf(e.charAt(c++)),a=this.keyStr.indexOf(e.charAt(c++)),t=o<<2|i>>4,r=(15&i)<<4|n>>2,s=(3&n)<<6|a,h+=String.fromCharCode(t),64!==n&&(h+=String.fromCharCode(r)),64!==a&&(h+=String.fromCharCode(s));return h=this.utf8_decode(h)},utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t,r,s="";for(t=0;t<e.length;t++)r=e.charCodeAt(t),128>r?s+=String.fromCharCode(r):r>127&&2048>r?(s+=String.fromCharCode(r>>6|192),s+=String.fromCharCode(63&r|128)):(s+=String.fromCharCode(r>>12|224),s+=String.fromCharCode(r>>6&63|128),s+=String.fromCharCode(63&r|128));return s},utf8_decode:function(e){for(var t="",r=0,s=0,o=0,i=0;r<e.length;)s=e.charCodeAt(r),128>s?(t+=String.fromCharCode(s),r++):s>191&&224>s?(o=e.charCodeAt(r+1),t+=String.fromCharCode((31&s)<<6|63&o),r+=2):(o=e.charCodeAt(r+1),i=e.charCodeAt(r+2),t+=String.fromCharCode((15&s)<<12|(63&o)<<6|63&i),r+=3);return t}};
|
||||||
* Aug 20th, 2010
|
|
||||||
*/
|
|
||||||
var processesGrid,
|
var processesGrid,
|
||||||
store,
|
store,
|
||||||
comboCategory,
|
comboCategory,
|
||||||
@@ -937,88 +935,109 @@ editNewProcess = function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteProcess = function(){
|
deleteProcess = function(){
|
||||||
var rows = processesGrid.getSelectionModel().getSelections();
|
var rows = processesGrid.getSelectionModel().getSelections(),
|
||||||
var i;
|
i,
|
||||||
if( rows.length > 0 ) {
|
e,
|
||||||
isValid = true;
|
ids,
|
||||||
errLog = Array();
|
errLog,
|
||||||
|
refreshTokenCalled = false,
|
||||||
|
deleteProcessF,
|
||||||
|
isValid;
|
||||||
|
|
||||||
//verify if the selected rows have not any started or delegated cases
|
if (rows.length > 0) {
|
||||||
for(i=0; i<rows.length; i++){
|
isValid = true;
|
||||||
if( rows[i].get('CASES_COUNT') != 0 ){
|
errLog = [];
|
||||||
errLog.push(i);
|
|
||||||
isValid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( isValid ){
|
//verify if the selected rows have not any started or delegated cases
|
||||||
ids = Array();
|
for (i = 0; i < rows.length; i += 1) {
|
||||||
for(i=0; i<rows.length; i++)
|
if (rows[i].get('CASES_COUNT') !== 0) {
|
||||||
ids[i] = rows[i].get('PRO_UID');
|
errLog.push(i);
|
||||||
|
isValid = false;
|
||||||
PRO_UIDS = ids.join(',');
|
break;
|
||||||
|
}
|
||||||
Ext.Msg.confirm(
|
}
|
||||||
_('ID_CONFIRM'),
|
|
||||||
(rows.length == 1) ? _('ID_PROCESS_DELETE_LABEL') : _('ID_PROCESS_DELETE_ALL_LABEL'),
|
deleteProcessF = function () {
|
||||||
function(btn, text){
|
Ext.Ajax.request({
|
||||||
if ( btn == 'yes' ){
|
url: HTTP_SERVER_HOSTNAME + '/api/1.0/' + SYS_SYS + '/project/' + PRO_UIDS,
|
||||||
Ext.MessageBox.show({ msg: _('ID_DELETING_ELEMENTS'), wait:true,waitConfig: {interval:200} });
|
method: 'DELETE',
|
||||||
Ext.Ajax.request({
|
success: function(response) {
|
||||||
url: 'processes_Delete',
|
Ext.MessageBox.hide();
|
||||||
success: function(response) {
|
processesGrid.store.reload();
|
||||||
Ext.MessageBox.hide();
|
result = Ext.util.JSON.decode(response.responseText);
|
||||||
processesGrid.store.reload();
|
|
||||||
result = Ext.util.JSON.decode(response.responseText);
|
if (result && result.status !== 0) {
|
||||||
|
Ext.MessageBox.show({
|
||||||
if(result){
|
title: _('ID_ERROR'),
|
||||||
if(result.status != 0){
|
msg: result.msg,
|
||||||
Ext.MessageBox.show({
|
buttons: Ext.MessageBox.OK,
|
||||||
title: _('ID_ERROR'),
|
icon: Ext.MessageBox.ERROR
|
||||||
msg: result.msg,
|
});
|
||||||
buttons: Ext.MessageBox.OK,
|
}
|
||||||
icon: Ext.MessageBox.ERROR
|
},
|
||||||
});
|
failure: function (xhr) {
|
||||||
}
|
if (xhr.status === 401 && !refreshTokenCalled) {
|
||||||
} else
|
refreshTokenCalled = true;
|
||||||
Ext.MessageBox.show({
|
return refreshAccessToken(deleteProcessF);
|
||||||
title: _('ID_ERROR'),
|
}
|
||||||
msg: response.responseText,
|
Ext.MessageBox.hide();
|
||||||
buttons: Ext.MessageBox.OK,
|
Ext.MessageBox.show({
|
||||||
icon: Ext.MessageBox.ERROR
|
title: _('ID_ERROR'),
|
||||||
});
|
msg: xhr.statusText,
|
||||||
},
|
buttons: Ext.MessageBox.OK,
|
||||||
params: {PRO_UIDS:PRO_UIDS}
|
icon: Ext.MessageBox.ERROR
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
headers: {
|
||||||
|
"Authorization": "Bearer " + credentials.access_token
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isValid) {
|
||||||
|
ids = [];
|
||||||
|
for (i = 0; i < rows.length; i += 1) {
|
||||||
|
ids[i] = rows[i].get('PRO_UID');
|
||||||
|
}
|
||||||
|
|
||||||
|
PRO_UIDS = ids.join(',');
|
||||||
|
|
||||||
|
Ext.Msg.confirm(
|
||||||
|
_('ID_CONFIRM'),
|
||||||
|
(rows.length == 1) ? _('ID_PROCESS_DELETE_LABEL') : _('ID_PROCESS_DELETE_ALL_LABEL'),
|
||||||
|
function (btn, text) {
|
||||||
|
if (btn === 'yes') {
|
||||||
|
Ext.MessageBox.show({ msg: _('ID_DELETING_ELEMENTS'), wait:true,waitConfig: {interval:200} });
|
||||||
|
deleteProcessF();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
errMsg = '';
|
||||||
|
for (i = 0; i < errLog.length; i += 1) {
|
||||||
|
e = _('ID_PROCESS_CANT_DELETE');
|
||||||
|
e = e.replace('{0}', rows[errLog[i]].get('PRO_TITLE'));
|
||||||
|
e = e.replace('{1}', rows[errLog[i]].get('CASES_COUNT'));
|
||||||
|
errMsg += e + '<br/>';
|
||||||
|
}
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: _('ID_ERROR'),
|
||||||
|
msg: errMsg,
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
icon: Ext.MessageBox.ERROR
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
errMsg = '';
|
Ext.Msg.show({
|
||||||
for(i=0; i<errLog.length; i++){
|
title: _("ID_INFORMATION"),
|
||||||
e = _('ID_PROCESS_CANT_DELETE');
|
msg: _('ID_NO_SELECTION_WARNING'),
|
||||||
e = e.replace('{0}', rows[errLog[i]].get('PRO_TITLE'));
|
buttons: Ext.Msg.INFO,
|
||||||
e = e.replace('{1}', rows[errLog[i]].get('CASES_COUNT'));
|
fn: function(){},
|
||||||
errMsg += e + '<br/>';
|
animEl: 'elId',
|
||||||
}
|
icon: Ext.MessageBox.INFO,
|
||||||
Ext.MessageBox.show({
|
buttons: Ext.MessageBox.OK
|
||||||
title: _('ID_ERROR'),
|
});
|
||||||
msg: errMsg,
|
|
||||||
buttons: Ext.MessageBox.OK,
|
|
||||||
icon: Ext.MessageBox.ERROR
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Ext.Msg.show({
|
|
||||||
title: _("ID_INFORMATION"),
|
|
||||||
msg: _('ID_NO_SELECTION_WARNING'),
|
|
||||||
buttons: Ext.Msg.INFO,
|
|
||||||
fn: function(){},
|
|
||||||
animEl: 'elId',
|
|
||||||
icon: Ext.MessageBox.INFO,
|
|
||||||
buttons: Ext.MessageBox.OK
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var deleteCases = function(){
|
var deleteCases = function(){
|
||||||
@@ -1028,14 +1047,14 @@ var deleteCases = function(){
|
|||||||
PRO_UIDS,
|
PRO_UIDS,
|
||||||
i;
|
i;
|
||||||
if( rows.length > 0 ) {
|
if( rows.length > 0 ) {
|
||||||
for(i=0; i<rows.length; i++){
|
for (i = 0; i < rows.length; i+= 1) {
|
||||||
var numCases = rows[i].get('CASES_COUNT');
|
var numCases = rows[i].get('CASES_COUNT');
|
||||||
if(numCases != 0) {
|
if(numCases != 0) {
|
||||||
totalCases = totalCases + parseInt(numCases);
|
totalCases = totalCases + parseInt(numCases);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i<rows.length; i++) {
|
for (i = 0; i < rows.length; i++) {
|
||||||
ids[i] = rows[i].get('PRO_UID');
|
ids[i] = rows[i].get('PRO_UID');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2411,3 +2430,55 @@ function openWindowIfIE(pathDesigner) {
|
|||||||
location.href = pathDesigner;
|
location.href = pathDesigner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshAccessToken(callback) {
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url: HTTP_SERVER_HOSTNAME + "/api/1.0/" + SYS_SYS + "/token",
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
params: JSON.stringify({
|
||||||
|
grant_type: "refresh_token",
|
||||||
|
client_id: credentials.client_id,
|
||||||
|
client_secret: credentials.client_secret,
|
||||||
|
refresh_token: credentials.refresh_token
|
||||||
|
}),
|
||||||
|
success: function (xhr) {
|
||||||
|
var jsonResponse = JSON.parse(xhr.responseText);
|
||||||
|
|
||||||
|
credentials.access_token = jsonResponse.access_token;
|
||||||
|
credentials.expires_in = jsonResponse.expires_in;
|
||||||
|
credentials.token_type = jsonResponse.token_type;
|
||||||
|
credentials.scope = jsonResponse.scope;
|
||||||
|
credentials.refresh_token = jsonResponse.refresh_token;
|
||||||
|
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
failure: function (xhr) {
|
||||||
|
Ext.MessageBox.hide();
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: _('ID_ERROR'),
|
||||||
|
msg: xhr.statusText,
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
icon: Ext.MessageBox.ERROR
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Ext.onReady(function () {
|
||||||
|
if (credentials) {
|
||||||
|
credentials = JSON.parse(RCBase64.decode(credentials));
|
||||||
|
}
|
||||||
|
if (typeof credentials !== 'object') {
|
||||||
|
Ext.MessageBox.hide();
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: _('ID_ERROR'),
|
||||||
|
msg: _('ID_CREDENTIAL_ERROR'),
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
icon: Ext.MessageBox.ERROR
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user