mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
Changes
This commit is contained in:
290
public/js/app.js
290
public/js/app.js
@ -1,152 +1,152 @@
|
||||
var biomed = {};
|
||||
|
||||
angular.module('biomed', ['biomed.filters', 'biomed.services', 'biomed.directives', 'ngResource', 'ngRoute', 'ui.bootstrap.dialog'])
|
||||
.run(function($rootScope) {
|
||||
$rootScope.TECH_GROUPS = {
|
||||
all: 'All',
|
||||
biomed: 'Biomed',
|
||||
ice: 'ICE',
|
||||
sales: 'Sales',
|
||||
other: 'Others'
|
||||
};
|
||||
$rootScope.dayOfYear = moment().dayOfYear();
|
||||
})
|
||||
.config(function($routeProvider, $locationProvider, $httpProvider) {
|
||||
.run(function ($rootScope) {
|
||||
$rootScope.TECH_GROUPS = {
|
||||
all: 'All',
|
||||
biomed: 'Biomed',
|
||||
ice: 'ICE',
|
||||
sales: 'Sales',
|
||||
other: 'Others'
|
||||
};
|
||||
$rootScope.dayOfYear = moment().dayOfYear();
|
||||
})
|
||||
.config(function ($routeProvider, $locationProvider, $httpProvider) {
|
||||
|
||||
var JSON_START = /^\s*(\[|\{[^\{])/,
|
||||
JSON_END = /[\}\]]\s*$/,
|
||||
PROTECTION_PREFIX = /^\)\]\}',?\n/,
|
||||
DATE_MATCHER = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/;
|
||||
var JSON_START = /^\s*(\[|\{[^\{])/,
|
||||
JSON_END = /[\}\]]\s*$/,
|
||||
PROTECTION_PREFIX = /^\)\]\}',?\n/,
|
||||
DATE_MATCHER = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/;
|
||||
|
||||
$httpProvider.defaults.transformResponse = [function(data) {
|
||||
if (angular.isString(data)) {
|
||||
data = data.replace(PROTECTION_PREFIX, '');
|
||||
if (JSON_START.test(data) && JSON_END.test(data)) {
|
||||
data = JSON.parse(data, function(key, val) {
|
||||
if (DATE_MATCHER.test(val)) {
|
||||
return new moment(val).zone(-5).toDate();
|
||||
}
|
||||
return val;
|
||||
})
|
||||
}
|
||||
$httpProvider.defaults.transformResponse = [function (data) {
|
||||
if (angular.isString(data)) {
|
||||
data = data.replace(PROTECTION_PREFIX, '');
|
||||
if (JSON_START.test(data) && JSON_END.test(data)) {
|
||||
data = JSON.parse(data, function (key, val) {
|
||||
if (DATE_MATCHER.test(val)) {
|
||||
return new moment(val).zone(-5).toDate();
|
||||
}
|
||||
return val;
|
||||
})
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}];
|
||||
return data;
|
||||
}
|
||||
}];
|
||||
|
||||
$locationProvider.html5Mode(true);
|
||||
$routeProvider
|
||||
.when('/schedule', {
|
||||
templateUrl: '/partials/schedule/index.html',
|
||||
controller: "ScheduleIndexCtrl"
|
||||
})
|
||||
.when('/schedule/pms', {
|
||||
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",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/clients/add', {
|
||||
templateUrl: '/partials/clients/add.html',
|
||||
controller: "ClientAddCtrl"
|
||||
})
|
||||
.when('/clients/:id', {
|
||||
templateUrl: '/partials/clients/edit.html',
|
||||
controller: "ClientEditCtrl"
|
||||
})
|
||||
.when('/deviceTypes', {
|
||||
templateUrl: '/partials/deviceTypes/index.html',
|
||||
controller: "DeviceTypeIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/deviceTypes/add', {
|
||||
templateUrl: '/partials/deviceTypes/add.html',
|
||||
controller: "DeviceTypeAddCtrl"
|
||||
})
|
||||
.when('/deviceTypes/:id', {
|
||||
templateUrl: '/partials/deviceTypes/edit.html',
|
||||
controller: "DeviceTypeEditCtrl"
|
||||
})
|
||||
.when('/devices/add', {
|
||||
templateUrl: '/partials/devices/add.html',
|
||||
controller: "DeviceAddCtrl"
|
||||
})
|
||||
.when('/devices/:id', {
|
||||
templateUrl: '/partials/devices/edit.html',
|
||||
controller: "DeviceEditCtrl"
|
||||
})
|
||||
.when('/checkLists', {
|
||||
templateUrl: '/partials/checkLists/index.html',
|
||||
controller: "CheckListIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/checkLists/add', {
|
||||
templateUrl: '/partials/checkLists/add.html',
|
||||
controller: "CheckListAddCtrl"
|
||||
})
|
||||
.when('/checkLists/:id', {
|
||||
templateUrl: '/partials/checkLists/add.html',
|
||||
controller: "CheckListEditCtrl"
|
||||
})
|
||||
.when('/testRuns/add', {
|
||||
templateUrl: '/partials/testRuns/add.html',
|
||||
controller: "TestRunAddCtrl"
|
||||
})
|
||||
.when('/testRuns/:id', {
|
||||
templateUrl: '/partials/testRuns/view.html',
|
||||
controller: "TestRunViewCtrl"
|
||||
})
|
||||
.when('/accounting', {
|
||||
templateUrl: '/partials/accounting/index.html',
|
||||
controller: "AccountingIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/workorders', {
|
||||
templateUrl: '/partials/workorders/index.html',
|
||||
controller: "WorkorderIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/workorders/add', {
|
||||
templateUrl: '/partials/workorders/add.html',
|
||||
controller: "WorkorderAddCtrl"
|
||||
})
|
||||
.when('/workorders/:id', {
|
||||
templateUrl: '/partials/workorders/edit.html',
|
||||
controller: "WorkorderEditCtrl"
|
||||
})
|
||||
.when('/techs/:id', {
|
||||
templateUrl: '/partials/techs/schedule.html',
|
||||
controller: "TechScheduleCtrl"
|
||||
})
|
||||
.when('/posts', {
|
||||
templateUrl: '/partials/posts/index.html',
|
||||
controller: "PostIndexCtrl"
|
||||
})
|
||||
.when('/posts/add', {
|
||||
templateUrl: '/partials/posts/add.html',
|
||||
controller: "PostAddCtrl"
|
||||
})
|
||||
.when('/posts/:id', {
|
||||
templateUrl: '/partials/posts/edit.html',
|
||||
controller: "PostEditCtrl"
|
||||
})
|
||||
.when('/admin', {
|
||||
templateUrl: '/partials/users/index.html',
|
||||
controller: "UsersIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/admin/users/:id', {
|
||||
templateUrl: '/partials/users/clock.html',
|
||||
controller: "UserClockCtrl"
|
||||
})
|
||||
.otherwise({
|
||||
redirectTo: '/schedule'
|
||||
});
|
||||
});
|
||||
$locationProvider.html5Mode(true);
|
||||
$routeProvider
|
||||
.when('/schedule', {
|
||||
templateUrl: '/partials/schedule/index.html',
|
||||
controller: "ScheduleIndexCtrl"
|
||||
})
|
||||
.when('/schedule/pms', {
|
||||
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",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/clients/add', {
|
||||
templateUrl: '/partials/clients/add.html',
|
||||
controller: "ClientAddCtrl"
|
||||
})
|
||||
.when('/clients/:id', {
|
||||
templateUrl: '/partials/clients/edit.html',
|
||||
controller: "ClientEditCtrl"
|
||||
})
|
||||
.when('/deviceTypes', {
|
||||
templateUrl: '/partials/deviceTypes/index.html',
|
||||
controller: "DeviceTypeIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/deviceTypes/add', {
|
||||
templateUrl: '/partials/deviceTypes/add.html',
|
||||
controller: "DeviceTypeAddCtrl"
|
||||
})
|
||||
.when('/deviceTypes/:id', {
|
||||
templateUrl: '/partials/deviceTypes/edit.html',
|
||||
controller: "DeviceTypeEditCtrl"
|
||||
})
|
||||
.when('/devices/add', {
|
||||
templateUrl: '/partials/devices/add.html',
|
||||
controller: "DeviceAddCtrl"
|
||||
})
|
||||
.when('/devices/:id', {
|
||||
templateUrl: '/partials/devices/edit.html',
|
||||
controller: "DeviceEditCtrl"
|
||||
})
|
||||
.when('/checkLists', {
|
||||
templateUrl: '/partials/checkLists/index.html',
|
||||
controller: "CheckListIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/checkLists/add', {
|
||||
templateUrl: '/partials/checkLists/add.html',
|
||||
controller: "CheckListAddCtrl"
|
||||
})
|
||||
.when('/checkLists/:id', {
|
||||
templateUrl: '/partials/checkLists/add.html',
|
||||
controller: "CheckListEditCtrl"
|
||||
})
|
||||
.when('/testRuns/add', {
|
||||
templateUrl: '/partials/testRuns/add.html',
|
||||
controller: "TestRunAddCtrl"
|
||||
})
|
||||
.when('/testRuns/:id', {
|
||||
templateUrl: '/partials/testRuns/view.html',
|
||||
controller: "TestRunViewCtrl"
|
||||
})
|
||||
.when('/accounting', {
|
||||
templateUrl: '/partials/accounting/index.html',
|
||||
controller: "AccountingIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/workorders', {
|
||||
templateUrl: '/partials/workorders/index.html',
|
||||
controller: "WorkorderIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/workorders/add', {
|
||||
templateUrl: '/partials/workorders/add.html',
|
||||
controller: "WorkorderAddCtrl"
|
||||
})
|
||||
.when('/workorders/:id', {
|
||||
templateUrl: '/partials/workorders/edit.html',
|
||||
controller: "WorkorderEditCtrl"
|
||||
})
|
||||
.when('/techs/:id', {
|
||||
templateUrl: '/partials/techs/schedule.html',
|
||||
controller: "TechScheduleCtrl"
|
||||
})
|
||||
.when('/posts', {
|
||||
templateUrl: '/partials/posts/index.html',
|
||||
controller: "PostIndexCtrl"
|
||||
})
|
||||
.when('/posts/add', {
|
||||
templateUrl: '/partials/posts/add.html',
|
||||
controller: "PostAddCtrl"
|
||||
})
|
||||
.when('/posts/:id', {
|
||||
templateUrl: '/partials/posts/edit.html',
|
||||
controller: "PostEditCtrl"
|
||||
})
|
||||
.when('/admin', {
|
||||
templateUrl: '/partials/users/index.html',
|
||||
controller: "UsersIndexCtrl",
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/admin/users/:id', {
|
||||
templateUrl: '/partials/users/clock.html',
|
||||
controller: "UserClockCtrl"
|
||||
})
|
||||
.otherwise({
|
||||
redirectTo: '/schedule'
|
||||
});
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
||||
angular.module('biomed')
|
||||
.controller("CheckListIndexCtrl", checkListsIndexController)
|
||||
.controller("CheckListAddCtrl", checkListsControllerFactory(false))
|
||||
.controller("CheckListEditCtrl", checkListsControllerFactory(true))
|
||||
.controller("CheckListIndexCtrl", checkListsIndexController)
|
||||
.controller("CheckListAddCtrl", checkListsControllerFactory(false))
|
||||
.controller("CheckListEditCtrl", checkListsControllerFactory(true))
|
||||
|
||||
function checkListsIndexController($scope, $filter, $routeParams, CheckLists, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
|
||||
var allData = CheckLists.index(function() {
|
||||
var allData = CheckLists.index(function () {
|
||||
$scope.loading = false;
|
||||
$scope.filter();
|
||||
});
|
||||
@ -18,20 +18,20 @@ function checkListsIndexController($scope, $filter, $routeParams, CheckLists, Lo
|
||||
|
||||
$scope.canLoad = true;
|
||||
|
||||
$scope.$watch('query', function() {
|
||||
$scope.$watch('query', function () {
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
LocationBinder($scope, ['query']);
|
||||
|
||||
$scope.filter = function() {
|
||||
$scope.filter = function () {
|
||||
filteredData = $filter('orderBy')($filter('filter')(allData, $scope.query), $scope.sort.column, $scope.sort.descending);
|
||||
index = initialPageSize;
|
||||
$scope.canLoad = true;
|
||||
$scope.checkLists = filteredData.slice(0, initialPageSize);
|
||||
};
|
||||
|
||||
$scope.addItems = function() {
|
||||
$scope.addItems = function () {
|
||||
$scope.checkLists = $scope.checkLists.concat(filteredData.slice(index, index + pageSize));
|
||||
index += pageSize;
|
||||
$scope.canLoad = index < filteredData.length;
|
||||
@ -42,11 +42,11 @@ function checkListsIndexController($scope, $filter, $routeParams, CheckLists, Lo
|
||||
descending: false
|
||||
};
|
||||
|
||||
$scope.selectedCls = function(column) {
|
||||
$scope.selectedCls = function (column) {
|
||||
return column == $scope.sort.column && 'sort-' + $scope.sort.descending;
|
||||
}
|
||||
|
||||
$scope.changeSorting = function(column) {
|
||||
$scope.changeSorting = function (column) {
|
||||
var sort = $scope.sort;
|
||||
if (sort.column == column) {
|
||||
sort.descending = !sort.descending;
|
||||
@ -60,10 +60,10 @@ function checkListsIndexController($scope, $filter, $routeParams, CheckLists, Lo
|
||||
}
|
||||
|
||||
function checkListsControllerFactory(isEdit) {
|
||||
return function($scope, CheckLists, $location, $filter, $routeParams) {
|
||||
return function ($scope, CheckLists, $location, $filter, $routeParams) {
|
||||
|
||||
function addField() {
|
||||
$scope.model.fields.push({ type: 'boolean' })
|
||||
$scope.model.fields.push({type: 'boolean'})
|
||||
}
|
||||
|
||||
function removeField(index) {
|
||||
@ -74,22 +74,22 @@ function checkListsControllerFactory(isEdit) {
|
||||
}
|
||||
|
||||
function moveUpField(index) {
|
||||
$scope.model.fields.splice(index - 1, 0, $scope.model.fields.splice(index, 1)[0]);
|
||||
$scope.model.fields.splice(index - 1, 0, $scope.model.fields.splice(index, 1)[0]);
|
||||
}
|
||||
|
||||
function moveDownField(index) {
|
||||
$scope.model.fields.splice(index + 1, 0, $scope.model.fields.splice(index, 1)[0]);
|
||||
}
|
||||
function moveDownField(index) {
|
||||
$scope.model.fields.splice(index + 1, 0, $scope.model.fields.splice(index, 1)[0]);
|
||||
}
|
||||
|
||||
function save() {
|
||||
if (isEdit) {
|
||||
CheckLists.update({id: $scope.model._id}, $scope.model, function() {
|
||||
CheckLists.update({id: $scope.model._id}, $scope.model, function () {
|
||||
$location.path("/checkLists/");
|
||||
});
|
||||
} else {
|
||||
CheckLists.create($scope.model, function(result) {
|
||||
CheckLists.create($scope.model, function (result) {
|
||||
$location.path("/checkLists/" + result._id);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,269 +1,269 @@
|
||||
angular.module('biomed')
|
||||
|
||||
.controller("DeviceTypeIndexCtrl", function($scope, $filter, $routeParams, DeviceTypes, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
.controller("DeviceTypeIndexCtrl", function ($scope, $filter, $routeParams, DeviceTypes, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
|
||||
var allData = DeviceTypes.index(function() {
|
||||
$scope.loading = false;
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
var filteredData = [];
|
||||
var index = 0;
|
||||
var initialPageSize = 100;
|
||||
var pageSize = 5;
|
||||
|
||||
$scope.canLoad = true;
|
||||
|
||||
$scope.$watch('query', function() {
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
LocationBinder($scope, ['query']);
|
||||
|
||||
$scope.filter = function() {
|
||||
filteredData = $filter('orderBy')($filter('filter')(allData, $scope.query), $scope.sort.column, $scope.sort.descending);
|
||||
index = initialPageSize;
|
||||
$scope.canLoad = true;
|
||||
$scope.devices = filteredData.slice(0, initialPageSize);
|
||||
};
|
||||
|
||||
$scope.addItems = function() {
|
||||
$scope.devices = $scope.devices.concat(filteredData.slice(index, index + pageSize));
|
||||
index += pageSize;
|
||||
$scope.canLoad = index < filteredData.length;
|
||||
}
|
||||
|
||||
$scope.sort = {
|
||||
column: 'category',
|
||||
descending: false
|
||||
};
|
||||
|
||||
$scope.selectedCls = function(column) {
|
||||
return column == $scope.sort.column && 'sort-' + $scope.sort.descending;
|
||||
}
|
||||
|
||||
$scope.changeSorting = function(column) {
|
||||
var sort = $scope.sort;
|
||||
if (sort.column == column) {
|
||||
sort.descending = !sort.descending;
|
||||
} else {
|
||||
sort.column = column;
|
||||
sort.descending = false;
|
||||
}
|
||||
|
||||
$scope.filter();
|
||||
};
|
||||
})
|
||||
|
||||
.controller("DeviceTypeAddCtrl", function($scope, DeviceTypes, CheckLists, $location, $filter) {
|
||||
$scope.model = {};
|
||||
|
||||
$scope.categories = DeviceTypes.categories();
|
||||
$scope.deviceMakes = DeviceTypes.makes();
|
||||
|
||||
$scope.checkLists = CheckLists.index();
|
||||
|
||||
$scope.categoryOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Type',
|
||||
query: function(query) {
|
||||
var data = $filter('filter')($scope.categories, query.term);
|
||||
var results = [];
|
||||
data.forEach(function(item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results });
|
||||
},
|
||||
createSearchChoice: function(term) {
|
||||
return { id: term, text: term };
|
||||
}
|
||||
};
|
||||
|
||||
$scope.makeOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Make',
|
||||
query: function(query) {
|
||||
var data = $filter('filter')($scope.deviceMakes, query.term);
|
||||
var results = [];
|
||||
data.forEach(function(item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results });
|
||||
},
|
||||
createSearchChoice: function(term) {
|
||||
return { id: term, text: term };
|
||||
}
|
||||
};
|
||||
|
||||
var images = {};
|
||||
|
||||
$scope.imageOpts = {
|
||||
options: {
|
||||
url: '/api/deviceTypes/images',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
file.filename = response.filename;
|
||||
|
||||
if (images[file.filename]) {
|
||||
images[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
images[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function(file) {
|
||||
images[file.filename]--;
|
||||
|
||||
if (images[file.filename] <= 0) {
|
||||
delete images[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$watch('categoryPicker', function() {
|
||||
if ($scope.categoryPicker) {
|
||||
$scope.model.category = $scope.categoryPicker.id;
|
||||
} else {
|
||||
$scope.model.category = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('makePicker', function() {
|
||||
if ($scope.makePicker) {
|
||||
$scope.model.make = $scope.makePicker.id;
|
||||
} else {
|
||||
$scope.model.make = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.save = function() {
|
||||
$scope.model.images = Object.keys(images);
|
||||
|
||||
DeviceTypes.create($scope.model, function(result) {
|
||||
$location.path("/deviceTypes/");
|
||||
});
|
||||
};
|
||||
})
|
||||
|
||||
.controller("DeviceTypeEditCtrl", function($scope, DeviceTypes, Devices, CheckLists, $location, $filter, $routeParams) {
|
||||
var images = {};
|
||||
|
||||
$scope.checkLists = CheckLists.index(function() {
|
||||
$scope.model = DeviceTypes.get($routeParams, function() {
|
||||
var allData = DeviceTypes.index(function () {
|
||||
$scope.loading = false;
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
$scope.existingImages = $scope.model.images;
|
||||
if ($scope.model.images) {
|
||||
for (var i = 0; i < $scope.model.images.length; i++) {
|
||||
images[$scope.model.images[i]] = 1;
|
||||
}
|
||||
var filteredData = [];
|
||||
var index = 0;
|
||||
var initialPageSize = 100;
|
||||
var pageSize = 5;
|
||||
|
||||
$scope.canLoad = true;
|
||||
|
||||
$scope.$watch('query', function () {
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
LocationBinder($scope, ['query']);
|
||||
|
||||
$scope.filter = function () {
|
||||
filteredData = $filter('orderBy')($filter('filter')(allData, $scope.query), $scope.sort.column, $scope.sort.descending);
|
||||
index = initialPageSize;
|
||||
$scope.canLoad = true;
|
||||
$scope.devices = filteredData.slice(0, initialPageSize);
|
||||
};
|
||||
|
||||
$scope.addItems = function () {
|
||||
$scope.devices = $scope.devices.concat(filteredData.slice(index, index + pageSize));
|
||||
index += pageSize;
|
||||
$scope.canLoad = index < filteredData.length;
|
||||
}
|
||||
|
||||
$scope.sort = {
|
||||
column: 'category',
|
||||
descending: false
|
||||
};
|
||||
|
||||
$scope.selectedCls = function (column) {
|
||||
return column == $scope.sort.column && 'sort-' + $scope.sort.descending;
|
||||
}
|
||||
|
||||
$scope.changeSorting = function (column) {
|
||||
var sort = $scope.sort;
|
||||
if (sort.column == column) {
|
||||
sort.descending = !sort.descending;
|
||||
} else {
|
||||
sort.column = column;
|
||||
sort.descending = false;
|
||||
}
|
||||
|
||||
$scope.categoryPicker = {id: $scope.model.category, text: $scope.model.category};
|
||||
$scope.makePicker = {id: $scope.model.make, text: $scope.model.make};
|
||||
});
|
||||
});
|
||||
$scope.filter();
|
||||
};
|
||||
})
|
||||
|
||||
console.log($routeParams);
|
||||
.controller("DeviceTypeAddCtrl", function ($scope, DeviceTypes, CheckLists, $location, $filter) {
|
||||
$scope.model = {};
|
||||
|
||||
$scope.devices = Devices.index({ deviceType: $routeParams.id });
|
||||
$scope.categories = DeviceTypes.categories();
|
||||
$scope.deviceMakes = DeviceTypes.makes();
|
||||
|
||||
$scope.categories = DeviceTypes.categories();
|
||||
$scope.deviceMakes = DeviceTypes.makes();
|
||||
$scope.checkLists = CheckLists.index();
|
||||
|
||||
|
||||
$scope.categoryOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Type',
|
||||
query: function(query) {
|
||||
var data = $filter('filter')($scope.categories, query.term);
|
||||
var results = [];
|
||||
data.forEach(function(item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results });
|
||||
},
|
||||
createSearchChoice: function(term) {
|
||||
return { id: term, text: term };
|
||||
}
|
||||
};
|
||||
|
||||
$scope.makeOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Make',
|
||||
query: function(query) {
|
||||
var data = $filter('filter')($scope.deviceMakes, query.term);
|
||||
var results = [];
|
||||
data.forEach(function(item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results });
|
||||
},
|
||||
createSearchChoice: function(term) {
|
||||
return { id: term, text: term };
|
||||
}
|
||||
};
|
||||
|
||||
$scope.imageOpts = {
|
||||
options: {
|
||||
url: '/api/deviceTypes/images',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
file.filename = response.filename;
|
||||
|
||||
if (images[file.filename]) {
|
||||
images[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
images[file.filename] = 1;
|
||||
}
|
||||
$scope.categoryOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Type',
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.categories, query.term);
|
||||
var results = [];
|
||||
data.forEach(function (item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results});
|
||||
},
|
||||
removedfile: function(file) {
|
||||
images[file.filename]--;
|
||||
createSearchChoice: function (term) {
|
||||
return {id: term, text: term};
|
||||
}
|
||||
};
|
||||
|
||||
if (images[file.filename] <= 0) {
|
||||
delete images[file.filename];
|
||||
$scope.makeOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Make',
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.deviceMakes, query.term);
|
||||
var results = [];
|
||||
data.forEach(function (item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results});
|
||||
},
|
||||
createSearchChoice: function (term) {
|
||||
return {id: term, text: term};
|
||||
}
|
||||
};
|
||||
|
||||
var images = {};
|
||||
|
||||
$scope.imageOpts = {
|
||||
options: {
|
||||
url: '/api/deviceTypes/images',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function (file, response) {
|
||||
file.filename = response.filename;
|
||||
|
||||
if (images[file.filename]) {
|
||||
images[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
images[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function (file) {
|
||||
images[file.filename]--;
|
||||
|
||||
if (images[file.filename] <= 0) {
|
||||
delete images[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
$scope.$watch('categoryPicker', function() {
|
||||
if ($scope.categoryPicker) {
|
||||
$scope.model.category = $scope.categoryPicker.id;
|
||||
} else {
|
||||
$scope.model.category = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('makePicker', function() {
|
||||
if ($scope.makePicker) {
|
||||
$scope.model.make = $scope.makePicker.id;
|
||||
} else {
|
||||
$scope.model.make = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.save = function() {
|
||||
$scope.model.images = Object.keys(images);
|
||||
|
||||
DeviceTypes.update({id: $scope.model._id}, $scope.model, function(result) {
|
||||
$location.path("/deviceTypes/");
|
||||
$scope.$watch('categoryPicker', function () {
|
||||
if ($scope.categoryPicker) {
|
||||
$scope.model.category = $scope.categoryPicker.id;
|
||||
} else {
|
||||
$scope.model.category = null;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function() {
|
||||
$scope.model.images = Object.keys(images);
|
||||
$scope.model.deleted = true;
|
||||
|
||||
DeviceTypes.update({id: $scope.model._id}, $scope.model, function(result) {
|
||||
$location.path("/deviceTypes/");
|
||||
$scope.$watch('makePicker', function () {
|
||||
if ($scope.makePicker) {
|
||||
$scope.model.make = $scope.makePicker.id;
|
||||
} else {
|
||||
$scope.model.make = null;
|
||||
}
|
||||
});
|
||||
};
|
||||
})
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.model.images = Object.keys(images);
|
||||
|
||||
DeviceTypes.create($scope.model, function (result) {
|
||||
$location.path("/deviceTypes/");
|
||||
});
|
||||
};
|
||||
})
|
||||
|
||||
.controller("DeviceTypeEditCtrl", function ($scope, DeviceTypes, Devices, CheckLists, $location, $filter, $routeParams) {
|
||||
var images = {};
|
||||
|
||||
$scope.checkLists = CheckLists.index(function () {
|
||||
$scope.model = DeviceTypes.get($routeParams, function () {
|
||||
$scope.loading = false;
|
||||
|
||||
$scope.existingImages = $scope.model.images;
|
||||
if ($scope.model.images) {
|
||||
for (var i = 0; i < $scope.model.images.length; i++) {
|
||||
images[$scope.model.images[i]] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.categoryPicker = {id: $scope.model.category, text: $scope.model.category};
|
||||
$scope.makePicker = {id: $scope.model.make, text: $scope.model.make};
|
||||
});
|
||||
});
|
||||
|
||||
console.log($routeParams);
|
||||
|
||||
$scope.devices = Devices.index({deviceType: $routeParams.id});
|
||||
|
||||
$scope.categories = DeviceTypes.categories();
|
||||
$scope.deviceMakes = DeviceTypes.makes();
|
||||
|
||||
|
||||
$scope.categoryOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Type',
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.categories, query.term);
|
||||
var results = [];
|
||||
data.forEach(function (item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results});
|
||||
},
|
||||
createSearchChoice: function (term) {
|
||||
return {id: term, text: term};
|
||||
}
|
||||
};
|
||||
|
||||
$scope.makeOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Make',
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.deviceMakes, query.term);
|
||||
var results = [];
|
||||
data.forEach(function (item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results});
|
||||
},
|
||||
createSearchChoice: function (term) {
|
||||
return {id: term, text: term};
|
||||
}
|
||||
};
|
||||
|
||||
$scope.imageOpts = {
|
||||
options: {
|
||||
url: '/api/deviceTypes/images',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function (file, response) {
|
||||
file.filename = response.filename;
|
||||
|
||||
if (images[file.filename]) {
|
||||
images[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
images[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function (file) {
|
||||
images[file.filename]--;
|
||||
|
||||
if (images[file.filename] <= 0) {
|
||||
delete images[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$watch('categoryPicker', function () {
|
||||
if ($scope.categoryPicker) {
|
||||
$scope.model.category = $scope.categoryPicker.id;
|
||||
} else {
|
||||
$scope.model.category = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('makePicker', function () {
|
||||
if ($scope.makePicker) {
|
||||
$scope.model.make = $scope.makePicker.id;
|
||||
} else {
|
||||
$scope.model.make = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.model.images = Object.keys(images);
|
||||
|
||||
DeviceTypes.update({id: $scope.model._id}, $scope.model, function (result) {
|
||||
$location.path("/deviceTypes/");
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.model.images = Object.keys(images);
|
||||
$scope.model.deleted = true;
|
||||
|
||||
DeviceTypes.update({id: $scope.model._id}, $scope.model, function (result) {
|
||||
$location.path("/deviceTypes/");
|
||||
});
|
||||
};
|
||||
})
|
||||
|
@ -1,14 +1,14 @@
|
||||
angular.module('biomed')
|
||||
.controller("DeviceAddCtrl", devicesControllerFactory(false))
|
||||
.controller("DeviceEditCtrl", devicesControllerFactory(true))
|
||||
.controller("DeviceAddCtrl", devicesControllerFactory(false))
|
||||
.controller("DeviceEditCtrl", devicesControllerFactory(true))
|
||||
|
||||
|
||||
function devicesControllerFactory(isEdit) {
|
||||
return function($scope, Devices, DeviceTypes, $location, $filter, $routeParams) {
|
||||
return function ($scope, Devices, DeviceTypes, $location, $filter, $routeParams) {
|
||||
function buildDeviceTypeFilterQuery(ignore) {
|
||||
var query = {};
|
||||
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
if (key == ignore)
|
||||
return;
|
||||
|
||||
@ -25,23 +25,23 @@ function devicesControllerFactory(isEdit) {
|
||||
|
||||
var data = {};
|
||||
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
var query = buildDeviceTypeFilterQuery(key);
|
||||
var filteredResults = $filter('filter')(deviceTypesList, query);
|
||||
|
||||
data[key] = [];
|
||||
|
||||
_.each(filteredResults, function(entry) {
|
||||
_.each(filteredResults, function (entry) {
|
||||
data[key].push(entry[key]);
|
||||
});
|
||||
});
|
||||
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
$scope.deviceTypes[key].data = _.uniq(data[key]);
|
||||
|
||||
if (data[key].length == 1) {
|
||||
var value = data[key][0];
|
||||
$scope.deviceTypes[key].picker = { id: value, text: value };
|
||||
$scope.deviceTypes[key].picker = {id: value, text: value};
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -53,33 +53,33 @@ function devicesControllerFactory(isEdit) {
|
||||
$scope.deviceTypes[key].opts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a ' + label,
|
||||
query: function(query) {
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.deviceTypes[key].data, query.term);
|
||||
query.callback({
|
||||
results: _.map(data, function(entry) {
|
||||
return { id: entry, text: entry }
|
||||
results: _.map(data, function (entry) {
|
||||
return {id: entry, text: entry}
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$watch('deviceTypes.' + key + '.picker',function() {
|
||||
$scope.$watch('deviceTypes.' + key + '.picker', function () {
|
||||
filterDeviceTypeSelectors();
|
||||
updateDeviceTypeSelection();
|
||||
}, true);
|
||||
}
|
||||
|
||||
function clearDeviceTypePickers() {
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
$scope.deviceTypes[key].picker = null;
|
||||
});
|
||||
}
|
||||
|
||||
function updateDeviceTypeSelection() {
|
||||
var query = buildDeviceTypeFilterQuery();
|
||||
var results = $filter('filter')(deviceTypesList, query);
|
||||
var query = buildDeviceTypeFilterQuery();
|
||||
var results = $filter('filter')(deviceTypesList, query);
|
||||
|
||||
$scope.model.deviceType = (results.length == 1) ? results[0]._id : null;
|
||||
$scope.model.deviceType = (results.length == 1) ? results[0]._id : null;
|
||||
}
|
||||
|
||||
function generateRandomIdentifier() {
|
||||
@ -93,27 +93,27 @@ function devicesControllerFactory(isEdit) {
|
||||
}
|
||||
|
||||
function create() {
|
||||
Devices.create($scope.model, function(result) {
|
||||
Devices.create($scope.model, function (result) {
|
||||
$location.path("/clients/" + result.client);
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function() {
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function () {
|
||||
$location.path("/clients/" + $scope.model.client);
|
||||
});
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
$scope.model.deleted = true;
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function() {
|
||||
$location.path("/clients/" + $scope.model.client);
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function () {
|
||||
$location.path("/clients/" + $scope.model.client);
|
||||
});
|
||||
}
|
||||
|
||||
function restore() {
|
||||
$scope.model.deleted = false;
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function() {
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function () {
|
||||
$location.path("/clients/" + $scope.model.client);
|
||||
});
|
||||
}
|
||||
@ -147,19 +147,19 @@ function devicesControllerFactory(isEdit) {
|
||||
console.log((isEdit ? "Edit" : "Create") + " Mode");
|
||||
|
||||
if (isEdit) {
|
||||
$scope.model = Devices.get($routeParams, function() {
|
||||
$scope.model = Devices.get($routeParams, function () {
|
||||
$scope.loading = false;
|
||||
|
||||
var deviceType = $scope.model.deviceType;
|
||||
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
$scope.deviceTypes[key].picker = { id: deviceType[key], text: deviceType[key] };
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
$scope.deviceTypes[key].picker = {id: deviceType[key], text: deviceType[key]};
|
||||
});
|
||||
|
||||
$scope.model.client = $scope.model.client._id;
|
||||
$scope.model.deviceType = $scope.model.deviceType._id;
|
||||
|
||||
$scope.testRuns = Devices.testRuns($routeParams, function() {
|
||||
$scope.testRuns = Devices.testRuns($routeParams, function () {
|
||||
console.log($scope.testRuns);
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
angular.module('biomed')
|
||||
.controller("TestRunAddCtrl", testRunAddController)
|
||||
.controller("TestRunViewCtrl", testRunViewController)
|
||||
.controller("TestRunAddCtrl", testRunAddController)
|
||||
.controller("TestRunViewCtrl", testRunViewController)
|
||||
|
||||
|
||||
function testRunAddController($scope, Devices, CheckLists, TestRuns, $location, $filter, $routeParams) {
|
||||
@ -8,10 +8,10 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location,
|
||||
|
||||
console.log(search);
|
||||
|
||||
$scope.device = Devices.get({id: search.deviceId}, function() {
|
||||
$scope.device = Devices.get({id: search.deviceId}, function () {
|
||||
console.log($scope.device);
|
||||
|
||||
$scope.checkList = CheckLists.get({id: $scope.device.deviceType.checkList}, function() {
|
||||
$scope.checkList = CheckLists.get({id: $scope.device.deviceType.checkList}, function () {
|
||||
$scope.loading = false;
|
||||
|
||||
$scope.model = {
|
||||
@ -20,7 +20,7 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location,
|
||||
fields: []
|
||||
};
|
||||
|
||||
_.each($scope.checkList.fields, function(field) {
|
||||
_.each($scope.checkList.fields, function (field) {
|
||||
|
||||
if (field.type == 'boolean') {
|
||||
field.value = 'false'
|
||||
@ -32,10 +32,10 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location,
|
||||
})
|
||||
});
|
||||
|
||||
$scope.$watch('model', function() {
|
||||
$scope.$watch('model', function () {
|
||||
$scope.model.result = true;
|
||||
|
||||
_.each($scope.model.fields, function(field) {
|
||||
_.each($scope.model.fields, function (field) {
|
||||
if (field.type == 'boolean') {
|
||||
field.result = (field.value == 'true');
|
||||
} else if (field.type == 'range') {
|
||||
@ -48,8 +48,8 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location,
|
||||
})
|
||||
}, true);
|
||||
|
||||
$scope.save = function() {
|
||||
TestRuns.create($scope.model, function(result) {
|
||||
$scope.save = function () {
|
||||
TestRuns.create($scope.model, function (result) {
|
||||
$location.path("/testRuns/" + result._id);
|
||||
});
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user