mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
latest changes
This commit is contained in:
@ -73,6 +73,18 @@ angular.module('biomed', ['biomed.filters', 'biomed.services', 'biomed.directive
|
||||
templateUrl: '/partials/techs/schedule.html',
|
||||
controller: biomed.TechScheduleCtrl
|
||||
})
|
||||
.when('/posts', {
|
||||
templateUrl: '/partials/posts/index.html',
|
||||
controller: biomed.PostIndexCtrl
|
||||
})
|
||||
.when('/posts/add', {
|
||||
templateUrl: '/partials/posts/add.html',
|
||||
controller: biomed.PostAddCtrl
|
||||
})
|
||||
.when('/posts/:id', {
|
||||
templateUrl: '/partials/posts/edit.html',
|
||||
controller: biomed.PostEditCtrl
|
||||
})
|
||||
.when('/admin', {
|
||||
templateUrl: '/partials/users/index.html',
|
||||
controller: biomed.UsersIndexCtrl,
|
||||
|
@ -174,13 +174,206 @@ biomed.UsersIndexCtrl = function($scope, $filter, $routeParams, $location, Users
|
||||
|
||||
biomed.UserClockCtrl = function($scope, $routeParams, Users) {
|
||||
Users.index({userid: $routeParams.id}, function(result) {
|
||||
console.log(result);
|
||||
$scope.tech = result[0];
|
||||
});
|
||||
|
||||
$scope.clocks = Users.clocks($routeParams);
|
||||
};
|
||||
|
||||
biomed.PostIndexCtrl = function($scope, $routeParams, Posts, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
|
||||
$scope.posts = Posts.index(function() {
|
||||
$scope.loading = false;
|
||||
});
|
||||
};
|
||||
|
||||
biomed.PostAddCtrl = function($scope, Posts, $location) {
|
||||
|
||||
$scope.model = {
|
||||
gallery: []
|
||||
};
|
||||
|
||||
$scope.titleImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
maxFiles: 1,
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('adding file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = response.filename;
|
||||
});
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('removing file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = undefined;
|
||||
});
|
||||
},
|
||||
maxfilesexceeded: function(file) {
|
||||
this.removeAllFiles();
|
||||
this.addFile(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var galleryImages = {};
|
||||
|
||||
$scope.galleryImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('Adding File');
|
||||
file.filename = response.filename;
|
||||
|
||||
if (galleryImages[file.filename]) {
|
||||
galleryImages[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
galleryImages[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('Removing File');
|
||||
galleryImages[file.filename]--;
|
||||
|
||||
if (galleryImages[file.filename] <= 0) {
|
||||
delete galleryImages[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var save = function(status) {
|
||||
$scope.model.gallery = Object.keys(galleryImages);
|
||||
$scope.model.status = status;
|
||||
$scope.model.createdOn = new Date();
|
||||
|
||||
if (status === 'posted') {
|
||||
$scope.model.postedOn = new Date();
|
||||
}
|
||||
|
||||
Posts.create($scope.model, function(result) {
|
||||
$location.path("/posts/" + result._id);
|
||||
});
|
||||
}
|
||||
|
||||
$scope.saveAsDraft = function() {
|
||||
save('draft');
|
||||
};
|
||||
|
||||
$scope.saveAsPosted = function() {
|
||||
save('posted');
|
||||
};
|
||||
};
|
||||
|
||||
biomed.PostEditCtrl = function($scope, Posts, $routeParams, $location) {
|
||||
var galleryImages = {};
|
||||
|
||||
$scope.model = Posts.get($routeParams, function() {
|
||||
$scope.loading = false;
|
||||
|
||||
if ($scope.model.image) {
|
||||
$scope.existingTitleImages = [$scope.model.image];
|
||||
}
|
||||
|
||||
$scope.existingGalleryImages = $scope.model.gallery;
|
||||
for (var i = 0; i < $scope.model.gallery.length; i++) {
|
||||
galleryImages[$scope.model.gallery[i]] = 1;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.titleImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
maxFiles: 1,
|
||||
addRemoveLinks: true,
|
||||
existing: []
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('adding file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = response.filename;
|
||||
});
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('removing file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = undefined;
|
||||
});
|
||||
},
|
||||
maxfilesexceeded: function(file) {
|
||||
this.removeAllFiles();
|
||||
this.addFile(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.galleryImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
addRemoveLinks: true,
|
||||
existing: []
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('Adding File');
|
||||
file.filename = response.filename;
|
||||
|
||||
if (galleryImages[file.filename]) {
|
||||
galleryImages[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
galleryImages[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('Removing File');
|
||||
galleryImages[file.filename]--;
|
||||
|
||||
if (galleryImages[file.filename] <= 0) {
|
||||
delete galleryImages[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var save = function(status) {
|
||||
$scope.model.gallery = Object.keys(galleryImages);
|
||||
$scope.model.status = status;
|
||||
|
||||
if (status === 'posted') {
|
||||
$scope.model.postedOn = new Date();
|
||||
} else {
|
||||
$scope.model.postedOn = null;
|
||||
}
|
||||
|
||||
Posts.update({id: $scope.model._id}, $scope.model, function(result) {
|
||||
$location.path("/posts/");
|
||||
});
|
||||
}
|
||||
|
||||
$scope.saveAsDraft = function() {
|
||||
save('draft');
|
||||
};
|
||||
|
||||
$scope.saveAsPosted = function() {
|
||||
save('posted');
|
||||
};
|
||||
|
||||
$scope.saveAsArchived = function() {
|
||||
save('archived');
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
biomed.ClientIndexCtrl = function($scope, $filter, $routeParams, Clients, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
|
||||
@ -347,7 +540,7 @@ biomed.ClientEditCtrl = function($scope, $routeParams, Clients) {
|
||||
}
|
||||
|
||||
$scope.toggleFrequency = function(frequency, month) {
|
||||
if (accountHasPermission('system.edit')) {
|
||||
if ($scope.accountHasPermission('system.edit')) {
|
||||
$scope.master.frequencies[frequency][month] =! $scope.master.frequencies[frequency][month];
|
||||
Clients.update({id: $scope.master._id}, $scope.master, function() {
|
||||
updatePms();
|
||||
@ -822,7 +1015,6 @@ biomed.PageCtrl = function($scope, $dialog, Account) {
|
||||
};
|
||||
|
||||
$scope.accountHasPermission = function(perm) {
|
||||
console.log($scope);
|
||||
if ($scope.account && $scope.account.perms) {
|
||||
return $scope.account.perms.indexOf(perm) > -1;
|
||||
}
|
||||
|
@ -787,4 +787,36 @@ angular.module('biomed.directives', [])
|
||||
};
|
||||
}
|
||||
};
|
||||
})
|
||||
.directive('dropzone', function() {
|
||||
return {
|
||||
scope: {
|
||||
dropzone: '=',
|
||||
existing: '='
|
||||
},
|
||||
controller: function($scope, $element, $attrs) {
|
||||
var config, dropzone;
|
||||
config = $scope.dropzone;
|
||||
|
||||
dropzone = new Dropzone($element[0], config.options);
|
||||
angular.forEach(config.eventHandlers, function (handler, event) {
|
||||
dropzone.on(event, handler);
|
||||
});
|
||||
|
||||
$scope.$watch('existing', function() {
|
||||
var existing = $scope.existing;
|
||||
|
||||
console.log(dropzone);
|
||||
|
||||
if (existing) {
|
||||
for (var i = 0; i < existing.length; i++) {
|
||||
var file = { name: existing[i], size: 0, accepted: true, filename: existing[i] };
|
||||
dropzone.options.addedfile.call(dropzone, file);
|
||||
dropzone.options.thumbnail.call(dropzone, file, "http://atlanticbiomedical.com/images/" + existing[i]);
|
||||
dropzone.files.push(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
1874
public/js/lib/dropzone.js
Normal file
1874
public/js/lib/dropzone.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,17 @@ angular.module('biomed.services', [])
|
||||
tags: { method: 'GET', params: { id: 0, cmd: 'tags' }, isArray: true }
|
||||
});
|
||||
})
|
||||
.factory("Posts", function($resource) {
|
||||
return $resource('/api/posts/:id',
|
||||
{ id: "@id" },
|
||||
{
|
||||
index: { method: 'GET', params: {}, isArray: true },
|
||||
get: { method: 'GET', params: { id: 0} },
|
||||
create: { method: 'POST', params: {} },
|
||||
update: { method: 'POST', params: { id: 0} },
|
||||
destroy: { method: 'DELETE', params: { id: 0 } },
|
||||
});
|
||||
})
|
||||
.factory("Workorders", function($resource) {
|
||||
return $resource('/api/workorders/:id',
|
||||
{ id: "@id" },
|
||||
|
Reference in New Issue
Block a user