Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
72ab24f3
Commit
72ab24f3
authored
Sep 05, 2018
by
Patrick O'Carroll
Committed by
Torkel Ödegaard
Sep 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed functions to arrow functions for only-arrow-functions rule. (#13131)
parent
7c88436a
Hide whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
367 additions
and
367 deletions
+367
-367
public/app/app.ts
+4
-4
public/app/containers/Explore/utils/debounce.ts
+1
-1
public/app/core/components/gf_page.ts
+1
-1
public/app/core/components/scroll/page_scroll.ts
+1
-1
public/app/core/components/scroll/scroll.ts
+1
-1
public/app/core/controllers/invited_ctrl.ts
+4
-4
public/app/core/controllers/login_ctrl.ts
+12
-12
public/app/core/controllers/reset_password_ctrl.ts
+4
-4
public/app/core/filters/filters.ts
+12
-12
public/app/core/lodash_extended.ts
+1
-1
public/app/core/services/alert_srv.ts
+1
-1
public/app/core/services/popover_srv.ts
+3
-3
public/app/core/services/segment_srv.ts
+15
-15
public/app/core/services/util_srv.ts
+3
-3
public/app/core/specs/backend_srv.test.ts
+1
-1
public/app/core/specs/datemath.test.ts
+6
-6
public/app/core/specs/file_export.test.ts
+1
-1
public/app/core/specs/kbn.test.ts
+81
-81
public/app/core/specs/time_series.test.ts
+72
-72
public/app/core/utils/css_loader.ts
+10
-10
public/app/features/dashboard/change_tracker.ts
+1
-1
public/app/features/dashboard/dashboard_loader_srv.ts
+1
-1
public/app/features/dashboard/repeat_option/repeat_option.ts
+2
-2
public/app/features/dashboard/shareModalCtrl.ts
+4
-4
public/app/features/dashboard/share_snapshot_ctrl.ts
+18
-18
public/app/features/dashboard/timepicker/input_date.ts
+3
-3
public/app/features/dashboard/upload.ts
+4
-4
public/app/features/dashboard/view_state_srv.ts
+7
-7
public/app/features/dashlinks/module.ts
+9
-9
public/app/features/org/change_password_ctrl.ts
+2
-2
public/app/features/org/new_org_ctrl.ts
+3
-3
public/app/features/org/org_api_keys_ctrl.ts
+6
-6
public/app/features/org/select_org_ctrl.ts
+5
-5
public/app/features/panel/panel_directive.ts
+7
-7
public/app/features/panel/panel_header.ts
+2
-2
public/app/features/panel/query_troubleshooter.ts
+2
-2
public/app/features/panel/solo_panel_ctrl.ts
+3
-3
public/app/features/panellinks/module.ts
+8
-8
public/app/features/playlist/playlist_routes.ts
+1
-1
public/app/features/plugins/ds_edit_ctrl.ts
+4
-4
public/app/features/plugins/plugin_component.ts
+11
-11
public/app/features/templating/all.ts
+1
-1
public/app/features/templating/custom_variable.ts
+1
-1
public/app/features/templating/editor_ctrl.ts
+16
-16
public/app/features/templating/interval_variable.ts
+1
-1
public/app/features/templating/query_variable.ts
+2
-2
public/app/features/templating/template_srv.ts
+3
-3
public/app/features/templating/variable_srv.ts
+3
-3
public/app/routes/ReactContainer.tsx
+1
-1
public/app/routes/dashboard_loaders.ts
+2
-2
No files found.
public/app/app.ts
View file @
72ab24f3
...
...
@@ -21,7 +21,7 @@ import _ from 'lodash';
import
moment
from
'moment'
;
// add move to lodash for backward compatabiltiy
_
.
move
=
function
(
array
,
fromIndex
,
toIndex
)
{
_
.
move
=
(
array
,
fromIndex
,
toIndex
)
=>
{
array
.
splice
(
toIndex
,
0
,
array
.
splice
(
fromIndex
,
1
)[
0
]);
return
array
;
};
...
...
@@ -76,9 +76,9 @@ export class GrafanaApp {
$provide
.
decorator
(
'$http'
,
[
'$delegate'
,
'$templateCache'
,
function
(
$delegate
,
$templateCache
)
{
(
$delegate
,
$templateCache
)
=>
{
const
get
=
$delegate
.
get
;
$delegate
.
get
=
function
(
url
,
config
)
{
$delegate
.
get
=
(
url
,
config
)
=>
{
if
(
url
.
match
(
/
\.
html$/
))
{
// some template's already exist in the cache
if
(
!
$templateCache
.
get
(
url
))
{
...
...
@@ -135,7 +135,7 @@ export class GrafanaApp {
this
.
preBootModules
=
null
;
});
})
.
catch
(
function
(
err
)
{
.
catch
(
err
=>
{
console
.
log
(
'Application boot failed:'
,
err
);
});
}
...
...
public/app/containers/Explore/utils/debounce.ts
View file @
72ab24f3
...
...
@@ -4,7 +4,7 @@ export default function debounce(func, wait) {
return
function
(
this
:
any
)
{
const
context
=
this
;
const
args
=
arguments
;
const
later
=
function
()
{
const
later
=
()
=>
{
timeout
=
null
;
func
.
apply
(
context
,
args
);
};
...
...
public/app/core/components/gf_page.ts
View file @
72ab24f3
...
...
@@ -31,7 +31,7 @@ export function gfPageDirective() {
header
:
'?gfPageHeader'
,
body
:
'gfPageBody'
,
},
link
:
function
(
scope
,
elem
,
attrs
)
{
link
:
(
scope
,
elem
,
attrs
)
=>
{
console
.
log
(
scope
);
},
};
...
...
public/app/core/components/scroll/page_scroll.ts
View file @
72ab24f3
...
...
@@ -4,7 +4,7 @@ import appEvents from 'app/core/app_events';
export
function
pageScrollbar
()
{
return
{
restrict
:
'A'
,
link
:
function
(
scope
,
elem
,
attrs
)
{
link
:
(
scope
,
elem
,
attrs
)
=>
{
let
lastPos
=
0
;
appEvents
.
on
(
...
...
public/app/core/components/scroll/scroll.ts
View file @
72ab24f3
...
...
@@ -14,7 +14,7 @@ const scrollerClass = 'baron__scroller';
export
function
geminiScrollbar
()
{
return
{
restrict
:
'A'
,
link
:
function
(
scope
,
elem
,
attrs
)
{
link
:
(
scope
,
elem
,
attrs
)
=>
{
let
scrollRoot
=
elem
.
parent
();
const
scroller
=
elem
;
...
...
public/app/core/controllers/invited_ctrl.ts
View file @
72ab24f3
...
...
@@ -16,8 +16,8 @@ export class InvitedCtrl {
},
};
$scope
.
init
=
function
()
{
backendSrv
.
get
(
'/api/user/invite/'
+
$routeParams
.
code
).
then
(
function
(
invite
)
{
$scope
.
init
=
()
=>
{
backendSrv
.
get
(
'/api/user/invite/'
+
$routeParams
.
code
).
then
(
invite
=>
{
$scope
.
formModel
.
name
=
invite
.
name
;
$scope
.
formModel
.
email
=
invite
.
email
;
$scope
.
formModel
.
username
=
invite
.
email
;
...
...
@@ -28,12 +28,12 @@ export class InvitedCtrl {
});
};
$scope
.
submit
=
function
()
{
$scope
.
submit
=
()
=>
{
if
(
!
$scope
.
inviteForm
.
$valid
)
{
return
;
}
backendSrv
.
post
(
'/api/user/invite/complete'
,
$scope
.
formModel
).
then
(
function
()
{
backendSrv
.
post
(
'/api/user/invite/complete'
,
$scope
.
formModel
).
then
(
()
=>
{
window
.
location
.
href
=
config
.
appSubUrl
+
'/'
;
});
};
...
...
public/app/core/controllers/login_ctrl.ts
View file @
72ab24f3
...
...
@@ -29,7 +29,7 @@ export class LoginCtrl {
$scope
.
loginMode
=
true
;
$scope
.
submitBtnText
=
'Log in'
;
$scope
.
init
=
function
()
{
$scope
.
init
=
()
=>
{
$scope
.
$watch
(
'loginMode'
,
$scope
.
loginModeChanged
);
if
(
config
.
loginError
)
{
...
...
@@ -37,7 +37,7 @@ export class LoginCtrl {
}
};
$scope
.
submit
=
function
()
{
$scope
.
submit
=
()
=>
{
if
(
$scope
.
loginMode
)
{
$scope
.
login
();
}
else
{
...
...
@@ -45,7 +45,7 @@ export class LoginCtrl {
}
};
$scope
.
changeView
=
function
()
{
$scope
.
changeView
=
()
=>
{
const
loginView
=
document
.
querySelector
(
'#login-view'
);
const
changePasswordView
=
document
.
querySelector
(
'#change-password-view'
);
...
...
@@ -65,7 +65,7 @@ export class LoginCtrl {
},
400
);
};
$scope
.
changePassword
=
function
()
{
$scope
.
changePassword
=
()
=>
{
$scope
.
command
.
oldPassword
=
'admin'
;
if
(
$scope
.
command
.
newPassword
!==
$scope
.
command
.
confirmNew
)
{
...
...
@@ -73,25 +73,25 @@ export class LoginCtrl {
return
;
}
backendSrv
.
put
(
'/api/user/password'
,
$scope
.
command
).
then
(
function
()
{
backendSrv
.
put
(
'/api/user/password'
,
$scope
.
command
).
then
(
()
=>
{
$scope
.
toGrafana
();
});
};
$scope
.
skip
=
function
()
{
$scope
.
skip
=
()
=>
{
$scope
.
toGrafana
();
};
$scope
.
loginModeChanged
=
function
(
newValue
)
{
$scope
.
loginModeChanged
=
newValue
=>
{
$scope
.
submitBtnText
=
newValue
?
'Log in'
:
'Sign up'
;
};
$scope
.
signUp
=
function
()
{
$scope
.
signUp
=
()
=>
{
if
(
!
$scope
.
loginForm
.
$valid
)
{
return
;
}
backendSrv
.
post
(
'/api/user/signup'
,
$scope
.
formModel
).
then
(
function
(
result
)
{
backendSrv
.
post
(
'/api/user/signup'
,
$scope
.
formModel
).
then
(
result
=>
{
if
(
result
.
status
===
'SignUpCreated'
)
{
$location
.
path
(
'/signup'
).
search
({
email
:
$scope
.
formModel
.
email
});
}
else
{
...
...
@@ -100,7 +100,7 @@ export class LoginCtrl {
});
};
$scope
.
login
=
function
()
{
$scope
.
login
=
()
=>
{
delete
$scope
.
loginError
;
if
(
!
$scope
.
loginForm
.
$valid
)
{
...
...
@@ -110,7 +110,7 @@ export class LoginCtrl {
backendSrv
.
post
(
'/login'
,
$scope
.
formModel
)
.
then
(
function
(
result
)
{
.
then
(
result
=>
{
$scope
.
result
=
result
;
if
(
$scope
.
formModel
.
password
!==
'admin'
||
$scope
.
ldapEnabled
||
$scope
.
authProxyEnabled
)
{
...
...
@@ -125,7 +125,7 @@ export class LoginCtrl {
});
};
$scope
.
toGrafana
=
function
()
{
$scope
.
toGrafana
=
()
=>
{
const
params
=
$location
.
search
();
if
(
params
.
redirect
&&
params
.
redirect
[
0
]
===
'/'
)
{
...
...
public/app/core/controllers/reset_password_ctrl.ts
View file @
72ab24f3
...
...
@@ -22,16 +22,16 @@ export class ResetPasswordCtrl {
},
};
$scope
.
sendResetEmail
=
function
()
{
$scope
.
sendResetEmail
=
()
=>
{
if
(
!
$scope
.
sendResetForm
.
$valid
)
{
return
;
}
backendSrv
.
post
(
'/api/user/password/send-reset-email'
,
$scope
.
formModel
).
then
(
function
()
{
backendSrv
.
post
(
'/api/user/password/send-reset-email'
,
$scope
.
formModel
).
then
(
()
=>
{
$scope
.
mode
=
'email-sent'
;
});
};
$scope
.
submitReset
=
function
()
{
$scope
.
submitReset
=
()
=>
{
if
(
!
$scope
.
resetForm
.
$valid
)
{
return
;
}
...
...
@@ -41,7 +41,7 @@ export class ResetPasswordCtrl {
return
;
}
backendSrv
.
post
(
'/api/user/password/reset'
,
$scope
.
formModel
).
then
(
function
()
{
backendSrv
.
post
(
'/api/user/password/reset'
,
$scope
.
formModel
).
then
(
()
=>
{
$location
.
path
(
'login'
);
});
};
...
...
public/app/core/filters/filters.ts
View file @
72ab24f3
...
...
@@ -3,22 +3,22 @@ import angular from 'angular';
import
moment
from
'moment'
;
import
coreModule
from
'../core_module'
;
coreModule
.
filter
(
'stringSort'
,
function
()
{
return
function
(
input
)
{
coreModule
.
filter
(
'stringSort'
,
()
=>
{
return
input
=>
{
return
input
.
sort
();
};
});
coreModule
.
filter
(
'slice'
,
function
()
{
return
function
(
arr
,
start
,
end
)
{
coreModule
.
filter
(
'slice'
,
()
=>
{
return
(
arr
,
start
,
end
)
=>
{
if
(
!
_
.
isUndefined
(
arr
))
{
return
arr
.
slice
(
start
,
end
);
}
};
});
coreModule
.
filter
(
'stringify'
,
function
()
{
return
function
(
arr
)
{
coreModule
.
filter
(
'stringify'
,
()
=>
{
return
arr
=>
{
if
(
_
.
isObject
(
arr
)
&&
!
_
.
isArray
(
arr
))
{
return
angular
.
toJson
(
arr
);
}
else
{
...
...
@@ -27,8 +27,8 @@ coreModule.filter('stringify', function() {
};
});
coreModule
.
filter
(
'moment'
,
function
()
{
return
function
(
date
,
mode
)
{
coreModule
.
filter
(
'moment'
,
()
=>
{
return
(
date
,
mode
)
=>
{
switch
(
mode
)
{
case
'ago'
:
return
moment
(
date
).
fromNow
();
...
...
@@ -37,8 +37,8 @@ coreModule.filter('moment', function() {
};
});
coreModule
.
filter
(
'noXml'
,
function
()
{
const
noXml
=
function
(
text
)
{
coreModule
.
filter
(
'noXml'
,
()
=>
{
const
noXml
=
text
=>
{
return
_
.
isString
(
text
)
?
text
.
replace
(
/&/g
,
'&'
)
...
...
@@ -48,14 +48,14 @@ coreModule.filter('noXml', function() {
.
replace
(
/"/g
,
'"'
)
:
text
;
};
return
function
(
text
)
{
return
text
=>
{
return
_
.
isArray
(
text
)
?
_
.
map
(
text
,
noXml
)
:
noXml
(
text
);
};
});
/** @ngInject */
function
interpolateTemplateVars
(
templateSrv
)
{
const
filterFunc
:
any
=
function
(
text
,
scope
)
{
const
filterFunc
:
any
=
(
text
,
scope
)
=>
{
let
scopedVars
;
if
(
scope
.
ctrl
)
{
scopedVars
=
(
scope
.
ctrl
.
panel
||
scope
.
ctrl
.
row
).
scopedVars
;
...
...
public/app/core/lodash_extended.ts
View file @
72ab24f3
...
...
@@ -4,7 +4,7 @@ import _ from 'lodash';
Mixins :)
*/
_
.
mixin
({
move
:
function
(
array
,
fromIndex
,
toIndex
)
{
move
:
(
array
,
fromIndex
,
toIndex
)
=>
{
array
.
splice
(
toIndex
,
0
,
array
.
splice
(
fromIndex
,
1
)[
0
]);
return
array
;
},
...
...
public/app/core/services/alert_srv.ts
View file @
72ab24f3
...
...
@@ -70,7 +70,7 @@ export class AlertSrv {
const
newAlertJson
=
angular
.
toJson
(
newAlert
);
// remove same alert if it already exists
_
.
remove
(
this
.
list
,
function
(
value
)
{
_
.
remove
(
this
.
list
,
value
=>
{
return
angular
.
toJson
(
value
)
===
newAlertJson
;
});
...
...
public/app/core/services/popover_srv.ts
View file @
72ab24f3
...
...
@@ -6,13 +6,13 @@ import Drop from 'tether-drop';
function
popoverSrv
(
this
:
any
,
$compile
,
$rootScope
,
$timeout
)
{
let
openDrop
=
null
;
this
.
close
=
function
()
{
this
.
close
=
()
=>
{
if
(
openDrop
)
{
openDrop
.
close
();
}
};
this
.
show
=
function
(
options
)
{
this
.
show
=
options
=>
{
if
(
openDrop
)
{
openDrop
.
close
();
openDrop
=
null
;
...
...
@@ -68,7 +68,7 @@ function popoverSrv(this: any, $compile, $rootScope, $timeout) {
},
100
);
// return close function
return
function
()
{
return
()
=>
{
if
(
drop
)
{
drop
.
close
();
}
...
...
public/app/core/services/segment_srv.ts
View file @
72ab24f3
...
...
@@ -42,48 +42,48 @@ export function uiSegmentSrv(this: any, $sce, templateSrv) {
}
};
this
.
newSelectMeasurement
=
function
()
{
this
.
newSelectMeasurement
=
()
=>
{
return
new
MetricSegment
({
value
:
'select measurement'
,
fake
:
true
});
};
this
.
newFake
=
function
(
text
,
type
,
cssClass
)
{
this
.
newFake
=
(
text
,
type
,
cssClass
)
=>
{
return
new
MetricSegment
({
value
:
text
,
fake
:
true
,
type
:
type
,
cssClass
:
cssClass
});
};
this
.
newSegment
=
function
(
options
)
{
this
.
newSegment
=
options
=>
{
return
new
MetricSegment
(
options
);
};
this
.
newKey
=
function
(
key
)
{
this
.
newKey
=
key
=>
{
return
new
MetricSegment
({
value
:
key
,
type
:
'key'
,
cssClass
:
'query-segment-key'
});
};
this
.
newKeyValue
=
function
(
value
)
{
this
.
newKeyValue
=
value
=>
{
return
new
MetricSegment
({
value
:
value
,
type
:
'value'
,
cssClass
:
'query-segment-value'
});
};
this
.
newCondition
=
function
(
condition
)
{
this
.
newCondition
=
condition
=>
{
return
new
MetricSegment
({
value
:
condition
,
type
:
'condition'
,
cssClass
:
'query-keyword'
});
};
this
.
newOperator
=
function
(
op
)
{
this
.
newOperator
=
op
=>
{
return
new
MetricSegment
({
value
:
op
,
type
:
'operator'
,
cssClass
:
'query-segment-operator'
});
};
this
.
newOperators
=
function
(
ops
)
{
return
_
.
map
(
ops
,
function
(
op
)
{
this
.
newOperators
=
ops
=>
{
return
_
.
map
(
ops
,
op
=>
{
return
new
MetricSegment
({
value
:
op
,
type
:
'operator'
,
cssClass
:
'query-segment-operator'
});
});
};
this
.
transformToSegments
=
function
(
addTemplateVars
,
variableTypeFilter
)
{
return
function
(
results
)
{
const
segments
=
_
.
map
(
results
,
function
(
segment
)
{
this
.
transformToSegments
=
(
addTemplateVars
,
variableTypeFilter
)
=>
{
return
results
=>
{
const
segments
=
_
.
map
(
results
,
segment
=>
{
return
self
.
newSegment
({
value
:
segment
.
text
,
expandable
:
segment
.
expandable
});
});
if
(
addTemplateVars
)
{
_
.
each
(
templateSrv
.
variables
,
function
(
variable
)
{
_
.
each
(
templateSrv
.
variables
,
variable
=>
{
if
(
variableTypeFilter
===
void
0
||
variableTypeFilter
===
variable
.
type
)
{
segments
.
unshift
(
self
.
newSegment
({
type
:
'value'
,
value
:
'$'
+
variable
.
name
,
expandable
:
true
}));
}
...
...
@@ -94,11 +94,11 @@ export function uiSegmentSrv(this: any, $sce, templateSrv) {
};
};
this
.
newSelectMetric
=
function
()
{
this
.
newSelectMetric
=
()
=>
{
return
new
MetricSegment
({
value
:
'select metric'
,
fake
:
true
});
};
this
.
newPlusButton
=
function
()
{
this
.
newPlusButton
=
()
=>
{
return
new
MetricSegment
({
fake
:
true
,
html
:
'<i class="fa fa-plus "></i>'
,
...
...
public/app/core/services/util_srv.ts
View file @
72ab24f3
...
...
@@ -44,7 +44,7 @@ export class UtilSrv {
backdrop
:
options
.
backdrop
,
});
Promise
.
resolve
(
modal
).
then
(
function
(
modalEl
)
{
Promise
.
resolve
(
modal
).
then
(
modalEl
=>
{
modalEl
.
modal
(
'show'
);
});
}
...
...
@@ -52,12 +52,12 @@ export class UtilSrv {
showConfirmModal
(
payload
)
{
const
scope
=
this
.
$rootScope
.
$new
();
scope
.
onConfirm
=
function
()
{
scope
.
onConfirm
=
()
=>
{
payload
.
onConfirm
();
scope
.
dismiss
();
};
scope
.
updateConfirmText
=
function
(
value
)
{
scope
.
updateConfirmText
=
value
=>
{
scope
.
confirmTextValid
=
payload
.
confirmText
.
toLowerCase
()
===
value
.
toLowerCase
();
};
...
...
public/app/core/specs/backend_srv.test.ts
View file @
72ab24f3
import
{
BackendSrv
}
from
'app/core/services/backend_srv'
;
jest
.
mock
(
'app/core/store'
);
describe
(
'backend_srv'
,
function
()
{
describe
(
'backend_srv'
,
()
=>
{
const
_httpBackend
=
options
=>
{
if
(
options
.
url
===
'gateway-error'
)
{
return
Promise
.
reject
({
status
:
502
});
...
...
public/app/core/specs/datemath.test.ts
View file @
72ab24f3
...
...
@@ -91,11 +91,11 @@ describe('DateMath', () => {
});
_
.
each
(
spans
,
span
=>
{
it
(
'should round now to the beginning of the '
+
span
,
function
()
{
it
(
'should round now to the beginning of the '
+
span
,
()
=>
{
expect
(
dateMath
.
parse
(
'now/'
+
span
).
format
(
format
)).
toEqual
(
now
.
startOf
(
span
).
format
(
format
));
});
it
(
'should round now to the end of the '
+
span
,
function
()
{
it
(
'should round now to the end of the '
+
span
,
()
=>
{
expect
(
dateMath
.
parse
(
'now/'
+
span
,
true
).
format
(
format
)).
toEqual
(
now
.
endOf
(
span
).
format
(
format
));
});
});
...
...
@@ -114,18 +114,18 @@ describe('DateMath', () => {
});
});
describe
(
'relative time to date parsing'
,
function
()
{
it
(
'should handle negative time'
,
function
()
{
describe
(
'relative time to date parsing'
,
()
=>
{
it
(
'should handle negative time'
,
()
=>
{
const
date
=
dateMath
.
parseDateMath
(
'-2d'
,
moment
([
2014
,
1
,
5
]));
expect
(
date
.
valueOf
()).
toEqual
(
moment
([
2014
,
1
,
3
]).
valueOf
());
});
it
(
'should handle multiple math expressions'
,
function
()
{
it
(
'should handle multiple math expressions'
,
()
=>
{
const
date
=
dateMath
.
parseDateMath
(
'-2d-6h'
,
moment
([
2014
,
1
,
5
]));
expect
(
date
.
valueOf
()).
toEqual
(
moment
([
2014
,
1
,
2
,
18
]).
valueOf
());
});
it
(
'should return false when invalid expression'
,
function
()
{
it
(
'should return false when invalid expression'
,
()
=>
{
const
date
=
dateMath
.
parseDateMath
(
'2'
,
moment
([
2014
,
1
,
5
]));
expect
(
date
).
toEqual
(
undefined
);
});
...
...
public/app/core/specs/file_export.test.ts
View file @
72ab24f3
...
...
@@ -101,7 +101,7 @@ describe('file_export', () => {
expect
(
returnedText
).
toBe
(
expectedText
);
});
it
(
'should decode HTML encoded characters'
,
function
()
{
it
(
'should decode HTML encoded characters'
,
()
=>
{
const
inputTable
=
{
columns
:
[{
text
:
'string_value'
}],
rows
:
[
...
...
public/app/core/specs/kbn.test.ts
View file @
72ab24f3
...
...
@@ -2,27 +2,27 @@ import kbn from '../utils/kbn';
import
*
as
dateMath
from
'../utils/datemath'
;
import
moment
from
'moment'
;
describe
(
'unit format menu'
,
function
()
{
describe
(
'unit format menu'
,
()
=>
{
const
menu
=
kbn
.
getUnitFormats
();
menu
.
map
(
function
(
submenu
)
{
describe
(
'submenu '
+
submenu
.
text
,
function
()
{
it
(
'should have a title'
,
function
()
{
menu
.
map
(
submenu
=>
{
describe
(
'submenu '
+
submenu
.
text
,
()
=>
{
it
(
'should have a title'
,
()
=>
{
expect
(
typeof
submenu
.
text
).
toBe
(
'string'
);
});
it
(
'should have a submenu'
,
function
()
{
it
(
'should have a submenu'
,
()
=>
{
expect
(
Array
.
isArray
(
submenu
.
submenu
)).
toBe
(
true
);
});
submenu
.
submenu
.
map
(
function
(
entry
)
{
describe
(
'entry '
+
entry
.
text
,
function
()
{
it
(
'should have a title'
,
function
()
{
submenu
.
submenu
.
map
(
entry
=>
{
describe
(
'entry '
+
entry
.
text
,
()
=>
{
it
(
'should have a title'
,
()
=>
{
expect
(
typeof
entry
.
text
).
toBe
(
'string'
);
});
it
(
'should have a format'
,
function
()
{
it
(
'should have a format'
,
()
=>
{
expect
(
typeof
entry
.
value
).
toBe
(
'string'
);
});
it
(
'should have a valid format'
,
function
()
{
it
(
'should have a valid format'
,
()
=>
{
expect
(
typeof
kbn
.
valueFormats
[
entry
.
value
]).
toBe
(
'function'
);
});
});
...
...
@@ -32,8 +32,8 @@ describe('unit format menu', function() {
});
function
describeValueFormat
(
desc
,
value
,
tickSize
,
tickDecimals
,
result
)
{
describe
(
'value format: '
+
desc
,
function
()
{
it
(
'should translate '
+
value
+
' as '
+
result
,
function
()
{
describe
(
'value format: '
+
desc
,
()
=>
{
it
(
'should translate '
+
value
+
' as '
+
result
,
()
=>
{
const
scaledDecimals
=
tickDecimals
-
Math
.
floor
(
Math
.
log
(
tickSize
)
/
Math
.
LN10
);
const
str
=
kbn
.
valueFormats
[
desc
](
value
,
tickDecimals
,
scaledDecimals
);
expect
(
str
).
toBe
(
result
);
...
...
@@ -100,85 +100,85 @@ describeValueFormat('d', 3, 1, 0, '3 day');
describeValueFormat
(
'd'
,
245
,
100
,
0
,
'35 week'
);
describeValueFormat
(
'd'
,
2456
,
10
,
0
,
'6.73 year'
);
describe
(
'date time formats'
,
function
()
{
describe
(
'date time formats'
,
()
=>
{
const
epoch
=
1505634997920
;
const
utcTime
=
moment
.
utc
(
epoch
);
const
browserTime
=
moment
(
epoch
);
it
(
'should format as iso date'
,
function
()
{
it
(
'should format as iso date'
,
()
=>
{
const
expected
=
browserTime
.
format
(
'YYYY-MM-DD HH:mm:ss'
);
const
actual
=
kbn
.
valueFormats
.
dateTimeAsIso
(
epoch
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as iso date (in UTC)'
,
function
()
{
it
(
'should format as iso date (in UTC)'
,
()
=>
{
const
expected
=
utcTime
.
format
(
'YYYY-MM-DD HH:mm:ss'
);
const
actual
=
kbn
.
valueFormats
.
dateTimeAsIso
(
epoch
,
true
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as iso date and skip date when today'
,
function
()
{
it
(
'should format as iso date and skip date when today'
,
()
=>
{
const
now
=
moment
();
const
expected
=
now
.
format
(
'HH:mm:ss'
);
const
actual
=
kbn
.
valueFormats
.
dateTimeAsIso
(
now
.
valueOf
(),
false
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as iso date (in UTC) and skip date when today'
,
function
()
{
it
(
'should format as iso date (in UTC) and skip date when today'
,
()
=>
{
const
now
=
moment
.
utc
();
const
expected
=
now
.
format
(
'HH:mm:ss'
);
const
actual
=
kbn
.
valueFormats
.
dateTimeAsIso
(
now
.
valueOf
(),
true
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as US date'
,
function
()
{
it
(
'should format as US date'
,
()
=>
{
const
expected
=
browserTime
.
format
(
'MM/DD/YYYY h:mm:ss a'
);
const
actual
=
kbn
.
valueFormats
.
dateTimeAsUS
(
epoch
,
false
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as US date (in UTC)'
,
function
()
{
it
(
'should format as US date (in UTC)'
,
()
=>
{
const
expected
=
utcTime
.
format
(
'MM/DD/YYYY h:mm:ss a'
);
const
actual
=
kbn
.
valueFormats
.
dateTimeAsUS
(
epoch
,
true
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as US date and skip date when today'
,
function
()
{
it
(
'should format as US date and skip date when today'
,
()
=>
{
const
now
=
moment
();
const
expected
=
now
.
format
(
'h:mm:ss a'
);
const
actual
=
kbn
.
valueFormats
.
dateTimeAsUS
(
now
.
valueOf
(),
false
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as US date (in UTC) and skip date when today'
,
function
()
{
it
(
'should format as US date (in UTC) and skip date when today'
,
()
=>
{
const
now
=
moment
.
utc
();
const
expected
=
now
.
format
(
'h:mm:ss a'
);
const
actual
=
kbn
.
valueFormats
.
dateTimeAsUS
(
now
.
valueOf
(),
true
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as from now with days'
,
function
()
{
it
(
'should format as from now with days'
,
()
=>
{
const
daysAgo
=
moment
().
add
(
-
7
,
'd'
);
const
expected
=
'7 days ago'
;
const
actual
=
kbn
.
valueFormats
.
dateTimeFromNow
(
daysAgo
.
valueOf
(),
false
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as from now with days (in UTC)'
,
function
()
{
it
(
'should format as from now with days (in UTC)'
,
()
=>
{
const
daysAgo
=
moment
.
utc
().
add
(
-
7
,
'd'
);
const
expected
=
'7 days ago'
;
const
actual
=
kbn
.
valueFormats
.
dateTimeFromNow
(
daysAgo
.
valueOf
(),
true
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as from now with minutes'
,
function
()
{
it
(
'should format as from now with minutes'
,
()
=>
{
const
daysAgo
=
moment
().
add
(
-
2
,
'm'
);
const
expected
=
'2 minutes ago'
;
const
actual
=
kbn
.
valueFormats
.
dateTimeFromNow
(
daysAgo
.
valueOf
(),
false
);
expect
(
actual
).
toBe
(
expected
);
});
it
(
'should format as from now with minutes (in UTC)'
,
function
()
{
it
(
'should format as from now with minutes (in UTC)'
,
()
=>
{
const
daysAgo
=
moment
.
utc
().
add
(
-
2
,
'm'
);
const
expected
=
'2 minutes ago'
;
const
actual
=
kbn
.
valueFormats
.
dateTimeFromNow
(
daysAgo
.
valueOf
(),
true
);
...
...
@@ -186,92 +186,92 @@ describe('date time formats', function() {
});
});
describe
(
'kbn.toFixed and negative decimals'
,
function
()
{
it
(
'should treat as zero decimals'
,
function
()
{
describe
(
'kbn.toFixed and negative decimals'
,
()
=>
{
it
(
'should treat as zero decimals'
,
()
=>
{
const
str
=
kbn
.
toFixed
(
186.123
,
-
2
);
expect
(
str
).
toBe
(
'186'
);
});
});
describe
(
'kbn ms format when scaled decimals is null do not use it'
,
function
()
{
it
(
'should use specified decimals'
,
function
()
{
describe
(
'kbn ms format when scaled decimals is null do not use it'
,
()
=>
{
it
(
'should use specified decimals'
,
()
=>
{
const
str
=
kbn
.
valueFormats
[
'ms'
](
10000086.123
,
1
,
null
);
expect
(
str
).
toBe
(
'2.8 hour'
);
});
});
describe
(
'kbn kbytes format when scaled decimals is null do not use it'
,
function
()
{
it
(
'should use specified decimals'
,
function
()
{
describe
(
'kbn kbytes format when scaled decimals is null do not use it'
,
()
=>
{
it
(
'should use specified decimals'
,
()
=>
{
const
str
=
kbn
.
valueFormats
[
'kbytes'
](
10000000
,
3
,
null
);
expect
(
str
).
toBe
(
'9.537 GiB'
);
});
});
describe
(
'kbn deckbytes format when scaled decimals is null do not use it'
,
function
()
{
it
(
'should use specified decimals'
,
function
()
{
describe
(
'kbn deckbytes format when scaled decimals is null do not use it'
,
()
=>
{
it
(
'should use specified decimals'
,
()
=>
{
const
str
=
kbn
.
valueFormats
[
'deckbytes'
](
10000000
,
3
,
null
);
expect
(
str
).
toBe
(
'10.000 GB'
);
});
});
describe
(
'kbn roundValue'
,
function
()
{
it
(
'should should handle null value'
,
function
()
{
describe
(
'kbn roundValue'
,
()
=>
{
it
(
'should should handle null value'
,
()
=>
{
const
str
=
kbn
.
roundValue
(
null
,
2
);
expect
(
str
).
toBe
(
null
);
});
it
(
'should round value'
,
function
()
{
it
(
'should round value'
,
()
=>
{
const
str
=
kbn
.
roundValue
(
200.877
,
2
);
expect
(
str
).
toBe
(
200.88
);
});
});
describe
(
'calculateInterval'
,
function
()
{
it
(
'1h 100 resultion'
,
function
()
{
describe
(
'calculateInterval'
,
()
=>
{
it
(
'1h 100 resultion'
,
()
=>
{
const
range
=
{
from
:
dateMath
.
parse
(
'now-1h'
),
to
:
dateMath
.
parse
(
'now'
)
};
const
res
=
kbn
.
calculateInterval
(
range
,
100
,
null
);
expect
(
res
.
interval
).
toBe
(
'30s'
);
});
it
(
'10m 1600 resolution'
,
function
()
{
it
(
'10m 1600 resolution'
,
()
=>
{
const
range
=
{
from
:
dateMath
.
parse
(
'now-10m'
),
to
:
dateMath
.
parse
(
'now'
)
};
const
res
=
kbn
.
calculateInterval
(
range
,
1600
,
null
);
expect
(
res
.
interval
).
toBe
(
'500ms'
);
expect
(
res
.
intervalMs
).
toBe
(
500
);
});
it
(
'fixed user min interval'
,
function
()
{
it
(
'fixed user min interval'
,
()
=>
{
const
range
=
{
from
:
dateMath
.
parse
(
'now-10m'
),
to
:
dateMath
.
parse
(
'now'
)
};
const
res
=
kbn
.
calculateInterval
(
range
,
1600
,
'10s'
);
expect
(
res
.
interval
).
toBe
(
'10s'
);
expect
(
res
.
intervalMs
).
toBe
(
10000
);
});
it
(
'short time range and user low limit'
,
function
()
{
it
(
'short time range and user low limit'
,
()
=>
{
const
range
=
{
from
:
dateMath
.
parse
(
'now-10m'
),
to
:
dateMath
.
parse
(
'now'
)
};
const
res
=
kbn
.
calculateInterval
(
range
,
1600
,
'>10s'
);
expect
(
res
.
interval
).
toBe
(
'10s'
);
});
it
(
'large time range and user low limit'
,
function
()
{
it
(
'large time range and user low limit'
,
()
=>
{
const
range
=
{
from
:
dateMath
.
parse
(
'now-14d'
),
to
:
dateMath
.
parse
(
'now'
)
};
const
res
=
kbn
.
calculateInterval
(
range
,
1000
,
'>10s'
);
expect
(
res
.
interval
).
toBe
(
'20m'
);
});
it
(
'10s 900 resolution and user low limit in ms'
,
function
()
{
it
(
'10s 900 resolution and user low limit in ms'
,
()
=>
{
const
range
=
{
from
:
dateMath
.
parse
(
'now-10s'
),
to
:
dateMath
.
parse
(
'now'
)
};
const
res
=
kbn
.
calculateInterval
(
range
,
900
,
'>15ms'
);
expect
(
res
.
interval
).
toBe
(
'15ms'
);
});
it
(
'1d 1 resolution'
,
function
()
{
it
(
'1d 1 resolution'
,
()
=>
{
const
range
=
{
from
:
dateMath
.
parse
(
'now-1d'
),
to
:
dateMath
.
parse
(
'now'
)
};
const
res
=
kbn
.
calculateInterval
(
range
,
1
,
null
);
expect
(
res
.
interval
).
toBe
(
'1d'
);
expect
(
res
.
intervalMs
).
toBe
(
86400000
);
});
it
(
'86399s 1 resolution'
,
function
()
{
it
(
'86399s 1 resolution'
,
()
=>
{
const
range
=
{
from
:
dateMath
.
parse
(
'now-86390s'
),
to
:
dateMath
.
parse
(
'now'
),
...
...
@@ -282,140 +282,140 @@ describe('calculateInterval', function() {
});
});
describe
(
'hex'
,
function
()
{
it
(
'positive integer'
,
function
()
{
describe
(
'hex'
,
()
=>
{
it
(
'positive integer'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex
(
100
,
0
);
expect
(
str
).
toBe
(
'64'
);
});
it
(
'negative integer'
,
function
()
{
it
(
'negative integer'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex
(
-
100
,
0
);
expect
(
str
).
toBe
(
'-64'
);
});
it
(
'null'
,
function
()
{
it
(
'null'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex
(
null
,
0
);
expect
(
str
).
toBe
(
''
);
});
it
(
'positive float'
,
function
()
{
it
(
'positive float'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex
(
50.52
,
1
);
expect
(
str
).
toBe
(
'32.8'
);
});
it
(
'negative float'
,
function
()
{
it
(
'negative float'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex
(
-
50.333
,
2
);
expect
(
str
).
toBe
(
'-32.547AE147AE14'
);
});
});
describe
(
'hex 0x'
,
function
()
{
it
(
'positive integeter'
,
function
()
{
describe
(
'hex 0x'
,
()
=>
{
it
(
'positive integeter'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex0x
(
7999
,
0
);
expect
(
str
).
toBe
(
'0x1F3F'
);
});
it
(
'negative integer'
,
function
()
{
it
(
'negative integer'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex0x
(
-
584
,
0
);
expect
(
str
).
toBe
(
'-0x248'
);
});
it
(
'null'
,
function
()
{
it
(
'null'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex0x
(
null
,
0
);
expect
(
str
).
toBe
(
''
);
});
it
(
'positive float'
,
function
()
{
it
(
'positive float'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex0x
(
74.443
,
3
);
expect
(
str
).
toBe
(
'0x4A.716872B020C4'
);
});
it
(
'negative float'
,
function
()
{
it
(
'negative float'
,
()
=>
{
const
str
=
kbn
.
valueFormats
.
hex0x
(
-
65.458
,
1
);
expect
(
str
).
toBe
(
'-0x41.8'
);
});
});
describe
(
'duration'
,
function
()
{
it
(
'null'
,
function
()
{
describe
(
'duration'
,
()
=>
{
it
(
'null'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
null
,
0
,
'millisecond'
);
expect
(
str
).
toBe
(
''
);
});
it
(
'0 milliseconds'
,
function
()
{
it
(
'0 milliseconds'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
0
,
0
,
'millisecond'
);
expect
(
str
).
toBe
(
'0 milliseconds'
);
});
it
(
'1 millisecond'
,
function
()
{
it
(
'1 millisecond'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1
,
0
,
'millisecond'
);
expect
(
str
).
toBe
(
'1 millisecond'
);
});
it
(
'-1 millisecond'
,
function
()
{
it
(
'-1 millisecond'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
-
1
,
0
,
'millisecond'
);
expect
(
str
).
toBe
(
'1 millisecond ago'
);
});
it
(
'seconds'
,
function
()
{
it
(
'seconds'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1
,
0
,
'second'
);
expect
(
str
).
toBe
(
'1 second'
);
});
it
(
'minutes'
,
function
()
{
it
(
'minutes'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1
,
0
,
'minute'
);
expect
(
str
).
toBe
(
'1 minute'
);
});
it
(
'hours'
,
function
()
{
it
(
'hours'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1
,
0
,
'hour'
);
expect
(
str
).
toBe
(
'1 hour'
);
});
it
(
'days'
,
function
()
{
it
(
'days'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1
,
0
,
'day'
);
expect
(
str
).
toBe
(
'1 day'
);
});
it
(
'weeks'
,
function
()
{
it
(
'weeks'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1
,
0
,
'week'
);
expect
(
str
).
toBe
(
'1 week'
);
});
it
(
'months'
,
function
()
{
it
(
'months'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1
,
0
,
'month'
);
expect
(
str
).
toBe
(
'1 month'
);
});
it
(
'years'
,
function
()
{
it
(
'years'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1
,
0
,
'year'
);
expect
(
str
).
toBe
(
'1 year'
);
});
it
(
'decimal days'
,
function
()
{
it
(
'decimal days'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1.5
,
2
,
'day'
);
expect
(
str
).
toBe
(
'1 day, 12 hours, 0 minutes'
);
});
it
(
'decimal months'
,
function
()
{
it
(
'decimal months'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
1.5
,
3
,
'month'
);
expect
(
str
).
toBe
(
'1 month, 2 weeks, 1 day, 0 hours'
);
});
it
(
'no decimals'
,
function
()
{
it
(
'no decimals'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
38898367008
,
0
,
'millisecond'
);
expect
(
str
).
toBe
(
'1 year'
);
});
it
(
'1 decimal'
,
function
()
{
it
(
'1 decimal'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
38898367008
,
1
,
'millisecond'
);
expect
(
str
).
toBe
(
'1 year, 2 months'
);
});
it
(
'too many decimals'
,
function
()
{
it
(
'too many decimals'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
38898367008
,
20
,
'millisecond'
);
expect
(
str
).
toBe
(
'1 year, 2 months, 3 weeks, 4 days, 5 hours, 6 minutes, 7 seconds, 8 milliseconds'
);
});
it
(
'floating point error'
,
function
()
{
it
(
'floating point error'
,
()
=>
{
const
str
=
kbn
.
toDuration
(
36993906007
,
8
,
'millisecond'
);
expect
(
str
).
toBe
(
'1 year, 2 months, 0 weeks, 3 days, 4 hours, 5 minutes, 6 seconds, 7 milliseconds'
);
});
});
describe
(
'volume'
,
function
()
{
it
(
'1000m3'
,
function
()
{
describe
(
'volume'
,
()
=>
{
it
(
'1000m3'
,
()
=>
{
const
str
=
kbn
.
valueFormats
[
'm3'
](
1000
,
1
,
null
);
expect
(
str
).
toBe
(
'1000.0 m³'
);
});
});
describe
(
'hh:mm:ss'
,
function
()
{
it
(
'00:04:06'
,
function
()
{
describe
(
'hh:mm:ss'
,
()
=>
{
it
(
'00:04:06'
,
()
=>
{
const
str
=
kbn
.
valueFormats
[
'dthms'
](
246
,
1
);
expect
(
str
).
toBe
(
'00:04:06'
);
});
it
(
'24:00:00'
,
function
()
{
it
(
'24:00:00'
,
()
=>
{
const
str
=
kbn
.
valueFormats
[
'dthms'
](
86400
,
1
);
expect
(
str
).
toBe
(
'24:00:00'
);
});
it
(
'6824413:53:20'
,
function
()
{
it
(
'6824413:53:20'
,
()
=>
{
const
str
=
kbn
.
valueFormats
[
'dthms'
](
24567890000
,
1
);
expect
(
str
).
toBe
(
'6824413:53:20'
);
});
...
...
public/app/core/specs/time_series.test.ts
View file @
72ab24f3
import
TimeSeries
from
'app/core/time_series2'
;
import
{
updateLegendValues
}
from
'app/core/time_series2'
;
describe
(
'TimeSeries'
,
function
()
{
describe
(
'TimeSeries'
,
()
=>
{
let
points
,
series
;
const
yAxisFormats
=
[
'short'
,
'ms'
];
let
testData
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
testData
=
{
alias
:
'test'
,
datapoints
:
[[
1
,
2
],
[
null
,
3
],
[
10
,
4
],
[
8
,
5
]],
};
});
describe
(
'when getting flot pairs'
,
function
()
{
it
(
'with connected style, should ignore nulls'
,
function
()
{
describe
(
'when getting flot pairs'
,
()
=>
{
it
(
'with connected style, should ignore nulls'
,
()
=>
{
series
=
new
TimeSeries
(
testData
);
points
=
series
.
getFlotPairs
(
'connected'
,
yAxisFormats
);
expect
(
points
.
length
).
toBe
(
3
);
});
it
(
'with null as zero style, should replace nulls with zero'
,
function
()
{
it
(
'with null as zero style, should replace nulls with zero'
,
()
=>
{
series
=
new
TimeSeries
(
testData
);
points
=
series
.
getFlotPairs
(
'null as zero'
,
yAxisFormats
);
expect
(
points
.
length
).
toBe
(
4
);
expect
(
points
[
1
][
1
]).
toBe
(
0
);
});
it
(
'if last is null current should pick next to last'
,
function
()
{
it
(
'if last is null current should pick next to last'
,
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
10
,
1
],
[
null
,
2
]],
});
...
...
@@ -35,7 +35,7 @@ describe('TimeSeries', function() {
expect
(
series
.
stats
.
current
).
toBe
(
10
);
});
it
(
'max value should work for negative values'
,
function
()
{
it
(
'max value should work for negative values'
,
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
-
10
,
1
],
[
-
4
,
2
]],
});
...
...
@@ -43,13 +43,13 @@ describe('TimeSeries', function() {
expect
(
series
.
stats
.
max
).
toBe
(
-
4
);
});
it
(
'average value should ignore nulls'
,
function
()
{
it
(
'average value should ignore nulls'
,
()
=>
{
series
=
new
TimeSeries
(
testData
);
series
.
getFlotPairs
(
'null'
,
yAxisFormats
);
expect
(
series
.
stats
.
avg
).
toBe
(
6.333333333333333
);
});
it
(
'the delta value should account for nulls'
,
function
()
{
it
(
'the delta value should account for nulls'
,
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
1
,
2
],
[
3
,
3
],
[
null
,
4
],
[
10
,
5
],
[
15
,
6
]],
});
...
...
@@ -57,7 +57,7 @@ describe('TimeSeries', function() {
expect
(
series
.
stats
.
delta
).
toBe
(
14
);
});
it
(
'the delta value should account for nulls on first'
,
function
()
{
it
(
'the delta value should account for nulls on first'
,
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
null
,
2
],
[
1
,
3
],
[
10
,
4
],
[
15
,
5
]],
});
...
...
@@ -65,7 +65,7 @@ describe('TimeSeries', function() {
expect
(
series
.
stats
.
delta
).
toBe
(
14
);
});
it
(
'the delta value should account for nulls on last'
,
function
()
{
it
(
'the delta value should account for nulls on last'
,
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
1
,
2
],
[
5
,
3
],
[
10
,
4
],
[
null
,
5
]],
});
...
...
@@ -73,7 +73,7 @@ describe('TimeSeries', function() {
expect
(
series
.
stats
.
delta
).
toBe
(
9
);
});
it
(
'the delta value should account for resets'
,
function
()
{
it
(
'the delta value should account for resets'
,
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
1
,
2
],
[
5
,
3
],
[
10
,
4
],
[
0
,
5
],
[
10
,
6
]],
});
...
...
@@ -81,7 +81,7 @@ describe('TimeSeries', function() {
expect
(
series
.
stats
.
delta
).
toBe
(
19
);
});
it
(
'the delta value should account for resets on last'
,
function
()
{
it
(
'the delta value should account for resets on last'
,
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
1
,
2
],
[
2
,
3
],
[
10
,
4
],
[
8
,
5
]],
});
...
...
@@ -89,13 +89,13 @@ describe('TimeSeries', function() {
expect
(
series
.
stats
.
delta
).
toBe
(
17
);
});
it
(
'the range value should be max - min'
,
function
()
{
it
(
'the range value should be max - min'
,
()
=>
{
series
=
new
TimeSeries
(
testData
);
series
.
getFlotPairs
(
'null'
,
yAxisFormats
);
expect
(
series
.
stats
.
range
).
toBe
(
9
);
});
it
(
'first value should ingone nulls'
,
function
()
{
it
(
'first value should ingone nulls'
,
()
=>
{
series
=
new
TimeSeries
(
testData
);
series
.
getFlotPairs
(
'null'
,
yAxisFormats
);
expect
(
series
.
stats
.
first
).
toBe
(
1
);
...
...
@@ -106,13 +106,13 @@ describe('TimeSeries', function() {
expect
(
series
.
stats
.
first
).
toBe
(
1
);
});
it
(
'with null as zero style, average value should treat nulls as 0'
,
function
()
{
it
(
'with null as zero style, average value should treat nulls as 0'
,
()
=>
{
series
=
new
TimeSeries
(
testData
);
series
.
getFlotPairs
(
'null as zero'
,
yAxisFormats
);
expect
(
series
.
stats
.
avg
).
toBe
(
4.75
);
});
it
(
'average value should be null if all values is null'
,
function
()
{
it
(
'average value should be null if all values is null'
,
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
null
,
2
],
[
null
,
3
],
[
null
,
4
],
[
null
,
5
]],
});
...
...
@@ -120,7 +120,7 @@ describe('TimeSeries', function() {
expect
(
series
.
stats
.
avg
).
toBe
(
null
);
});
it
(
'calculates timeStep'
,
function
()
{
it
(
'calculates timeStep'
,
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
null
,
1
],
[
null
,
2
],
[
null
,
3
]],
});
...
...
@@ -135,190 +135,190 @@ describe('TimeSeries', function() {
});
});
describe
(
'When checking if ms resolution is needed'
,
function
()
{
describe
(
'msResolution with second resolution timestamps'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'When checking if ms resolution is needed'
,
()
=>
{
describe
(
'msResolution with second resolution timestamps'
,
()
=>
{
beforeEach
(
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
45
,
1234567890
],
[
60
,
1234567899
]],
});
});
it
(
'should set hasMsResolution to false'
,
function
()
{
it
(
'should set hasMsResolution to false'
,
()
=>
{
expect
(
series
.
hasMsResolution
).
toBe
(
false
);
});
});
describe
(
'msResolution with millisecond resolution timestamps'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'msResolution with millisecond resolution timestamps'
,
()
=>
{
beforeEach
(
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
55
,
1236547890001
],
[
90
,
1234456709000
]],
});
});
it
(
'should show millisecond resolution tooltip'
,
function
()
{
it
(
'should show millisecond resolution tooltip'
,
()
=>
{
expect
(
series
.
hasMsResolution
).
toBe
(
true
);
});
});
describe
(
'msResolution with millisecond resolution timestamps but with trailing zeroes'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'msResolution with millisecond resolution timestamps but with trailing zeroes'
,
()
=>
{
beforeEach
(
()
=>
{
series
=
new
TimeSeries
({
datapoints
:
[[
45
,
1234567890000
],
[
60
,
1234567899000
]],
});
});
it
(
'should not show millisecond resolution tooltip'
,
function
()
{
it
(
'should not show millisecond resolution tooltip'
,
()
=>
{
expect
(
series
.
hasMsResolution
).
toBe
(
false
);
});
});
});
describe
(
'can detect if series contains ms precision'
,
function
()
{
describe
(
'can detect if series contains ms precision'
,
()
=>
{
let
fakedata
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
fakedata
=
testData
;
});
it
(
'missing datapoint with ms precision'
,
function
()
{
it
(
'missing datapoint with ms precision'
,
()
=>
{
fakedata
.
datapoints
[
0
]
=
[
1337
,
1234567890000
];
series
=
new
TimeSeries
(
fakedata
);
expect
(
series
.
isMsResolutionNeeded
()).
toBe
(
false
);
});
it
(
'contains datapoint with ms precision'
,
function
()
{
it
(
'contains datapoint with ms precision'
,
()
=>
{
fakedata
.
datapoints
[
0
]
=
[
1337
,
1236547890001
];
series
=
new
TimeSeries
(
fakedata
);
expect
(
series
.
isMsResolutionNeeded
()).
toBe
(
true
);
});
});
describe
(
'series overrides'
,
function
()
{
describe
(
'series overrides'
,
()
=>
{
let
series
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
series
=
new
TimeSeries
(
testData
);
});
describe
(
'fill & points'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'fill & points'
,
()
=>
{
beforeEach
(
()
=>
{
series
.
alias
=
'test'
;
series
.
applySeriesOverrides
([{
alias
:
'test'
,
fill
:
0
,
points
:
true
}]);
});
it
(
'should set fill zero, and enable points'
,
function
()
{
it
(
'should set fill zero, and enable points'
,
()
=>
{
expect
(
series
.
lines
.
fill
).
toBe
(
0.001
);
expect
(
series
.
points
.
show
).
toBe
(
true
);
});
});
describe
(
'series option overrides, bars, true & lines false'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'series option overrides, bars, true & lines false'
,
()
=>
{
beforeEach
(
()
=>
{
series
.
alias
=
'test'
;
series
.
applySeriesOverrides
([{
alias
:
'test'
,
bars
:
true
,
lines
:
false
}]);
});
it
(
'should disable lines, and enable bars'
,
function
()
{
it
(
'should disable lines, and enable bars'
,
()
=>
{
expect
(
series
.
lines
.
show
).
toBe
(
false
);
expect
(
series
.
bars
.
show
).
toBe
(
true
);
});
});
describe
(
'series option overrides, linewidth, stack'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'series option overrides, linewidth, stack'
,
()
=>
{
beforeEach
(
()
=>
{
series
.
alias
=
'test'
;
series
.
applySeriesOverrides
([{
alias
:
'test'
,
linewidth
:
5
,
stack
:
false
}]);
});
it
(
'should disable stack, and set lineWidth'
,
function
()
{
it
(
'should disable stack, and set lineWidth'
,
()
=>
{
expect
(
series
.
stack
).
toBe
(
false
);
expect
(
series
.
lines
.
lineWidth
).
toBe
(
5
);
});
});
describe
(
'series option overrides, dashes and lineWidth'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'series option overrides, dashes and lineWidth'
,
()
=>
{
beforeEach
(
()
=>
{
series
.
alias
=
'test'
;
series
.
applySeriesOverrides
([{
alias
:
'test'
,
linewidth
:
5
,
dashes
:
true
}]);
});
it
(
'should enable dashes, set dashes lineWidth to 5 and lines lineWidth to 0'
,
function
()
{
it
(
'should enable dashes, set dashes lineWidth to 5 and lines lineWidth to 0'
,
()
=>
{
expect
(
series
.
dashes
.
show
).
toBe
(
true
);
expect
(
series
.
dashes
.
lineWidth
).
toBe
(
5
);
expect
(
series
.
lines
.
lineWidth
).
toBe
(
0
);
});
});
describe
(
'series option overrides, fill below to'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'series option overrides, fill below to'
,
()
=>
{
beforeEach
(
()
=>
{
series
.
alias
=
'test'
;
series
.
applySeriesOverrides
([{
alias
:
'test'
,
fillBelowTo
:
'min'
}]);
});
it
(
'should disable line fill and add fillBelowTo'
,
function
()
{
it
(
'should disable line fill and add fillBelowTo'
,
()
=>
{
expect
(
series
.
fillBelowTo
).
toBe
(
'min'
);
});
});
describe
(
'series option overrides, pointradius, steppedLine'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'series option overrides, pointradius, steppedLine'
,
()
=>
{
beforeEach
(
()
=>
{
series
.
alias
=
'test'
;
series
.
applySeriesOverrides
([{
alias
:
'test'
,
pointradius
:
5
,
steppedLine
:
true
}]);
});
it
(
'should set pointradius, and set steppedLine'
,
function
()
{
it
(
'should set pointradius, and set steppedLine'
,
()
=>
{
expect
(
series
.
points
.
radius
).
toBe
(
5
);
expect
(
series
.
lines
.
steps
).
toBe
(
true
);
});
});
describe
(
'override match on regex'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'override match on regex'
,
()
=>
{
beforeEach
(
()
=>
{
series
.
alias
=
'test_01'
;
series
.
applySeriesOverrides
([{
alias
:
'/.*01/'
,
lines
:
false
}]);
});
it
(
'should match second series'
,
function
()
{
it
(
'should match second series'
,
()
=>
{
expect
(
series
.
lines
.
show
).
toBe
(
false
);
});
});
describe
(
'override series y-axis, and z-index'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'override series y-axis, and z-index'
,
()
=>
{
beforeEach
(
()
=>
{
series
.
alias
=
'test'
;
series
.
applySeriesOverrides
([{
alias
:
'test'
,
yaxis
:
2
,
zindex
:
2
}]);
});
it
(
'should set yaxis'
,
function
()
{
it
(
'should set yaxis'
,
()
=>
{
expect
(
series
.
yaxis
).
toBe
(
2
);
});
it
(
'should set zindex'
,
function
()
{
it
(
'should set zindex'
,
()
=>
{
expect
(
series
.
zindex
).
toBe
(
2
);
});
});
describe
(
'override color'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'override color'
,
()
=>
{
beforeEach
(
()
=>
{
series
.
applySeriesOverrides
([{
alias
:
'test'
,
color
:
'#112233'
}]);
});
it
(
'should set color'
,
function
()
{
it
(
'should set color'
,
()
=>
{
expect
(
series
.
color
).
toBe
(
'#112233'
);
});
it
(
'should set bars.fillColor'
,
function
()
{
it
(
'should set bars.fillColor'
,
()
=>
{
expect
(
series
.
bars
.
fillColor
).
toBe
(
'#112233'
);
});
});
});
describe
(
'value formatter'
,
function
()
{
describe
(
'value formatter'
,
()
=>
{
let
series
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
series
=
new
TimeSeries
(
testData
);
});
it
(
'should format non-numeric values as empty string'
,
function
()
{
it
(
'should format non-numeric values as empty string'
,
()
=>
{
expect
(
series
.
formatValue
(
null
)).
toBe
(
''
);
expect
(
series
.
formatValue
(
undefined
)).
toBe
(
''
);
expect
(
series
.
formatValue
(
NaN
)).
toBe
(
''
);
...
...
@@ -327,10 +327,10 @@ describe('TimeSeries', function() {
});
});
describe
(
'legend decimals'
,
function
()
{
describe
(
'legend decimals'
,
()
=>
{
let
series
,
panel
;
const
height
=
200
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
testData
=
{
alias
:
'test'
,
datapoints
:
[[
1
,
2
],
[
0
,
3
],
[
10
,
4
],
[
8
,
5
]],
...
...
@@ -347,14 +347,14 @@ describe('TimeSeries', function() {
};
});
it
(
'should set decimals based on Y axis (expect calculated decimals = 1)'
,
function
()
{
it
(
'should set decimals based on Y axis (expect calculated decimals = 1)'
,
()
=>
{
const
data
=
[
series
];
// Expect ticks with this data will have decimals = 1
updateLegendValues
(
data
,
panel
,
height
);
expect
(
data
[
0
].
decimals
).
toBe
(
2
);
});
it
(
'should set decimals based on Y axis to 0 if calculated decimals = 0)'
,
function
()
{
it
(
'should set decimals based on Y axis to 0 if calculated decimals = 0)'
,
()
=>
{
testData
.
datapoints
=
[[
10
,
2
],
[
0
,
3
],
[
100
,
4
],
[
80
,
5
]];
series
=
new
TimeSeries
(
testData
);
series
.
getFlotPairs
();
...
...
@@ -363,14 +363,14 @@ describe('TimeSeries', function() {
expect
(
data
[
0
].
decimals
).
toBe
(
0
);
});
it
(
'should set decimals to Y axis decimals + 1'
,
function
()
{
it
(
'should set decimals to Y axis decimals + 1'
,
()
=>
{
panel
.
yaxes
[
0
].
decimals
=
2
;
const
data
=
[
series
];
updateLegendValues
(
data
,
panel
,
height
);
expect
(
data
[
0
].
decimals
).
toBe
(
3
);
});
it
(
'should set decimals to legend decimals value if it was set explicitly'
,
function
()
{
it
(
'should set decimals to legend decimals value if it was set explicitly'
,
()
=>
{
panel
.
decimals
=
3
;
const
data
=
[
series
];
updateLegendValues
(
data
,
panel
,
height
);
...
...
public/app/core/utils/css_loader.ts
View file @
72ab24f3
...
...
@@ -9,8 +9,8 @@ for (let i = 0; i < links.length; i++) {
}
const
isWebkit
=
!!
window
.
navigator
.
userAgent
.
match
(
/AppleWebKit
\/([^
;
]
*
)
/
);
const
webkitLoadCheck
=
function
(
link
,
callback
)
{
setTimeout
(
function
()
{
const
webkitLoadCheck
=
(
link
,
callback
)
=>
{
setTimeout
(
()
=>
{
for
(
let
i
=
0
;
i
<
document
.
styleSheets
.
length
;
i
++
)
{
const
sheet
=
document
.
styleSheets
[
i
];
if
(
sheet
.
href
===
link
.
href
)
{
...
...
@@ -21,19 +21,19 @@ const webkitLoadCheck = function(link, callback) {
},
10
);
};
const
noop
=
function
()
{};
const
noop
=
()
=>
{};
const
loadCSS
=
function
(
url
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
const
loadCSS
=
url
=>
{
return
new
Promise
(
(
resolve
,
reject
)
=>
{
const
link
=
document
.
createElement
(
'link'
);
const
timeout
=
setTimeout
(
function
()
{
const
timeout
=
setTimeout
(
()
=>
{
reject
(
'Unable to load CSS'
);
},
waitSeconds
*
1000
);
const
_callback
=
function
(
error
)
{
const
_callback
=
error
=>
{
clearTimeout
(
timeout
);
link
.
onload
=
link
.
onerror
=
noop
;
setTimeout
(
function
()
{
setTimeout
(
()
=>
{
if
(
error
)
{
reject
(
error
);
}
else
{
...
...
@@ -47,14 +47,14 @@ const loadCSS = function(url) {
link
.
href
=
url
;
if
(
!
isWebkit
)
{
link
.
onload
=
function
()
{
link
.
onload
=
()
=>
{
_callback
(
undefined
);
};
}
else
{
webkitLoadCheck
(
link
,
_callback
);
}
link
.
onerror
=
function
(
evt
:
any
)
{
link
.
onerror
=
(
evt
:
any
)
=>
{
_callback
(
evt
.
error
||
new
Error
(
'Error loading CSS file.'
));
};
...
...
public/app/features/dashboard/change_tracker.ts
View file @
72ab24f3
...
...
@@ -128,7 +128,7 @@ export class ChangeTracker {
});
// ignore template variable values
_
.
each
(
dash
.
templating
.
list
,
function
(
value
)
{
_
.
each
(
dash
.
templating
.
list
,
value
=>
{
value
.
current
=
null
;
value
.
options
=
null
;
value
.
filters
=
null
;
...
...
public/app/features/dashboard/dashboard_loader_srv.ts
View file @
72ab24f3
...
...
@@ -59,7 +59,7 @@ export class DashboardLoaderSrv {
});
}
promise
.
then
(
function
(
result
)
{
promise
.
then
(
result
=>
{
if
(
result
.
meta
.
dashboardNotFound
!==
true
)
{
impressionSrv
.
addDashboardImpression
(
result
.
dashboard
.
id
);
}
...
...
public/app/features/dashboard/repeat_option/repeat_option.ts
View file @
72ab24f3
...
...
@@ -15,7 +15,7 @@ function dashRepeatOptionDirective(variableSrv) {
scope
:
{
panel
:
'='
,
},
link
:
function
(
scope
,
element
)
{
link
:
(
scope
,
element
)
=>
{
element
.
css
({
display
:
'block'
,
width
:
'100%'
});
scope
.
variables
=
variableSrv
.
variables
.
map
(
item
=>
{
...
...
@@ -36,7 +36,7 @@ function dashRepeatOptionDirective(variableSrv) {
scope
.
panel
.
repeatDirection
=
'h'
;
}
scope
.
optionChanged
=
function
()
{
scope
.
optionChanged
=
()
=>
{
if
(
scope
.
panel
.
repeat
)
{
scope
.
panel
.
repeatDirection
=
'h'
;
}
...
...
public/app/features/dashboard/shareModalCtrl.ts
View file @
72ab24f3
...
...
@@ -11,7 +11,7 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv,
};
$scope
.
editor
=
{
index
:
$scope
.
tabIndex
||
0
};
$scope
.
init
=
function
()
{
$scope
.
init
=
()
=>
{
$scope
.
modeSharePanel
=
$scope
.
panel
?
true
:
false
;
$scope
.
tabs
=
[{
title
:
'Link'
,
src
:
'shareLink.html'
}];
...
...
@@ -34,7 +34,7 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv,
$scope
.
buildUrl
();
};
$scope
.
buildUrl
=
function
()
{
$scope
.
buildUrl
=
()
=>
{
let
baseUrl
=
$location
.
absUrl
();
const
queryStart
=
baseUrl
.
indexOf
(
'?'
);
...
...
@@ -90,7 +90,7 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv,
// This function will try to return the proper full name of the local timezone
// Chrome does not handle the timezone offset (but phantomjs does)
$scope
.
getLocalTimeZone
=
function
()
{
$scope
.
getLocalTimeZone
=
()
=>
{
const
utcOffset
=
'&tz=UTC'
+
encodeURIComponent
(
moment
().
format
(
'Z'
));
// Older browser does not the internationalization API
...
...
@@ -111,7 +111,7 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv,
return
'&tz='
+
encodeURIComponent
(
options
.
timeZone
);
};
$scope
.
getShareUrl
=
function
()
{
$scope
.
getShareUrl
=
()
=>
{
return
$scope
.
shareUrl
;
};
}
...
...
public/app/features/dashboard/share_snapshot_ctrl.ts
View file @
72ab24f3
...
...
@@ -25,8 +25,8 @@ export class ShareSnapshotCtrl {
{
text
:
'Public on the web'
,
value
:
3
},
];
$scope
.
init
=
function
()
{
backendSrv
.
get
(
'/api/snapshot/shared-options'
).
then
(
function
(
options
)
{
$scope
.
init
=
()
=>
{
backendSrv
.
get
(
'/api/snapshot/shared-options'
).
then
(
options
=>
{
$scope
.
externalUrl
=
options
[
'externalSnapshotURL'
];
$scope
.
sharingButtonText
=
options
[
'externalSnapshotName'
];
$scope
.
externalEnabled
=
options
[
'externalEnabled'
];
...
...
@@ -35,7 +35,7 @@ export class ShareSnapshotCtrl {
$scope
.
apiUrl
=
'/api/snapshots'
;
$scope
.
createSnapshot
=
function
(
external
)
{
$scope
.
createSnapshot
=
external
=>
{
$scope
.
dashboard
.
snapshot
=
{
timestamp
:
new
Date
(),
};
...
...
@@ -49,12 +49,12 @@ export class ShareSnapshotCtrl {
$rootScope
.
$broadcast
(
'refresh'
);
$timeout
(
function
()
{
$timeout
(
()
=>
{
$scope
.
saveSnapshot
(
external
);
},
$scope
.
snapshot
.
timeoutSeconds
*
1000
);
};
$scope
.
saveSnapshot
=
function
(
external
)
{
$scope
.
saveSnapshot
=
external
=>
{
const
dash
=
$scope
.
dashboard
.
getSaveModelClone
();
$scope
.
scrubDashboard
(
dash
);
...
...
@@ -67,7 +67,7 @@ export class ShareSnapshotCtrl {
const
postUrl
=
external
?
$scope
.
externalUrl
+
$scope
.
apiUrl
:
$scope
.
apiUrl
;
backendSrv
.
post
(
postUrl
,
cmdData
).
then
(
function
(
results
)
{
results
=>
{
$scope
.
loading
=
false
;
if
(
external
)
{
...
...
@@ -88,17 +88,17 @@ export class ShareSnapshotCtrl {
$scope
.
step
=
2
;
},
function
()
{
()
=>
{
$scope
.
loading
=
false
;
}
);
};
$scope
.
getSnapshotUrl
=
function
()
{
$scope
.
getSnapshotUrl
=
()
=>
{
return
$scope
.
snapshotUrl
;
};
$scope
.
scrubDashboard
=
function
(
dash
)
{
$scope
.
scrubDashboard
=
dash
=>
{
// change title
dash
.
title
=
$scope
.
snapshot
.
name
;
...
...
@@ -106,7 +106,7 @@ export class ShareSnapshotCtrl {
dash
.
time
=
timeSrv
.
timeRange
();
// remove panel queries & links
_
.
each
(
dash
.
panels
,
function
(
panel
)
{
_
.
each
(
dash
.
panels
,
panel
=>
{
panel
.
targets
=
[];
panel
.
links
=
[];
panel
.
datasource
=
null
;
...
...
@@ -114,10 +114,10 @@ export class ShareSnapshotCtrl {
// remove annotation queries
dash
.
annotations
.
list
=
_
.
chain
(
dash
.
annotations
.
list
)
.
filter
(
function
(
annotation
)
{
.
filter
(
annotation
=>
{
return
annotation
.
enable
;
})
.
map
(
function
(
annotation
)
{
.
map
(
annotation
=>
{
return
{
name
:
annotation
.
name
,
enable
:
annotation
.
enable
,
...
...
@@ -131,7 +131,7 @@ export class ShareSnapshotCtrl {
.
value
();
// remove template queries
_
.
each
(
dash
.
templating
.
list
,
function
(
variable
)
{
_
.
each
(
dash
.
templating
.
list
,
variable
=>
{
variable
.
query
=
''
;
variable
.
options
=
variable
.
current
;
variable
.
refresh
=
false
;
...
...
@@ -149,21 +149,21 @@ export class ShareSnapshotCtrl {
// cleanup snapshotData
delete
$scope
.
dashboard
.
snapshot
;
$scope
.
dashboard
.
forEachPanel
(
function
(
panel
)
{
$scope
.
dashboard
.
forEachPanel
(
panel
=>
{
delete
panel
.
snapshotData
;
});
_
.
each
(
$scope
.
dashboard
.
annotations
.
list
,
function
(
annotation
)
{
_
.
each
(
$scope
.
dashboard
.
annotations
.
list
,
annotation
=>
{
delete
annotation
.
snapshotData
;
});
};
$scope
.
deleteSnapshot
=
function
()
{
backendSrv
.
get
(
$scope
.
deleteUrl
).
then
(
function
()
{
$scope
.
deleteSnapshot
=
()
=>
{
backendSrv
.
get
(
$scope
.
deleteUrl
).
then
(
()
=>
{
$scope
.
step
=
3
;
});
};
$scope
.
saveExternalSnapshotRef
=
function
(
cmdData
,
results
)
{
$scope
.
saveExternalSnapshotRef
=
(
cmdData
,
results
)
=>
{
// save external in local instance as well
cmdData
.
external
=
true
;
cmdData
.
key
=
results
.
key
;
...
...
public/app/features/dashboard/timepicker/input_date.ts
View file @
72ab24f3
...
...
@@ -5,10 +5,10 @@ export function inputDateDirective() {
return
{
restrict
:
'A'
,
require
:
'ngModel'
,
link
:
function
(
$scope
,
$elem
,
attrs
,
ngModel
)
{
link
:
(
$scope
,
$elem
,
attrs
,
ngModel
)
=>
{
const
format
=
'YYYY-MM-DD HH:mm:ss'
;
const
fromUser
=
function
(
text
)
{
const
fromUser
=
text
=>
{
if
(
text
.
indexOf
(
'now'
)
!==
-
1
)
{
if
(
!
dateMath
.
isValid
(
text
))
{
ngModel
.
$setValidity
(
'error'
,
false
);
...
...
@@ -34,7 +34,7 @@ export function inputDateDirective() {
return
parsed
;
};
const
toUser
=
function
(
currentValue
)
{
const
toUser
=
currentValue
=>
{
if
(
moment
.
isMoment
(
currentValue
))
{
return
currentValue
.
format
(
format
);
}
else
{
...
...
public/app/features/dashboard/upload.ts
View file @
72ab24f3
...
...
@@ -16,11 +16,11 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
scope
:
{
onUpload
:
'&'
,
},
link
:
function
(
scope
)
{
link
:
scope
=>
{
function
file_selected
(
evt
)
{
const
files
=
evt
.
target
.
files
;
// FileList object
const
readerOnload
=
function
()
{
return
function
(
e
)
{
const
readerOnload
=
()
=>
{
return
e
=>
{
let
dash
;
try
{
dash
=
JSON
.
parse
(
e
.
target
.
result
);
...
...
@@ -30,7 +30,7 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
return
;
}
scope
.
$apply
(
function
()
{
scope
.
$apply
(
()
=>
{
scope
.
onUpload
({
dash
:
dash
});
});
};
...
...
public/app/features/dashboard/view_state_srv.ts
View file @
72ab24f3
...
...
@@ -22,18 +22,18 @@ export class DashboardViewState {
self
.
$scope
=
$scope
;
self
.
dashboard
=
$scope
.
dashboard
;
$scope
.
onAppEvent
(
'$routeUpdate'
,
function
()
{
$scope
.
onAppEvent
(
'$routeUpdate'
,
()
=>
{
const
urlState
=
self
.
getQueryStringState
();
if
(
self
.
needsSync
(
urlState
))
{
self
.
update
(
urlState
,
true
);
}
});
$scope
.
onAppEvent
(
'panel-change-view'
,
function
(
evt
,
payload
)
{
$scope
.
onAppEvent
(
'panel-change-view'
,
(
evt
,
payload
)
=>
{
self
.
update
(
payload
);
});
$scope
.
onAppEvent
(
'panel-initialized'
,
function
(
evt
,
payload
)
{
$scope
.
onAppEvent
(
'panel-initialized'
,
(
evt
,
payload
)
=>
{
self
.
registerPanel
(
payload
.
scope
);
});
...
...
@@ -156,7 +156,7 @@ export class DashboardViewState {
}
getPanelScope
(
id
)
{
return
_
.
find
(
this
.
panelScopes
,
function
(
panelScope
)
{
return
_
.
find
(
this
.
panelScopes
,
panelScope
=>
{
return
panelScope
.
ctrl
.
panel
.
id
===
id
;
});
}
...
...
@@ -176,7 +176,7 @@ export class DashboardViewState {
return
false
;
}
this
.
$timeout
(
function
()
{
this
.
$timeout
(
()
=>
{
if
(
self
.
oldTimeRange
!==
ctrl
.
range
)
{
self
.
$rootScope
.
$broadcast
(
'refresh'
);
}
else
{
...
...
@@ -216,7 +216,7 @@ export class DashboardViewState {
}
}
const
unbind
=
panelScope
.
$on
(
'$destroy'
,
function
()
{
const
unbind
=
panelScope
.
$on
(
'$destroy'
,
()
=>
{
self
.
panelScopes
=
_
.
without
(
self
.
panelScopes
,
panelScope
);
unbind
();
});
...
...
@@ -226,7 +226,7 @@ export class DashboardViewState {
/** @ngInject */
export
function
dashboardViewStateSrv
(
$location
,
$timeout
,
$rootScope
)
{
return
{
create
:
function
(
$scope
)
{
create
:
$scope
=>
{
return
new
DashboardViewState
(
$scope
,
$location
,
$timeout
,
$rootScope
);
},
};
...
...
public/app/features/dashlinks/module.ts
View file @
72ab24f3
...
...
@@ -10,7 +10,7 @@ function dashLinksContainer() {
restrict
:
'E'
,
controller
:
'DashLinksContainerCtrl'
,
template
:
'<dash-link ng-repeat="link in generatedLinks" link="link"></dash-link>'
,
link
:
function
()
{},
link
:
()
=>
{},
};
}
...
...
@@ -18,7 +18,7 @@ function dashLinksContainer() {
function
dashLink
(
$compile
,
$sanitize
,
linkSrv
)
{
return
{
restrict
:
'E'
,
link
:
function
(
scope
,
elem
)
{
link
:
(
scope
,
elem
)
=>
{
const
link
=
scope
.
link
;
let
template
=
'<div class="gf-form">'
+
...
...
@@ -130,16 +130,16 @@ export class DashLinksContainerCtrl {
function
updateDashLinks
()
{
const
promises
=
_
.
map
(
$scope
.
links
,
buildLinks
);
$q
.
all
(
promises
).
then
(
function
(
results
)
{
$q
.
all
(
promises
).
then
(
results
=>
{
$scope
.
generatedLinks
=
_
.
flatten
(
results
);
});
}
$scope
.
searchDashboards
=
function
(
link
,
limit
)
{
return
backendSrv
.
search
({
tag
:
link
.
tags
,
limit
:
limit
}).
then
(
function
(
results
)
{
$scope
.
searchDashboards
=
(
link
,
limit
)
=>
{
return
backendSrv
.
search
({
tag
:
link
.
tags
,
limit
:
limit
}).
then
(
results
=>
{
return
_
.
reduce
(
results
,
function
(
memo
,
dash
)
{
(
memo
,
dash
)
=>
{
// do not add current dashboard
if
(
dash
.
id
!==
currentDashId
)
{
memo
.
push
({
...
...
@@ -158,9 +158,9 @@ export class DashLinksContainerCtrl {
});
};
$scope
.
fillDropdown
=
function
(
link
)
{
$scope
.
searchDashboards
(
link
,
100
).
then
(
function
(
results
)
{
_
.
each
(
results
,
function
(
hit
)
{
$scope
.
fillDropdown
=
link
=>
{
$scope
.
searchDashboards
(
link
,
100
).
then
(
results
=>
{
_
.
each
(
results
,
hit
=>
{
hit
.
url
=
linkSrv
.
getLinkUrl
(
hit
);
});
link
.
searchHits
=
results
;
...
...
public/app/features/org/change_password_ctrl.ts
View file @
72ab24f3
...
...
@@ -9,7 +9,7 @@ export class ChangePasswordCtrl {
$scope
.
ldapEnabled
=
config
.
ldapEnabled
;
$scope
.
navModel
=
navModelSrv
.
getNav
(
'profile'
,
'change-password'
,
0
);
$scope
.
changePassword
=
function
()
{
$scope
.
changePassword
=
()
=>
{
if
(
!
$scope
.
userForm
.
$valid
)
{
return
;
}
...
...
@@ -19,7 +19,7 @@ export class ChangePasswordCtrl {
return
;
}
backendSrv
.
put
(
'/api/user/password'
,
$scope
.
command
).
then
(
function
()
{
backendSrv
.
put
(
'/api/user/password'
,
$scope
.
command
).
then
(
()
=>
{
$location
.
path
(
'profile'
);
});
};
...
...
public/app/features/org/new_org_ctrl.ts
View file @
72ab24f3
...
...
@@ -7,9 +7,9 @@ export class NewOrgCtrl {
$scope
.
navModel
=
navModelSrv
.
getNav
(
'cfg'
,
'admin'
,
'global-orgs'
,
1
);
$scope
.
newOrg
=
{
name
:
''
};
$scope
.
createOrg
=
function
()
{
backendSrv
.
post
(
'/api/orgs/'
,
$scope
.
newOrg
).
then
(
function
(
result
)
{
backendSrv
.
post
(
'/api/user/using/'
+
result
.
orgId
).
then
(
function
()
{
$scope
.
createOrg
=
()
=>
{
backendSrv
.
post
(
'/api/orgs/'
,
$scope
.
newOrg
).
then
(
result
=>
{
backendSrv
.
post
(
'/api/user/using/'
+
result
.
orgId
).
then
(
()
=>
{
window
.
location
.
href
=
config
.
appSubUrl
+
'/org'
;
});
});
...
...
public/app/features/org/org_api_keys_ctrl.ts
View file @
72ab24f3
...
...
@@ -8,22 +8,22 @@ export class OrgApiKeysCtrl {
$scope
.
roleTypes
=
[
'Viewer'
,
'Editor'
,
'Admin'
];
$scope
.
token
=
{
role
:
'Viewer'
};
$scope
.
init
=
function
()
{
$scope
.
init
=
()
=>
{
$scope
.
getTokens
();
};
$scope
.
getTokens
=
function
()
{
backendSrv
.
get
(
'/api/auth/keys'
).
then
(
function
(
tokens
)
{
$scope
.
getTokens
=
()
=>
{
backendSrv
.
get
(
'/api/auth/keys'
).
then
(
tokens
=>
{
$scope
.
tokens
=
tokens
;
});
};
$scope
.
removeToken
=
function
(
id
)
{
$scope
.
removeToken
=
id
=>
{
backendSrv
.
delete
(
'/api/auth/keys/'
+
id
).
then
(
$scope
.
getTokens
);
};
$scope
.
addToken
=
function
()
{
backendSrv
.
post
(
'/api/auth/keys'
,
$scope
.
token
).
then
(
function
(
result
)
{
$scope
.
addToken
=
()
=>
{
backendSrv
.
post
(
'/api/auth/keys'
,
$scope
.
token
).
then
(
result
=>
{
const
modalScope
=
$scope
.
$new
(
true
);
modalScope
.
key
=
result
.
key
;
modalScope
.
rootPath
=
window
.
location
.
origin
+
$scope
.
$root
.
appSubUrl
;
...
...
public/app/features/org/select_org_ctrl.ts
View file @
72ab24f3
...
...
@@ -14,18 +14,18 @@ export class SelectOrgCtrl {
},
};
$scope
.
init
=
function
()
{
$scope
.
init
=
()
=>
{
$scope
.
getUserOrgs
();
};
$scope
.
getUserOrgs
=
function
()
{
backendSrv
.
get
(
'/api/user/orgs'
).
then
(
function
(
orgs
)
{
$scope
.
getUserOrgs
=
()
=>
{
backendSrv
.
get
(
'/api/user/orgs'
).
then
(
orgs
=>
{
$scope
.
orgs
=
orgs
;
});
};
$scope
.
setUsingOrg
=
function
(
org
)
{
backendSrv
.
post
(
'/api/user/using/'
+
org
.
orgId
).
then
(
function
()
{
$scope
.
setUsingOrg
=
org
=>
{
backendSrv
.
post
(
'/api/user/using/'
+
org
.
orgId
).
then
(
()
=>
{
window
.
location
.
href
=
config
.
appSubUrl
+
'/'
;
});
};
...
...
public/app/features/panel/panel_directive.ts
View file @
72ab24f3
...
...
@@ -54,13 +54,13 @@ const panelTemplate = `
</div>
`
;
module
.
directive
(
'grafanaPanel'
,
function
(
$rootScope
,
$document
,
$timeout
)
{
module
.
directive
(
'grafanaPanel'
,
(
$rootScope
,
$document
,
$timeout
)
=>
{
return
{
restrict
:
'E'
,
template
:
panelTemplate
,
transclude
:
true
,
scope
:
{
ctrl
:
'='
},
link
:
function
(
scope
,
elem
)
{
link
:
(
scope
,
elem
)
=>
{
const
panelContainer
=
elem
.
find
(
'.panel-container'
);
const
panelContent
=
elem
.
find
(
'.panel-content'
);
const
cornerInfoElem
=
elem
.
find
(
'.panel-info-corner'
);
...
...
@@ -184,7 +184,7 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
infoDrop
=
new
Drop
({
target
:
cornerInfoElem
[
0
],
content
:
function
()
{
content
:
()
=>
{
return
ctrl
.
getInfoContent
({
mode
:
'tooltip'
});
},
classes
:
ctrl
.
error
?
'drop-error'
:
'drop-help'
,
...
...
@@ -208,7 +208,7 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
scope
.
$watchGroup
([
'ctrl.error'
,
'ctrl.panel.description'
],
updatePanelCornerInfo
);
scope
.
$watchCollection
(
'ctrl.panel.links'
,
updatePanelCornerInfo
);
cornerInfoElem
.
on
(
'click'
,
function
()
{
cornerInfoElem
.
on
(
'click'
,
()
=>
{
infoDrop
.
close
();
scope
.
$apply
(
ctrl
.
openInspector
.
bind
(
ctrl
));
});
...
...
@@ -216,7 +216,7 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
elem
.
on
(
'mouseenter'
,
mouseEnter
);
elem
.
on
(
'mouseleave'
,
mouseLeave
);
scope
.
$on
(
'$destroy'
,
function
()
{
scope
.
$on
(
'$destroy'
,
()
=>
{
elem
.
off
();
cornerInfoElem
.
off
();
...
...
@@ -232,7 +232,7 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
};
});
module
.
directive
(
'panelHelpCorner'
,
function
(
$rootScope
)
{
module
.
directive
(
'panelHelpCorner'
,
$rootScope
=>
{
return
{
restrict
:
'E'
,
template
:
`
...
...
@@ -242,6 +242,6 @@ module.directive('panelHelpCorner', function($rootScope) {
</span>
</span>
`
,
link
:
function
(
scope
,
elem
)
{},
link
:
(
scope
,
elem
)
=>
{},
};
});
public/app/features/panel/panel_header.ts
View file @
72ab24f3
...
...
@@ -85,12 +85,12 @@ function panelHeader($compile) {
return
{
restrict
:
'E'
,
template
:
template
,
link
:
function
(
scope
,
elem
,
attrs
)
{
link
:
(
scope
,
elem
,
attrs
)
=>
{
const
menuElem
=
elem
.
find
(
'.panel-menu'
);
let
menuScope
;
let
isDragged
;
elem
.
click
(
function
(
evt
)
{
elem
.
click
(
evt
=>
{
const
targetClass
=
evt
.
target
.
className
;
// remove existing scope
...
...
public/app/features/panel/query_troubleshooter.ts
View file @
72ab24f3
...
...
@@ -170,8 +170,8 @@ export function queryTroubleshooter() {
panelCtrl
:
'='
,
isOpen
:
'='
,
},
link
:
function
(
scope
,
elem
,
attrs
,
ctrl
)
{
ctrl
.
renderJsonExplorer
=
function
(
data
)
{
link
:
(
scope
,
elem
,
attrs
,
ctrl
)
=>
{
ctrl
.
renderJsonExplorer
=
data
=>
{
const
jsonElem
=
elem
.
find
(
'.query-troubleshooter-json'
);
ctrl
.
jsonExplorer
=
new
JsonExplorer
(
data
,
3
,
{
...
...
public/app/features/panel/solo_panel_ctrl.ts
View file @
72ab24f3
...
...
@@ -7,7 +7,7 @@ export class SoloPanelCtrl {
constructor
(
$scope
,
$routeParams
,
$location
,
dashboardLoaderSrv
,
contextSrv
,
backendSrv
)
{
let
panelId
;
$scope
.
init
=
function
()
{
$scope
.
init
=
()
=>
{
contextSrv
.
sidemenu
=
false
;
appEvents
.
emit
(
'toggle-sidemenu-hidden'
);
...
...
@@ -27,13 +27,13 @@ export class SoloPanelCtrl {
return
;
}
dashboardLoaderSrv
.
loadDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
,
$routeParams
.
uid
).
then
(
function
(
result
)
{
dashboardLoaderSrv
.
loadDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
,
$routeParams
.
uid
).
then
(
result
=>
{
result
.
meta
.
soloMode
=
true
;
$scope
.
initDashboard
(
result
,
$scope
);
});
};
$scope
.
initPanelScope
=
function
()
{
$scope
.
initPanelScope
=
()
=>
{
const
panelInfo
=
$scope
.
dashboard
.
getPanelInfoById
(
panelId
);
// fake row ctrl scope
...
...
public/app/features/panellinks/module.ts
View file @
72ab24f3
...
...
@@ -10,7 +10,7 @@ function panelLinksEditor() {
restrict
:
'E'
,
controller
:
'PanelLinksEditorCtrl'
,
templateUrl
:
'public/app/features/panellinks/module.html'
,
link
:
function
()
{},
link
:
()
=>
{},
};
}
...
...
@@ -19,15 +19,15 @@ export class PanelLinksEditorCtrl {
constructor
(
$scope
,
backendSrv
)
{
$scope
.
panel
.
links
=
$scope
.
panel
.
links
||
[];
$scope
.
addLink
=
function
()
{
$scope
.
addLink
=
()
=>
{
$scope
.
panel
.
links
.
push
({
type
:
'dashboard'
,
});
};
$scope
.
searchDashboards
=
function
(
queryStr
,
callback
)
{
backendSrv
.
search
({
query
:
queryStr
}).
then
(
function
(
hits
)
{
const
dashboards
=
_
.
map
(
hits
,
function
(
dash
)
{
$scope
.
searchDashboards
=
(
queryStr
,
callback
)
=>
{
backendSrv
.
search
({
query
:
queryStr
}).
then
(
hits
=>
{
const
dashboards
=
_
.
map
(
hits
,
dash
=>
{
return
dash
.
title
;
});
...
...
@@ -35,8 +35,8 @@ export class PanelLinksEditorCtrl {
});
};
$scope
.
dashboardChanged
=
function
(
link
)
{
backendSrv
.
search
({
query
:
link
.
dashboard
}).
then
(
function
(
hits
)
{
$scope
.
dashboardChanged
=
link
=>
{
backendSrv
.
search
({
query
:
link
.
dashboard
}).
then
(
hits
=>
{
const
dashboard
=
_
.
find
(
hits
,
{
title
:
link
.
dashboard
});
if
(
dashboard
)
{
if
(
dashboard
.
url
)
{
...
...
@@ -50,7 +50,7 @@ export class PanelLinksEditorCtrl {
});
};
$scope
.
deleteLink
=
function
(
link
)
{
$scope
.
deleteLink
=
link
=>
{
$scope
.
panel
.
links
=
_
.
without
(
$scope
.
panel
.
links
,
link
);
};
}
...
...
public/app/features/playlist/playlist_routes.ts
View file @
72ab24f3
...
...
@@ -21,7 +21,7 @@ function grafanaRoutes($routeProvider) {
.
when
(
'/playlists/play/:id'
,
{
template
:
''
,
resolve
:
{
init
:
function
(
playlistSrv
,
$route
)
{
init
:
(
playlistSrv
,
$route
)
=>
{
const
playlistId
=
$route
.
current
.
params
.
id
;
playlistSrv
.
start
(
playlistId
);
},
...
...
public/app/features/plugins/ds_edit_ctrl.ts
View file @
72ab24f3
...
...
@@ -200,7 +200,7 @@ export class DataSourceEditCtrl {
coreModule
.
controller
(
'DataSourceEditCtrl'
,
DataSourceEditCtrl
);
coreModule
.
directive
(
'datasourceHttpSettings'
,
function
()
{
coreModule
.
directive
(
'datasourceHttpSettings'
,
()
=>
{
return
{
scope
:
{
current
:
'='
,
...
...
@@ -209,15 +209,15 @@ coreModule.directive('datasourceHttpSettings', function() {
},
templateUrl
:
'public/app/features/plugins/partials/ds_http_settings.html'
,
link
:
{
pre
:
function
(
$scope
,
elem
,
attrs
)
{
pre
:
(
$scope
,
elem
,
attrs
)
=>
{
// do not show access option if direct access is disabled
$scope
.
showAccessOption
=
$scope
.
noDirectAccess
!==
'true'
;
$scope
.
showAccessHelp
=
false
;
$scope
.
toggleAccessHelp
=
function
()
{
$scope
.
toggleAccessHelp
=
()
=>
{
$scope
.
showAccessHelp
=
!
$scope
.
showAccessHelp
;
};
$scope
.
getSuggestUrls
=
function
()
{
$scope
.
getSuggestUrls
=
()
=>
{
return
[
$scope
.
suggestUrl
];
};
},
...
...
public/app/features/plugins/plugin_component.ts
View file @
72ab24f3
...
...
@@ -36,7 +36,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
// handle relative template urls for plugin templates
options
.
Component
.
templateUrl
=
relativeTemplateUrlToAbs
(
options
.
Component
.
templateUrl
,
options
.
baseUrl
);
return
function
()
{
return
()
=>
{
return
{
templateUrl
:
options
.
Component
.
templateUrl
,
template
:
options
.
Component
.
template
,
...
...
@@ -71,12 +71,12 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
const
panelInfo
=
config
.
panels
[
scope
.
panel
.
type
];
let
panelCtrlPromise
=
Promise
.
resolve
(
UnknownPanelCtrl
);
if
(
panelInfo
)
{
panelCtrlPromise
=
importPluginModule
(
panelInfo
.
module
).
then
(
function
(
panelModule
)
{
panelCtrlPromise
=
importPluginModule
(
panelInfo
.
module
).
then
(
panelModule
=>
{
return
panelModule
.
PanelCtrl
;
});
}
return
panelCtrlPromise
.
then
(
function
(
PanelCtrl
:
any
)
{
return
panelCtrlPromise
.
then
(
(
PanelCtrl
:
any
)
=>
{
componentInfo
.
Component
=
PanelCtrl
;
if
(
!
PanelCtrl
||
PanelCtrl
.
registered
)
{
...
...
@@ -128,7 +128,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
}
// Annotations
case
'annotations-query-ctrl'
:
{
return
importPluginModule
(
scope
.
ctrl
.
currentDatasource
.
meta
.
module
).
then
(
function
(
dsModule
)
{
return
importPluginModule
(
scope
.
ctrl
.
currentDatasource
.
meta
.
module
).
then
(
dsModule
=>
{
return
{
baseUrl
:
scope
.
ctrl
.
currentDatasource
.
meta
.
baseUrl
,
name
:
'annotations-query-ctrl-'
+
scope
.
ctrl
.
currentDatasource
.
meta
.
id
,
...
...
@@ -144,7 +144,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
// Datasource ConfigCtrl
case
'datasource-config-ctrl'
:
{
const
dsMeta
=
scope
.
ctrl
.
datasourceMeta
;
return
importPluginModule
(
dsMeta
.
module
).
then
(
function
(
dsModule
):
any
{
return
importPluginModule
(
dsMeta
.
module
).
then
(
(
dsModule
):
any
=>
{
if
(
!
dsModule
.
ConfigCtrl
)
{
return
{
notFound
:
true
};
}
...
...
@@ -161,7 +161,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
// AppConfigCtrl
case
'app-config-ctrl'
:
{
const
model
=
scope
.
ctrl
.
model
;
return
importPluginModule
(
model
.
module
).
then
(
function
(
appModule
)
{
return
importPluginModule
(
model
.
module
).
then
(
appModule
=>
{
return
{
baseUrl
:
model
.
baseUrl
,
name
:
'app-config-'
+
model
.
id
,
...
...
@@ -174,7 +174,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
// App Page
case
'app-page'
:
{
const
appModel
=
scope
.
ctrl
.
appModel
;
return
importPluginModule
(
appModel
.
module
).
then
(
function
(
appModule
)
{
return
importPluginModule
(
appModel
.
module
).
then
(
appModule
=>
{
return
{
baseUrl
:
appModel
.
baseUrl
,
name
:
'app-page-'
+
appModel
.
id
+
'-'
+
scope
.
ctrl
.
page
.
slug
,
...
...
@@ -206,9 +206,9 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
elem
.
empty
();
// let a binding digest cycle complete before adding to dom
setTimeout
(
function
()
{
setTimeout
(
()
=>
{
elem
.
append
(
child
);
scope
.
$applyAsync
(
function
()
{
scope
.
$applyAsync
(
()
=>
{
scope
.
$broadcast
(
'component-did-mount'
);
scope
.
$broadcast
(
'refresh'
);
});
...
...
@@ -239,9 +239,9 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
return
{
restrict
:
'E'
,
link
:
function
(
scope
,
elem
,
attrs
)
{
link
:
(
scope
,
elem
,
attrs
)
=>
{
getModule
(
scope
,
attrs
)
.
then
(
function
(
componentInfo
)
{
.
then
(
componentInfo
=>
{
registerPluginComponent
(
scope
,
elem
,
attrs
,
componentInfo
);
})
.
catch
(
err
=>
{
...
...
public/app/features/templating/all.ts
View file @
72ab24f3
...
...
@@ -10,7 +10,7 @@ import { CustomVariable } from './custom_variable';
import
{
ConstantVariable
}
from
'./constant_variable'
;
import
{
AdhocVariable
}
from
'./adhoc_variable'
;
coreModule
.
factory
(
'templateSrv'
,
function
()
{
coreModule
.
factory
(
'templateSrv'
,
()
=>
{
return
templateSrv
;
});
...
...
public/app/features/templating/custom_variable.ts
View file @
72ab24f3
...
...
@@ -39,7 +39,7 @@ export class CustomVariable implements Variable {
updateOptions
()
{
// extract options in comma separated string
this
.
options
=
_
.
map
(
this
.
query
.
split
(
/
[
,
]
+/
),
function
(
text
)
{
this
.
options
=
_
.
map
(
this
.
query
.
split
(
/
[
,
]
+/
),
text
=>
{
return
{
text
:
text
.
trim
(),
value
:
text
.
trim
()
};
});
...
...
public/app/features/templating/editor_ctrl.ts
View file @
72ab24f3
...
...
@@ -30,31 +30,31 @@ export class VariableEditorCtrl {
$scope
.
hideOptions
=
[{
value
:
0
,
text
:
''
},
{
value
:
1
,
text
:
'Label'
},
{
value
:
2
,
text
:
'Variable'
}];
$scope
.
init
=
function
()
{
$scope
.
init
=
()
=>
{
$scope
.
mode
=
'list'
;
$scope
.
variables
=
variableSrv
.
variables
;
$scope
.
reset
();
$scope
.
$watch
(
'mode'
,
function
(
val
)
{
$scope
.
$watch
(
'mode'
,
val
=>
{
if
(
val
===
'new'
)
{
$scope
.
reset
();
}
});
};
$scope
.
setMode
=
function
(
mode
)
{
$scope
.
setMode
=
mode
=>
{
$scope
.
mode
=
mode
;
};
$scope
.
add
=
function
()
{
$scope
.
add
=
()
=>
{
if
(
$scope
.
isValid
())
{
variableSrv
.
addVariable
(
$scope
.
current
);
$scope
.
update
();
}
};
$scope
.
isValid
=
function
()
{
$scope
.
isValid
=
()
=>
{
if
(
!
$scope
.
ctrl
.
form
.
$valid
)
{
return
false
;
}
...
...
@@ -84,7 +84,7 @@ export class VariableEditorCtrl {
return
true
;
};
$scope
.
validate
=
function
()
{
$scope
.
validate
=
()
=>
{
$scope
.
infoText
=
''
;
if
(
$scope
.
current
.
type
===
'adhoc'
&&
$scope
.
current
.
datasource
!==
null
)
{
$scope
.
infoText
=
'Adhoc filters are applied automatically to all queries that target this datasource'
;
...
...
@@ -96,7 +96,7 @@ export class VariableEditorCtrl {
}
};
$scope
.
runQuery
=
function
()
{
$scope
.
runQuery
=
()
=>
{
$scope
.
optionsLimit
=
20
;
return
variableSrv
.
updateOptions
(
$scope
.
current
).
catch
(
err
=>
{
if
(
err
.
data
&&
err
.
data
.
message
)
{
...
...
@@ -106,23 +106,23 @@ export class VariableEditorCtrl {
});
};
$scope
.
edit
=
function
(
variable
)
{
$scope
.
edit
=
variable
=>
{
$scope
.
current
=
variable
;
$scope
.
currentIsNew
=
false
;
$scope
.
mode
=
'edit'
;
$scope
.
validate
();
};
$scope
.
duplicate
=
function
(
variable
)
{
$scope
.
duplicate
=
variable
=>
{
const
clone
=
_
.
cloneDeep
(
variable
.
getSaveModel
());
$scope
.
current
=
variableSrv
.
createVariableFromModel
(
clone
);
$scope
.
current
.
name
=
'copy_of_'
+
variable
.
name
;
variableSrv
.
addVariable
(
$scope
.
current
);
};
$scope
.
update
=
function
()
{
$scope
.
update
=
()
=>
{
if
(
$scope
.
isValid
())
{
$scope
.
runQuery
().
then
(
function
()
{
$scope
.
runQuery
().
then
(
()
=>
{
$scope
.
reset
();
$scope
.
mode
=
'list'
;
templateSrv
.
updateTemplateData
();
...
...
@@ -130,18 +130,18 @@ export class VariableEditorCtrl {
}
};
$scope
.
reset
=
function
()
{
$scope
.
reset
=
()
=>
{
$scope
.
currentIsNew
=
true
;
$scope
.
current
=
variableSrv
.
createVariableFromModel
({
type
:
'query'
});
// this is done here in case a new data source type variable was added
$scope
.
datasources
=
_
.
filter
(
datasourceSrv
.
getMetricSources
(),
function
(
ds
)
{
$scope
.
datasources
=
_
.
filter
(
datasourceSrv
.
getMetricSources
(),
ds
=>
{
return
!
ds
.
meta
.
mixed
&&
ds
.
value
!==
null
;
});
$scope
.
datasourceTypes
=
_
(
$scope
.
datasources
)
.
uniqBy
(
'meta.id'
)
.
map
(
function
(
ds
)
{
.
map
(
ds
=>
{
return
{
text
:
ds
.
meta
.
name
,
value
:
ds
.
meta
.
id
};
})
.
value
();
...
...
@@ -164,11 +164,11 @@ export class VariableEditorCtrl {
$scope
.
validate
();
};
$scope
.
removeVariable
=
function
(
variable
)
{
$scope
.
removeVariable
=
variable
=>
{
variableSrv
.
removeVariable
(
variable
);
};
$scope
.
showMoreOptions
=
function
()
{
$scope
.
showMoreOptions
=
()
=>
{
$scope
.
optionsLimit
+=
20
;
};
}
...
...
public/app/features/templating/interval_variable.ts
View file @
72ab24f3
...
...
@@ -65,7 +65,7 @@ export class IntervalVariable implements Variable {
updateOptions
()
{
// extract options between quotes and/or comma
this
.
options
=
_
.
map
(
this
.
query
.
match
(
/
([
"'
])(
.*
?)\1
|
\w
+/g
),
function
(
text
)
{
this
.
options
=
_
.
map
(
this
.
query
.
match
(
/
([
"'
])(
.*
?)\1
|
\w
+/g
),
text
=>
{
text
=
text
.
replace
(
/
[
"'
]
+/g
,
''
);
return
{
text
:
text
.
trim
(),
value
:
text
.
trim
()
};
});
...
...
public/app/features/templating/query_variable.ts
View file @
72ab24f3
...
...
@@ -106,8 +106,8 @@ export class QueryVariable implements Variable {
getValuesForTag
(
tagKey
)
{
return
this
.
datasourceSrv
.
get
(
this
.
datasource
).
then
(
datasource
=>
{
const
query
=
this
.
tagValuesQuery
.
replace
(
'$tag'
,
tagKey
);
return
this
.
metricFindQuery
(
datasource
,
query
).
then
(
function
(
results
)
{
return
_
.
map
(
results
,
function
(
value
)
{
return
this
.
metricFindQuery
(
datasource
,
query
).
then
(
results
=>
{
return
_
.
map
(
results
,
value
=>
{
return
value
.
text
;
});
});
...
...
public/app/features/templating/template_srv.ts
View file @
72ab24f3
...
...
@@ -77,7 +77,7 @@ export class TemplateSrv {
if
(
value
instanceof
Array
&&
value
.
length
===
0
)
{
return
'__empty__'
;
}
const
quotedValues
=
_
.
map
(
value
,
function
(
val
)
{
const
quotedValues
=
_
.
map
(
value
,
val
=>
{
return
'"'
+
luceneEscape
(
val
)
+
'"'
;
});
return
'('
+
quotedValues
.
join
(
' OR '
)
+
')'
;
...
...
@@ -248,7 +248,7 @@ export class TemplateSrv {
}
fillVariableValuesForUrl
(
params
,
scopedVars
)
{
_
.
each
(
this
.
variables
,
function
(
variable
)
{
_
.
each
(
this
.
variables
,
variable
=>
{
if
(
scopedVars
&&
scopedVars
[
variable
.
name
]
!==
void
0
)
{
if
(
scopedVars
[
variable
.
name
].
skipUrlSync
)
{
return
;
...
...
@@ -264,7 +264,7 @@ export class TemplateSrv {
}
distributeVariable
(
value
,
variable
)
{
value
=
_
.
map
(
value
,
function
(
val
,
index
)
{
value
=
_
.
map
(
value
,
(
val
,
index
)
=>
{
if
(
index
!==
0
)
{
return
variable
+
'='
+
val
;
}
else
{
...
...
public/app/features/templating/variable_srv.ts
View file @
72ab24f3
...
...
@@ -175,10 +175,10 @@ export class VariableSrv {
selected
=
variable
.
options
[
0
];
}
else
{
selected
=
{
value
:
_
.
map
(
selected
,
function
(
val
)
{
value
:
_
.
map
(
selected
,
val
=>
{
return
val
.
value
;
}),
text
:
_
.
map
(
selected
,
function
(
val
)
{
text
:
_
.
map
(
selected
,
val
=>
{
return
val
.
text
;
}).
join
(
' + '
),
};
...
...
@@ -250,7 +250,7 @@ export class VariableSrv {
const
params
=
this
.
$location
.
search
();
// remove variable params
_
.
each
(
params
,
function
(
value
,
key
)
{
_
.
each
(
params
,
(
value
,
key
)
=>
{
if
(
key
.
indexOf
(
'var-'
)
===
0
)
{
delete
params
[
key
];
}
...
...
public/app/routes/ReactContainer.tsx
View file @
72ab24f3
...
...
@@ -50,7 +50,7 @@ export function reactContainer(
ReactDOM
.
render
(
WrapInProvider
(
store
,
component
,
props
),
elem
[
0
]);
scope
.
$on
(
'$destroy'
,
function
()
{
scope
.
$on
(
'$destroy'
,
()
=>
{
ReactDOM
.
unmountComponentAtNode
(
elem
[
0
]);
});
},
...
...
public/app/routes/dashboard_loaders.ts
View file @
72ab24f3
...
...
@@ -7,7 +7,7 @@ export class LoadDashboardCtrl {
$scope
.
appEvent
(
'dashboard-fetch-start'
);
if
(
!
$routeParams
.
uid
&&
!
$routeParams
.
slug
)
{
backendSrv
.
get
(
'/api/dashboards/home'
).
then
(
function
(
homeDash
)
{
backendSrv
.
get
(
'/api/dashboards/home'
).
then
(
homeDash
=>
{
if
(
homeDash
.
redirectUri
)
{
const
newUrl
=
locationUtil
.
stripBaseFromUrl
(
homeDash
.
redirectUri
);
$location
.
path
(
newUrl
);
...
...
@@ -30,7 +30,7 @@ export class LoadDashboardCtrl {
return
;
}
dashboardLoaderSrv
.
loadDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
,
$routeParams
.
uid
).
then
(
function
(
result
)
{
dashboardLoaderSrv
.
loadDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
,
$routeParams
.
uid
).
then
(
result
=>
{
if
(
result
.
meta
.
url
)
{
const
url
=
locationUtil
.
stripBaseFromUrl
(
result
.
meta
.
url
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment