GUACAMOLE-598: Add absolute, global, fatal error handling.

This commit is contained in:
Michael Jumper
2018-06-26 22:45:28 -07:00
parent 587c0c2073
commit 4bc7700d57
4 changed files with 112 additions and 17 deletions

View File

@@ -28,7 +28,15 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
var $window = $injector.get('$window');
var clipboardService = $injector.get('clipboardService');
var guacNotification = $injector.get('guacNotification');
/**
* The error that prevents the current page from rendering at all. If no
* such error has occurred, this will be null.
*
* @type Error
*/
$scope.fatalError = null;
/**
* The notification service.
*/
@@ -159,6 +167,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
$scope.loginHelpText = null;
$scope.acceptedCredentials = {};
$scope.expectedCredentials = error.expected;
$scope.fatalError = null;
});
// Prompt for remaining credentials if provided credentials were not enough
@@ -168,6 +177,15 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
$scope.loginHelpText = error.translatableMessage;
$scope.acceptedCredentials = parameters;
$scope.expectedCredentials = error.expected;
$scope.fatalError = null;
});
// Replace absolutely all content with an error message if the page itself
// cannot be displayed due to an error
$scope.$on('guacFatalPageError', function fatalPageError(error) {
$scope.page.title = 'APP.NAME';
$scope.page.bodyClassName = '';
$scope.fatalError = error;
});
// Update title and CSS class upon navigation
@@ -181,6 +199,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
$scope.loginHelpText = null;
$scope.acceptedCredentials = null;
$scope.expectedCredentials = null;
$scope.fatalError = null;
// Set title
var title = current.$$route.title;

View File

@@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
.fatal-page-error-outer {
display: table;
height: 100%;
width: 100%;
position: fixed;
left: 0;
top: 0;
z-index: 30;
}
.fatal-page-error-middle {
width: 100%;
text-align: center;
display: table-cell;
vertical-align: middle;
}
.fatal-page-error {
display: inline-block;
width: 100%;
max-width: 5in;
padding: 1em;
text-align: left;
}
.fatal-page-error h1 {
text-transform: uppercase;
padding: 0;
padding-right: 1em;
}
.fatal-page-error h1::before {
content: ' ';
display: inline-block;
background: url('images/warning.png');
background-repeat: no-repeat;
height: 1em;
width: 1em;
background-size: contain;
margin: 0 0.25em;
margin-bottom: -0.2em;
}

View File

@@ -32,26 +32,40 @@
</head>
<body ng-class="page.bodyClassName">
<!-- Content for logged-in users -->
<div ng-if="!expectedCredentials">
<!-- Global status/error dialog -->
<div ng-class="{shown: guacNotification.getStatus()}" class="status-outer">
<div class="status-middle">
<guac-notification notification="guacNotification.getStatus()"></guac-notification>
<div ng-if="!fatalError">
<!-- Content for logged-in users -->
<div ng-if="!expectedCredentials">
<!-- Global status/error dialog -->
<div ng-class="{shown: guacNotification.getStatus()}" class="status-outer">
<div class="status-middle">
<guac-notification notification="guacNotification.getStatus()"></guac-notification>
</div>
</div>
<div id="content" ng-view>
</div>
</div>
<div id="content" ng-view>
</div>
<!-- Login screen for logged-out users -->
<guac-login ng-show="expectedCredentials"
help-text="loginHelpText"
form="expectedCredentials"
values="acceptedCredentials"></guac-login>
</div>
<!-- Login screen for logged-out users -->
<guac-login ng-show="expectedCredentials"
help-text="loginHelpText"
form="expectedCredentials"
values="acceptedCredentials"></guac-login>
<!-- Absolute fatal error -->
<div ng-if="fatalError" class="fatal-page-error-outer">
<div class="fatal-page-error-middle">
<div class="fatal-page-error">
<h1 translate="APP.DIALOG_HEADER_ERROR"></h1>
<p translate="APP.ERROR_PAGE_UNAVAILABLE"></p>
</div>
</div>
</div>
<!-- Reformat URL for AngularJS if query parameters are present -->
<script type="text/javascript" src="relocateParameters.js"></script>

View File

@@ -31,6 +31,7 @@
"DIALOG_HEADER_ERROR" : "Error",
"ERROR_PAGE_UNAVAILABLE" : "An error has occurred and this action cannot be completed. If the problem persists, please notify your system administrator or check your system logs.",
"ERROR_PASSWORD_BLANK" : "Your password cannot be blank.",
"ERROR_PASSWORD_MISMATCH" : "The provided passwords do not match.",