Commit 84371f03 by Torkel Ödegaard

tech(typescript): more testing and migration

parent 20407bca
......@@ -80,11 +80,11 @@ function (angular, $, _, appLevelRequire) {
});
var preBootRequires = [
'core/core',
'services/all',
'features/all',
'controllers/all',
'directives/all',
'filters/all',
'components/partials',
'routes/all',
];
......
export * from './directives/cool_dir'
export * from './routes/module_loader'
export * from './filters/filters'
define(['angular', 'jquery', 'lodash', 'moment'], function (angular, $, _, moment) {
'use strict';
///<reference path="../../headers/require/require.d.ts" />
///<reference path="../../headers/angularjs/angularjs.d.ts" />
///<amd-dependency path="angular"/>
///<amd-dependency path="config"/>
///<amd-dependency path="moment"/>
///<amd-dependency path="lodash"/>
var module = angular.module('grafana.filters');
var angular = require('angular');
var jquery = require('jquery');
var moment = require('moment');
var _ = require('lodash');
module.filter('stringSort', function() {
return function(input) {
return input.sort();
};
});
var module = angular.module('grafana.filters');
module.filter('slice', function() {
return function(arr, start, end) {
if(!_.isUndefined(arr)) {
return arr.slice(start, end);
}
};
});
module.filter('stringSort', function() {
return function(input) {
return input.sort();
};
});
module.filter('slice', function() {
return function(arr, start, end) {
if(!_.isUndefined(arr)) {
return arr.slice(start, end);
}
};
});
module.filter('stringify', function() {
return function(arr) {
if(_.isObject(arr) && !_.isArray(arr)) {
return angular.toJson(arr);
} else {
return _.isNull(arr) ? null : arr.toString();
}
};
});
module.filter('stringify', function() {
return function(arr) {
if(_.isObject(arr) && !_.isArray(arr)) {
return angular.toJson(arr);
} else {
return _.isNull(arr) ? null : arr.toString();
}
};
});
module.filter('moment', function() {
return function(date,mode) {
switch(mode) {
module.filter('moment', function() {
return function(date,mode) {
switch(mode) {
case 'ago':
return moment(date).fromNow();
}
return moment(date).fromNow();
};
});
}
return moment(date).fromNow();
};
});
module.filter('noXml', function() {
var noXml = function(text) {
return _.isString(text)
? text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/'/g, '&#39;')
.replace(/"/g, '&quot;')
: text;
};
return function(text) {
return _.isArray(text)
? _.map(text, noXml)
: noXml(text);
};
});
module.filter('noXml', function() {
var noXml = function(text) {
return _.isString(text)
? text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/'/g, '&#39;')
.replace(/"/g, '&quot;')
: text;
};
return function(text) {
return _.isArray(text)
? _.map(text, noXml)
: noXml(text);
};
});
module.filter('interpolateTemplateVars', function(templateSrv) {
function interpolateTemplateVars(text, scope) {
if (scope.panel) {
return templateSrv.replaceWithText(text, scope.panel.scopedVars);
} else {
return templateSrv.replaceWithText(text, scope.row.scopedVars);
}
module.filter('interpolateTemplateVars', function(templateSrv) {
var interpolateTemplateVars : any = function (text, scope) {
if (scope.panel) {
return templateSrv.replaceWithText(text, scope.panel.scopedVars);
} else {
return templateSrv.replaceWithText(text, scope.row.scopedVars);
}
}
interpolateTemplateVars.$stateful = true;
return interpolateTemplateVars;
});
interpolateTemplateVars.$stateful = true;
return interpolateTemplateVars;
});
export function filters() {}
......@@ -15,14 +15,14 @@ module.exports = function(grunt) {
'ngtemplates',
'cssmin:build',
'ngAnnotate:build',
// 'requirejs:build',
// 'concat:js',
// 'clean:temp',
// 'filerev',
// 'remapFilerev',
// 'usemin',
// 'clean:temp',
// 'uglify:genDir'
'requirejs:build',
'concat:js',
'clean:temp',
'filerev',
'remapFilerev',
'usemin',
'clean:temp',
'uglify:genDir'
]);
// task to add [[.AppSubUrl]] to reved path
......
......@@ -54,10 +54,10 @@ module.exports = function(config,grunt) {
'jquery.flot',
'angular-strap',
'angular-dragdrop',
'core/core',
'services/all',
'features/all',
'directives/all',
'filters/all',
'controllers/all',
'routes/all',
'components/partials',
......
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