Skip to content

Commit abac8bc

Browse files
committed
tech(typescript): its looking good
1 parent 82061c7 commit abac8bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+133
-66
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ coverage/
44
awsconfig
55
/dist
66
/emails/dist
7-
/public/.app_gen
7+
/public_gen
88
/tmp
99

1010
docs/AWS_S3_BUCKET

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = function (grunt) {
66
pkg: grunt.file.readJSON('package.json'),
77
baseDir: '.',
88
srcDir: 'public',
9+
genDir: 'public_gen',
910
destDir: 'dist',
1011
tempDir: 'tmp',
1112
arch: os.arch(),

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"license": "Apache-2.0",
6262
"dependencies": {
6363
"grunt-jscs": "~1.5.x",
64+
"grunt-sync": "^0.4.1",
6465
"karma-sinon": "^1.0.3",
6566
"lodash": "^2.4.1",
6667
"sinon": "1.10.3"

public/app/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ function (angular, $, _, appLevelRequire) {
104104
_.each(pre_boot_modules, function (module) {
105105
_.extend(module, register_fns);
106106
});
107-
pre_boot_modules = false;
108107

108+
pre_boot_modules = false;
109109
$rootScope.requireContext = appLevelRequire;
110110
$rootScope.require = function (deps, fn) {
111111
var $scope = this;

public/app/components/require.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require.config({
22
urlArgs: 'bust=' + (new Date().getTime()),
3-
baseUrl: 'public/.app_gen',
3+
baseUrl: 'public/app',
44

55
paths: {
66
config: 'components/config',

public/app/controllers/errorCtrl.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function (angular) {
88

99
var module = angular.module('grafana.controllers');
1010

11+
1112
module.controller('ErrorCtrl', function($scope, contextSrv) {
1213

1314
var showSideMenu = contextSrv.sidemenu;

public/app/controllers/grafanaCtrl.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ define([
44
'lodash',
55
'jquery',
66
'store',
7-
'./testCtrl',
87
],
9-
function (angular, config, _, $, store, TestCtrl) {
8+
function (angular, config, _, $, store) {
109
"use strict";
1110

12-
console.log(new TestCtrl().getName());
13-
1411
var module = angular.module('grafana.controllers');
1512

1613
module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootScope, $controller, contextSrv) {

public/app/core/core.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
export * from './time_series'
3+
export * from './directives/cool_dir'
4+
export * from './routes/module_loader'
5+
6+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
export class CoolDir {
3+
getName() : string {
4+
return "CoolDir";
5+
}
6+
}
7+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
///<reference path="../../headers/require.d.ts" />
2+
3+
export class ModuleLoader {
4+
lazy: any
5+
6+
constructor(moduleName) {
7+
8+
this.lazy = ["$q", "$route", "$rootScope", function($q, $route, $rootScope) {
9+
var defered = $q.defer();
10+
11+
require([moduleName], function () {
12+
defered.resolve();
13+
});
14+
15+
return defered.promise;
16+
}];
17+
18+
}
19+
}

public/app/core/time_series.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export class TimeSeries {
2+
getName() : string {
3+
return "TimeSeries";
4+
}
5+
}
6+

public/app/features/all.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ define([
88
'./profile/profileCtrl',
99
'./profile/changePasswordCtrl',
1010
'./profile/selectOrgCtrl',
11-
'./org/all',
1211
'./admin/all',
1312
], function () {});

public/app/routes/all.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
define([
22
'angular',
3+
'../core/core',
34
'./dashLoadControllers',
4-
], function(angular) {
5+
], function(angular, core) {
56
"use strict";
67

78
var module = angular.module('grafana.routes');
@@ -41,30 +42,37 @@ define([
4142
.when('/datasources', {
4243
templateUrl: 'app/features/org/partials/datasources.html',
4344
controller : 'DataSourcesCtrl',
45+
resolve: new core.ModuleLoader("features/org/all"),
4446
})
4547
.when('/datasources/edit/:id', {
4648
templateUrl: 'app/features/org/partials/datasourceEdit.html',
4749
controller : 'DataSourceEditCtrl',
50+
resolve: new core.ModuleLoader("features/org/all"),
4851
})
4952
.when('/datasources/new', {
5053
templateUrl: 'app/features/org/partials/datasourceEdit.html',
5154
controller : 'DataSourceEditCtrl',
55+
resolve: new core.ModuleLoader("features/org/all"),
5256
})
5357
.when('/org', {
5458
templateUrl: 'app/features/org/partials/orgDetails.html',
5559
controller : 'OrgDetailsCtrl',
60+
resolve: new core.ModuleLoader("features/org/all"),
5661
})
5762
.when('/org/new', {
5863
templateUrl: 'app/features/org/partials/newOrg.html',
5964
controller : 'NewOrgCtrl',
65+
resolve: new core.ModuleLoader("features/org/all"),
6066
})
6167
.when('/org/users', {
6268
templateUrl: 'app/features/org/partials/orgUsers.html',
6369
controller : 'OrgUsersCtrl',
70+
resolve: new core.ModuleLoader("features/org/all"),
6471
})
6572
.when('/org/apikeys', {
6673
templateUrl: 'app/features/org/partials/orgApiKeys.html',
6774
controller : 'OrgApiKeysCtrl',
75+
resolve: new core.ModuleLoader("features/org/all"),
6876
})
6977
.when('/profile', {
7078
templateUrl: 'app/features/profile/partials/profile.html',
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

public/test/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = function(config) {
99
// list of files / patterns to load in the browser
1010
files: [
1111
'public/test/test-main.js',
12-
{pattern: 'public/app/**/*.js', included: false},
12+
{pattern: 'public/.app_gen/**/*.js', included: false},
1313
{pattern: 'public/vendor/**/*.js', included: false},
1414
{pattern: 'public/test/**/*.js', included: false},
1515
{pattern: 'public/**/*.js', included: false}

public/test/test-main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require.config({
2-
baseUrl: 'http://localhost:9876/base/public/app',
2+
baseUrl: 'http://localhost:9876/base/public/app_gen',
33

44
paths: {
55
specs: '../test/specs',

public/views/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<!-- build:js [[.AppSubUrl]]/app/app.js -->
2121
<script src="[[.AppSubUrl]]/public/vendor/requirejs/require.js"></script>
22-
<script src="[[.AppSubUrl]]/public/.app_gen/components/require.config.js"></script>
22+
<script src="[[.AppSubUrl]]/public/app/components/require.config.js"></script>
2323
<!-- endbuild -->
2424
</head>
2525

tasks/build_task.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ module.exports = function(grunt) {
66
'jshint:source',
77
'jshint:tests',
88
'jscs',
9-
'karma:test',
109
'clean:on_start',
11-
'less:src',
12-
'concat:cssDark',
13-
'concat:cssLight',
10+
'copy:app_gen_build',
11+
'typescript:build',
12+
'karma:test',
13+
'css',
1414
'copy:everything_but_less_to_temp',
1515
'htmlmin:build',
1616
'ngtemplates',
@@ -25,7 +25,6 @@ module.exports = function(grunt) {
2525
'uglify:dest'
2626
]);
2727

28-
2928
// task to add [[.AppSubUrl]] to reved path
3029
grunt.registerTask('remapFilerev', function(){
3130
var root = grunt.config().destDir;

tasks/default_task.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
// Lint and build CSS
22
module.exports = function(grunt) {
3-
grunt.registerTask('css', ['less:src', 'concat:cssDark', 'concat:cssLight']);
4-
grunt.registerTask('default', ['jscs', 'jshint', 'css']);
3+
'use strict';
4+
5+
grunt.registerTask('css', ['less', 'concat:cssDark', 'concat:cssLight']);
6+
grunt.registerTask('default', [
7+
'jscs',
8+
'jshint',
9+
'clean:gen',
10+
'copy:everything_but_ts_and_less',
11+
'css',
12+
'typescript:build'
13+
]);
14+
515
grunt.registerTask('test', ['default', 'karma:test']);
616
};

tasks/options/clean.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports = function(config) {
2+
'use strict';
3+
24
return {
3-
on_start: ['<%= destDir %>', '<%= tempDir %>'],
5+
release: ['<%= destDir %>', '<%= tempDir %>', '<%= genDir %>'],
6+
gen: ['<%= genDir %>'],
47
temp: ['<%= tempDir %>']
58
};
69
};

tasks/options/concat.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ module.exports = function(config) {
44
return {
55
cssDark: {
66
src: [
7-
'<%= srcDir %>/vendor/css/normalize.min.css',
8-
'<%= srcDir %>/vendor/css/timepicker.css',
9-
'<%= srcDir %>/vendor/css/spectrum.css',
10-
'<%= srcDir %>/css/bootstrap.dark.min.css',
11-
'<%= srcDir %>/css/bootstrap-responsive.min.css',
12-
'<%= srcDir %>/vendor/css/font-awesome.min.css'
7+
'<%= genDir %>/vendor/css/normalize.min.css',
8+
'<%= genDir %>/vendor/css/timepicker.css',
9+
'<%= genDir %>/vendor/css/spectrum.css',
10+
'<%= genDir %>/css/bootstrap.dark.min.css',
11+
'<%= genDir %>/css/bootstrap-responsive.min.css',
12+
'<%= genDir %>/vendor/css/font-awesome.min.css'
1313
],
14-
dest: '<%= srcDir %>/css/grafana.dark.min.css'
14+
dest: '<%= genDir %>/css/grafana.dark.min.css'
1515
},
1616
cssLight: {
1717
src: [
18-
'<%= srcDir %>/vendor/css/normalize.min.css',
19-
'<%= srcDir %>/vendor/css/timepicker.css',
20-
'<%= srcDir %>/vendor/css/spectrum.css',
21-
'<%= srcDir %>/css/bootstrap.light.min.css',
22-
'<%= srcDir %>/css/bootstrap-responsive.min.css',
23-
'<%= srcDir %>/vendor/css/font-awesome.min.css'
18+
'<%= genDir %>/vendor/css/normalize.min.css',
19+
'<%= genDir %>/vendor/css/timepicker.css',
20+
'<%= genDir %>/vendor/css/spectrum.css',
21+
'<%= genDir %>/css/bootstrap.light.min.css',
22+
'<%= genDir %>/css/bootstrap-responsive.min.css',
23+
'<%= genDir %>/vendor/css/font-awesome.min.css'
2424
],
25-
dest: '<%= srcDir %>/css/grafana.light.min.css'
25+
dest: '<%= genDir %>/css/grafana.light.min.css'
2626
},
2727

2828
js: {

tasks/options/copy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ module.exports = function(config) {
88
dest: '<%= tempDir %>'
99
},
1010

11-
app_gen_build: {
12-
cwd: '<%= srcDir %>/app',
11+
everything_but_less: {
12+
cwd: '<%= srcDir %>',
1313
expand: true,
14-
src: ['**/*.js', '**/*.html'],
15-
dest: '<%= srcDir %>/.app_gen'
14+
src: ['**/*', '!**/*.less'],
15+
dest: '<%= genDir %>'
1616
}
1717

1818
};

tasks/options/less.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
module.exports = function(config) {
2+
23
return {
3-
// this is the only task, other than copy, that runs on the src directory, since we don't really need
4-
// the less files in the dist. Everything else runs from on temp, and require copys everything
5-
// from temp -> dist
6-
dist:{
7-
expand: true,
8-
cwd:'<%= srcDir %>/vendor/bootstrap/less/',
9-
src: ['bootstrap.dark.less', 'bootstrap.light.less'],
10-
dest: '<%= tempDir %>/css/',
11-
},
12-
// Compile in place when not building
134
src:{
145
options: {
15-
paths: ["<%= srcDir %>/vendor/bootstrap/less", "<%= srcDir %>/css/less"],
16-
yuicompress:true
6+
paths: ["<%= srcDir %>/vendor/bootstrap/less", "<%= srcDir %>/less"],
7+
yuicompress: true
178
},
189
files: {
19-
"<%= srcDir %>/css/bootstrap.dark.min.css": "<%= srcDir %>/css/less/bootstrap.dark.less",
20-
"<%= srcDir %>/css/bootstrap.light.min.css": "<%= srcDir %>/css/less/bootstrap.light.less",
21-
"<%= srcDir %>/css/bootstrap-responsive.min.css": "<%= srcDir %>/css/less/grafana-responsive.less"
10+
"<%= genDir %>/css/bootstrap.dark.min.css": "<%= srcDir %>/less/bootstrap.dark.less",
11+
"<%= genDir %>/css/bootstrap.light.min.css": "<%= srcDir %>/less/bootstrap.light.less",
12+
"<%= genDir %>/css/bootstrap-responsive.min.css": "<%= srcDir %>/less/grafana-responsive.less"
2213
}
2314
}
2415
};
25-
};
16+
};

tasks/options/requirejs.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = function(config,grunt) {
77
appDir: '<%= tempDir %>',
88
dir: '<%= destDir %>',
99
mainConfigFile: '<%= tempDir %>/app/components/require.config.js',
10-
baseUrl: './app',
10+
baseUrl: 'app_gen',
1111
waitSeconds: 0,
1212

1313
modules: [], // populated below,
@@ -37,9 +37,9 @@ module.exports = function(config,grunt) {
3737

3838
// setup the modules require will build
3939
var requireModules = options.modules = [
40-
{
41-
// main/common module
42-
name: 'app',
40+
{
41+
// main/common module
42+
name: 'app',
4343
include: [
4444
'kbn',
4545
'text',
@@ -66,7 +66,11 @@ module.exports = function(config,grunt) {
6666
'plugins/datasource/graphite/datasource',
6767
'plugins/datasource/influxdb_08/datasource',
6868
]
69-
}
69+
},
70+
// {
71+
// name: 'features/org/all',
72+
// exclude: ['app'],
73+
// }
7074
];
7175

7276
var fs = require('fs');

tasks/options/typescript.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = function() {
44
return {
55
build: {
66
src: ['public/app/**/*.ts'],
7-
dest: 'public/.app_gen',
7+
dest: 'public_gen/app',
88
options: {
99
module: 'amd', //or commonjs
1010
target: 'es5', //or es3
@@ -14,9 +14,20 @@ module.exports = function() {
1414
generateTsConfig: true,
1515
}
1616
},
17+
18+
// build2: {
19+
// src: ['public/app/alerting#<{(||)}>#*.ts'],
20+
// dest: 'public/.app_gen/alerting/all.js',
21+
// options: {
22+
// target: 'es5', //or es3
23+
// declaration: true,
24+
// sourceMap: true,
25+
// }
26+
// },
27+
1728
watch: {
1829
src: ['public/app/**/*.ts'],
19-
dest: 'public/.app_gen',
30+
dest: 'public/app_gen',
2031
options: {
2132
module: 'amd', //or commonjs
2233
target: 'es5', //or es3

0 commit comments

Comments
 (0)