Skip to content

Commit

Permalink
updated temporary admin-panel and checkout app for 1.6.0 refactoring …
Browse files Browse the repository at this point in the history
…changes
  • Loading branch information
Hufschmidt committed Nov 10, 2016
1 parent 909606e commit 676cdd9
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 326 deletions.
20 changes: 10 additions & 10 deletions apps/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<meta name="description" content="">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>{{'INDEX_TITLE' | translate}}</title>

<link rel="icon" href="img/icon.png">
<link rel="shortcut icon" href="img/logo.png">
<link rel="apple-touch-icon" href="img/logo.png">
Expand All @@ -23,9 +23,9 @@
<link rel="stylesheet" href="libs/css/angular-loading-bar.css">
<link rel="stylesheet" href="libs/css/angular-xeditable.css">
<link rel="stylesheet" href="libs/css/angular-flash.css">

<link rel="stylesheet" href="css/app.css" />

<script type="text/javascript" src="libs/js/modernizr.js"></script>
<script>
<?php
Expand All @@ -47,7 +47,7 @@
$restEndpoint = addslashes (htmlspecialchars($restEndpoint, ENT_COMPAT));
$iliasClient = addslashes (htmlspecialchars($iliasClient, ENT_COMPAT));
?>

var postVars = {
userId: "<?php echo $userId; ?>",
userName: "<?php echo $userName; ?>",
Expand All @@ -65,7 +65,7 @@
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

<nav class="navbar navbar-default-x" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-header">
Expand All @@ -80,15 +80,15 @@

</ul>
</ul>

<ul class="nav navbar-nav navbar-right addRightPadding" data-ng-show="authentication.isAuthenticated()" data-ng-cloak>
<li><button class="btn btn-default-outline navbar-btn" type="button" data-ng-click="reload()"><span class="glyphicon glyphicon-repeat"></span></button></li>
<li><span class="navbar-text">{{'INDEX_LOGGED_IN' | translate:translationData}} [<timer countdown="1800" max-time-unit="'minute'" interval="1000" finish-callback="authentication.logout()">{{mminutes}}:{{sseconds}}</timer>]</span></li>
<li><button class="btn btn-default-outline navbar-btn" type="button" data-ng-click="authentication.logout()">{{'INDEX_LOGOUT' | translate}}</button></li>
</ul>
</div>
</nav>

<div data-ng-show="authentication.hasError()" class="alert alert-warning" role="alert" data-ng-cloak><div ng-bind-html-compile="authentication.getError()"></div></div>
<div data-ng-show="!authentication.hasError() || isLoginRoute()" class="page-main" data-ng-view></div>

Expand All @@ -108,7 +108,7 @@
</nav>-->

</div>

<script src="libs/js/jquery.js"></script>
<script src="libs/js/less.js"></script>
<script src="libs/js/bootstrap.js"></script>
Expand All @@ -129,7 +129,7 @@

<script src="lang/angular_en-US.js"></script>
<script src="lang/angular_de-DE.js"></script>

<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
Expand Down
16 changes: 1 addition & 15 deletions apps/admin/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ app.constant('restConfigURL', '/v2/admin/config/:key'); // Con
* Setup all routes (used to display different functionality)
*/
app.config(function($routeProvider) {
// Login page
$routeProvider.when('/offline', {
templateUrl : 'partials/offline.html',
label: 'LABEL_LATER', // This will be replaced later!
controller: 'OfflineCtrl'
});

// Login page
$routeProvider.when('/login', {
templateUrl : 'partials/login.html',
Expand Down Expand Up @@ -132,17 +125,10 @@ app.config(function(cfpLoadingBarProvider) {
app.run(function($rootScope, $location, authentication, restEndpoint, $templateCache) {
// Go to login page if not logged in (and we should not display the offline notification)
$rootScope.$on('$routeChangeStart', function(event, current, previous, rejection) {
if (!(authentication.isAuthenticated() || $location.url() == "/offline")) {
if (!authentication.isAuthenticated()) {
$location.url("/login");
}
});

// Something went wrong (rest-interfac down, maybe?)
$rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {
if (rejection == "NoEndpoint") {
$location.path("/offline");
}
});
});


Expand Down
67 changes: 21 additions & 46 deletions apps/admin/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ctrl.controller("MainCtrl", function($scope, $location, $filter, breadcrumbs, au
// Add breadcrumbs to scope and setup translations
breadcrumbs.options = {
'LABEL_LOGIN': $filter('translate')('LABEL_LOGIN'),
'LABEL_OFFLINE': $filter('translate')('LABEL_OFFLINE'),
'LABEL_CLIENTS': $filter('translate')('LABEL_CLIENTS'),
'LABEL_EDIT': $filter('translate')('LABEL_EDIT'),
'LABEL_OVERVIEW': $filter('translate')('LABEL_OVERVIEW'),
Expand Down Expand Up @@ -736,8 +735,20 @@ ctrl.controller('LoginCtrl', function($scope, $location, $filter, apiKey, restAu
},
// Failure (Logout internally and redirdct)
function (response){
$scope.authentication.logout();
$location.url("/login");
// Try to decode the more common error-codes
if (response.status == 401)
$scope.authentication.setError($filter('translate')('LOGIN_REJECTED'));
else if (response.status == 404)
$scope.authentication.setError($filter('translate')('NOT_INSTALLED'));
else if (response.status == 405)
$scope.authentication.setError($filter('translate')('LOGIN_DISABLED'));
else if (response.status == 500)
$scope.authentication.setError($filter('translate')('CRITICAL_ERROR'));
else if (response.status != 200)
$scope.authentication.setError($filter('translate')('LOGIN_UNKNOWN'));

$scope.authentication.logout();
$location.url("/login");
}
);
};
Expand Down Expand Up @@ -775,14 +786,17 @@ ctrl.controller('LoginCtrl', function($scope, $location, $filter, apiKey, restAu
},
// Failure (Logout internally and redirdct)
function (response){
console.log("NOT OK");
// Try to decode the more common error-codes
if (response.status == 401)
$scope.authentication.setError($filter('restInfo')($filter('translate')('LOGIN_REJECTED'), response.status, response.data));
$scope.authentication.setError($filter('translate')('LOGIN_REJECTED'));
else if (response.status == 404)
$scope.authentication.setError($filter('translate')('NOT_INSTALLED'));
else if (response.status == 405)
$scope.authentication.setError($filter('restInfo')($filter('translate')('LOGIN_DISABLED'), response.status, response.data));
$scope.authentication.setError($filter('translate')('LOGIN_DISABLED'));
else if (response.status == 500)
$scope.authentication.setError($filter('translate')('CRITICAL_ERROR'));
else if (response.status != 200)
$scope.authentication.setError($filter('restInfo')($filter('translate')('LOGIN_UNKNOWN'), response.status, response.data));
$scope.authentication.setError($filter('translate')('LOGIN_UNKNOWN'));

// Logout and redirect
$scope.authentication.logout();
Expand All @@ -794,42 +808,3 @@ ctrl.controller('LoginCtrl', function($scope, $location, $filter, apiKey, restAu
// Do the initialisation
$scope.init();
});


/*
* Simple controller that manages functionality of the route that
* should be displayed IFF the REST-Interface can't be contacted.
* Note: Currently this is only implemented for when the "connection" is
* unavailable during page-load. (Nothing happens when the "connection"
* is lost after AngularJS was loaded and initialized)
*/
ctrl.controller('OfflineCtrl', function($scope, $location, restEndpoint) {
/*
* Called during (every) instantiation of this controller.
*
* Note: Using a dedicated method is cleaner and more reusable than
* doing it directly inside the controller.
*/
$scope.init = function() {
// Convert URL to absolute [Cheat a bit >:->]
var a = document.createElement('a');
a.href = "/";

// Set endpoints (for display purpose only)
$scope.postEndPoint = a.href+postVars.restEndpoint;
$scope.installDir = a.href+restEndpoint.getInstallDir();
};


/*
* Retry connection by completly reloading page,
* thus reloading AngularJS.
*/
$scope.retry = function() {
document.location.href = './';
};


// Do the initialisation
$scope.init();
});
2 changes: 0 additions & 2 deletions apps/admin/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ services.factory('clientStorage', function() {
* This services tries to find the REST Endpoint, in the following order:
* - Using the 'restEndpoint' POST variable
* - Find the ILIAS main folder (<ILIAS>) by using 'window.location.pathname' and finding the 'Customizing' folder
* - Try to find restplugin.php endpoint using http.get(<ILIAS>/restplugin.php/routes)
* - Try to find sub-domain endpoint using http.get(<ILIAS>/routes)
* Als contains a promise that gets resolved once endpoint has been found (or rejected if non is found).
*/
services.factory('restEndpoint', function($q, $http, restRoutesURL) {
Expand Down
44 changes: 18 additions & 26 deletions apps/admin/lang/angular_en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This variable will manage all en-US translations
*/
var lang_en_us = angular.module('myApp.translate.en-US', []);


/*
* Load en-US translations
Expand All @@ -29,41 +29,42 @@ lang_en_us.config(function($translateProvider) {
DIALOGS_OK: "OK",
DIALOGS_YES: "Yes",
DIALOGS_NO: "No",

// Custom AngularJS texts
DIALOG_DELETE: 'Delete Client',
DIALOG_DELETE_MSG: 'Do you really want to remove this client?',
DIALOG_DELETE_AP: 'Delete Admin-Panel Client',
DIALOG_DELETE_AP_MSG: 'This clients API-Key is required by the the Admin-Panel, you should change the default api-key (inside app.js) first!<br/><br/>Do you really want to remove this client?',
DIALOG_UPDATE: 'Update Admin-Panel Client',
DIALOG_UPDATE_MSG: 'This clients API-Key is required by the the Admin-Panel, you should change the default api-key (inside app.js) first!<br/><br/>Do you really want to apply this changes?',

// Breadcrumb labels
LABEL_OFFLINE: 'Offline',
LABEL_LOGIN: 'Login',
LABEL_CLIENTS: 'Clients',
LABEL_EDIT: 'Edit',
LABEL_OVERVIEW: 'Overview',
LABEL_CONFIGURATIONS: 'Configurations',

// Warning & error-messages
AUTH_PERM: 'You have been logged out because you don\'t have enough permissions to access this menu.',
NO_CLIENTS: '<strong>Warning:</strong> Could not contact REST-Interface to fetch client data! %INFO%',
DEL_FAILED_REMOTE: '<strong>Warning:</strong> Delete-Operation failed, could not contact REST-Interface! %INFO%',
SAVE_FAILED_UNKOWN: '<strong>Warning:</strong> Save-Operation failed, for unknown reason! %INFO%',
SAVE_FAILED_REMOTE: '<strong>Warning:</strong> Save-Operation failed, could not contact REST-Interface! %INFO%',
LOGIN_REJECTED: '<strong>Login failed:</strong> Username/Password combination was rejected. %INFO%',
LOGIN_DISABLED: '<strong>Login failed:</strong> REST-Interface is disabled! %INFO%',
LOGIN_UNKNOWN: '<strong>Login failed:</strong> An unknown error occured while trying to contact the REST-Interface. %INFO%',

NO_CLIENTS: '<strong>Warning:</strong> Could not contact REST-Interface to fetch client data!',
DEL_FAILED_REMOTE: '<strong>Warning:</strong> Delete-Operation failed, could not contact REST-Interface!',
SAVE_FAILED_UNKOWN: '<strong>Warning:</strong> Save-Operation failed, for unknown reason!',
SAVE_FAILED_REMOTE: '<strong>Warning:</strong> Save-Operation failed, could not contact REST-Interface!',
LOGIN_REJECTED: '<strong>Login failed:</strong> Username/Password combination was rejected.',
LOGIN_DISABLED: '<strong>Login failed:</strong> REST-Interface is disabled!',
LOGIN_UNKNOWN: '<strong>Login failed:</strong> An unknown error occured while trying to contact the REST-Interface.',
NOT_INSTALLED: '<strong>Login failed:</strong> The RESTPlugin does not seem to be installed correclty (404).',
CRITICAL_ERROR: '<strong>Login failed:</strong> The RESTPlugin raised a critical error, please report as bug.',

// Index.php
INDEX_TITLE: 'ILIAS REST Plugin - Administration',
INDEX_BRAND: 'ILIAS REST Plugin',
INDEX_LOGGED_IN: 'Logged in as {{authentication.getUserName()}} / {{authentication.getIliasClient()}}',
INDEX_LOGOUT: 'Logout',
INDEX_VERSION: 'Version',
INDEX_POWERED: 'Powered by',

// partials/login.html
LOGIN_AUTO: 'You came from the ILIAS platform. Trying to login automatically ...',
LOGIN_HEAD: 'REST Plugin Administration',
Expand Down Expand Up @@ -98,16 +99,7 @@ lang_en_us.config(function($translateProvider) {
LIST_GRANT_CC: 'Client Credentials',
LIST_NEW_CLIENT: 'Create a new REST client',
LIST_IP_RESTRICTION: 'IP',

// partials/offline.html
OFFLINE_WARNING: 'Warning!',
OFFLINE_ISSUE: 'Could not locate/contact the REST-API endpoint(s) at:',
OFFLINE_URL_POST: '[POST information]',
OFFLINE_URL_FILE: '[File URL]',
OFFLINE_URL_SUB: '[Subdomain URL]',
OFFLINE_EXPLANATION: 'The Admin-Panel requires an active REST-Endpoint to work.',
OFFLINE_RETRY: 'Retry',


// partials/clientedit.html
EDIT_BACK: 'Back',
EDIT_SAVE: 'Save',
Expand Down Expand Up @@ -156,7 +148,7 @@ lang_en_us.config(function($translateProvider) {
EDIT_CONFIG_SALT_DESCRIPTION_TEXT: 'SALT is a unique character sequence which is used to lift the entropy of the tokens.',

});

// Ste default language
$translateProvider.preferredLanguage('en-US');
});
});
12 changes: 0 additions & 12 deletions apps/admin/partials/offline.html

This file was deleted.

Loading

0 comments on commit 676cdd9

Please sign in to comment.