standardized angularjs dependency ingention syntax to work with minification

This commit is contained in:
Jonathan Eads 2014-04-24 18:10:30 -07:00
Родитель 4f5735fde3
Коммит 3e9261092c
27 изменённых файлов: 218 добавлений и 100 удалений

Просмотреть файл

@ -4,13 +4,31 @@ module.exports = function(grunt) {
pkg: grunt.file.readJSON('package.json'),
clean: ['dist'],
useminPrepare:{
html:'webapp/app/index.html',
options:{
dest:'dist'
index: {
src:'webapp/app/index.html',
options:{
dest:'dist'
}
},
help: {
src:'webapp/app/help.html',
options:{
dest:'dist'
}
},
logviewer: {
src:'webapp/app/logviewer.html',
options:{
dest:'dist'
}
}
},
usemin:{ html:['dist/index.html'] },
usemin:{ html:['dist/index.html', 'dist/help.html', 'dist/logviewer.html'] },
copy:{
main: {
@ -31,23 +49,34 @@ module.exports = function(grunt) {
dest: 'dist/img/',
flatten: true
},
// Copy html in partials
partials:{
expand: true,
src: 'webapp/app/partials/*',
dest: 'dist/partials/',
flatten: true
},
// Copy fonts
fonts:{
expand: true,
src: 'webapp/app/fonts/*',
dest: 'dist/fonts/',
flatten: true
},
// Copy html in plugins, make sure not to flatten
// src: 'webapp/app/plugins/**/*.html',
plugins:{
expand: true,
cwd: 'webapp/app/plugins/',
src: '**/*.html',
dest: 'dist/plugins/',
flatten: false
}
},
uglify:{
options:{
report: 'min',
compress: true,
//compress: true,
// Cannot use mangle, it will break angularjs's dependency
// injection
mangle: false
@ -68,6 +97,7 @@ module.exports = function(grunt) {
'copy:img',
'copy:partials',
'copy:fonts',
'copy:plugins',
'useminPrepare',
'concat',
'cssmin',

Просмотреть файл

@ -14,7 +14,8 @@
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-cssmin": "^0.9.0",
"grunt-contrib-uglify": "^0.4.0"
"grunt-contrib-uglify": "^0.4.0",
"ngmin": "^0.5.0"
},
"scripts": {
"test": "./node_modules/.bin/karma start webapp/config/karma.conf.js --single-run --browsers Firefox"

Просмотреть файл

@ -2,8 +2,10 @@
<html>
<head>
<title>Treeherder Help</title>
<!-- build:css css/help.min.css -->
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/treeherder.css" rel="stylesheet" media="screen">
<!-- endbuild -->
</head>
<body class="container" id="help">
<div class="panel panel-default">

Просмотреть файл

@ -6,7 +6,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<!-- build:css css/style.min.css -->
<!-- build:css css/index.min.css -->
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/select2.css" rel="stylesheet" media="screen">
<link href="css/font-awesome.min.css" rel="stylesheet" media="screen">
@ -33,7 +33,7 @@
<th-notification-box></th-notification-box>
<!-- build:js js/treeherder.min.js -->
<!-- build:js js/index.min.js -->
<script src="vendor/jquery-2.0.3.js"></script>
<script src="vendor/angular/angular.js"></script>
<script src="vendor/angular/angular-route.js"></script>

Просмотреть файл

@ -1,9 +1,12 @@
"use strict";
treeherder.controller('FilterPanelCtrl',
function FilterPanelCtrl($scope, $rootScope, $routeParams, $location, ThLog,
localStorageService, thResultStatusList, thEvents,
thJobFilters) {
treeherder.controller('FilterPanelCtrl', [
'$scope', '$rootScope', '$routeParams', '$location', 'ThLog',
'localStorageService', 'thResultStatusList', 'thEvents', 'thJobFilters',
function FilterPanelCtrl(
$scope, $rootScope, $routeParams, $location, ThLog,
localStorageService, thResultStatusList, thEvents, thJobFilters) {
var $log = new ThLog(this.constructor.name);
$scope.filterOptions = thResultStatusList;
@ -218,9 +221,10 @@ treeherder.controller('FilterPanelCtrl',
}
};
}
);
]);
treeherder.controller('SearchCtrl',
treeherder.controller('SearchCtrl', [
'$scope', '$rootScope', 'thEvents',
function SearchCtrl($scope, $rootScope, thEvents){
$rootScope.searchQuery = "";
@ -240,4 +244,4 @@ treeherder.controller('SearchCtrl',
};
}
);
]);

Просмотреть файл

@ -1,9 +1,14 @@
"use strict";
treeherder.controller('JobsCtrl',
function JobsCtrl($scope, $http, $rootScope, $routeParams, ThLog, $cookies,
localStorageService, thUrl, ThRepositoryModel, thSocket,
ThResultSetModel, thResultStatusList, $location, thEvents) {
treeherder.controller('JobsCtrl', [
'$scope', '$http', '$rootScope', '$routeParams', 'ThLog', '$cookies',
'localStorageService', 'thUrl', 'ThRepositoryModel', 'thSocket',
'ThResultSetModel', 'thResultStatusList', '$location', 'thEvents',
function JobsCtrl(
$scope, $http, $rootScope, $routeParams, ThLog, $cookies,
localStorageService, thUrl, ThRepositoryModel, thSocket,
ThResultSetModel, thResultStatusList, $location, thEvents) {
var $log = new ThLog(this.constructor.name);
// load our initial set of resultsets
@ -60,13 +65,17 @@ treeherder.controller('JobsCtrl',
}
);
]);
treeherder.controller('ResultSetCtrl',
function ResultSetCtrl($scope, $rootScope, $http, ThLog, $location,
thUrl, thServiceDomain, thResultStatusInfo,
ThResultSetModel, thEvents, thJobFilters) {
treeherder.controller('ResultSetCtrl', [
'$scope', '$rootScope', '$http', 'ThLog', '$location', 'thUrl',
'thServiceDomain', 'thResultStatusInfo', 'ThResultSetModel', 'thEvents',
'thJobFilters',
function ResultSetCtrl(
$scope, $rootScope, $http, ThLog, $location,
thUrl, thServiceDomain, thResultStatusInfo,
ThResultSetModel, thEvents, thJobFilters) {
var $log = new ThLog(this.constructor.name);
@ -164,5 +173,5 @@ treeherder.controller('ResultSetCtrl',
//$scope.viewLog(job.resource_uri);
});
}
);
]);

Просмотреть файл

@ -1,7 +1,11 @@
'use strict';
logViewer.controller('LogviewerCtrl',
function Logviewer($anchorScroll, $scope, ThLog, $rootScope, $location, $http, $timeout, ThJobArtifactModel) {
logViewer.controller('LogviewerCtrl', [
'$anchorScroll', '$scope', 'ThLog', '$rootScope', '$location', '$http',
'$timeout', 'ThJobArtifactModel',
function Logviewer(
$anchorScroll, $scope, ThLog, $rootScope, $location, $http,
$timeout, ThJobArtifactModel) {
var $log = new ThLog("LogviewerCtrl");
@ -101,4 +105,4 @@ logViewer.controller('LogviewerCtrl',
});
};
}
);
]);

Просмотреть файл

@ -1,5 +1,6 @@
"use strict";
treeherder.controller('MachinesCtrl',
treeherder.controller('MachinesCtrl', [
'$scope',
function MachinesCtrl($scope){}
);
]);

Просмотреть файл

@ -1,9 +1,14 @@
"use strict";
treeherder.controller('MainCtrl',
function MainController($scope, $rootScope, $routeParams, $location, ThLog,
localStorageService, ThRepositoryModel, thPinboard,
thClassificationTypes, thEvents, $interval, ThExclusionProfileModel) {
treeherder.controller('MainCtrl', [
'$scope', '$rootScope', '$routeParams', '$location', 'ThLog',
'localStorageService', 'ThRepositoryModel', 'thPinboard',
'thClassificationTypes', 'thEvents', '$interval',
'ThExclusionProfileModel',
function MainController(
$scope, $rootScope, $routeParams, $location, ThLog,
localStorageService, ThRepositoryModel, thPinboard,
thClassificationTypes, thEvents, $interval, ThExclusionProfileModel) {
var $log = new ThLog("MainCtrl");
@ -160,4 +165,4 @@ treeherder.controller('MainCtrl',
}
}, null);
}
);
]);

Просмотреть файл

@ -1,8 +1,12 @@
"use strict";
treeherder.controller('RepositoryPanelCtrl',
function RepositoryPanelCtrl($scope, $rootScope, $routeParams, $location, ThLog,
localStorageService, ThRepositoryModel, thSocket) {
treeherder.controller('RepositoryPanelCtrl', [
'$scope', '$rootScope', '$routeParams', '$location', 'ThLog',
'localStorageService', 'ThRepositoryModel', 'thSocket',
function RepositoryPanelCtrl(
$scope, $rootScope, $routeParams, $location, ThLog,
localStorageService, ThRepositoryModel, thSocket) {
var $log = new ThLog(this.constructor.name);
for (var repo in $scope.watchedRepos) {
@ -16,4 +20,4 @@ treeherder.controller('RepositoryPanelCtrl',
ThRepositoryModel.watchedReposUpdated(repoName);
};
}
);
]);

Просмотреть файл

@ -1,5 +1,6 @@
"use strict";
treeherder.controller('SettingsCtrl',
treeherder.controller('SettingsCtrl', [
'$scope', '$log',
function SheriffController($scope, $log){
}
)
])

Просмотреть файл

@ -1,7 +1,12 @@
'use strict';
treeherder.controller('SheriffCtrl',
function SheriffController($scope, $rootScope, ThBuildPlatformModel, ThJobTypeModel, thEvents,
ThRepositoryModel, ThOptionModel, ThJobExclusionModel, ThExclusionProfileModel) {
treeherder.controller('SheriffCtrl', [
'$scope', '$rootScope', 'ThBuildPlatformModel', 'ThJobTypeModel',
'thEvents', 'ThRepositoryModel', 'ThOptionModel', 'ThJobExclusionModel',
'ThExclusionProfileModel',
function SheriffController(
$scope, $rootScope, ThBuildPlatformModel, ThJobTypeModel, thEvents,
ThRepositoryModel, ThOptionModel, ThJobExclusionModel,
ThExclusionProfileModel) {
// fetch the reference data
$scope.exclusions = [];
@ -209,4 +214,4 @@ treeherder.controller('SheriffCtrl',
$scope.switchView('exclusion_profile_add');
};
}
);
]);

Просмотреть файл

@ -1,5 +1,6 @@
"use strict";
treeherder.controller('TimelineCtrl',
treeherder.controller('TimelineCtrl', [
'$scope',
function TimelineCtrl($scope){}
);
]);

Просмотреть файл

@ -1,6 +1,8 @@
'use strict';
treeherder.factory('thClassificationTypes', function($http, thUrl) {
treeherder.factory('thClassificationTypes', [
'$http', 'thUrl',
function($http, thUrl) {
var classifications = {};
@ -31,5 +33,5 @@ treeherder.factory('thClassificationTypes', function($http, thUrl) {
classifications: classifications,
load: load
};
});
}]);

Просмотреть файл

@ -21,9 +21,12 @@
* Each field is AND'ed so that, if a field exists in ``filters`` then the job
* must match at least one value in every field.
*/
treeherder.factory('thJobFilters',
function(thResultStatusList, ThLog, $rootScope,
ThResultSetModel, thPinboard, thNotify) {
treeherder.factory('thJobFilters', [
'thResultStatusList', 'ThLog', '$rootScope', 'ThResultSetModel',
'thPinboard', 'thNotify',
function(
thResultStatusList, ThLog, $rootScope,
ThResultSetModel, thPinboard, thNotify) {
var $log = new ThLog("thJobFilters");
@ -280,4 +283,4 @@ treeherder.factory('thJobFilters',
return api;
});
}]);

Просмотреть файл

@ -1,6 +1,8 @@
'use strict';
treeherder.factory('ThLog', function($log, ThLogConfig) {
treeherder.factory('ThLog', [
'$log', 'ThLogConfig',
function($log, ThLogConfig) {
// a logger that states the object doing the logging
var ThLog = function(name) {
@ -35,7 +37,7 @@ treeherder.factory('ThLog', function($log, ThLogConfig) {
};
return ThLog;
});
}]);
/**

Просмотреть файл

@ -1,7 +1,9 @@
'use strict';
/* Services */
treeherder.factory('thUrl', function($rootScope, thServiceDomain, ThLog) {
treeherder.factory('thUrl', [
'$rootScope', 'thServiceDomain', 'ThLog',
function($rootScope, thServiceDomain, ThLog) {
var thUrl = {
getRootUrl: function(uri) {
@ -23,9 +25,12 @@ treeherder.factory('thUrl', function($rootScope, thServiceDomain, ThLog) {
};
return thUrl;
});
}]);
treeherder.factory('thSocket', [
'$rootScope', 'ThLog', 'thUrl',
function ($rootScope, ThLog, thUrl) {
treeherder.factory('thSocket', function ($rootScope, ThLog, thUrl) {
var $log = new ThLog("thSocket");
var socket = io.connect(thUrl.getSocketEventUrl());
@ -52,9 +57,11 @@ treeherder.factory('thSocket', function ($rootScope, ThLog, thUrl) {
});
}
};
});
}]);
treeherder.factory('thCloneHtml', function($interpolate) {
treeherder.factory('thCloneHtml', [
'$interpolate',
function($interpolate) {
var cloneTemplateIds = [
'revisionsClone.html',
@ -90,7 +97,7 @@ treeherder.factory('thCloneHtml', function($interpolate) {
get:getClone
};
});
}]);
treeherder.factory('ThPaginator', function(){
//dead-simple implementation of an in-memory paginator
@ -113,7 +120,9 @@ treeherder.factory('ThPaginator', function(){
});
treeherder.factory('BrowserId', function($http, $q, ThLog, thServiceDomain){
treeherder.factory('BrowserId', [
'$http', '$q', 'ThLog', 'thServiceDomain',
function($http, $q, ThLog, thServiceDomain){
/*
* BrowserId is a wrapper for the persona authentication service
@ -184,9 +193,11 @@ treeherder.factory('BrowserId', function($http, $q, ThLog, thServiceDomain){
}
}
return browserid;
});
}]);
treeherder.factory('thNotify', function($timeout, ThLog){
treeherder.factory('thNotify', [
'$timeout', 'ThLog',
function($timeout, ThLog){
//a growl-like notification system
var $log = new ThLog("thNotify");
@ -235,4 +246,4 @@ treeherder.factory('thNotify', function($timeout, ThLog){
}
return thNotify;
});
}]);

Просмотреть файл

@ -1,8 +1,11 @@
'use strict';
treeherder.factory('thPinboard',
function($http, thUrl, ThJobClassificationModel, $rootScope,
thEvents, ThBugJobMapModel, thNotify, ThLog) {
treeherder.factory('thPinboard', [
'$http', 'thUrl', 'ThJobClassificationModel', '$rootScope', 'thEvents',
'ThBugJobMapModel', 'thNotify', 'ThLog',
function(
$http, thUrl, ThJobClassificationModel, $rootScope, thEvents,
ThBugJobMapModel, thNotify, ThLog) {
var $log = new ThLog("thPinboard");
@ -139,5 +142,5 @@ treeherder.factory('thPinboard',
};
return api;
});
}]);

Просмотреть файл

@ -1,7 +1,8 @@
'use strict';
treeherder.factory('thResultSets',
function($http, $location, thUrl, thServiceDomain, ThLog) {
treeherder.factory('thResultSets', [
'$http', '$location', 'thUrl', 'thServiceDomain', 'ThLog',
function($http, $location, thUrl, thServiceDomain, ThLog) {
var $log = new ThLog("thResultSets");
@ -64,4 +65,4 @@ treeherder.factory('thResultSets',
return $http.get(thServiceDomain + uri, {params: {format: "json"}});
}
};
});
}]);

Просмотреть файл

@ -1,6 +1,8 @@
'use strict';
treeherder.factory('treeStatus', function($http, $q) {
treeherder.factory('treeStatus', [
'$http', '$q',
function($http, $q) {
var urlBase = "https://treestatus.mozilla.org/";
@ -27,5 +29,5 @@ treeherder.factory('treeStatus', function($http, $q) {
return {
get: get
};
});
}]);

Просмотреть файл

@ -2,8 +2,10 @@
<html ng-app="logViewer">
<head>
<title>Treeherder Log Viewer </title>
<link href="css/treeherder.css" rel="stylesheet" type="text/css">
<!-- build:css css/logviewer.min.css -->
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/treeherder.css" rel="stylesheet" type="text/css">
<!-- endbuild -->
</head>
<body ng-controller="LogviewerCtrl" ng-init="init()">
<div class="container">
@ -51,6 +53,7 @@
</div>
</div>
</div>
<!-- build:js js/logviewer.min.js -->
<script src="vendor/angular/angular.js"></script>
<script src="vendor/angular/angular-route.js"></script>
<script src="vendor/angular/angular-resource.js"></script>
@ -68,5 +71,6 @@
<script src="js/models/job_artifact.js"></script>
<script src="js/providers.js"></script>
<script src="js/controllers/logviewer.js"></script>
<!-- endbuild -->
</body>
</html>

Просмотреть файл

@ -1,8 +1,12 @@
"use strict";
treeherder.controller('AnnotationsPluginCtrl',
function AnnotationsPluginCtrl($scope, $rootScope, ThLog, ThJobClassificationModel,
thNotify, thEvents, ThResultSetModel, ThBugJobMapModel) {
treeherder.controller('AnnotationsPluginCtrl', [
'$scope', '$rootScope', 'ThLog', 'ThJobClassificationModel', 'thNotify',
'thEvents', 'ThResultSetModel', 'ThBugJobMapModel',
function AnnotationsPluginCtrl(
$scope, $rootScope, ThLog, ThJobClassificationModel,
thNotify, thEvents, ThResultSetModel, ThBugJobMapModel) {
var $log = new ThLog(this.constructor.name);
$log.debug("annotations plugin initialized");
@ -50,4 +54,4 @@ treeherder.controller('AnnotationsPluginCtrl',
);
};
}
);
]);

Просмотреть файл

@ -1,8 +1,12 @@
"use strict";
treeherder.controller('BugsPluginCtrl',
function BugsPluginCtrl($scope, $rootScope, ThLog, ThJobArtifactModel,
ThBugJobMapModel, ThJobClassificationModel, thNotify, $modal) {
treeherder.controller('BugsPluginCtrl', [
'$scope', '$rootScope', 'ThLog', 'ThJobArtifactModel', 'ThBugJobMapModel',
'ThJobClassificationModel', 'thNotify', '$modal',
function BugsPluginCtrl(
$scope, $rootScope, ThLog, ThJobArtifactModel, ThBugJobMapModel,
ThJobClassificationModel, thNotify, $modal) {
var $log = new ThLog(this.constructor.name);
$log.debug("bugs plugin initialized");
@ -43,4 +47,4 @@ treeherder.controller('BugsPluginCtrl',
$scope.$watch("job.id", update_bugs, true);
}
);
]);

Просмотреть файл

@ -1,10 +1,15 @@
"use strict";
treeherder.controller('PluginCtrl',
function PluginCtrl($scope, $rootScope, thUrl, ThJobClassificationModel,
thClassificationTypes, ThJobModel, thEvents, dateFilter,
numberFilter, ThBugJobMapModel, thResultStatus, thSocket,
ThResultSetModel, ThLog) {
treeherder.controller('PluginCtrl', [
'$scope', '$rootScope', 'thUrl', 'ThJobClassificationModel',
'thClassificationTypes', 'ThJobModel', 'thEvents', 'dateFilter',
'numberFilter', 'ThBugJobMapModel', 'thResultStatus', 'thSocket',
'ThResultSetModel', 'ThLog',
function PluginCtrl(
$scope, $rootScope, thUrl, ThJobClassificationModel,
thClassificationTypes, ThJobModel, thEvents, dateFilter,
numberFilter, ThBugJobMapModel, thResultStatus, thSocket,
ThResultSetModel, ThLog) {
var $log = new ThLog("PluginCtrl");
@ -160,4 +165,4 @@ treeherder.controller('PluginCtrl',
};
}
);
]);

Просмотреть файл

@ -1,7 +1,9 @@
"use strict";
treeherder.controller('PinboardCtrl',
function PinboardCtrl($scope, $rootScope, thEvents, thPinboard, thNotify, ThLog) {
treeherder.controller('PinboardCtrl', [
'$scope', '$rootScope', 'thEvents', 'thPinboard', 'thNotify', 'ThLog',
function PinboardCtrl(
$scope, $rootScope, thEvents, thPinboard, thNotify, ThLog) {
var $log = new ThLog(this.constructor.name);
@ -96,4 +98,4 @@ treeherder.controller('PinboardCtrl',
$scope.relatedBugs = thPinboard.relatedBugs;
}
);
]);

Просмотреть файл

@ -1,9 +1,14 @@
"use strict";
treeherder.controller('SimilarJobsPluginCtrl',
function SimilarJobsPluginCtrl($scope, ThLog, $rootScope, ThJobModel, thResultStatusInfo, thEvents,
numberFilter, dateFilter, thClassificationTypes, thResultStatus,
ThJobArtifactModel) {
treeherder.controller('SimilarJobsPluginCtrl', [
'$scope', 'ThLog', '$rootScope', 'ThJobModel', 'thResultStatusInfo',
'thEvents', 'numberFilter', 'dateFilter', 'thClassificationTypes',
'thResultStatus', 'ThJobArtifactModel',
function SimilarJobsPluginCtrl(
$scope, ThLog, $rootScope, ThJobModel, thResultStatusInfo, thEvents,
numberFilter, dateFilter, thClassificationTypes, thResultStatus,
ThJobArtifactModel) {
var $log = new ThLog(this.constructor.name);
$log.debug("similar jobs plugin initialized");
@ -95,6 +100,6 @@ treeherder.controller('SimilarJobsPluginCtrl',
});
};
});
}]);

Просмотреть файл

@ -1,7 +1,10 @@
"use strict";
treeherder.controller('TinderboxPluginCtrl',
function TinderboxPluginCtrl($scope, $rootScope, ThLog, ThJobArtifactModel) {
treeherder.controller('TinderboxPluginCtrl', [
'$scope', '$rootScope', 'ThLog', 'ThJobArtifactModel',
function TinderboxPluginCtrl(
$scope, $rootScope, ThLog, ThJobArtifactModel) {
var $log = new ThLog(this.constructor.name);
$log.debug("Tinderbox plugin initialized");
@ -91,4 +94,4 @@ treeherder.controller('TinderboxPluginCtrl',
};
$scope.$watch("job.id", update_job_info, true);
}
);
]);