Skip to content

Commit

Permalink
Merge pull request #16 from EmmetBlue/harm-ui
Browse files Browse the repository at this point in the history
Harm ui
  • Loading branch information
Samshal authored Feb 18, 2018
2 parents 92d2c26 + 3c65d4a commit ac71f29
Show file tree
Hide file tree
Showing 321 changed files with 29,471 additions and 2,903 deletions.
73 changes: 62 additions & 11 deletions assets/angular/core/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,27 @@ angular.module("EmmetBlue")
}

services.notify = function(title, text, type){
new PNotify({
PNotify.desktop.permission();
new PNotify({
title: title,
text: text,
addclass: 'alert-styled-left alert-arrow-left text-sky-royal',
type: type,
mouse_reset: true,
insert_brs: true
insert_brs: true,
nonblock: {
nonblock: true
},
desktop: {
desktop: false
},
history: {
menu: false
},
mobile: {
swipe_dismiss: true,
styling: true
}
});
};

Expand Down Expand Up @@ -115,11 +129,19 @@ angular.module("EmmetBlue")
services.serverRequest = function(url, requestType, data={}){
var deferred = $q.defer();

return $http({
var _req = {
"url":services.restServer+url,
"method":requestType,
"data":data
}).then(function(result){
}

if (typeof $cookies.getObject(CONSTANTS.USER_COOKIE_IDENTIFIER) !== "undefined"){
_req.headers = {
"Authorization":$cookies.getObject(CONSTANTS.USER_COOKIE_IDENTIFIER).token
}
}

return $http(_req).then(function(result){
deferred.resolve(result.data.contentData);
return deferred.promise;
}, function(result){
Expand All @@ -131,13 +153,19 @@ angular.module("EmmetBlue")
services.serverUpload = function(url, requestType, data={}){
var deferred = $q.defer();

return $http({
var _req = {
url: url,
method: requestType,
data: data,
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
}).then(function(result){
}

if (typeof $cookies.getObject(CONSTANTS.USER_COOKIE_IDENTIFIER) !== "undefined"){
_req.headers.Authorization = $cookies.getObject(CONSTANTS.USER_COOKIE_IDENTIFIER).token;
}

return $http(_req).then(function(result){
deferred.resolve(result.data.contentData);
return deferred.promise;
}, function(result){
Expand All @@ -153,8 +181,18 @@ angular.module("EmmetBlue")
services.notify('Invalid Resource Requested', 'The requested resource was not found on this server, please contact an administrator if this error persists', 'warning');
break;
}
case 500:{
services.notify('Unable To Process Request', 'This is usually due to making request for a missing resource or sending improperly formatted data to the server. Please contact an administrator if this error persists');
case 500:
case 501:
case 400:{
services.notify('Unable To Process Request', 'This is usually due to making request for a missing resource or sending improperly formatted data to the server. Please contact an administrator if this error persists. Error Code: AB0'+errorObject.status+' Server Message: '+errorObject.data.errorMessage, "error");
break;
}
case 503:{
services.notify('The Server Refused To Process Your Request', 'This is usally due to the creation of duplicate data. This resource does not allow you to create data of the same exact type, please contact an administrator if this error persists. Error Code: AB0'+errorObject.status, 'warning');
break;
}
case 401:{
console.log("Request Denied");
break;
}
default:
Expand All @@ -164,7 +202,7 @@ angular.module("EmmetBlue")
}
else{
if (errorObject.status == -1){
services.notify('Unable to reach server', "Please check your network connectivity to confirm the server is still accessible from this computer. Contact an administrator if this error persists", "warning");
services.notify('Unable to reach server', "Please check your network connectivity to confirm the server is still accessible from this computer. Contact an administrator if this error persists. Error Code: AB0"+errorObject.status, "warning");
}
else {
services.notify("Unknown error", "A general error has occurred, please contact an administrator", 'error');
Expand Down Expand Up @@ -244,11 +282,19 @@ angular.module("EmmetBlue")
return services.userSession.cookie().username;
},
clear: function(){
$cookies.remove(CONSTANTS.USER_COOKIE_IDENTIFIER);
$location.path('user/login');
services.serverRequest("/user/session/deactivate?resourceId="+services.userSession.getID(), "GET").then(function(response){
$cookies.remove(CONSTANTS.USER_COOKIE_IDENTIFIER);
$location.path('user/login');
}, function(error){
services.errorHandler(error);
})
}
}

services.newWebSocket = function(){
return new WebSocket(CONSTANTS.WEB_SOCKET_SERVER);
}

services.substringMatcher = function(strs) {
return function findMatches(q, cb) {
var matches, substringRegex;
Expand All @@ -273,6 +319,11 @@ angular.module("EmmetBlue")
};
};

services.generateQrCode = function(content, type="label"){
var data = {type: type, content: content};
return generateQrCode(JSON.stringify(data));
}

services.globalConstants = CONSTANTS;

services.serializeParams = $httpParamSerializer;
Expand Down
93 changes: 90 additions & 3 deletions assets/angular/core/controllers/core/core-controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
angular.module("EmmetBlue")

.controller('coreController', function($scope, $location, $routeParams, CONSTANTS, utils){
.controller('coreController', function($scope, $location, $routeParams, CONSTANTS, utils, $cookies){
$scope.loadImage = utils.loadImage;
$scope.userClient = utils.globalConstants.USER_CLIENT;
$scope.$on('$routeChangeSuccess', function(event, current, previous){
var path = ($location.path()).split('/');
var userDashboard = ("/"+utils.userSession.getDashboard()).split("/");
Expand Down Expand Up @@ -35,6 +36,33 @@ angular.module("EmmetBlue")
var checkLogin = function(){
if ($location.path() != '/user/login'){
utils.userSession.cookie();

$.sessionTimeout({
heading: 'h5',
title: 'Session expiration',
message: 'Your session is about to expire. Do you want to stay connected and extend your session?',
keepAlive: false,
warnAfter: 900000, //10 mins
redirAfter: 1020000, //15 mins
ignoreUserActivity: false,
onWarn: function(){
var title = "IDLE TIMEOUT";
var text = "Your session is about to expire. Click on the cancel button to stay connected and extend your session or click on Logout to close the current session"
var close = true;
var type = "info";
var btnText = "Logout";

var process = function(){
$scope.logout();
}

utils.confirm(title, text, close, process, type, btnText);
},
onRedir: function(){
utils.notify('Your session has expired!', 'You are being redirected to the login page, please enter your username and password to access your account', 'info');
$scope.logout();
}
});
}
}

Expand Down Expand Up @@ -78,9 +106,68 @@ angular.module("EmmetBlue")
}

$scope.showEmmetBlueInfo = function(){
utils.alert("Emmetblue "+$scope.currentYear, "This software has been designed for and deployed to St. Gerard's Catholic Hospital. Unless stated otherwise, every part of the system is considered a property of Emmetblue and are presently in the closed-source domain with appropriate licenses. Contact an appropriate department for help or [email protected] for technical support.", "info");
utils.alert("Emmetblue "+$scope.currentYear, "This software has been customized for and deployed to "+$scope.userClient.short_name+". Unless stated otherwise, every part of the system is considered a property of Emmetblue and are presently in the closed-source domain with appropriate licenses. Contact an appropriate department for help or [email protected] for technical support.", "info");
}

function updateCookieDashboardUrl(url, department = ""){
var cookie = $cookies.getObject(utils.globalConstants.USER_COOKIE_IDENTIFIER);
cookie.dashboard = url;
$cookies.putObject(utils.globalConstants.USER_COOKIE_IDENTIFIER, cookie);

$location.path(url);
if (department !== ""){
utils.storage.currentStaffDepartmentID = department
}
}

$scope.$watch(function(){
return utils.storage.currentStaffDepartmentID;
}, function(nv){
var req = utils.serverRequest("/human-resources/department/view?resourceId="+nv, "GET");
req.then(function(response){
$scope.currentDepartmentName = response[0].Name;
});
})

$scope.switch = function(id){
var data = {
"staff": utils.userSession.getID(),
"department":id
};

utils.serverRequest("/user/account/get-switch-data", "POST", data)
.then(function(response){
updateCookieDashboardUrl(response.Url, response.DepartmentID);
}, function(error){
utils.errorHandler(error);
})
}

$scope.returnToPrimaryDept = function(){
utils.serverRequest("/human-resources/staff/view-root-url?resourceId="+utils.userSession.getID(), "GET").then(function(response){
updateCookieDashboardUrl(response.Url, response.DepartmentID);
}, function(error){
utils.errorHandler(error);
})
}

checkLogin();
loadUserProfile();
loadUserProfile();

$scope.loadSwitchableDepts = function(){
if (typeof $scope.switchableDepartments == "undefined"){
utils.serverRequest("/human-resources/staff-department/view-secondary-departments?resourceId="+utils.userSession.getID(), "GET")
.then(function(response){
$scope.switchableDepartments = response;
}, function(error){
utils.errorHandler(error);
})
}
}

var userSessionQrCodeHandler = function(){
$(".userSessionQrCodeSvg").html(utils.generateQrCode(JSON.stringify(utils.userSession.cookie()), "user"));
}

userSessionQrCodeHandler();
});
18 changes: 3 additions & 15 deletions assets/angular/core/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ angular.module('EmmetBlue', [
'ngSanitize',
'datatables',
'datatables.buttons',
// 'datatables.bootstrap',
'datatables.fixedheader',
'ngCookies',
'ngStorage',
'ngPrint',
'angularUtils.directives.dirPagination',
'angular-toArrayFilter' //<--- LIFE SAVER! Thanks https://github.com/petebacondarwin! (in case, paradventure, probably, you ever read this code)
'angular-toArrayFilter', //<--- LIFE SAVER! Thanks https://github.com/petebacondarwin! (in case, paradventure, probably, you ever read this code)
'mwl.calendar'
])

.constant("CONSTANTS", getConstants())
Expand Down Expand Up @@ -74,18 +76,4 @@ function determineRouteAvailability(url){
var _url = 'plugins/'+urlParts.join('/')+'.html';

return _url;
}


function getConstants(){
var server = "https://sglt:700/";

return {
"TEMPLATE_DIR":"plugins/",
"MODULE_MENU_LOCATION":"assets/includes/menu.html",
"MODULE_HEADER_LOCATION":"assets/includes/header.html",
"EMMETBLUE_SERVER":server,
"EMMETBLUE_SERVER_VERSION":"v1",
"USER_COOKIE_IDENTIFIER":"_______"
};
}
69 changes: 49 additions & 20 deletions assets/angular/core/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,29 @@
<ul class="nav navbar-nav pull-right visible-xs-block">
<li><a data-toggle="collapse" data-target="#navbar-mobile"><i class="icon-menu5"></i></a></li>
</ul>
</div>

<div class=" navbar-collapse collapse" id="navbar-mobile">
<ul class="nav navbar-nav">

</ul>
<p class="navbar-text"><i class="icon-location4"></i> {{currentDepartmentName}}</p>
<p class="navbar-text"><span class="label bg-success-400">Local Intranet</span></p>
</div>

<div class="navbar-collapse collapse" id="navbar-mobile">
<ul class="no-login nav navbar-nav navbar-right">
<li>
<a>
<i class="icon-vcard"></i>
<span class="position-right">{{currentStaffDepartmentInfo.Name}}</span>
<li><a ng-click="returnToPrimaryDept()"><i class="fa fa-home"></i></a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" ng-click="loadSwitchableDepts()">
Switch Department <i class="caret"></i>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<div class="form-group" style=" padding: 0 !important; margin: 0 !important;">
<input class="form-control" type="text" placeholder="Filter departments " style="border-radius: 0;" ng-model="departmentsFilter" id="__departmentsFilter"/>
</div>
</li>
<li class="divider"></li>
<li ng-repeat="department in switchableDepartments | filter: departmentsFilter" ng-click="switch(department.DepartmentID)"><a href="#">{{department.Name}}</a></li>
</ul>
</li>

<!-- <li>
<a>
<i class="fa fa-user-secret"></i>
<span class="position-right"></span>
</a>
</li> -->

<li class="dropdown dropdown-user">
<a class="dropdown-toggle" data-toggle="dropdown">
<img ng-src="{{loadImage(currentStaffInfo.StaffPicture)}}" alt="" ng-if="staffProfileExists()">
Expand All @@ -37,13 +38,41 @@
</a>

<ul class="dropdown-menu dropdown-menu-right">
<!-- <li><a href="#"><i class="icon-user-plus"></i> My profile</a></li>
<li><a href="#"><i class="icon-coins"></i> Inbox</a></li>
<li class="divider"></li>
<li><a href="#"><i class="icon-cog5"></i> Account settings</a></li> -->
<li data-toggle="modal" data-target="#userSessionQrCodeSvgModal">
<a href="#"><div style="width:100%; background-color:transparent;" class="userSessionQrCodeSvg"></div></a>
</li>
<li class="divider"></li>
<li><a href="/user/switch-department"><i class="icon-cog5"></i> Switch Department</a></li>
<!-- <li><a href="#"><i class="icon-coins"></i> Inbox</a></li> -->
<li data-toggle="modal" data-target="#userWorkScheduleModal"><a href="#"><i class="fa fa-calendar"></i> Work Schedules</a></li>

<li class="divider"></li>
<li><a href="#" ng-click="logout()"><i class="icon-switch2"></i> Logout</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="modal modal-fade" id="userSessionQrCodeSvgModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div style="width:98%; height: 90%; background-color:transparent;" class="userSessionQrCodeSvg"></div>
</div>
</div>
</div>
</div>
</div>

<div class="modal modal-fade" id="userWorkScheduleModal">
<div class="modal-full">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<ng-include src="'plugins/user/work-schedules.html'"></ng-include>
</div>
</div>
</div>
</div>
</div>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit ac71f29

Please sign in to comment.