Skip to content

Commit

Permalink
fix grunt generates invalid minified css and js
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Prudencio authored and ymarcon committed Apr 24, 2015
1 parent 5174d67 commit 4f89f8e
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 151 deletions.
83 changes: 43 additions & 40 deletions mica-webapp/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ module.exports = function (grunt) {
}
},
autoprefixer: {
options: ['last 1 version'],
dist: {
files: [
{
Expand Down Expand Up @@ -180,11 +179,10 @@ module.exports = function (grunt) {
]
}
},
// not used since Uglify task does concat,
// but still available if needed
/*concat: {
dist: {}
},*/
// generated dynamically by useminPrepare
//concat: {
// dist: {}
//},
rev: {
dist: {
files: {
Expand All @@ -200,7 +198,16 @@ module.exports = function (grunt) {
useminPrepare: {
html: 'src/main/webapp/{,*/}*.html',
options: {
dest: '<%= yeoman.dist %>'
dest: '<%= yeoman.dist %>',
flow: {
html: {
steps: {
css: ['concat', 'cssmin'],
js: ['concat', 'uglifyjs']
},
post: {}
}
}
}
},
usemin: {
Expand Down Expand Up @@ -234,19 +241,20 @@ module.exports = function (grunt) {
]
}
},
cssmin: {
// By default, your `index.html` <!-- Usemin Block --> will take care of
// minification. This option is pre-configured if you do not wish to use
// Usemin blocks.
// dist: {
// files: {
// '<%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css',
// 'styles/{,*/}*.css'
// ]
// }
// }
},
// generated dynamically by useminPrepare
//cssmin: {
// // By default, your `index.html` <!-- Usemin Block --> will take care of
// // minification. This option is pre-configured if you do not wish to use
// // Usemin blocks.
// dist: {
// files: {
// '<%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css',
// 'styles/{,*/}*.css'
// ]
// }
// }
//},
htmlmin: {
dist: {
options: {
Expand Down Expand Up @@ -328,18 +336,6 @@ module.exports = function (grunt) {
html: ['<%= yeoman.dist %>/*.html']
}
},
ngmin: {
dist: {
files: [
{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}
]
}
},
replace: {
dist: {
src: ['<%= yeoman.dist %>/index.html'],
Expand All @@ -352,15 +348,21 @@ module.exports = function (grunt) {
]
}
},
uglify: {
dist: {
files: {
'<%= yeoman.dist %>/app/scripts.js': [
'<%= yeoman.dist %>/app/scripts.js'
]
}
wiredep: {
task: {
src: 'src/main/webapp/index.html'
}
}
// generated dynamically by useminPrepare
//uglify: {
// dist: {
// files: {
// '<%= yeoman.dist %>/scripts/scripts.js': [
// '<%= yeoman.dist %>/scripts/scripts.js'
// ]
// }
// }
//}
});

grunt.registerTask('server', function (target) {
Expand Down Expand Up @@ -396,7 +398,6 @@ module.exports = function (grunt) {
'autoprefixer',
'concat',
'copy:dist',
'ngmin',
'cssmin',
'replace',
'uglify',
Expand All @@ -408,4 +409,6 @@ module.exports = function (grunt) {
'test',
'build'
]);

grunt.loadNpmTasks('grunt-wiredep');
};
26 changes: 25 additions & 1 deletion mica-webapp/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,34 @@
"ng-obiba": "git@github.com:obiba/ng-obiba.git",
"modernizr": "2.7.1",
"swagger-ui": "2.0.16",
"filesize": "~2.0.3"
"filesize": "~2.0.3",
"angular-utils-pagination": "~0.6.0"
},
"devDependencies": {
"angular-mocks": "1.2.16",
"angular-scenario": "1.2.16"
},
"overrides": {
"angular-ui": {
"main": "./build/angular-ui.min.js"
},
"filesize": {
"main": "./lib/filesize.min.js"
},
"angular-dynamic-locale": {
"main": "./src/tmhDinamicLocale.js"
},
"bootstrap": {
"main": "./dist/js/bootstrap.min.js"
},
"chosen": {
"main": "./chosen.jquery.js"
},
"ng-obiba": {
"main": "./dist/ng-obiba.js"
},
"ng-file-upload": {
"main": ["angular-file-upload.js", "angular-file-upload-shim.min.js"]
}
}
}
1 change: 1 addition & 0 deletions mica-webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"grunt-contrib-less": "^0.11.0",
"grunt-contrib-uglify": "0.4.0",
"grunt-contrib-watch": "0.6.1",
"grunt-wiredep": "^2.0.0",
"grunt-karma": "0.8.3",
"grunt-modernizr": "0.5.2",
"grunt-ngmin": "0.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

mica.attachment

.directive('attachmentInput', ['$upload', '$timeout', '$log', 'TempFileResource',
function ($upload, $timeout, $log, TempFileResource) {
.directive('attachmentInput', [function () {
return {
restrict: 'E',
require: '^form',
Expand All @@ -13,80 +12,83 @@ mica.attachment
files: '='
},
templateUrl: 'app/commons/attachment/attachment-input-template.html',
controller: function ($scope) {
$scope.onFileSelect = function ($file) {
$scope.uploadedFiles = $file;
$scope.uploadedFiles.forEach(function (file) {
uploadFile(file);
});
};
controller: 'AttachmentCtrl'
};
}])
.controller('AttachmentCtrl', ['$scope', '$timeout', '$log', '$upload', 'TempFileResource',
function ($scope, $timeout, $log, $upload, TempFileResource) {
$scope.onFileSelect = function (file) {
$scope.uploadedFiles = file;
$scope.uploadedFiles.forEach(function (f) {
uploadFile(f);
});
};

var uploadFile = function (file) {
$log.debug('file', file);
var uploadFile = function (file) {
$log.debug('file', file);

var attachment = {
showProgressBar: true,
lang: 'en',
progress: 0,
file: file,
fileName: file.name,
size: file.size
};
var attachment = {
showProgressBar: true,
lang: 'en',
progress: 0,
file: file,
fileName: file.name,
size: file.size
};

if($scope.multiple) {
$scope.files.push(attachment);
} else {
$scope.files.splice(0, $scope.files.length);
$scope.files.push(attachment);
}
if ($scope.multiple) {
$scope.files.push(attachment);
} else {
$scope.files.splice(0, $scope.files.length);
$scope.files.push(attachment);
}

$scope.upload = $upload
.upload({
url: '/ws/files/temp',
method: 'POST',
file: file
})
.progress(function (evt) {
attachment.progress = parseInt(100.0 * evt.loaded / evt.total);
})
.success(function (data, status, getResponseHeaders) {
var parts = getResponseHeaders().location.split('/');
var fileId = parts[parts.length - 1];
TempFileResource.get(
{id: fileId},
function (tempFile) {
$log.debug('tempFile', tempFile);
attachment.id = tempFile.id;
attachment.md5 = tempFile.md5;
attachment.justUploaded = true;
// wait for 1 second before hiding progress bar
$timeout(function () { attachment.showProgressBar = false; }, 1000);
}
);
});
};
$scope.upload = $upload
.upload({
url: '/ws/files/temp',
method: 'POST',
file: file
})
.progress(function (evt) {
attachment.progress = parseInt(100.0 * evt.loaded / evt.total);
})
.success(function (data, status, getResponseHeaders) {
var parts = getResponseHeaders().location.split('/');
var fileId = parts[parts.length - 1];
TempFileResource.get(
{id: fileId},
function (tempFile) {
$log.debug('tempFile', tempFile);
attachment.id = tempFile.id;
attachment.md5 = tempFile.md5;
attachment.justUploaded = true;
// wait for 1 second before hiding progress bar
$timeout(function () { attachment.showProgressBar = false; }, 1000);
}
);
});
};

$scope.deleteTempFile = function (tempFileId) {
TempFileResource.delete(
{id: tempFileId},
function () {
for (var i = $scope.files.length; i--;) {
var attachment = $scope.files[i];
if (attachment.justUploaded && attachment.id === tempFileId) {
$scope.files.splice(i, 1);
}
$scope.deleteTempFile = function (tempFileId) {
TempFileResource.delete(
{id: tempFileId},
function () {
for (var i = $scope.files.length; i--;) {
var attachment = $scope.files[i];
if (attachment.justUploaded && attachment.id === tempFileId) {
$scope.files.splice(i, 1);
}
}
);
};
}
);
};

$scope.deleteFile = function (fileId) {
for(var i = $scope.files.length; i--;) {
if($scope.files[i].id === fileId) {
$scope.files.splice(i, 1);
}
$scope.deleteFile = function (fileId) {
for (var i = $scope.files.length; i--;) {
if ($scope.files[i].id === fileId) {
$scope.files.splice(i, 1);
}
};
}
};
}]);
}
};
}
]);
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

mica.attachment = angular.module('mica.attachment', [
'mica.config'
'mica.file',
'ui',
'ui.bootstrap',
'angularFileUpload'
]);
1 change: 0 additions & 1 deletion mica-webapp/src/main/webapp/app/file/file.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

mica.file = angular.module('mica.file', [
'angularFileUpload',
'ngResource'
]);
4 changes: 2 additions & 2 deletions mica-webapp/src/main/webapp/app/study/study-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,9 @@ mica.study

}])

.controller('StudyEditController', ['$rootScope', '$scope', '$routeParams', '$log', '$location', '$upload', '$timeout', '$modal', 'DraftStudyResource', 'DraftStudiesResource', 'MicaConfigResource', 'StringUtils', 'FormServerValidation',
.controller('StudyEditController', ['$rootScope', '$scope', '$routeParams', '$log', '$location', '$modal', 'DraftStudyResource', 'DraftStudiesResource', 'MicaConfigResource', 'StringUtils', 'FormServerValidation',

function ($rootScope, $scope, $routeParams, $log, $location, $upload, $timeout, $modal, DraftStudyResource, DraftStudiesResource, MicaConfigResource, StringUtils, FormServerValidation) {
function ($rootScope, $scope, $routeParams, $log, $location, $modal, DraftStudyResource, DraftStudiesResource, MicaConfigResource, StringUtils, FormServerValidation) {
$scope.fileTypes = '.doc, .docx, .odm, .odt, .gdoc, .pdf, .txt .xml .xls, .xlsx, .ppt';
$scope.accessTypes = ['data', 'bio_samples', 'other'];
$scope.methodDesignTypes = ['case_control', 'case_only', 'clinical_trial', 'cohort_study', 'cross_sectional', 'other'];
Expand Down
4 changes: 2 additions & 2 deletions mica-webapp/src/main/webapp/app/study/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ mica.study = angular.module('mica.study', [
'mica.config',
'obiba.form',
'mica.localized',
'mica.file',
'mica.attributes',
'obiba.notification',
'mica.publish',
Expand All @@ -13,5 +12,6 @@ mica.study = angular.module('mica.study', [
'ngRoute',
'ui.bootstrap',
'ui',
'pascalprecht.translate'
'pascalprecht.translate',
'mica.attachment'
]);
Loading

0 comments on commit 4f89f8e

Please sign in to comment.