mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
more experiments for mixing javascript and typescript
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ coverage/
|
||||
awsconfig
|
||||
/dist
|
||||
/emails/dist
|
||||
/public/app_gen
|
||||
/tmp
|
||||
|
||||
docs/AWS_S3_BUCKET
|
||||
|
||||
7
public/app/components/panelmeta.d.ts
vendored
7
public/app/components/panelmeta.d.ts
vendored
@@ -1,7 +0,0 @@
|
||||
/// <reference path="../headers/require.d.ts" />
|
||||
declare class Base {
|
||||
constructor();
|
||||
testFunc(): number
|
||||
getName(): string
|
||||
}
|
||||
export = Base;
|
||||
@@ -1,9 +1,13 @@
|
||||
define([
|
||||
],
|
||||
function () {
|
||||
"use strict";
|
||||
class PanelMeta {
|
||||
description: any
|
||||
fullscreen: any
|
||||
editIcon: any
|
||||
panelName: any
|
||||
menu: any
|
||||
editorTabs: any
|
||||
extendedMenu: any
|
||||
|
||||
function PanelMeta(options) {
|
||||
constructor(options : any) {
|
||||
this.description = options.description;
|
||||
this.fullscreen = options.fullscreen;
|
||||
this.editIcon = options.editIcon;
|
||||
@@ -29,22 +33,17 @@ function () {
|
||||
this.addExtendedMenuItem('Panel JSON', '', 'editPanelJson(); dismiss();');
|
||||
}
|
||||
|
||||
PanelMeta.prototype.addMenuItem = function(text, icon, click, role) {
|
||||
addMenuItem (text, icon, click, role?) {
|
||||
this.menu.push({text: text, icon: icon, click: click, role: role});
|
||||
};
|
||||
}
|
||||
|
||||
PanelMeta.prototype.getName = function() {
|
||||
return "javascript";
|
||||
};
|
||||
|
||||
PanelMeta.prototype.addExtendedMenuItem = function(text, icon, click, role) {
|
||||
addExtendedMenuItem (text, icon, click, role?) {
|
||||
this.extendedMenu.push({text: text, icon: icon, click: click, role: role});
|
||||
};
|
||||
}
|
||||
|
||||
PanelMeta.prototype.addEditorTab = function(title, src) {
|
||||
addEditorTab (title, src) {
|
||||
this.editorTabs.push({title: title, src: src});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return PanelMeta;
|
||||
|
||||
});
|
||||
export = PanelMeta;
|
||||
@@ -1,6 +1,6 @@
|
||||
require.config({
|
||||
urlArgs: 'bust=' + (new Date().getTime()),
|
||||
baseUrl: 'public/app',
|
||||
baseUrl: 'public/app_gen',
|
||||
|
||||
paths: {
|
||||
config: 'components/config',
|
||||
|
||||
6
public/app/controllers/fileSearcher.d.ts
vendored
6
public/app/controllers/fileSearcher.d.ts
vendored
@@ -1,6 +0,0 @@
|
||||
/// <reference path="../headers/require.d.ts" />
|
||||
declare class FileSearcher {
|
||||
constructor();
|
||||
getFiles(): string[];
|
||||
}
|
||||
export = FileSearcher;
|
||||
@@ -1,13 +0,0 @@
|
||||
///<reference path="../headers/require.d.ts" />
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var FileSearcher = (function () {
|
||||
function FileSearcher() {
|
||||
}
|
||||
FileSearcher.prototype.getFiles = function () {
|
||||
return ["asd"];
|
||||
};
|
||||
return FileSearcher;
|
||||
})();
|
||||
return FileSearcher;
|
||||
});
|
||||
//# sourceMappingURL=fileSearcher.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"fileSearcher.js","sourceRoot":"","sources":["fileSearcher.ts"],"names":["FileSearcher","FileSearcher.constructor","FileSearcher.getFiles"],"mappings":"AAAA,+CAA+C;;IAE/C;QAEIA;QACAC,CAACA;QAEMD,+BAAQA,GAAfA;YACEE,MAAMA,CAACA,CAACA,KAAKA,CAACA,CAACA;QACjBA,CAACA;QACLF,mBAACA;IAADA,CAACA,AARD,IAQC;IAEqB,AAAtB,OAAS,YAAY,CAAC"}
|
||||
6
public/app/controllers/testCtrl.d.ts
vendored
6
public/app/controllers/testCtrl.d.ts
vendored
@@ -1,6 +0,0 @@
|
||||
/// <reference path="../headers/require.d.ts" />
|
||||
declare class Base {
|
||||
constructor();
|
||||
getName(): string;
|
||||
}
|
||||
export = Base;
|
||||
@@ -1,15 +0,0 @@
|
||||
///<reference path="../headers/require.d.ts" />
|
||||
define(["require", "exports", './fileSearcher', "../components/panelmeta"], function (require, exports, FileSearcher) {
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
var test = new FileSearcher();
|
||||
test.getFiles();
|
||||
}
|
||||
Base.prototype.getName = function () {
|
||||
return "asd";
|
||||
};
|
||||
return Base;
|
||||
})();
|
||||
return Base;
|
||||
});
|
||||
//# sourceMappingURL=testCtrl.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"testCtrl.js","sourceRoot":"","sources":["testCtrl.ts"],"names":["Base","Base.constructor","Base.getName"],"mappings":"AAAA,+CAA+C;;IAO/C;QAEIA;YACEC,IAAIA,IAAIA,GAAGA,IAAIA,YAAYA,EAAEA,CAACA;YAC9BA,IAAIA,CAACA,QAAQA,EAAEA,CAACA;QAClBA,CAACA;QAEMD,sBAAOA,GAAdA;YACEE,MAAMA,CAACA,KAAKA,CAACA;QACfA,CAACA;QACLF,WAACA;IAADA,CAACA,AAVD,IAUC;IAEa,AAAd,OAAS,IAAI,CAAC"}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
///<amd-dependency path="../components/panelmeta" />
|
||||
|
||||
import PanelMeta = require('../components/panelmeta');
|
||||
import FileSearcher = require('./fileSearcher');
|
||||
|
||||
class Base {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<!-- build:js [[.AppSubUrl]]/app/app.js -->
|
||||
<script src="[[.AppSubUrl]]/public/vendor/requirejs/require.js"></script>
|
||||
<script src="[[.AppSubUrl]]/public/app/components/require.config.js"></script>
|
||||
<script src="[[.AppSubUrl]]/public/app_gen/components/require.config.js"></script>
|
||||
<!-- endbuild -->
|
||||
</head>
|
||||
|
||||
|
||||
@@ -4,8 +4,16 @@ module.exports = function(config) {
|
||||
everything_but_less_to_temp: {
|
||||
cwd: '<%= srcDir %>',
|
||||
expand: true,
|
||||
src: ['**/*', '!**/*.less', '!config.js'],
|
||||
src: ['**/*', '!**/*.less'],
|
||||
dest: '<%= tempDir %>'
|
||||
},
|
||||
|
||||
app_gen_build: {
|
||||
cwd: '<%= srcDir %>/app',
|
||||
expand: true,
|
||||
src: ['**/*.js', '**/*.html'],
|
||||
dest: '<%= srcDir %>/app_gen'
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,16 +2,29 @@ module.exports = function() {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
base: {
|
||||
build: {
|
||||
src: ['public/app/**/*.ts'],
|
||||
dest: '',
|
||||
dest: 'public/app_gen',
|
||||
options: {
|
||||
module: 'amd', //or commonjs
|
||||
target: 'es5', //or es3
|
||||
keepDirectoryHierarchy: true,
|
||||
rootDir: 'public/app',
|
||||
declaration: true,
|
||||
watch: true,
|
||||
sourceMap: true,
|
||||
generateTsConfig: true,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
src: ['public/app/**/*.ts'],
|
||||
dest: 'public/app_gen',
|
||||
options: {
|
||||
module: 'amd', //or commonjs
|
||||
target: 'es5', //or es3
|
||||
rootDir: 'public/app',
|
||||
declaration: true,
|
||||
sourceMap: true,
|
||||
watch: true,
|
||||
generateTsConfig: true,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,6 +6,23 @@ module.exports = function(config) {
|
||||
options: {
|
||||
spawn: false
|
||||
}
|
||||
},
|
||||
|
||||
app_gen: {
|
||||
files: ['<%= srcDir %>/app/**/*.js', '<%= srcDir %>/app/**/*.html'],
|
||||
tasks: ['copy:app_gen_build'],
|
||||
options: {
|
||||
spawn: false
|
||||
}
|
||||
},
|
||||
|
||||
typescript: {
|
||||
files: ['<%= srcDir %>/app/**/*.ts'],
|
||||
tasks: ['typescript:build'],
|
||||
options: {
|
||||
spawn: false
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
17
tsconfig.json
Normal file
17
tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"outDir": "public/app_gen",
|
||||
"target": "ES5",
|
||||
"rootDir": "public/app",
|
||||
"module": "amd",
|
||||
"noEmitOnError": true
|
||||
},
|
||||
"files": [
|
||||
"public/app/components/panelmeta.ts",
|
||||
"public/app/controllers/fileSearcher.ts",
|
||||
"public/app/controllers/testCtrl.ts",
|
||||
"public/app/headers/require.d.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user