diff --git a/Gruntfile.js b/Gruntfile.js index 30f82ff..0732c09 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -18,6 +18,7 @@ var proxyConfig = { forward: { '/socket.io/*': serverEndpoint, '/socket.io': serverEndpoint, + '/cms-content': serverEndpoint, '/api': serverEndpoint } } diff --git a/app/scripts/config.coffee b/app/scripts/config.coffee index ba914fe..591f8a9 100644 --- a/app/scripts/config.coffee +++ b/app/scripts/config.coffee @@ -6,13 +6,19 @@ window.Config = sitecopy: "2014 " version: '0.1' email: "jonniespratley@me.com" + "staticDir": "www/cms-content" + "publicDir": "www" + "uploadsTmpDir": ".tmp" + "uploadsDestDir": "www/cms-content/uploads" + "uploadsUrl": ":8181/cms-content/" + "logFormat": "[:date] - [:method] - :url - :status - :response-time ms" debug: true #I hold the home page feature content - feature: + feature: title: 'angular-cms' body: 'A content management system of some sort.' - + features: [ id: 1 title: "HTML5" @@ -44,12 +50,12 @@ window.Config = body: "The database of choice is Mongo, its fast and scalable." image: "/images/feature-mongodb.png" ] - - session: + + session: authorized: false user: null - - layout: + + layout: header: "views/_header.html" sidebar: "views/_sidebar.html" content:"views/_content.html" @@ -125,13 +131,13 @@ window.Config = currentdate: new Date() dateformats: ["medium", "short", "fullDate", "longDate", "mediumDate", "shortDate"] timeformats: ["mediumTime", "shortTime"] - + #Default date format dateformat: "medium" - + #Default time format timeformat: "shortTime" - + #Default timezone timezone: null servers: [ @@ -145,26 +151,26 @@ window.Config = port: 3000 body: "This is the v2 api server" ] - + #SocketIO configuration socketio: host: "127.1.0.1" port: 8081 - + #Network configuration network: online: true cache: true - + #Database configuration database: host: "127.1.0.1" port: 27017 name: "angular-cms" - + #API configuration. api: url: "" @@ -220,4 +226,4 @@ window.Config = user: username: '' password: '' - message: "Welcome {{user.username}}" \ No newline at end of file + message: "Welcome {{user.username}}" diff --git a/app/scripts/controllers/media.coffee b/app/scripts/controllers/media.coffee index 87e390d..ab53220 100644 --- a/app/scripts/controllers/media.coffee +++ b/app/scripts/controllers/media.coffee @@ -1,32 +1,13 @@ 'use strict' angular.module('angularCmsApp').controller 'MediaCtrl', ($scope, $http, DataService) -> - $scope.awesomeThings = ['HTML5 Boilerplate', 'AngularJS','Karma'] + $scope.awesomeThings = ['HTML5 Boilerplate', 'AngularJS', 'Karma'] $scope.uploads = [] $scope.getUploads = () -> DataService.fetch('uploads').then((res)-> $scope.uploads = res.data ) - - $ -> - $("#fileupload").fileupload( - dataType: 'json' - dropZone: $('.dropzone') - add: (e, data) -> - console.log(e, data) - - data.url = '/api/upload' - data.context = $('

').text('Uploading...').appendTo(document.body) - data.submit() - progressall: (e, data) -> - progress = parseInt(data.loaded / data.total * 100, 10) - $("#progress .bar").css "width", progress + "%" - done: (e, data) -> - $.each data.result.files, (index, file) -> - $("

").text(file.name).appendTo document.body - ) - $scope.uploader = { files: [] }; - + $scope.getUploads() diff --git a/app/scripts/directives/cmsuploader.coffee b/app/scripts/directives/cmsuploader.coffee index 1584a78..ab19a4a 100644 --- a/app/scripts/directives/cmsuploader.coffee +++ b/app/scripts/directives/cmsuploader.coffee @@ -53,9 +53,28 @@ angular.module('angularCmsApp').directive 'cmsUploader', -> form.append('files[]', file) xhr = new XMLHttpRequest() + + # progress on transfers from the server to the client (downloads) + updateProgress = (oEvent) -> + console.log(oEvent.loaded, oEvent.total) + if oEvent.lengthComputable + percentComplete = oEvent.loaded / oEvent.total + console.log(percentComplete) + else + console.log(event) + # Unable to compute progress information since the total size is unknown + transferComplete = (evt) -> + console.warn "The transfer is complete." + transferFailed = (evt) -> + console.error "An error occurred while transferring the file." + transferCanceled = (evt) -> + console.warn "The transfer has been canceled by the user." + xhr.addEventListener "progress", updateProgress, false + xhr.addEventListener "load", transferComplete, false + xhr.addEventListener "error", transferFailed, false + xhr.addEventListener "abort", transferCanceled, false xhr.onload = () -> console.log('Upload complete') - xhr.open('POST', $attrs.action, true) xhr.send(form) @@ -68,4 +87,4 @@ angular.module('angularCmsApp').directive 'cmsUploader', -> #Initialize Uploader - new Uploader() \ No newline at end of file + new Uploader() diff --git a/app/styles/main.css b/app/styles/main.css index 68e1fc2..822a593 100755 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -8,6 +8,27 @@ height: 20px; } +.uploads img{ + +} +.thumbnail a{ + cursor: pointer; +} +.thumbnail:hover{ + opacity: 1; +} +.thumbnail img{ + width: 100%; +} +.thumbnail { + margin: 5px; + padding: 2px; + cursor: pointer; + opacity: .9; + height: 100px; + overflow: hidden; +} + html { overflow-y: scroll; } diff --git a/app/views/media.html b/app/views/media.html index 46cdee4..f9f0373 100755 --- a/app/views/media.html +++ b/app/views/media.html @@ -13,20 +13,75 @@

Media

btncrop="Crop" cropper="true" collection="imageCollection" showthumbs="true" litmpl="#liTmpl" showtable="true" showlist="true" filelimit="10" sizelimit="5000" action="/api/v2/upload"> - Media -