Commit abac8bcc by Torkel Ödegaard

tech(typescript): its looking good

parent 82061c7c
......@@ -4,7 +4,7 @@ coverage/
awsconfig
/dist
/emails/dist
/public/.app_gen
/public_gen
/tmp
docs/AWS_S3_BUCKET
......
......@@ -6,6 +6,7 @@ module.exports = function (grunt) {
pkg: grunt.file.readJSON('package.json'),
baseDir: '.',
srcDir: 'public',
genDir: 'public_gen',
destDir: 'dist',
tempDir: 'tmp',
arch: os.arch(),
......
......@@ -61,6 +61,7 @@
"license": "Apache-2.0",
"dependencies": {
"grunt-jscs": "~1.5.x",
"grunt-sync": "^0.4.1",
"karma-sinon": "^1.0.3",
"lodash": "^2.4.1",
"sinon": "1.10.3"
......
......@@ -104,8 +104,8 @@ function (angular, $, _, appLevelRequire) {
_.each(pre_boot_modules, function (module) {
_.extend(module, register_fns);
});
pre_boot_modules = false;
pre_boot_modules = false;
$rootScope.requireContext = appLevelRequire;
$rootScope.require = function (deps, fn) {
var $scope = this;
......
require.config({
urlArgs: 'bust=' + (new Date().getTime()),
baseUrl: 'public/.app_gen',
baseUrl: 'public/app',
paths: {
config: 'components/config',
......
......@@ -8,6 +8,7 @@ function (angular) {
var module = angular.module('grafana.controllers');
module.controller('ErrorCtrl', function($scope, contextSrv) {
var showSideMenu = contextSrv.sidemenu;
......
......@@ -4,13 +4,10 @@ define([
'lodash',
'jquery',
'store',
'./testCtrl',
],
function (angular, config, _, $, store, TestCtrl) {
function (angular, config, _, $, store) {
"use strict";
console.log(new TestCtrl().getName());
var module = angular.module('grafana.controllers');
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([
'./profile/profileCtrl',
'./profile/changePasswordCtrl',
'./profile/selectOrgCtrl',
'./org/all',
'./admin/all',
], function () {});
define([
'angular',
'../core/core',
'./dashLoadControllers',
], function(angular) {
], function(angular, core) {
"use strict";
var module = angular.module('grafana.routes');
......@@ -41,30 +42,37 @@ define([
.when('/datasources', {
templateUrl: 'app/features/org/partials/datasources.html',
controller : 'DataSourcesCtrl',
resolve: new core.ModuleLoader("features/org/all"),
})
.when('/datasources/edit/:id', {
templateUrl: 'app/features/org/partials/datasourceEdit.html',
controller : 'DataSourceEditCtrl',
resolve: new core.ModuleLoader("features/org/all"),
})
.when('/datasources/new', {
templateUrl: 'app/features/org/partials/datasourceEdit.html',
controller : 'DataSourceEditCtrl',
resolve: new core.ModuleLoader("features/org/all"),
})
.when('/org', {
templateUrl: 'app/features/org/partials/orgDetails.html',
controller : 'OrgDetailsCtrl',
resolve: new core.ModuleLoader("features/org/all"),
})
.when('/org/new', {
templateUrl: 'app/features/org/partials/newOrg.html',
controller : 'NewOrgCtrl',
resolve: new core.ModuleLoader("features/org/all"),
})
.when('/org/users', {
templateUrl: 'app/features/org/partials/orgUsers.html',
controller : 'OrgUsersCtrl',
resolve: new core.ModuleLoader("features/org/all"),
})
.when('/org/apikeys', {
templateUrl: 'app/features/org/partials/orgApiKeys.html',
controller : 'OrgApiKeysCtrl',
resolve: new core.ModuleLoader("features/org/all"),
})
.when('/profile', {
templateUrl: 'app/features/profile/partials/profile.html',
......
......@@ -9,7 +9,7 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
'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/test/**/*.js', included: false},
{pattern: 'public/**/*.js', included: false}
......
require.config({
baseUrl: 'http://localhost:9876/base/public/app',
baseUrl: 'http://localhost:9876/base/public/app_gen',
paths: {
specs: '../test/specs',
......
......@@ -19,7 +19,7 @@
<!-- build:js [[.AppSubUrl]]/app/app.js -->
<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 -->
</head>
......
......@@ -6,11 +6,11 @@ module.exports = function(grunt) {
'jshint:source',
'jshint:tests',
'jscs',
'karma:test',
'clean:on_start',
'less:src',
'concat:cssDark',
'concat:cssLight',
'copy:app_gen_build',
'typescript:build',
'karma:test',
'css',
'copy:everything_but_less_to_temp',
'htmlmin:build',
'ngtemplates',
......@@ -25,7 +25,6 @@ module.exports = function(grunt) {
'uglify:dest'
]);
// task to add [[.AppSubUrl]] to reved path
grunt.registerTask('remapFilerev', function(){
var root = grunt.config().destDir;
......
// Lint and build CSS
module.exports = function(grunt) {
grunt.registerTask('css', ['less:src', 'concat:cssDark', 'concat:cssLight']);
grunt.registerTask('default', ['jscs', 'jshint', 'css']);
'use strict';
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']);
};
module.exports = function(config) {
'use strict';
return {
on_start: ['<%= destDir %>', '<%= tempDir %>'],
release: ['<%= destDir %>', '<%= tempDir %>', '<%= genDir %>'],
gen: ['<%= genDir %>'],
temp: ['<%= tempDir %>']
};
};
......@@ -4,25 +4,25 @@ module.exports = function(config) {
return {
cssDark: {
src: [
'<%= srcDir %>/vendor/css/normalize.min.css',
'<%= srcDir %>/vendor/css/timepicker.css',
'<%= srcDir %>/vendor/css/spectrum.css',
'<%= srcDir %>/css/bootstrap.dark.min.css',
'<%= srcDir %>/css/bootstrap-responsive.min.css',
'<%= srcDir %>/vendor/css/font-awesome.min.css'
'<%= genDir %>/vendor/css/normalize.min.css',
'<%= genDir %>/vendor/css/timepicker.css',
'<%= genDir %>/vendor/css/spectrum.css',
'<%= genDir %>/css/bootstrap.dark.min.css',
'<%= genDir %>/css/bootstrap-responsive.min.css',
'<%= genDir %>/vendor/css/font-awesome.min.css'
],
dest: '<%= srcDir %>/css/grafana.dark.min.css'
dest: '<%= genDir %>/css/grafana.dark.min.css'
},
cssLight: {
src: [
'<%= srcDir %>/vendor/css/normalize.min.css',
'<%= srcDir %>/vendor/css/timepicker.css',
'<%= srcDir %>/vendor/css/spectrum.css',
'<%= srcDir %>/css/bootstrap.light.min.css',
'<%= srcDir %>/css/bootstrap-responsive.min.css',
'<%= srcDir %>/vendor/css/font-awesome.min.css'
'<%= genDir %>/vendor/css/normalize.min.css',
'<%= genDir %>/vendor/css/timepicker.css',
'<%= genDir %>/vendor/css/spectrum.css',
'<%= genDir %>/css/bootstrap.light.min.css',
'<%= genDir %>/css/bootstrap-responsive.min.css',
'<%= genDir %>/vendor/css/font-awesome.min.css'
],
dest: '<%= srcDir %>/css/grafana.light.min.css'
dest: '<%= genDir %>/css/grafana.light.min.css'
},
js: {
......
......@@ -8,11 +8,11 @@ module.exports = function(config) {
dest: '<%= tempDir %>'
},
app_gen_build: {
cwd: '<%= srcDir %>/app',
everything_but_less: {
cwd: '<%= srcDir %>',
expand: true,
src: ['**/*.js', '**/*.html'],
dest: '<%= srcDir %>/.app_gen'
src: ['**/*', '!**/*.less'],
dest: '<%= genDir %>'
}
};
......
module.exports = function(config) {
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:{
options: {
paths: ["<%= srcDir %>/vendor/bootstrap/less", "<%= srcDir %>/css/less"],
yuicompress:true
paths: ["<%= srcDir %>/vendor/bootstrap/less", "<%= srcDir %>/less"],
yuicompress: true
},
files: {
"<%= srcDir %>/css/bootstrap.dark.min.css": "<%= srcDir %>/css/less/bootstrap.dark.less",
"<%= srcDir %>/css/bootstrap.light.min.css": "<%= srcDir %>/css/less/bootstrap.light.less",
"<%= srcDir %>/css/bootstrap-responsive.min.css": "<%= srcDir %>/css/less/grafana-responsive.less"
"<%= genDir %>/css/bootstrap.dark.min.css": "<%= srcDir %>/less/bootstrap.dark.less",
"<%= genDir %>/css/bootstrap.light.min.css": "<%= srcDir %>/less/bootstrap.light.less",
"<%= genDir %>/css/bootstrap-responsive.min.css": "<%= srcDir %>/less/grafana-responsive.less"
}
}
};
};
\ No newline at end of file
};
......@@ -7,7 +7,7 @@ module.exports = function(config,grunt) {
appDir: '<%= tempDir %>',
dir: '<%= destDir %>',
mainConfigFile: '<%= tempDir %>/app/components/require.config.js',
baseUrl: './app',
baseUrl: 'app_gen',
waitSeconds: 0,
modules: [], // populated below,
......@@ -37,9 +37,9 @@ module.exports = function(config,grunt) {
// setup the modules require will build
var requireModules = options.modules = [
{
// main/common module
name: 'app',
{
// main/common module
name: 'app',
include: [
'kbn',
'text',
......@@ -66,7 +66,11 @@ module.exports = function(config,grunt) {
'plugins/datasource/graphite/datasource',
'plugins/datasource/influxdb_08/datasource',
]
}
},
// {
// name: 'features/org/all',
// exclude: ['app'],
// }
];
var fs = require('fs');
......
......@@ -4,7 +4,7 @@ module.exports = function() {
return {
build: {
src: ['public/app/**/*.ts'],
dest: 'public/.app_gen',
dest: 'public_gen/app',
options: {
module: 'amd', //or commonjs
target: 'es5', //or es3
......@@ -14,9 +14,20 @@ module.exports = function() {
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: {
src: ['public/app/**/*.ts'],
dest: 'public/.app_gen',
dest: 'public/app_gen',
options: {
module: 'amd', //or commonjs
target: 'es5', //or es3
......
module.exports = function(config) {
return {
css: {
files: [ '<%= srcDir %>/css/**/*.less' ],
files: [ '<%= srcDir %>/less/**/*.less' ],
tasks: ['css'],
options: {
spawn: false
}
},
app_gen: {
files: ['<%= srcDir %>/app/**/*.js', '<%= srcDir %>/app/**/*.html'],
tasks: ['copy:app_gen_build'],
copy_to_gen: {
files: ['<%= srcDir %>/**/*', '!<%= srcDir %>/**/*.less'],
tasks: ['copy:everything_but_less'],
options: {
spawn: false
}
......
......@@ -2,7 +2,7 @@
"compilerOptions": {
"sourceMap": true,
"declaration": true,
"outDir": "public/.app_gen",
"outDir": "public_gen/app",
"target": "ES5",
"rootDir": "public/app",
"module": "amd",
......@@ -12,6 +12,10 @@
"public/app/components/panelmeta.ts",
"public/app/controllers/fileSearcher.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"
]
}
\ 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