mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
Latest bits
This commit is contained in:
@ -6,7 +6,7 @@ var mongoose = require('mongoose'),
|
||||
|
||||
var log = require('log4node');
|
||||
|
||||
var frequencies = ["Medical Device","Sterilizer - TT","Vaporizer","Ice Maker","Anesthesia","Waste Management System","Imaging","Medical Gas Systems","RAE","ERT","N2O Trace Gas","Sterilizer - F","Quarterly","Semi","Annual","legacy","DLLR", "Isolation Panel", "Battery Backup"];
|
||||
var frequencies = ["Medical Device","Sterilizer - TT","Vaporizer","Ice Maker","Anesthesia","Waste Management System","Imaging","Medical Gas Systems","RAE","ERT","N2O Trace Gas","Sterilizer - F","Quarterly","Semi","Annual","legacy","DLLR", "Isolation Panel", "Battery Backup", "Sterilizer - Cleaning"];
|
||||
|
||||
exports.index = function(req, res) {
|
||||
log.info("clients.index");
|
||||
|
@ -14,13 +14,11 @@ module.exports = function(config) {
|
||||
|
||||
return {
|
||||
send: function(req, res) {
|
||||
console.log(req);
|
||||
var userId = req.body.user;
|
||||
if (!userId) {
|
||||
return res.json(404, null);
|
||||
}
|
||||
|
||||
console.log("Sending message");
|
||||
User.findById(userId, function(err, user) {
|
||||
if (err) return res.json(500, err);
|
||||
|
||||
|
@ -43,7 +43,6 @@ function renderHtml(input) {
|
||||
try {
|
||||
return markdown.toHTML(input);
|
||||
} catch (err) {
|
||||
console.log('Failed to render html', err);
|
||||
return input;
|
||||
}
|
||||
} else {
|
||||
@ -108,8 +107,6 @@ exports.create = function(req, res, next) {
|
||||
exports.update = function(req, res, next) {
|
||||
var id = req.param('post_id');
|
||||
|
||||
console.log('updating post');
|
||||
|
||||
return Post.findById(id, function(err, post) {
|
||||
post.title = req.body.title;
|
||||
post.preview = req.body.preview;
|
||||
|
@ -139,9 +139,6 @@ module.exports = function(config, calendar) {
|
||||
|
||||
var subject = 'Workorder created: ' + workorder.biomedId;
|
||||
|
||||
console.log('-------------------------');
|
||||
console.log(to);
|
||||
|
||||
async.waterfall([
|
||||
function(cb) {
|
||||
if (to && to.length > 0) {
|
||||
@ -151,7 +148,6 @@ module.exports = function(config, calendar) {
|
||||
to: to,
|
||||
subject: subject
|
||||
};
|
||||
console.log(msg);
|
||||
server.send(msg, function(err, message) { cb(err); });
|
||||
} else {
|
||||
cb();
|
||||
@ -165,7 +161,6 @@ module.exports = function(config, calendar) {
|
||||
to: techTo,
|
||||
subject: subject
|
||||
};
|
||||
console.log(msg);
|
||||
server.send(msg, function(err, message) { cb(err); });
|
||||
} else {
|
||||
cb();
|
||||
@ -318,7 +313,6 @@ module.exports = function(config, calendar) {
|
||||
to: to,
|
||||
subject: subject
|
||||
};
|
||||
console.log(msg);
|
||||
server.send(msg, function(err, message) { cb(err); });
|
||||
} else {
|
||||
cb();
|
||||
@ -332,7 +326,6 @@ module.exports = function(config, calendar) {
|
||||
to: techTo,
|
||||
subject: subject
|
||||
};
|
||||
console.log(msg);
|
||||
server.send(msg, function(err, message) { cb(err); });
|
||||
} else {
|
||||
cb();
|
||||
|
@ -44,6 +44,10 @@ angular.module('biomed', ['biomed.filters', 'biomed.services', 'biomed.directive
|
||||
templateUrl: '/partials/schedule/pms.html',
|
||||
controller: "SchedulePmsCtrl"
|
||||
})
|
||||
.when('/schedule/pms/report', {
|
||||
templateUrl: '/partials/schedule/report.html',
|
||||
controller: "FrequencyReportCtrl"
|
||||
})
|
||||
.when('/clients', {
|
||||
templateUrl: '/partials/clients/index.html',
|
||||
controller: "ClientIndexCtrl",
|
||||
|
@ -118,6 +118,59 @@ angular.module('biomed')
|
||||
$scope.$watch('frequency', update);
|
||||
})
|
||||
|
||||
.controller("FrequencyReportCtrl", function($scope, $q, $filter, Clients, Workorders, Pms) {
|
||||
$scope.loading = true;
|
||||
|
||||
// Setup initial state
|
||||
$scope.month = moment().month();
|
||||
$scope.year = 2015;
|
||||
$scope.frequency = "Anesthesia";
|
||||
|
||||
$scope.sort = {
|
||||
column: 'client.name',
|
||||
descending: false
|
||||
};
|
||||
|
||||
function update() {
|
||||
$scope.loading = true;
|
||||
|
||||
if ($scope.month == "" && $scope.frequency == "") {
|
||||
$scope.frequency = "Anesthesia";
|
||||
}
|
||||
|
||||
var query = {
|
||||
year: $scope.year,
|
||||
month: $scope.month,
|
||||
frequency: $scope.frequency,
|
||||
type: 'all'
|
||||
};
|
||||
|
||||
$scope.pms = Pms.index(query, function() {
|
||||
$scope.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.selectedCls = function(column) {
|
||||
return column == $scope.sort.column && 'sort-' + $scope.sort.descending;
|
||||
}
|
||||
|
||||
$scope.changeSorting = function(column) {
|
||||
console.log(column);
|
||||
var sort = $scope.sort;
|
||||
if (sort.column == column) {
|
||||
sort.descending = !sort.descending;
|
||||
} else {
|
||||
sort.column = column;
|
||||
sort.descending = false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$watch('month', update);
|
||||
$scope.$watch('year', update);
|
||||
$scope.$watch('frequency', update);
|
||||
})
|
||||
|
||||
|
||||
.controller("UsersIndexCtrl", function($scope, $filter, $routeParams, $location, Users, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
|
||||
@ -814,7 +867,7 @@ angular.module('biomed')
|
||||
}
|
||||
})
|
||||
|
||||
.controller("WorkorderAddCtrl", function($scope, $location, Workorders, Schedule, Clients, Users) {
|
||||
.controller("WorkorderAddCtrl", function($scope, $location, $filter, Workorders, Schedule, Clients, Users) {
|
||||
|
||||
$scope.emailsOptions = {
|
||||
'multiple': true,
|
||||
@ -864,19 +917,46 @@ angular.module('biomed')
|
||||
}
|
||||
}
|
||||
|
||||
if ($scope.model.client) {
|
||||
Clients.get({ id: $scope.model.client }, function(item) {
|
||||
$scope.clientPicker = {id: item._id, text: item.name + " (" + item.identifier + ")", data: item};
|
||||
});
|
||||
}
|
||||
|
||||
updateAllUsers();
|
||||
updateUsers();
|
||||
|
||||
$scope.$watch('group', updateUsers);
|
||||
|
||||
$scope.$watch('model.client', function() {
|
||||
$scope.currentClient = Clients.get({ id: $scope.model.client });
|
||||
$scope.$watch('clientPicker', function() {
|
||||
if ($scope.clientPicker) {
|
||||
var client = $scope.clientPicker.data;
|
||||
$scope.model.client = client._id;
|
||||
$scope.currentClient = client;
|
||||
} else {
|
||||
$scope.model.client = null;
|
||||
$scope.currentClient = null;
|
||||
}
|
||||
});
|
||||
|
||||
Clients.index(function(result) {
|
||||
$scope.clients = result;
|
||||
});
|
||||
|
||||
$scope.clientOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Client',
|
||||
minimumInputLength: 2,
|
||||
query: function(query) {
|
||||
var data = $filter('filter')($scope.clients, query.term);
|
||||
var results = [];
|
||||
data.forEach(function(item) {
|
||||
results.push({id: item._id, text: item.name + " (" + item.identifier + ")", data: item});
|
||||
});
|
||||
query.callback({ results: results });
|
||||
}
|
||||
};
|
||||
|
||||
function convertToDate(date, time) {
|
||||
return moment(moment(date).format('YYYY-MM-DD') + 'T' + time).toDate();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/clients"><i class="icon-calendar"></i> Schedule</a><li>
|
||||
<li><a href="/schedule"><i class="icon-calendar"></i> Schedule</a><li>
|
||||
</ul>
|
||||
<header>
|
||||
<h1>Schedule</h1>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/clients"><i class="icon-briefcase"></i> Schedule</a><li>
|
||||
<li><a href="/schedule/pms"><i class="icon-briefcase"></i>Preventive Maintenance</a><li>
|
||||
<li><a href="/schedule/pms/report"><i class="icon-book"></i>Frequency Report</a></li>
|
||||
</ul>
|
||||
<header>
|
||||
<h1>Preventive Maintenance</h1>
|
||||
@ -32,6 +33,7 @@
|
||||
<option value="Quarterly">Quarterly</option>
|
||||
<option value="RAE">RAE</option>
|
||||
<option value="Semi">Semi</option>
|
||||
<option value="Sterilizer - Cleaning">Sterilizer - Cleaning</option>
|
||||
<option value="Sterilizer - F">Sterilizer - F</option>
|
||||
<option value="Sterilizer - TT">Sterilizer - TT</option>
|
||||
<option value="Vaporizer">Vaporizer</option>
|
||||
|
73
public/partials/schedule/report.html
Normal file
73
public/partials/schedule/report.html
Normal file
@ -0,0 +1,73 @@
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/schedule/pms"><i class="icon-briefcase"></i>Preventive Maintenance</a><li>
|
||||
<li><a href="/schedule/pms/report"><i class="icon-book"></i>Frequency Report</a></li>
|
||||
</ul>
|
||||
<header>
|
||||
<h1>Frequency Report</h1>
|
||||
</header>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="toolbelt">
|
||||
<span class="toolbelt-text">Frequency:</span>
|
||||
<select ng-model="frequency" name="frequency" class="input-xlarge">
|
||||
<option value="Anesthesia">Anesthesia</option>
|
||||
<option value="Annual">Annual</option>
|
||||
<option value="DLLR">DLLR</option>
|
||||
<option value="ERT">ERT</option>
|
||||
<option value="Ice Maker">Ice Maker</option>
|
||||
<option value="Imaging">Imaging</option>
|
||||
<option value="Medical Device">Medical Device</option>
|
||||
<option value="Medical Gas Systems">Medical Gas Systems</option>
|
||||
<option value="N2O Trace Gas">N2O Trace Gas</option>
|
||||
<option value="Quarterly">Quarterly</option>
|
||||
<option value="RAE">RAE</option>
|
||||
<option value="Semi">Semi</option>
|
||||
<option value="Sterilizer - Cleaning">Sterilizer - Cleaning</option>
|
||||
<option value="Sterilizer - F">Sterilizer - F</option>
|
||||
<option value="Sterilizer - TT">Sterilizer - TT</option>
|
||||
<option value="Vaporizer">Vaporizer</option>
|
||||
<option value="Waste Management System">Waste Management System</option>
|
||||
<select>
|
||||
<div class="pull-right">
|
||||
<span class="toolbelt-text">Month:</span>
|
||||
<div class="input-append">
|
||||
<select ng-model="month" name="month" class="input-xlarge">
|
||||
<option value="">All</option>
|
||||
<option value="0">January</option>
|
||||
<option value="1">February</option>
|
||||
<option value="2">March</option>
|
||||
<option value="3">April</option>
|
||||
<option value="4">May</option>
|
||||
<option value="5">June</option>
|
||||
<option value="6">July</option>
|
||||
<option value="7">August</option>
|
||||
<option value="8">September</option>
|
||||
<option value="9">October</option>
|
||||
<option value="10">November</option>
|
||||
<option value="11">December</option>
|
||||
</select>
|
||||
<span class="add-on"><i class="icon-calendar"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="biomed-table" infinite-scroll="addItems()" can-load="canLoad" threshold="300">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 60%" ng-class="selectedCls('name')" ng-click="changeSorting('name')">Client Name</th>
|
||||
<th style="width: 25%" ng-class="selectedCls('contacts[0].name')" ng-click="changeSorting('contacts[0].name')">Contact</th>
|
||||
<th style="width: 15%" ng-class="selectedCls('contacts[0].phone')" ng-click="changeSorting('contacts[0].phone')">Phone</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-show="loading"><td colspan="3" class="table-loading"><i class="loader"></i></td></tr>
|
||||
<tr ng-hide="loading || pms.length"><td colspan="3" class="table-message">There is no information to display.</td></tr>
|
||||
<tr ng-hide="loading" ng-repeat="pm in pms | orderBy : sort.column : sort.descending">
|
||||
<td>{{pm.name}} ({{pm.identifier | uppercase}})</td>
|
||||
<td>{{pm.contacts[0].name}}</td>
|
||||
<td>{{pm.contacts[0].phone}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
@ -16,9 +16,7 @@
|
||||
<div class="control-group">
|
||||
<label class="control-label">Client</label>
|
||||
<div class="controls">
|
||||
<select ui-select2 ng-model="model.client" data-placeholder="Choose a Client" class="input-xxlarge">
|
||||
<option ng-repeat="client in clients" value="{{client._id}}">{{client.name}} ({{client.identifier}})</option>
|
||||
</select>
|
||||
<input type="hidden" ng-model="clientPicker" ui-select2="clientOpts" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" ng-show="currentClient.address">
|
||||
@ -301,8 +299,8 @@
|
||||
<div class="form-section">
|
||||
<div class="section-label"> </div>
|
||||
<div class="section-container">
|
||||
<button ng-click="save(false)" type="button" class="btn btn-primary">Save</button>
|
||||
<button ng-click="save(true)" type="button" class="btn">Save & Notify</button>
|
||||
<button ng-disabled="!model.client" ng-click="save(false)" type="button" class="btn btn-primary">Save</button>
|
||||
<button ng-disabled="!model.client" ng-click="save(true)" type="button" class="btn">Save & Notify</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -72,6 +72,6 @@ require('./config/routes')(app, auth, piler, calendar, directory, config);
|
||||
|
||||
GLOBAL.health = 'OK'
|
||||
|
||||
var port = process.env.PORT || 8000
|
||||
var port = process.env.PORT || 9000
|
||||
server.listen(port)
|
||||
console.log('Express app started on port ' + port)
|
||||
|
77
test.js
77
test.js
@ -1,10 +1,77 @@
|
||||
var env = process.env.NODE_ENV || 'development',
|
||||
config = require('./config/config')[env];
|
||||
var pushover = require('pushover-notifications');
|
||||
|
||||
config.auth.accessToken = "ya29.1.AADtN_Xjt0PK6YVs8q5csiQFXQg2ZDtrVhsH6P4a5zm0mHqhGx0Nnjx4Jk68Gw";
|
||||
config.auth.refreshToken = "1/_5SkDLYmsi4XNaQyAzld-W5-GEqEqt5byH6VkI-j5QI";
|
||||
var express = require('express')
|
||||
fs = require('fs'),
|
||||
passport = require('passport');
|
||||
|
||||
var env = 'prod',
|
||||
config = require('./config/config')[env],
|
||||
mongoose = require('mongoose'),
|
||||
Promise = require('bluebird');
|
||||
|
||||
var log = require('log4node');
|
||||
|
||||
Promise.promisifyAll(mongoose);
|
||||
|
||||
process.on('uncaughtException', function(err) {
|
||||
console.log('Uncaught Exception:', err);
|
||||
console.log(err.stack);
|
||||
|
||||
var p = new pushover({
|
||||
user: 'aJmPD4KigO0vLwim76n3WqWKwbKA3k',
|
||||
token: 'YxspDLz3WinbPmwBThuZXCME9QmkDb'
|
||||
});
|
||||
|
||||
var message = {
|
||||
title: 'Unhandled error in portal',
|
||||
message: 'Process was reset on ' + new Date(),
|
||||
sound: 'falling'
|
||||
};
|
||||
p.send(message, function(err, result) {
|
||||
if (err) {
|
||||
log.emergency('Error while sending pushover notification');
|
||||
log.emergency(err);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
||||
log.info("----- Server Started -----");
|
||||
|
||||
// bootstrap db connection
|
||||
mongoose.set('debug', config.debug);
|
||||
mongoose.connect(config.database);
|
||||
|
||||
// bootstrap model
|
||||
var modelPath = __dirname + '/app/model'
|
||||
fs.readdirSync(modelPath).forEach(function (file) {
|
||||
require(modelPath + '/' + file)
|
||||
})
|
||||
|
||||
require('./config/passport')(passport, config);
|
||||
|
||||
var app = express(),
|
||||
http = require('http'),
|
||||
server = http.createServer(app),
|
||||
io = require('socket.io').listen(server);
|
||||
|
||||
// Configure piler
|
||||
var piler = require('./config/piler')(app, server, io, config);
|
||||
|
||||
// Express settings
|
||||
require('./config/express')(app, config, passport, piler);
|
||||
|
||||
var auth = require('./config/auth')(app, passport);
|
||||
|
||||
var calendar = require('./config/calendar')(config);
|
||||
|
||||
var directory = require('./config/directory')(config);
|
||||
|
||||
// Bootstrap routes
|
||||
require('./config/routes')(app, auth, piler, calendar, directory, config);
|
||||
|
||||
directory.listUsers(function(err, result) { console.log(result); console.log(err); console.log('Done.'); });
|
||||
GLOBAL.health = 'OK'
|
||||
|
||||
var port = process.env.PORT || 6500
|
||||
server.listen(port)
|
||||
console.log('Express app started on port ' + port)
|
||||
|
Reference in New Issue
Block a user