GUACAMOLE-526: Handle rejections for absolutely all promises.

This commit is contained in:
Michael Jumper
2018-04-26 22:15:17 -07:00
parent f6d5e5662b
commit 266b445c21
23 changed files with 118 additions and 276 deletions

View File

@@ -44,6 +44,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
var $translate = $injector.get('$translate');
var csvService = $injector.get('csvService');
var historyService = $injector.get('historyService');
var requestService = $injector.get('requestService');
/**
* The identifier of the currently-selected data source.
@@ -95,7 +96,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
// Store received date format
$scope.dateFormat = retrievedDateFormat;
});
}, angular.noop);
/**
* Returns true if the connection history records have been loaded,
@@ -177,7 +178,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
$scope.historyEntryWrappers.push(new ConnectionHistoryEntryWrapper(historyEntry));
});
});
}, requestService.WARN);
};
@@ -227,7 +228,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
// Save the result
saveAs(csvService.toBlob(records), translations['SETTINGS_CONNECTION_HISTORY.FILENAME_HISTORY_CSV']);
});
}, angular.noop);
};

View File

@@ -46,6 +46,7 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe
var dataSourceService = $injector.get('dataSourceService');
var guacNotification = $injector.get('guacNotification');
var permissionService = $injector.get('permissionService');
var requestService = $injector.get('requestService');
/**
* The identifier of the current user.
@@ -54,18 +55,6 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe
*/
var currentUsername = authenticationService.getCurrentUsername();
/**
* An action to be provided along with the object sent to
* showStatus which closes the currently-shown status dialog.
*/
var ACKNOWLEDGE_ACTION = {
name : "SETTINGS_CONNECTIONS.ACTION_ACKNOWLEDGE",
// Handle action
callback : function acknowledgeCallback() {
guacNotification.showStatus(false);
}
};
/**
* The identifier of the currently-selected data source.
*
@@ -426,9 +415,9 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe
)
.then(function connectionGroupsReceived(rootGroups) {
$scope.rootGroups = rootGroups;
});
}, requestService.WARN);
}); // end retrieve permissions
}, requestService.WARN); // end retrieve permissions
}]
};

View File

@@ -42,6 +42,7 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
var languageService = $injector.get('languageService');
var permissionService = $injector.get('permissionService');
var preferenceService = $injector.get('preferenceService');
var requestService = $injector.get('requestService');
var userService = $injector.get('userService');
/**
@@ -164,17 +165,7 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
},
actions : [ ACKNOWLEDGE_ACTION ]
});
})
// Notify of any errors
['catch'](function passwordUpdateFailed(error) {
guacNotification.showStatus({
className : 'error',
title : 'SETTINGS_PREFERENCES.DIALOG_HEADER_ERROR',
text : error.translatableMessage,
actions : [ ACKNOWLEDGE_ACTION ]
});
});
}, requestService.SHOW_NOTIFICATION);
};
@@ -186,8 +177,8 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
key: key,
value: languages[key]
};
})
});
});
}, requestService.WARN);
// Retrieve current permissions
permissionService.getEffectivePermissions(dataSource, username)
@@ -198,9 +189,9 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
PermissionSet.ObjectPermissionType.UPDATE, username);
})
['catch'](function permissionsFailed(error) {
['catch'](requestService.createErrorCallback(function permissionsFailed(error) {
$scope.canChangePassword = false;
});
}));
/**
* Returns whether critical data has completed being loaded.

View File

@@ -47,6 +47,7 @@ angular.module('settings').directive('guacSettingsSessions', [function guacSetti
var connectionGroupService = $injector.get('connectionGroupService');
var dataSourceService = $injector.get('dataSourceService');
var guacNotification = $injector.get('guacNotification');
var requestService = $injector.get('requestService');
/**
* The identifiers of all data sources accessible by the current
@@ -219,7 +220,7 @@ angular.module('settings').directive('guacSettingsSessions', [function guacSetti
// Attempt to produce wrapped list of active connections
wrapAllActiveConnections();
});
}, requestService.WARN);
// Query active sessions
dataSourceService.apply(
@@ -234,7 +235,7 @@ angular.module('settings').directive('guacSettingsSessions', [function guacSetti
// Attempt to produce wrapped list of active connections
wrapAllActiveConnections();
});
}, requestService.WARN);
// Get session date format
$translate('SETTINGS_SESSIONS.FORMAT_STARTDATE').then(function sessionDateFormatReceived(retrievedSessionDateFormat) {
@@ -245,7 +246,7 @@ angular.module('settings').directive('guacSettingsSessions', [function guacSetti
// Attempt to produce wrapped list of active connections
wrapAllActiveConnections();
});
}, angular.noop);
/**
* Returns whether critical data has completed being loaded.
@@ -258,18 +259,6 @@ angular.module('settings').directive('guacSettingsSessions', [function guacSetti
return $scope.wrappers !== null;
};
/**
* An action to be provided along with the object sent to
* showStatus which closes the currently-shown status dialog.
*/
var ACKNOWLEDGE_ACTION = {
name : "SETTINGS_SESSIONS.ACTION_ACKNOWLEDGE",
// Handle action
callback : function acknowledgeCallback() {
guacNotification.showStatus(false);
}
};
/**
* An action to be provided along with the object sent to
* showStatus which closes the currently-shown status dialog.
@@ -327,17 +316,7 @@ angular.module('settings').directive('guacSettingsSessions', [function guacSetti
// Clear selection
allSelectedWrappers = {};
},
// Notify of any errors
function activeConnectionDeletionFailed(error) {
guacNotification.showStatus({
'className' : 'error',
'title' : 'SETTINGS_SESSIONS.DIALOG_HEADER_ERROR',
'text' : error.translatableMessage,
'actions' : [ ACKNOWLEDGE_ACTION ]
});
});
}, requestService.SHOW_NOTIFICATION);
};

View File

@@ -43,25 +43,13 @@ angular.module('settings').directive('guacSettingsUsers', [function guacSettings
var $translate = $injector.get('$translate');
var authenticationService = $injector.get('authenticationService');
var dataSourceService = $injector.get('dataSourceService');
var guacNotification = $injector.get('guacNotification');
var permissionService = $injector.get('permissionService');
var requestService = $injector.get('requestService');
var userService = $injector.get('userService');
// Identifier of the current user
var currentUsername = authenticationService.getCurrentUsername();
/**
* An action to be provided along with the object sent to
* showStatus which closes the currently-shown status dialog.
*/
var ACKNOWLEDGE_ACTION = {
name : "SETTINGS_USERS.ACTION_ACKNOWLEDGE",
// Handle action
callback : function acknowledgeCallback() {
guacNotification.showStatus(false);
}
};
/**
* The identifiers of all data sources accessible by the current
* user.
@@ -129,7 +117,7 @@ angular.module('settings').directive('guacSettingsUsers', [function guacSettings
// Store received date format
$scope.dateFormat = retrievedDateFormat;
});
}, angular.noop);
/**
* Returns whether critical data has completed being loaded.
@@ -287,9 +275,9 @@ angular.module('settings').directive('guacSettingsUsers', [function guacSettings
});
});
});
}, requestService.WARN);
});
}, requestService.WARN);
}]
};