Commit abac8bcc by Torkel Ödegaard

tech(typescript): its looking good

parent 82061c7c
...@@ -4,7 +4,7 @@ coverage/ ...@@ -4,7 +4,7 @@ coverage/
awsconfig awsconfig
/dist /dist
/emails/dist /emails/dist
/public/.app_gen /public_gen
/tmp /tmp
docs/AWS_S3_BUCKET docs/AWS_S3_BUCKET
......
...@@ -6,6 +6,7 @@ module.exports = function (grunt) { ...@@ -6,6 +6,7 @@ module.exports = function (grunt) {
pkg: grunt.file.readJSON('package.json'), pkg: grunt.file.readJSON('package.json'),
baseDir: '.', baseDir: '.',
srcDir: 'public', srcDir: 'public',
genDir: 'public_gen',
destDir: 'dist', destDir: 'dist',
tempDir: 'tmp', tempDir: 'tmp',
arch: os.arch(), arch: os.arch(),
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"grunt-jscs": "~1.5.x", "grunt-jscs": "~1.5.x",
"grunt-sync": "^0.4.1",
"karma-sinon": "^1.0.3", "karma-sinon": "^1.0.3",
"lodash": "^2.4.1", "lodash": "^2.4.1",
"sinon": "1.10.3" "sinon": "1.10.3"
......
...@@ -104,8 +104,8 @@ function (angular, $, _, appLevelRequire) { ...@@ -104,8 +104,8 @@ function (angular, $, _, appLevelRequire) {
_.each(pre_boot_modules, function (module) { _.each(pre_boot_modules, function (module) {
_.extend(module, register_fns); _.extend(module, register_fns);
}); });
pre_boot_modules = false;
pre_boot_modules = false;
$rootScope.requireContext = appLevelRequire; $rootScope.requireContext = appLevelRequire;
$rootScope.require = function (deps, fn) { $rootScope.require = function (deps, fn) {
var $scope = this; var $scope = this;
......
require.config({ require.config({
urlArgs: 'bust=' + (new Date().getTime()), urlArgs: 'bust=' + (new Date().getTime()),
baseUrl: 'public/.app_gen', baseUrl: 'public/app',
paths: { paths: {
config: 'components/config', config: 'components/config',
......
...@@ -8,6 +8,7 @@ function (angular) { ...@@ -8,6 +8,7 @@ function (angular) {
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
module.controller('ErrorCtrl', function($scope, contextSrv) { module.controller('ErrorCtrl', function($scope, contextSrv) {
var showSideMenu = contextSrv.sidemenu; var showSideMenu = contextSrv.sidemenu;
......
...@@ -4,13 +4,10 @@ define([ ...@@ -4,13 +4,10 @@ define([
'lodash', 'lodash',
'jquery', 'jquery',
'store', 'store',
'./testCtrl',
], ],
function (angular, config, _, $, store, TestCtrl) { function (angular, config, _, $, store) {
"use strict"; "use strict";
console.log(new TestCtrl().getName());
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootScope, $controller, contextSrv) { module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootScope, $controller, contextSrv) {
......
export * from './time_series'
export * from './directives/cool_dir'
export * from './routes/module_loader'
export class CoolDir {
getName() : string {
return "CoolDir";
}
}
///<reference path="../../headers/require.d.ts" />
export class ModuleLoader {
lazy: any
constructor(moduleName) {
this.lazy = ["$q", "$route", "$rootScope", function($q, $route, $rootScope) {
var defered = $q.defer();
require([moduleName], function () {
defered.resolve();
});
return defered.promise;
}];
}
}
export class TimeSeries {
getName() : string {
return "TimeSeries";
}
}
...@@ -8,6 +8,5 @@ define([ ...@@ -8,6 +8,5 @@ define([
'./profile/profileCtrl', './profile/profileCtrl',
'./profile/changePasswordCtrl', './profile/changePasswordCtrl',
'./profile/selectOrgCtrl', './profile/selectOrgCtrl',
'./org/all',
'./admin/all', './admin/all',
], function () {}); ], function () {});
define([ define([
'angular', 'angular',
'../core/core',
'./dashLoadControllers', './dashLoadControllers',
], function(angular) { ], function(angular, core) {
"use strict"; "use strict";
var module = angular.module('grafana.routes'); var module = angular.module('grafana.routes');
...@@ -41,30 +42,37 @@ define([ ...@@ -41,30 +42,37 @@ define([
.when('/datasources', { .when('/datasources', {
templateUrl: 'app/features/org/partials/datasources.html', templateUrl: 'app/features/org/partials/datasources.html',
controller : 'DataSourcesCtrl', controller : 'DataSourcesCtrl',
resolve: new core.ModuleLoader("features/org/all"),
}) })
.when('/datasources/edit/:id', { .when('/datasources/edit/:id', {
templateUrl: 'app/features/org/partials/datasourceEdit.html', templateUrl: 'app/features/org/partials/datasourceEdit.html',
controller : 'DataSourceEditCtrl', controller : 'DataSourceEditCtrl',
resolve: new core.ModuleLoader("features/org/all"),
}) })
.when('/datasources/new', { .when('/datasources/new', {
templateUrl: 'app/features/org/partials/datasourceEdit.html', templateUrl: 'app/features/org/partials/datasourceEdit.html',
controller : 'DataSourceEditCtrl', controller : 'DataSourceEditCtrl',
resolve: new core.ModuleLoader("features/org/all"),
}) })
.when('/org', { .when('/org', {
templateUrl: 'app/features/org/partials/orgDetails.html', templateUrl: 'app/features/org/partials/orgDetails.html',
controller : 'OrgDetailsCtrl', controller : 'OrgDetailsCtrl',
resolve: new core.ModuleLoader("features/org/all"),
}) })
.when('/org/new', { .when('/org/new', {
templateUrl: 'app/features/org/partials/newOrg.html', templateUrl: 'app/features/org/partials/newOrg.html',
controller : 'NewOrgCtrl', controller : 'NewOrgCtrl',
resolve: new core.ModuleLoader("features/org/all"),
}) })
.when('/org/users', { .when('/org/users', {
templateUrl: 'app/features/org/partials/orgUsers.html', templateUrl: 'app/features/org/partials/orgUsers.html',
controller : 'OrgUsersCtrl', controller : 'OrgUsersCtrl',
resolve: new core.ModuleLoader("features/org/all"),
}) })
.when('/org/apikeys', { .when('/org/apikeys', {
templateUrl: 'app/features/org/partials/orgApiKeys.html', templateUrl: 'app/features/org/partials/orgApiKeys.html',
controller : 'OrgApiKeysCtrl', controller : 'OrgApiKeysCtrl',
resolve: new core.ModuleLoader("features/org/all"),
}) })
.when('/profile', { .when('/profile', {
templateUrl: 'app/features/profile/partials/profile.html', templateUrl: 'app/features/profile/partials/profile.html',
......
...@@ -9,7 +9,7 @@ module.exports = function(config) { ...@@ -9,7 +9,7 @@ module.exports = function(config) {
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: [ files: [
'public/test/test-main.js', 'public/test/test-main.js',
{pattern: 'public/app/**/*.js', included: false}, {pattern: 'public/.app_gen/**/*.js', included: false},
{pattern: 'public/vendor/**/*.js', included: false}, {pattern: 'public/vendor/**/*.js', included: false},
{pattern: 'public/test/**/*.js', included: false}, {pattern: 'public/test/**/*.js', included: false},
{pattern: 'public/**/*.js', included: false} {pattern: 'public/**/*.js', included: false}
......
require.config({ require.config({
baseUrl: 'http://localhost:9876/base/public/app', baseUrl: 'http://localhost:9876/base/public/app_gen',
paths: { paths: {
specs: '../test/specs', specs: '../test/specs',
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<!-- build:js [[.AppSubUrl]]/app/app.js --> <!-- build:js [[.AppSubUrl]]/app/app.js -->
<script src="[[.AppSubUrl]]/public/vendor/requirejs/require.js"></script> <script src="[[.AppSubUrl]]/public/vendor/requirejs/require.js"></script>
<script src="[[.AppSubUrl]]/public/.app_gen/components/require.config.js"></script> <script src="[[.AppSubUrl]]/public/app/components/require.config.js"></script>
<!-- endbuild --> <!-- endbuild -->
</head> </head>
......
...@@ -6,11 +6,11 @@ module.exports = function(grunt) { ...@@ -6,11 +6,11 @@ module.exports = function(grunt) {
'jshint:source', 'jshint:source',
'jshint:tests', 'jshint:tests',
'jscs', 'jscs',
'karma:test',
'clean:on_start', 'clean:on_start',
'less:src', 'copy:app_gen_build',
'concat:cssDark', 'typescript:build',
'concat:cssLight', 'karma:test',
'css',
'copy:everything_but_less_to_temp', 'copy:everything_but_less_to_temp',
'htmlmin:build', 'htmlmin:build',
'ngtemplates', 'ngtemplates',
...@@ -25,7 +25,6 @@ module.exports = function(grunt) { ...@@ -25,7 +25,6 @@ module.exports = function(grunt) {
'uglify:dest' 'uglify:dest'
]); ]);
// task to add [[.AppSubUrl]] to reved path // task to add [[.AppSubUrl]] to reved path
grunt.registerTask('remapFilerev', function(){ grunt.registerTask('remapFilerev', function(){
var root = grunt.config().destDir; var root = grunt.config().destDir;
......
// Lint and build CSS // Lint and build CSS
module.exports = function(grunt) { module.exports = function(grunt) {
grunt.registerTask('css', ['less:src', 'concat:cssDark', 'concat:cssLight']); 'use strict';
grunt.registerTask('default', ['jscs', 'jshint', 'css']);
grunt.registerTask('css', ['less', 'concat:cssDark', 'concat:cssLight']);
grunt.registerTask('default', [
'jscs',
'jshint',
'clean:gen',
'copy:everything_but_ts_and_less',
'css',
'typescript:build'
]);
grunt.registerTask('test', ['default', 'karma:test']); grunt.registerTask('test', ['default', 'karma:test']);
}; };
module.exports = function(config) { module.exports = function(config) {
'use strict';
return { return {
on_start: ['<%= destDir %>', '<%= tempDir %>'], release: ['<%= destDir %>', '<%= tempDir %>', '<%= genDir %>'],
gen: ['<%= genDir %>'],
temp: ['<%= tempDir %>'] temp: ['<%= tempDir %>']
}; };
}; };
...@@ -4,25 +4,25 @@ module.exports = function(config) { ...@@ -4,25 +4,25 @@ module.exports = function(config) {
return { return {
cssDark: { cssDark: {
src: [ src: [
'<%= srcDir %>/vendor/css/normalize.min.css', '<%= genDir %>/vendor/css/normalize.min.css',
'<%= srcDir %>/vendor/css/timepicker.css', '<%= genDir %>/vendor/css/timepicker.css',
'<%= srcDir %>/vendor/css/spectrum.css', '<%= genDir %>/vendor/css/spectrum.css',
'<%= srcDir %>/css/bootstrap.dark.min.css', '<%= genDir %>/css/bootstrap.dark.min.css',
'<%= srcDir %>/css/bootstrap-responsive.min.css', '<%= genDir %>/css/bootstrap-responsive.min.css',
'<%= srcDir %>/vendor/css/font-awesome.min.css' '<%= genDir %>/vendor/css/font-awesome.min.css'
], ],
dest: '<%= srcDir %>/css/grafana.dark.min.css' dest: '<%= genDir %>/css/grafana.dark.min.css'
}, },
cssLight: { cssLight: {
src: [ src: [
'<%= srcDir %>/vendor/css/normalize.min.css', '<%= genDir %>/vendor/css/normalize.min.css',
'<%= srcDir %>/vendor/css/timepicker.css', '<%= genDir %>/vendor/css/timepicker.css',
'<%= srcDir %>/vendor/css/spectrum.css', '<%= genDir %>/vendor/css/spectrum.css',
'<%= srcDir %>/css/bootstrap.light.min.css', '<%= genDir %>/css/bootstrap.light.min.css',
'<%= srcDir %>/css/bootstrap-responsive.min.css', '<%= genDir %>/css/bootstrap-responsive.min.css',
'<%= srcDir %>/vendor/css/font-awesome.min.css' '<%= genDir %>/vendor/css/font-awesome.min.css'
], ],
dest: '<%= srcDir %>/css/grafana.light.min.css' dest: '<%= genDir %>/css/grafana.light.min.css'
}, },
js: { js: {
......
...@@ -8,11 +8,11 @@ module.exports = function(config) { ...@@ -8,11 +8,11 @@ module.exports = function(config) {
dest: '<%= tempDir %>' dest: '<%= tempDir %>'
}, },
app_gen_build: { everything_but_less: {
cwd: '<%= srcDir %>/app', cwd: '<%= srcDir %>',
expand: true, expand: true,
src: ['**/*.js', '**/*.html'], src: ['**/*', '!**/*.less'],
dest: '<%= srcDir %>/.app_gen' dest: '<%= genDir %>'
} }
}; };
......
module.exports = function(config) { module.exports = function(config) {
return { return {
// this is the only task, other than copy, that runs on the src directory, since we don't really need
// the less files in the dist. Everything else runs from on temp, and require copys everything
// from temp -> dist
dist:{
expand: true,
cwd:'<%= srcDir %>/vendor/bootstrap/less/',
src: ['bootstrap.dark.less', 'bootstrap.light.less'],
dest: '<%= tempDir %>/css/',
},
// Compile in place when not building
src:{ src:{
options: { options: {
paths: ["<%= srcDir %>/vendor/bootstrap/less", "<%= srcDir %>/css/less"], paths: ["<%= srcDir %>/vendor/bootstrap/less", "<%= srcDir %>/less"],
yuicompress:true yuicompress: true
}, },
files: { files: {
"<%= srcDir %>/css/bootstrap.dark.min.css": "<%= srcDir %>/css/less/bootstrap.dark.less", "<%= genDir %>/css/bootstrap.dark.min.css": "<%= srcDir %>/less/bootstrap.dark.less",
"<%= srcDir %>/css/bootstrap.light.min.css": "<%= srcDir %>/css/less/bootstrap.light.less", "<%= genDir %>/css/bootstrap.light.min.css": "<%= srcDir %>/less/bootstrap.light.less",
"<%= srcDir %>/css/bootstrap-responsive.min.css": "<%= srcDir %>/css/less/grafana-responsive.less" "<%= genDir %>/css/bootstrap-responsive.min.css": "<%= srcDir %>/less/grafana-responsive.less"
} }
} }
}; };
......
...@@ -7,7 +7,7 @@ module.exports = function(config,grunt) { ...@@ -7,7 +7,7 @@ module.exports = function(config,grunt) {
appDir: '<%= tempDir %>', appDir: '<%= tempDir %>',
dir: '<%= destDir %>', dir: '<%= destDir %>',
mainConfigFile: '<%= tempDir %>/app/components/require.config.js', mainConfigFile: '<%= tempDir %>/app/components/require.config.js',
baseUrl: './app', baseUrl: 'app_gen',
waitSeconds: 0, waitSeconds: 0,
modules: [], // populated below, modules: [], // populated below,
...@@ -66,7 +66,11 @@ module.exports = function(config,grunt) { ...@@ -66,7 +66,11 @@ module.exports = function(config,grunt) {
'plugins/datasource/graphite/datasource', 'plugins/datasource/graphite/datasource',
'plugins/datasource/influxdb_08/datasource', 'plugins/datasource/influxdb_08/datasource',
] ]
} },
// {
// name: 'features/org/all',
// exclude: ['app'],
// }
]; ];
var fs = require('fs'); var fs = require('fs');
......
...@@ -4,7 +4,7 @@ module.exports = function() { ...@@ -4,7 +4,7 @@ module.exports = function() {
return { return {
build: { build: {
src: ['public/app/**/*.ts'], src: ['public/app/**/*.ts'],
dest: 'public/.app_gen', dest: 'public_gen/app',
options: { options: {
module: 'amd', //or commonjs module: 'amd', //or commonjs
target: 'es5', //or es3 target: 'es5', //or es3
...@@ -14,9 +14,20 @@ module.exports = function() { ...@@ -14,9 +14,20 @@ module.exports = function() {
generateTsConfig: true, generateTsConfig: true,
} }
}, },
// build2: {
// src: ['public/app/alerting#<{(||)}>#*.ts'],
// dest: 'public/.app_gen/alerting/all.js',
// options: {
// target: 'es5', //or es3
// declaration: true,
// sourceMap: true,
// }
// },
watch: { watch: {
src: ['public/app/**/*.ts'], src: ['public/app/**/*.ts'],
dest: 'public/.app_gen', dest: 'public/app_gen',
options: { options: {
module: 'amd', //or commonjs module: 'amd', //or commonjs
target: 'es5', //or es3 target: 'es5', //or es3
......
module.exports = function(config) { module.exports = function(config) {
return { return {
css: { css: {
files: [ '<%= srcDir %>/css/**/*.less' ], files: [ '<%= srcDir %>/less/**/*.less' ],
tasks: ['css'], tasks: ['css'],
options: { options: {
spawn: false spawn: false
} }
}, },
app_gen: { copy_to_gen: {
files: ['<%= srcDir %>/app/**/*.js', '<%= srcDir %>/app/**/*.html'], files: ['<%= srcDir %>/**/*', '!<%= srcDir %>/**/*.less'],
tasks: ['copy:app_gen_build'], tasks: ['copy:everything_but_less'],
options: { options: {
spawn: false spawn: false
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
"sourceMap": true, "sourceMap": true,
"declaration": true, "declaration": true,
"outDir": "public/.app_gen", "outDir": "public_gen/app",
"target": "ES5", "target": "ES5",
"rootDir": "public/app", "rootDir": "public/app",
"module": "amd", "module": "amd",
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
"public/app/components/panelmeta.ts", "public/app/components/panelmeta.ts",
"public/app/controllers/fileSearcher.ts", "public/app/controllers/fileSearcher.ts",
"public/app/controllers/testCtrl.ts", "public/app/controllers/testCtrl.ts",
"public/app/core/core.ts",
"public/app/core/directives/cool_dir.ts",
"public/app/core/routes/module_loader.ts",
"public/app/core/time_series.ts",
"public/app/headers/require.d.ts" "public/app/headers/require.d.ts"
] ]
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment