Adds ability to store documents
@@ -24,7 +24,7 @@ this["JST"]["assets/templates/docs.html"] = function(obj) {
|
||||
obj || (obj = {});
|
||||
var __t, __p = '', __e = _.escape;
|
||||
with (obj) {
|
||||
__p += '<form action="http://localhost:3000/doc/upload" enctype="multipart/form-data" method="post">\n <input type="text" name="title"><br>\n <input type="file" name="document" multiple="multiple"><br>\n <input type="submit" value="Upload">\n</form>\n';
|
||||
__p += '<div class="container">\n <div class="row">\n <div ng-repeat="doc in docs" class="col-md-3 well">\n <h2><a href="{{doc.location}}">{{doc.name}}</a></h2>\n <img ng-if="doc.img_url" class="img img-responsive" src="{{doc.img_url}}">\n <img ng-if="!doc.img_url" class="img img-responsive" src="/images/icons/_blank.png">\n </div>\n </div>\n\n\n <div class="row">\n <div clas="col-md-6 col-md-offset-3 well">\n <form action="http://localhost:3000/doc/upload" enctype="multipart/form-data" method="post">\n <input type="text" name="title"><br>\n <input type="file" name="document" multiple="multiple"><br>\n <input type="submit" value="Upload">\n </form>\n </div>\n </div>\n</div>\n';
|
||||
|
||||
}
|
||||
return __p
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
module.exports = {
|
||||
|
||||
upload: function (req, res) {
|
||||
console.log(require('path').resolve(sails.config.appPath, './assets/filestorage'));
|
||||
console.log(require('path').resolve(sails.config.appPath));
|
||||
req.file('document').upload({
|
||||
dirname: require('path').resolve(sails.config.appPath, './assets/filestorage')
|
||||
}, function (err, files) {
|
||||
if (err) return res.serverError(err);
|
||||
for (var i = 0; i < files.length; i ++){
|
||||
Doc.create({
|
||||
name: files[i].name,
|
||||
location: files[i].fd,
|
||||
name: files[i].filename,
|
||||
location: files[i].fd.split("assets/")[1],
|
||||
visible: true
|
||||
}).exec(function(err, created){
|
||||
if (err) console.log(err);
|
||||
@@ -29,5 +29,4 @@ module.exports = {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BIN
www/assets/images/icons/_blank.png
Executable file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
www/assets/images/icons/_page.png
Executable file
|
After Width: | Height: | Size: 16 KiB |
BIN
www/assets/images/icons/aac.png
Executable file
|
After Width: | Height: | Size: 24 KiB |
BIN
www/assets/images/icons/ai.png
Executable file
|
After Width: | Height: | Size: 20 KiB |
BIN
www/assets/images/icons/aiff.png
Executable file
|
After Width: | Height: | Size: 21 KiB |
BIN
www/assets/images/icons/avi.png
Executable file
|
After Width: | Height: | Size: 36 KiB |
BIN
www/assets/images/icons/bmp.png
Executable file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/assets/images/icons/c.png
Executable file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
www/assets/images/icons/cpp.png
Executable file
|
After Width: | Height: | Size: 7.8 KiB |
BIN
www/assets/images/icons/css.png
Executable file
|
After Width: | Height: | Size: 32 KiB |
BIN
www/assets/images/icons/dat.png
Executable file
|
After Width: | Height: | Size: 16 KiB |
BIN
www/assets/images/icons/dmg.png
Executable file
|
After Width: | Height: | Size: 14 KiB |
BIN
www/assets/images/icons/doc.png
Executable file
|
After Width: | Height: | Size: 20 KiB |
BIN
www/assets/images/icons/dotx.png
Executable file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/assets/images/icons/dwg.png
Executable file
|
After Width: | Height: | Size: 21 KiB |
BIN
www/assets/images/icons/dxf.png
Executable file
|
After Width: | Height: | Size: 24 KiB |
BIN
www/assets/images/icons/eps.png
Executable file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/assets/images/icons/exe.png
Executable file
|
After Width: | Height: | Size: 17 KiB |
BIN
www/assets/images/icons/flv.png
Executable file
|
After Width: | Height: | Size: 21 KiB |
BIN
www/assets/images/icons/gif.png
Executable file
|
After Width: | Height: | Size: 17 KiB |
BIN
www/assets/images/icons/h.png
Executable file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
www/assets/images/icons/hpp.png
Executable file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
www/assets/images/icons/html.png
Executable file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
www/assets/images/icons/ics.png
Executable file
|
After Width: | Height: | Size: 22 KiB |
BIN
www/assets/images/icons/iso.png
Executable file
|
After Width: | Height: | Size: 20 KiB |
BIN
www/assets/images/icons/java.png
Executable file
|
After Width: | Height: | Size: 17 KiB |
BIN
www/assets/images/icons/jpg.png
Executable file
|
After Width: | Height: | Size: 18 KiB |
BIN
www/assets/images/icons/js.png
Executable file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/assets/images/icons/key.png
Executable file
|
After Width: | Height: | Size: 14 KiB |
BIN
www/assets/images/icons/less.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
www/assets/images/icons/mid.png
Executable file
|
After Width: | Height: | Size: 24 KiB |
BIN
www/assets/images/icons/mp3.png
Executable file
|
After Width: | Height: | Size: 26 KiB |
BIN
www/assets/images/icons/mp4.png
Executable file
|
After Width: | Height: | Size: 22 KiB |
BIN
www/assets/images/icons/mpg.png
Executable file
|
After Width: | Height: | Size: 41 KiB |
BIN
www/assets/images/icons/odf.png
Executable file
|
After Width: | Height: | Size: 11 KiB |
BIN
www/assets/images/icons/ods.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
www/assets/images/icons/odt.png
Executable file
|
After Width: | Height: | Size: 14 KiB |
BIN
www/assets/images/icons/otp.png
Executable file
|
After Width: | Height: | Size: 11 KiB |
BIN
www/assets/images/icons/ots.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
www/assets/images/icons/ott.png
Executable file
|
After Width: | Height: | Size: 12 KiB |
BIN
www/assets/images/icons/pdf.png
Executable file
|
After Width: | Height: | Size: 16 KiB |
BIN
www/assets/images/icons/php.png
Executable file
|
After Width: | Height: | Size: 10 KiB |
BIN
www/assets/images/icons/png.png
Executable file
|
After Width: | Height: | Size: 19 KiB |
BIN
www/assets/images/icons/ppt.png
Executable file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
www/assets/images/icons/psd.png
Executable file
|
After Width: | Height: | Size: 21 KiB |
BIN
www/assets/images/icons/py.png
Executable file
|
After Width: | Height: | Size: 14 KiB |
BIN
www/assets/images/icons/qt.png
Executable file
|
After Width: | Height: | Size: 22 KiB |
BIN
www/assets/images/icons/rar.png
Executable file
|
After Width: | Height: | Size: 17 KiB |
BIN
www/assets/images/icons/rb.png
Executable file
|
After Width: | Height: | Size: 14 KiB |
BIN
www/assets/images/icons/rtf.png
Executable file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
www/assets/images/icons/sass.png
Executable file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/assets/images/icons/scss.png
Executable file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/assets/images/icons/sql.png
Executable file
|
After Width: | Height: | Size: 19 KiB |
BIN
www/assets/images/icons/tga.png
Executable file
|
After Width: | Height: | Size: 16 KiB |
BIN
www/assets/images/icons/tgz.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
www/assets/images/icons/tiff.png
Executable file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/assets/images/icons/txt.png
Executable file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
www/assets/images/icons/wav.png
Executable file
|
After Width: | Height: | Size: 27 KiB |
BIN
www/assets/images/icons/xls.png
Executable file
|
After Width: | Height: | Size: 16 KiB |
BIN
www/assets/images/icons/xlsx.png
Executable file
|
After Width: | Height: | Size: 16 KiB |
BIN
www/assets/images/icons/xml.png
Executable file
|
After Width: | Height: | Size: 12 KiB |
BIN
www/assets/images/icons/yml.png
Executable file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
www/assets/images/icons/zip.png
Executable file
|
After Width: | Height: | Size: 23 KiB |
@@ -1,6 +1,27 @@
|
||||
poconsole.controller('docsCtrl', function($scope, $route, Page, $log) {
|
||||
poconsole.controller('docsCtrl', function($scope, $route, Page, $log, docs) {
|
||||
Page.setTitle('Documents');
|
||||
Page.setPage('docs');
|
||||
|
||||
var file_types = ["_blank", "c", "dwg", "hpp", "key", "ods", "png", "rtf", "txt", "_page", "cpp", "dxf", "html", "less", "odt", "ppt", "sass", "wav", "aac", "css", "eps", "ics", "mid", "otp", "psd", "scss", "xls", "ai", "dat", "exe", "iso", "mp3", "ots", "py", "sql", "xlsx", "aiff", "dmg", "flv", "java", "mp4", "ott", "qt", "tga", "xml", "avi", "doc", "gif", "jpg", "mpg", "pdf", "rar", "tgz", "yml", "bmp", "dotx", "h", "js", "odf", "php", "rb", "tiff", "zip" ];
|
||||
|
||||
$scope.loadDocs = function(){
|
||||
var loadDocs = docs.getAllDocs();
|
||||
loadDocs.then(function(d){
|
||||
var imageBase = "/images/icons/";
|
||||
var imageExtension = ".png";
|
||||
$scope.docs = d.docs.map(function(doc){
|
||||
var spl = doc.location.split(".");
|
||||
var ext = spl[spl.length - 1];
|
||||
if(file_types.indexOf(ext) > -1){
|
||||
doc.img_url = imageBase + ext + imageExtension;
|
||||
} else {
|
||||
doc.img_url = false;
|
||||
}
|
||||
return doc;
|
||||
});
|
||||
});
|
||||
};
|
||||
$scope.loadDocs();
|
||||
|
||||
|
||||
});
|
||||
|
||||
29
www/assets/js/ng/factory_docs.js
Normal file
@@ -0,0 +1,29 @@
|
||||
poconsole.factory('docs',function($q, $http, $log){
|
||||
|
||||
var getAllDocs = function(){
|
||||
var deferred = $q.defer();
|
||||
$http.get('/doc').success(function(data) {
|
||||
deferred.resolve({
|
||||
docs:data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getDoc = function(id){
|
||||
var deferred = $q.defer();
|
||||
$http.get('/doc/' + id).success(function(data) {
|
||||
deferred.resolve({
|
||||
docs:data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
getAllDocs:getAllDocs,
|
||||
getDoc: getDoc
|
||||
};
|
||||
|
||||
});
|
||||
@@ -1,5 +1,20 @@
|
||||
<form action="http://localhost:3000/doc/upload" enctype="multipart/form-data" method="post">
|
||||
<input type="text" name="title"><br>
|
||||
<input type="file" name="document" multiple="multiple"><br>
|
||||
<input type="submit" value="Upload">
|
||||
</form>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div ng-repeat="doc in docs" class="col-md-3 well">
|
||||
<h2><a href="{{doc.location}}">{{doc.name}}</a></h2>
|
||||
<img ng-if="doc.img_url" class="img img-responsive" src="{{doc.img_url}}">
|
||||
<img ng-if="!doc.img_url" class="img img-responsive" src="/images/icons/_blank.png">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div clas="col-md-6 col-md-offset-3 well">
|
||||
<form action="http://localhost:3000/doc/upload" enctype="multipart/form-data" method="post">
|
||||
<input type="text" name="title"><br>
|
||||
<input type="file" name="document" multiple="multiple"><br>
|
||||
<input type="submit" value="Upload">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="data_source">Data Source</label>
|
||||
<select ng-model="newTag.deviceID" ng-options="d as d.address for d in devices track by d.id" class="form-control" id="data_source"></select>
|
||||
<select ng-model="newTag.deviceID" ng-options="d as device_label(d) for d in devices track by d.id" class="form-control" id="data_source"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="tag">Tag</label>
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
<script src="/js/ng/factory_dateConversion.js"></script>
|
||||
<script src="/js/ng/factory_config.js"></script>
|
||||
<script src="/js/ng/factory_devices.js"></script>
|
||||
<script src="/js/ng/factory_docs.js"></script>
|
||||
<script src="/js/ng/factory_page.js"></script>
|
||||
<script src="/js/ng/factory_tags.js"></script>
|
||||
<script src="/js/ng/controller_config.js"></script>
|
||||
|
||||