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
e1beaaa0
Unverified
Commit
e1beaaa0
authored
Aug 26, 2018
by
Torkel Ödegaard
Committed by
GitHub
Aug 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tslint: tslint to const fixes part3 (#13036)
parent
35c00891
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
56 changed files
with
271 additions
and
275 deletions
+271
-275
public/app/app.ts
+5
-5
public/app/containers/Explore/Explore.tsx
+6
-1
public/app/containers/Explore/Graph.tsx
+4
-4
public/app/core/components/PageHeader/PageHeader.tsx
+2
-2
public/app/core/components/form_dropdown/form_dropdown.ts
+5
-5
public/app/core/components/manage_dashboards/manage_dashboards.ts
+1
-1
public/app/core/controllers/inspect_ctrl.ts
+5
-5
public/app/core/controllers/json_editor_ctrl.ts
+1
-1
public/app/core/controllers/login_ctrl.ts
+1
-1
public/app/core/controllers/reset_password_ctrl.ts
+1
-1
public/app/core/controllers/signup_ctrl.ts
+1
-1
public/app/core/filters/filters.ts
+2
-2
public/app/core/services/alert_srv.ts
+2
-2
public/app/core/services/analytics.ts
+3
-3
public/app/core/services/dynamic_directive_srv.ts
+1
-1
public/app/core/services/keybindingSrv.ts
+5
-5
public/app/core/services/popover_srv.ts
+4
-4
public/app/core/services/util_srv.ts
+2
-2
public/app/core/specs/datemath.test.ts
+15
-15
public/app/core/specs/emitter.test.ts
+8
-8
public/app/core/specs/flatten.test.ts
+1
-1
public/app/core/specs/kbn.test.ts
+0
-0
public/app/core/specs/rangeutil.test.ts
+18
-18
public/app/core/specs/table_model.test.ts
+3
-3
public/app/core/specs/time_series.test.ts
+3
-3
public/app/core/utils/css_loader.ts
+13
-13
public/app/core/utils/flatten.ts
+9
-9
public/app/core/utils/kbn.ts
+41
-41
public/app/core/utils/rangeutil.ts
+9
-9
public/app/features/dashboard/dashboard_ctrl.ts
+2
-2
public/app/features/dashboard/dashboard_loader_srv.ts
+5
-5
public/app/features/dashboard/dashgrid/PanelLoader.ts
+2
-2
public/app/features/dashboard/dashnav/dashnav.ts
+2
-2
public/app/features/dashboard/save_as_modal.ts
+1
-1
public/app/features/dashboard/save_modal.ts
+3
-3
public/app/features/dashboard/save_provisioned_modal.ts
+1
-1
public/app/features/dashboard/shareModalCtrl.ts
+3
-3
public/app/features/dashboard/share_snapshot_ctrl.ts
+6
-6
public/app/features/dashboard/submenu/submenu.ts
+1
-1
public/app/features/dashboard/view_state_srv.ts
+10
-10
public/app/features/dashlinks/module.ts
+4
-4
public/app/features/panellinks/module.ts
+2
-2
public/app/features/plugins/ds_edit_ctrl.ts
+1
-1
public/app/features/plugins/import_list/import_list.ts
+1
-1
public/app/features/plugins/plugin_component.ts
+6
-6
public/app/features/plugins/plugin_edit_ctrl.ts
+3
-3
public/app/features/plugins/plugin_page_ctrl.ts
+1
-1
public/app/features/templating/adhoc_variable.ts
+1
-1
public/app/features/templating/datasource_variable.ts
+3
-3
public/app/features/templating/editor_ctrl.ts
+4
-4
public/app/features/templating/interval_variable.ts
+1
-1
public/app/features/templating/query_variable.ts
+6
-6
public/app/features/templating/template_srv.ts
+9
-9
public/app/features/templating/variable_srv.ts
+11
-11
public/app/routes/dashboard_loaders.ts
+1
-1
public/test/lib/common.ts
+10
-19
No files found.
public/app/app.ts
View file @
e1beaaa0
...
@@ -53,7 +53,7 @@ export class GrafanaApp {
...
@@ -53,7 +53,7 @@ export class GrafanaApp {
}
}
init
()
{
init
()
{
var
app
=
angular
.
module
(
'grafana'
,
[]);
const
app
=
angular
.
module
(
'grafana'
,
[]);
moment
.
locale
(
config
.
bootData
.
user
.
locale
);
moment
.
locale
(
config
.
bootData
.
user
.
locale
);
...
@@ -77,7 +77,7 @@ export class GrafanaApp {
...
@@ -77,7 +77,7 @@ export class GrafanaApp {
'$delegate'
,
'$delegate'
,
'$templateCache'
,
'$templateCache'
,
function
(
$delegate
,
$templateCache
)
{
function
(
$delegate
,
$templateCache
)
{
var
get
=
$delegate
.
get
;
const
get
=
$delegate
.
get
;
$delegate
.
get
=
function
(
url
,
config
)
{
$delegate
.
get
=
function
(
url
,
config
)
{
if
(
url
.
match
(
/
\.
html$/
))
{
if
(
url
.
match
(
/
\.
html$/
))
{
// some template's already exist in the cache
// some template's already exist in the cache
...
@@ -105,10 +105,10 @@ export class GrafanaApp {
...
@@ -105,10 +105,10 @@ export class GrafanaApp {
'react'
,
'react'
,
];
];
var
module_types
=
[
'controllers'
,
'directives'
,
'factories'
,
'services'
,
'filters'
,
'routes'
];
const
module_types
=
[
'controllers'
,
'directives'
,
'factories'
,
'services'
,
'filters'
,
'routes'
];
_
.
each
(
module_types
,
type
=>
{
_
.
each
(
module_types
,
type
=>
{
var
moduleName
=
'grafana.'
+
type
;
const
moduleName
=
'grafana.'
+
type
;
this
.
useModule
(
angular
.
module
(
moduleName
,
[]));
this
.
useModule
(
angular
.
module
(
moduleName
,
[]));
});
});
...
@@ -119,7 +119,7 @@ export class GrafanaApp {
...
@@ -119,7 +119,7 @@ export class GrafanaApp {
coreModule
.
config
(
setupAngularRoutes
);
coreModule
.
config
(
setupAngularRoutes
);
registerAngularDirectives
();
registerAngularDirectives
();
var
preBootRequires
=
[
System
.
import
(
'app/features/all'
)];
const
preBootRequires
=
[
System
.
import
(
'app/features/all'
)];
Promise
.
all
(
preBootRequires
)
Promise
.
all
(
preBootRequires
)
.
then
(()
=>
{
.
then
(()
=>
{
...
...
public/app/containers/Explore/Explore.tsx
View file @
e1beaaa0
...
@@ -346,19 +346,24 @@ export class Explore extends React.Component<any, ExploreState> {
...
@@ -346,19 +346,24 @@ export class Explore extends React.Component<any, ExploreState> {
onQuerySuccess
(
datasourceId
:
string
,
queries
:
any
[]):
void
{
onQuerySuccess
(
datasourceId
:
string
,
queries
:
any
[]):
void
{
// save queries to history
// save queries to history
let
{
datasource
,
history
}
=
this
.
state
;
let
{
history
}
=
this
.
state
;
const
{
datasource
}
=
this
.
state
;
if
(
datasource
.
meta
.
id
!==
datasourceId
)
{
if
(
datasource
.
meta
.
id
!==
datasourceId
)
{
// Navigated away, queries did not matter
// Navigated away, queries did not matter
return
;
return
;
}
}
const
ts
=
Date
.
now
();
const
ts
=
Date
.
now
();
queries
.
forEach
(
q
=>
{
queries
.
forEach
(
q
=>
{
const
{
query
}
=
q
;
const
{
query
}
=
q
;
history
=
[{
query
,
ts
},
...
history
];
history
=
[{
query
,
ts
},
...
history
];
});
});
if
(
history
.
length
>
MAX_HISTORY_ITEMS
)
{
if
(
history
.
length
>
MAX_HISTORY_ITEMS
)
{
history
=
history
.
slice
(
0
,
MAX_HISTORY_ITEMS
);
history
=
history
.
slice
(
0
,
MAX_HISTORY_ITEMS
);
}
}
// Combine all queries of a datasource type into one history
// Combine all queries of a datasource type into one history
const
historyKey
=
`grafana.explore.history.
${
datasourceId
}
`
;
const
historyKey
=
`grafana.explore.history.
${
datasourceId
}
`
;
store
.
setObject
(
historyKey
,
history
);
store
.
setObject
(
historyKey
,
history
);
...
...
public/app/containers/Explore/Graph.tsx
View file @
e1beaaa0
...
@@ -12,10 +12,10 @@ import Legend from './Legend';
...
@@ -12,10 +12,10 @@ import Legend from './Legend';
// Copied from graph.ts
// Copied from graph.ts
function
time_format
(
ticks
,
min
,
max
)
{
function
time_format
(
ticks
,
min
,
max
)
{
if
(
min
&&
max
&&
ticks
)
{
if
(
min
&&
max
&&
ticks
)
{
var
range
=
max
-
min
;
const
range
=
max
-
min
;
var
secPerTick
=
range
/
ticks
/
1000
;
const
secPerTick
=
range
/
ticks
/
1000
;
var
oneDay
=
86400000
;
const
oneDay
=
86400000
;
var
oneYear
=
31536000000
;
const
oneYear
=
31536000000
;
if
(
secPerTick
<=
45
)
{
if
(
secPerTick
<=
45
)
{
return
'%H:%M:%S'
;
return
'%H:%M:%S'
;
...
...
public/app/core/components/PageHeader/PageHeader.tsx
View file @
e1beaaa0
...
@@ -15,8 +15,8 @@ const SelectNav = ({ main, customCss }: { main: NavModelItem; customCss: string
...
@@ -15,8 +15,8 @@ const SelectNav = ({ main, customCss }: { main: NavModelItem; customCss: string
});
});
const
gotoUrl
=
evt
=>
{
const
gotoUrl
=
evt
=>
{
var
element
=
evt
.
target
;
const
element
=
evt
.
target
;
var
url
=
element
.
options
[
element
.
selectedIndex
].
value
;
const
url
=
element
.
options
[
element
.
selectedIndex
].
value
;
appEvents
.
emit
(
'location-change'
,
{
href
:
url
});
appEvents
.
emit
(
'location-change'
,
{
href
:
url
});
};
};
...
...
public/app/core/components/form_dropdown/form_dropdown.ts
View file @
e1beaaa0
...
@@ -67,7 +67,7 @@ export class FormDropdownCtrl {
...
@@ -67,7 +67,7 @@ export class FormDropdownCtrl {
// modify typeahead lookup
// modify typeahead lookup
// this = typeahead
// this = typeahead
var
typeahead
=
this
.
inputElement
.
data
(
'typeahead'
);
const
typeahead
=
this
.
inputElement
.
data
(
'typeahead'
);
typeahead
.
lookup
=
function
()
{
typeahead
.
lookup
=
function
()
{
this
.
query
=
this
.
$element
.
val
()
||
''
;
this
.
query
=
this
.
$element
.
val
()
||
''
;
this
.
source
(
this
.
query
,
this
.
process
.
bind
(
this
));
this
.
source
(
this
.
query
,
this
.
process
.
bind
(
this
));
...
@@ -100,7 +100,7 @@ export class FormDropdownCtrl {
...
@@ -100,7 +100,7 @@ export class FormDropdownCtrl {
}
}
getOptionsInternal
(
query
)
{
getOptionsInternal
(
query
)
{
var
result
=
this
.
getOptions
({
$query
:
query
});
const
result
=
this
.
getOptions
({
$query
:
query
});
if
(
this
.
isPromiseLike
(
result
))
{
if
(
this
.
isPromiseLike
(
result
))
{
return
result
;
return
result
;
}
}
...
@@ -118,7 +118,7 @@ export class FormDropdownCtrl {
...
@@ -118,7 +118,7 @@ export class FormDropdownCtrl {
// if we have text use it
// if we have text use it
if
(
this
.
lookupText
)
{
if
(
this
.
lookupText
)
{
this
.
getOptionsInternal
(
''
).
then
(
options
=>
{
this
.
getOptionsInternal
(
''
).
then
(
options
=>
{
var
item
=
_
.
find
(
options
,
{
value
:
this
.
model
});
const
item
=
_
.
find
(
options
,
{
value
:
this
.
model
});
this
.
updateDisplay
(
item
?
item
.
text
:
this
.
model
);
this
.
updateDisplay
(
item
?
item
.
text
:
this
.
model
);
});
});
}
else
{
}
else
{
...
@@ -186,7 +186,7 @@ export class FormDropdownCtrl {
...
@@ -186,7 +186,7 @@ export class FormDropdownCtrl {
}
}
this
.
$scope
.
$apply
(()
=>
{
this
.
$scope
.
$apply
(()
=>
{
var
option
=
_
.
find
(
this
.
optionCache
,
{
text
:
text
});
const
option
=
_
.
find
(
this
.
optionCache
,
{
text
:
text
});
if
(
option
)
{
if
(
option
)
{
if
(
_
.
isObject
(
this
.
model
))
{
if
(
_
.
isObject
(
this
.
model
))
{
...
@@ -228,7 +228,7 @@ export class FormDropdownCtrl {
...
@@ -228,7 +228,7 @@ export class FormDropdownCtrl {
this
.
linkElement
.
hide
();
this
.
linkElement
.
hide
();
this
.
linkMode
=
false
;
this
.
linkMode
=
false
;
var
typeahead
=
this
.
inputElement
.
data
(
'typeahead'
);
const
typeahead
=
this
.
inputElement
.
data
(
'typeahead'
);
if
(
typeahead
)
{
if
(
typeahead
)
{
this
.
inputElement
.
val
(
''
);
this
.
inputElement
.
val
(
''
);
typeahead
.
lookup
();
typeahead
.
lookup
();
...
...
public/app/core/components/manage_dashboards/manage_dashboards.ts
View file @
e1beaaa0
...
@@ -238,7 +238,7 @@ export class ManageDashboardsCtrl {
...
@@ -238,7 +238,7 @@ export class ManageDashboardsCtrl {
}
}
onTagFilterChange
()
{
onTagFilterChange
()
{
var
res
=
this
.
filterByTag
(
this
.
selectedTagFilter
.
term
);
const
res
=
this
.
filterByTag
(
this
.
selectedTagFilter
.
term
);
this
.
selectedTagFilter
=
this
.
tagFilterOptions
[
0
];
this
.
selectedTagFilter
=
this
.
tagFilterOptions
[
0
];
return
res
;
return
res
;
}
}
...
...
public/app/core/controllers/inspect_ctrl.ts
View file @
e1beaaa0
...
@@ -6,7 +6,7 @@ import coreModule from '../core_module';
...
@@ -6,7 +6,7 @@ import coreModule from '../core_module';
export
class
InspectCtrl
{
export
class
InspectCtrl
{
/** @ngInject */
/** @ngInject */
constructor
(
$scope
,
$sanitize
)
{
constructor
(
$scope
,
$sanitize
)
{
var
model
=
$scope
.
inspector
;
const
model
=
$scope
.
inspector
;
$scope
.
init
=
function
()
{
$scope
.
init
=
function
()
{
$scope
.
editor
=
{
index
:
0
};
$scope
.
editor
=
{
index
:
0
};
...
@@ -53,10 +53,10 @@ export class InspectCtrl {
...
@@ -53,10 +53,10 @@ export class InspectCtrl {
};
};
}
}
getParametersFromQueryString
(
queryString
)
{
getParametersFromQueryString
(
queryString
)
{
var
result
=
[];
const
result
=
[];
var
parameters
=
queryString
.
split
(
'&'
);
const
parameters
=
queryString
.
split
(
'&'
);
for
(
var
i
=
0
;
i
<
parameters
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
parameters
.
length
;
i
++
)
{
var
keyValue
=
parameters
[
i
].
split
(
'='
);
const
keyValue
=
parameters
[
i
].
split
(
'='
);
if
(
keyValue
[
1
].
length
>
0
)
{
if
(
keyValue
[
1
].
length
>
0
)
{
result
.
push
({
result
.
push
({
key
:
keyValue
[
0
],
key
:
keyValue
[
0
],
...
...
public/app/core/controllers/json_editor_ctrl.ts
View file @
e1beaaa0
...
@@ -9,7 +9,7 @@ export class JsonEditorCtrl {
...
@@ -9,7 +9,7 @@ export class JsonEditorCtrl {
$scope
.
canCopy
=
$scope
.
enableCopy
;
$scope
.
canCopy
=
$scope
.
enableCopy
;
$scope
.
update
=
function
()
{
$scope
.
update
=
function
()
{
var
newObject
=
angular
.
fromJson
(
$scope
.
json
);
const
newObject
=
angular
.
fromJson
(
$scope
.
json
);
$scope
.
updateHandler
(
newObject
,
$scope
.
object
);
$scope
.
updateHandler
(
newObject
,
$scope
.
object
);
};
};
...
...
public/app/core/controllers/login_ctrl.ts
View file @
e1beaaa0
...
@@ -118,7 +118,7 @@ export class LoginCtrl {
...
@@ -118,7 +118,7 @@ export class LoginCtrl {
};
};
$scope
.
toGrafana
=
function
()
{
$scope
.
toGrafana
=
function
()
{
var
params
=
$location
.
search
();
const
params
=
$location
.
search
();
if
(
params
.
redirect
&&
params
.
redirect
[
0
]
===
'/'
)
{
if
(
params
.
redirect
&&
params
.
redirect
[
0
]
===
'/'
)
{
window
.
location
.
href
=
config
.
appSubUrl
+
params
.
redirect
;
window
.
location
.
href
=
config
.
appSubUrl
+
params
.
redirect
;
...
...
public/app/core/controllers/reset_password_ctrl.ts
View file @
e1beaaa0
...
@@ -7,7 +7,7 @@ export class ResetPasswordCtrl {
...
@@ -7,7 +7,7 @@ export class ResetPasswordCtrl {
$scope
.
formModel
=
{};
$scope
.
formModel
=
{};
$scope
.
mode
=
'send'
;
$scope
.
mode
=
'send'
;
var
params
=
$location
.
search
();
const
params
=
$location
.
search
();
if
(
params
.
code
)
{
if
(
params
.
code
)
{
$scope
.
mode
=
'reset'
;
$scope
.
mode
=
'reset'
;
$scope
.
formModel
.
code
=
params
.
code
;
$scope
.
formModel
.
code
=
params
.
code
;
...
...
public/app/core/controllers/signup_ctrl.ts
View file @
e1beaaa0
...
@@ -9,7 +9,7 @@ export class SignUpCtrl {
...
@@ -9,7 +9,7 @@ export class SignUpCtrl {
$scope
.
formModel
=
{};
$scope
.
formModel
=
{};
var
params
=
$location
.
search
();
const
params
=
$location
.
search
();
// validate email is semi ok
// validate email is semi ok
if
(
params
.
email
&&
!
params
.
email
.
match
(
/^
\S
+@
\S
+$/
))
{
if
(
params
.
email
&&
!
params
.
email
.
match
(
/^
\S
+@
\S
+$/
))
{
...
...
public/app/core/filters/filters.ts
View file @
e1beaaa0
...
@@ -38,7 +38,7 @@ coreModule.filter('moment', function() {
...
@@ -38,7 +38,7 @@ coreModule.filter('moment', function() {
});
});
coreModule
.
filter
(
'noXml'
,
function
()
{
coreModule
.
filter
(
'noXml'
,
function
()
{
var
noXml
=
function
(
text
)
{
const
noXml
=
function
(
text
)
{
return
_
.
isString
(
text
)
return
_
.
isString
(
text
)
?
text
?
text
.
replace
(
/&/g
,
'&'
)
.
replace
(
/&/g
,
'&'
)
...
@@ -55,7 +55,7 @@ coreModule.filter('noXml', function() {
...
@@ -55,7 +55,7 @@ coreModule.filter('noXml', function() {
/** @ngInject */
/** @ngInject */
function
interpolateTemplateVars
(
templateSrv
)
{
function
interpolateTemplateVars
(
templateSrv
)
{
var
filterFunc
:
any
=
function
(
text
,
scope
)
{
const
filterFunc
:
any
=
function
(
text
,
scope
)
{
var
scopedVars
;
var
scopedVars
;
if
(
scope
.
ctrl
)
{
if
(
scope
.
ctrl
)
{
scopedVars
=
(
scope
.
ctrl
.
panel
||
scope
.
ctrl
.
row
).
scopedVars
;
scopedVars
=
(
scope
.
ctrl
.
panel
||
scope
.
ctrl
.
row
).
scopedVars
;
...
...
public/app/core/services/alert_srv.ts
View file @
e1beaaa0
...
@@ -60,14 +60,14 @@ export class AlertSrv {
...
@@ -60,14 +60,14 @@ export class AlertSrv {
}
}
}
}
var
newAlert
=
{
const
newAlert
=
{
title
:
title
||
''
,
title
:
title
||
''
,
text
:
text
||
''
,
text
:
text
||
''
,
severity
:
severity
||
'info'
,
severity
:
severity
||
'info'
,
icon
:
this
.
getIconForSeverity
(
severity
),
icon
:
this
.
getIconForSeverity
(
severity
),
};
};
var
newAlertJson
=
angular
.
toJson
(
newAlert
);
const
newAlertJson
=
angular
.
toJson
(
newAlert
);
// remove same alert if it already exists
// remove same alert if it already exists
_
.
remove
(
this
.
list
,
function
(
value
)
{
_
.
remove
(
this
.
list
,
function
(
value
)
{
...
...
public/app/core/services/analytics.ts
View file @
e1beaaa0
...
@@ -12,7 +12,7 @@ export class Analytics {
...
@@ -12,7 +12,7 @@ export class Analytics {
dataType
:
'script'
,
dataType
:
'script'
,
cache
:
true
,
cache
:
true
,
});
});
var
ga
=
((
<
any
>
window
).
ga
=
const
ga
=
((
<
any
>
window
).
ga
=
(
<
any
>
window
).
ga
||
(
<
any
>
window
).
ga
||
function
()
{
function
()
{
(
ga
.
q
=
ga
.
q
||
[]).
push
(
arguments
);
(
ga
.
q
=
ga
.
q
||
[]).
push
(
arguments
);
...
@@ -25,8 +25,8 @@ export class Analytics {
...
@@ -25,8 +25,8 @@ export class Analytics {
init
()
{
init
()
{
this
.
$rootScope
.
$on
(
'$viewContentLoaded'
,
()
=>
{
this
.
$rootScope
.
$on
(
'$viewContentLoaded'
,
()
=>
{
var
track
=
{
page
:
this
.
$location
.
url
()
};
const
track
=
{
page
:
this
.
$location
.
url
()
};
var
ga
=
(
<
any
>
window
).
ga
||
this
.
gaInit
();
const
ga
=
(
<
any
>
window
).
ga
||
this
.
gaInit
();
ga
(
'set'
,
track
);
ga
(
'set'
,
track
);
ga
(
'send'
,
'pageview'
);
ga
(
'send'
,
'pageview'
);
});
});
...
...
public/app/core/services/dynamic_directive_srv.ts
View file @
e1beaaa0
...
@@ -6,7 +6,7 @@ class DynamicDirectiveSrv {
...
@@ -6,7 +6,7 @@ class DynamicDirectiveSrv {
constructor
(
private
$compile
,
private
$rootScope
)
{}
constructor
(
private
$compile
,
private
$rootScope
)
{}
addDirective
(
element
,
name
,
scope
)
{
addDirective
(
element
,
name
,
scope
)
{
var
child
=
angular
.
element
(
document
.
createElement
(
name
));
const
child
=
angular
.
element
(
document
.
createElement
(
name
));
this
.
$compile
(
child
)(
scope
);
this
.
$compile
(
child
)(
scope
);
element
.
empty
();
element
.
empty
();
...
...
public/app/core/services/keybindingSrv.ts
View file @
e1beaaa0
...
@@ -70,7 +70,7 @@ export class KeybindingSrv {
...
@@ -70,7 +70,7 @@ export class KeybindingSrv {
}
}
exit
()
{
exit
()
{
var
popups
=
$
(
'.popover.in'
);
const
popups
=
$
(
'.popover.in'
);
if
(
popups
.
length
>
0
)
{
if
(
popups
.
length
>
0
)
{
return
;
return
;
}
}
...
@@ -89,7 +89,7 @@ export class KeybindingSrv {
...
@@ -89,7 +89,7 @@ export class KeybindingSrv {
}
}
// close settings view
// close settings view
var
search
=
this
.
$location
.
search
();
const
search
=
this
.
$location
.
search
();
if
(
search
.
editview
)
{
if
(
search
.
editview
)
{
delete
search
.
editview
;
delete
search
.
editview
;
this
.
$location
.
search
(
search
);
this
.
$location
.
search
(
search
);
...
@@ -123,7 +123,7 @@ export class KeybindingSrv {
...
@@ -123,7 +123,7 @@ export class KeybindingSrv {
}
}
showDashEditView
()
{
showDashEditView
()
{
var
search
=
_
.
extend
(
this
.
$location
.
search
(),
{
editview
:
'settings'
});
const
search
=
_
.
extend
(
this
.
$location
.
search
(),
{
editview
:
'settings'
});
this
.
$location
.
search
(
search
);
this
.
$location
.
search
(
search
);
}
}
...
@@ -218,8 +218,8 @@ export class KeybindingSrv {
...
@@ -218,8 +218,8 @@ export class KeybindingSrv {
// share panel
// share panel
this
.
bind
(
'p s'
,
()
=>
{
this
.
bind
(
'p s'
,
()
=>
{
if
(
dashboard
.
meta
.
focusPanelId
)
{
if
(
dashboard
.
meta
.
focusPanelId
)
{
var
shareScope
=
scope
.
$new
();
const
shareScope
=
scope
.
$new
();
var
panelInfo
=
dashboard
.
getPanelInfoById
(
dashboard
.
meta
.
focusPanelId
);
const
panelInfo
=
dashboard
.
getPanelInfoById
(
dashboard
.
meta
.
focusPanelId
);
shareScope
.
panel
=
panelInfo
.
panel
;
shareScope
.
panel
=
panelInfo
.
panel
;
shareScope
.
dashboard
=
dashboard
;
shareScope
.
dashboard
=
dashboard
;
...
...
public/app/core/services/popover_srv.ts
View file @
e1beaaa0
...
@@ -18,10 +18,10 @@ function popoverSrv($compile, $rootScope, $timeout) {
...
@@ -18,10 +18,10 @@ function popoverSrv($compile, $rootScope, $timeout) {
openDrop
=
null
;
openDrop
=
null
;
}
}
var
scope
=
_
.
extend
(
$rootScope
.
$new
(
true
),
options
.
model
);
const
scope
=
_
.
extend
(
$rootScope
.
$new
(
true
),
options
.
model
);
var
drop
;
let
drop
;
var
cleanUp
=
()
=>
{
const
cleanUp
=
()
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
scope
.
$destroy
();
scope
.
$destroy
();
...
@@ -41,7 +41,7 @@ function popoverSrv($compile, $rootScope, $timeout) {
...
@@ -41,7 +41,7 @@ function popoverSrv($compile, $rootScope, $timeout) {
drop
.
close
();
drop
.
close
();
};
};
var
contentElement
=
document
.
createElement
(
'div'
);
const
contentElement
=
document
.
createElement
(
'div'
);
contentElement
.
innerHTML
=
options
.
template
;
contentElement
.
innerHTML
=
options
.
template
;
$compile
(
contentElement
)(
scope
);
$compile
(
contentElement
)(
scope
);
...
...
public/app/core/services/util_srv.ts
View file @
e1beaaa0
...
@@ -33,7 +33,7 @@ export class UtilSrv {
...
@@ -33,7 +33,7 @@ export class UtilSrv {
this
.
modalScope
=
this
.
$rootScope
.
$new
();
this
.
modalScope
=
this
.
$rootScope
.
$new
();
}
}
var
modal
=
this
.
$modal
({
const
modal
=
this
.
$modal
({
modalClass
:
options
.
modalClass
,
modalClass
:
options
.
modalClass
,
template
:
options
.
src
,
template
:
options
.
src
,
templateHtml
:
options
.
templateHtml
,
templateHtml
:
options
.
templateHtml
,
...
@@ -50,7 +50,7 @@ export class UtilSrv {
...
@@ -50,7 +50,7 @@ export class UtilSrv {
}
}
showConfirmModal
(
payload
)
{
showConfirmModal
(
payload
)
{
var
scope
=
this
.
$rootScope
.
$new
();
const
scope
=
this
.
$rootScope
.
$new
();
scope
.
onConfirm
=
function
()
{
scope
.
onConfirm
=
function
()
{
payload
.
onConfirm
();
payload
.
onConfirm
();
...
...
public/app/core/specs/datemath.test.ts
View file @
e1beaaa0
...
@@ -5,11 +5,11 @@ import moment from 'moment';
...
@@ -5,11 +5,11 @@ import moment from 'moment';
import
_
from
'lodash'
;
import
_
from
'lodash'
;
describe
(
'DateMath'
,
()
=>
{
describe
(
'DateMath'
,
()
=>
{
var
spans
=
[
's'
,
'm'
,
'h'
,
'd'
,
'w'
,
'M'
,
'y'
];
const
spans
=
[
's'
,
'm'
,
'h'
,
'd'
,
'w'
,
'M'
,
'y'
];
var
anchor
=
'2014-01-01T06:06:06.666Z'
;
const
anchor
=
'2014-01-01T06:06:06.666Z'
;
var
unix
=
moment
(
anchor
).
valueOf
();
const
unix
=
moment
(
anchor
).
valueOf
();
var
format
=
'YYYY-MM-DDTHH:mm:ss.SSSZ'
;
const
format
=
'YYYY-MM-DDTHH:mm:ss.SSSZ'
;
var
clock
;
let
clock
;
describe
(
'errors'
,
()
=>
{
describe
(
'errors'
,
()
=>
{
it
(
'should return undefined if passed something falsy'
,
()
=>
{
it
(
'should return undefined if passed something falsy'
,
()
=>
{
...
@@ -36,21 +36,21 @@ describe('DateMath', () => {
...
@@ -36,21 +36,21 @@ describe('DateMath', () => {
});
});
it
(
'now/d should set to start of current day'
,
()
=>
{
it
(
'now/d should set to start of current day'
,
()
=>
{
var
expected
=
new
Date
();
const
expected
=
new
Date
();
expected
.
setHours
(
0
);
expected
.
setHours
(
0
);
expected
.
setMinutes
(
0
);
expected
.
setMinutes
(
0
);
expected
.
setSeconds
(
0
);
expected
.
setSeconds
(
0
);
expected
.
setMilliseconds
(
0
);
expected
.
setMilliseconds
(
0
);
var
startOfDay
=
dateMath
.
parse
(
'now/d'
,
false
).
valueOf
();
const
startOfDay
=
dateMath
.
parse
(
'now/d'
,
false
).
valueOf
();
expect
(
startOfDay
).
toBe
(
expected
.
getTime
());
expect
(
startOfDay
).
toBe
(
expected
.
getTime
());
});
});
it
(
'now/d on a utc dashboard should be start of the current day in UTC time'
,
()
=>
{
it
(
'now/d on a utc dashboard should be start of the current day in UTC time'
,
()
=>
{
var
today
=
new
Date
();
const
today
=
new
Date
();
var
expected
=
new
Date
(
Date
.
UTC
(
today
.
getUTCFullYear
(),
today
.
getUTCMonth
(),
today
.
getUTCDate
(),
0
,
0
,
0
,
0
));
const
expected
=
new
Date
(
Date
.
UTC
(
today
.
getUTCFullYear
(),
today
.
getUTCMonth
(),
today
.
getUTCDate
(),
0
,
0
,
0
,
0
));
var
startOfDay
=
dateMath
.
parse
(
'now/d'
,
false
,
'utc'
).
valueOf
();
const
startOfDay
=
dateMath
.
parse
(
'now/d'
,
false
,
'utc'
).
valueOf
();
expect
(
startOfDay
).
toBe
(
expected
.
getTime
());
expect
(
startOfDay
).
toBe
(
expected
.
getTime
());
});
});
...
@@ -65,8 +65,8 @@ describe('DateMath', () => {
...
@@ -65,8 +65,8 @@ describe('DateMath', () => {
});
});
_
.
each
(
spans
,
span
=>
{
_
.
each
(
spans
,
span
=>
{
var
nowEx
=
'now-5'
+
span
;
const
nowEx
=
'now-5'
+
span
;
var
thenEx
=
anchor
+
'||-5'
+
span
;
const
thenEx
=
anchor
+
'||-5'
+
span
;
it
(
'should return 5'
+
span
+
' ago'
,
()
=>
{
it
(
'should return 5'
+
span
+
' ago'
,
()
=>
{
expect
(
dateMath
.
parse
(
nowEx
).
format
(
format
)).
toEqual
(
now
.
subtract
(
5
,
span
).
format
(
format
));
expect
(
dateMath
.
parse
(
nowEx
).
format
(
format
)).
toEqual
(
now
.
subtract
(
5
,
span
).
format
(
format
));
...
@@ -116,17 +116,17 @@ describe('DateMath', () => {
...
@@ -116,17 +116,17 @@ describe('DateMath', () => {
describe
(
'relative time to date parsing'
,
function
()
{
describe
(
'relative time to date parsing'
,
function
()
{
it
(
'should handle negative time'
,
function
()
{
it
(
'should handle negative time'
,
function
()
{
var
date
=
dateMath
.
parseDateMath
(
'-2d'
,
moment
([
2014
,
1
,
5
]));
const
date
=
dateMath
.
parseDateMath
(
'-2d'
,
moment
([
2014
,
1
,
5
]));
expect
(
date
.
valueOf
()).
toEqual
(
moment
([
2014
,
1
,
3
]).
valueOf
());
expect
(
date
.
valueOf
()).
toEqual
(
moment
([
2014
,
1
,
3
]).
valueOf
());
});
});
it
(
'should handle multiple math expressions'
,
function
()
{
it
(
'should handle multiple math expressions'
,
function
()
{
var
date
=
dateMath
.
parseDateMath
(
'-2d-6h'
,
moment
([
2014
,
1
,
5
]));
const
date
=
dateMath
.
parseDateMath
(
'-2d-6h'
,
moment
([
2014
,
1
,
5
]));
expect
(
date
.
valueOf
()).
toEqual
(
moment
([
2014
,
1
,
2
,
18
]).
valueOf
());
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'
,
function
()
{
var
date
=
dateMath
.
parseDateMath
(
'2'
,
moment
([
2014
,
1
,
5
]));
const
date
=
dateMath
.
parseDateMath
(
'2'
,
moment
([
2014
,
1
,
5
]));
expect
(
date
).
toEqual
(
undefined
);
expect
(
date
).
toEqual
(
undefined
);
});
});
});
});
...
...
public/app/core/specs/emitter.test.ts
View file @
e1beaaa0
...
@@ -3,9 +3,9 @@ import { Emitter } from '../utils/emitter';
...
@@ -3,9 +3,9 @@ import { Emitter } from '../utils/emitter';
describe
(
'Emitter'
,
()
=>
{
describe
(
'Emitter'
,
()
=>
{
describe
(
'given 2 subscribers'
,
()
=>
{
describe
(
'given 2 subscribers'
,
()
=>
{
it
(
'should notfiy subscribers'
,
()
=>
{
it
(
'should notfiy subscribers'
,
()
=>
{
var
events
=
new
Emitter
();
const
events
=
new
Emitter
();
var
sub1Called
=
false
;
let
sub1Called
=
false
;
var
sub2Called
=
false
;
let
sub2Called
=
false
;
events
.
on
(
'test'
,
()
=>
{
events
.
on
(
'test'
,
()
=>
{
sub1Called
=
true
;
sub1Called
=
true
;
...
@@ -21,8 +21,8 @@ describe('Emitter', () => {
...
@@ -21,8 +21,8 @@ describe('Emitter', () => {
});
});
it
(
'when subscribing twice'
,
()
=>
{
it
(
'when subscribing twice'
,
()
=>
{
var
events
=
new
Emitter
();
const
events
=
new
Emitter
();
var
sub1Called
=
0
;
let
sub1Called
=
0
;
function
handler
()
{
function
handler
()
{
sub1Called
+=
1
;
sub1Called
+=
1
;
...
@@ -37,9 +37,9 @@ describe('Emitter', () => {
...
@@ -37,9 +37,9 @@ describe('Emitter', () => {
});
});
it
(
'should handle errors'
,
()
=>
{
it
(
'should handle errors'
,
()
=>
{
var
events
=
new
Emitter
();
const
events
=
new
Emitter
();
var
sub1Called
=
0
;
let
sub1Called
=
0
;
var
sub2Called
=
0
;
let
sub2Called
=
0
;
events
.
on
(
'test'
,
()
=>
{
events
.
on
(
'test'
,
()
=>
{
sub1Called
++
;
sub1Called
++
;
...
...
public/app/core/specs/flatten.test.ts
View file @
e1beaaa0
...
@@ -2,7 +2,7 @@ import flatten from 'app/core/utils/flatten';
...
@@ -2,7 +2,7 @@ import flatten from 'app/core/utils/flatten';
describe
(
'flatten'
,
()
=>
{
describe
(
'flatten'
,
()
=>
{
it
(
'should return flatten object'
,
()
=>
{
it
(
'should return flatten object'
,
()
=>
{
var
flattened
=
flatten
(
const
flattened
=
flatten
(
{
{
level1
:
'level1-value'
,
level1
:
'level1-value'
,
deeper
:
{
deeper
:
{
...
...
public/app/core/specs/kbn.test.ts
View file @
e1beaaa0
This diff is collapsed.
Click to expand it.
public/app/core/specs/rangeutil.test.ts
View file @
e1beaaa0
...
@@ -5,7 +5,7 @@ import moment from 'moment';
...
@@ -5,7 +5,7 @@ import moment from 'moment';
describe
(
'rangeUtil'
,
()
=>
{
describe
(
'rangeUtil'
,
()
=>
{
describe
(
'Can get range grouped list of ranges'
,
()
=>
{
describe
(
'Can get range grouped list of ranges'
,
()
=>
{
it
(
'when custom settings should return default range list'
,
()
=>
{
it
(
'when custom settings should return default range list'
,
()
=>
{
var
groups
=
rangeUtil
.
getRelativeTimesList
({
time_options
:
[]
},
'Last 5 minutes'
);
const
groups
=
rangeUtil
.
getRelativeTimesList
({
time_options
:
[]
},
'Last 5 minutes'
);
expect
(
_
.
keys
(
groups
).
length
).
toBe
(
4
);
expect
(
_
.
keys
(
groups
).
length
).
toBe
(
4
);
expect
(
groups
[
3
][
0
].
active
).
toBe
(
true
);
expect
(
groups
[
3
][
0
].
active
).
toBe
(
true
);
});
});
...
@@ -13,62 +13,62 @@ describe('rangeUtil', () => {
...
@@ -13,62 +13,62 @@ describe('rangeUtil', () => {
describe
(
'Can get range text described'
,
()
=>
{
describe
(
'Can get range text described'
,
()
=>
{
it
(
'should handle simple old expression with only amount and unit'
,
()
=>
{
it
(
'should handle simple old expression with only amount and unit'
,
()
=>
{
var
info
=
rangeUtil
.
describeTextRange
(
'5m'
);
const
info
=
rangeUtil
.
describeTextRange
(
'5m'
);
expect
(
info
.
display
).
toBe
(
'Last 5 minutes'
);
expect
(
info
.
display
).
toBe
(
'Last 5 minutes'
);
});
});
it
(
'should have singular when amount is 1'
,
()
=>
{
it
(
'should have singular when amount is 1'
,
()
=>
{
var
info
=
rangeUtil
.
describeTextRange
(
'1h'
);
const
info
=
rangeUtil
.
describeTextRange
(
'1h'
);
expect
(
info
.
display
).
toBe
(
'Last 1 hour'
);
expect
(
info
.
display
).
toBe
(
'Last 1 hour'
);
});
});
it
(
'should handle non default amount'
,
()
=>
{
it
(
'should handle non default amount'
,
()
=>
{
var
info
=
rangeUtil
.
describeTextRange
(
'13h'
);
const
info
=
rangeUtil
.
describeTextRange
(
'13h'
);
expect
(
info
.
display
).
toBe
(
'Last 13 hours'
);
expect
(
info
.
display
).
toBe
(
'Last 13 hours'
);
expect
(
info
.
from
).
toBe
(
'now-13h'
);
expect
(
info
.
from
).
toBe
(
'now-13h'
);
});
});
it
(
'should handle non default future amount'
,
()
=>
{
it
(
'should handle non default future amount'
,
()
=>
{
var
info
=
rangeUtil
.
describeTextRange
(
'+3h'
);
const
info
=
rangeUtil
.
describeTextRange
(
'+3h'
);
expect
(
info
.
display
).
toBe
(
'Next 3 hours'
);
expect
(
info
.
display
).
toBe
(
'Next 3 hours'
);
expect
(
info
.
from
).
toBe
(
'now'
);
expect
(
info
.
from
).
toBe
(
'now'
);
expect
(
info
.
to
).
toBe
(
'now+3h'
);
expect
(
info
.
to
).
toBe
(
'now+3h'
);
});
});
it
(
'should handle now/d'
,
()
=>
{
it
(
'should handle now/d'
,
()
=>
{
var
info
=
rangeUtil
.
describeTextRange
(
'now/d'
);
const
info
=
rangeUtil
.
describeTextRange
(
'now/d'
);
expect
(
info
.
display
).
toBe
(
'Today so far'
);
expect
(
info
.
display
).
toBe
(
'Today so far'
);
});
});
it
(
'should handle now/w'
,
()
=>
{
it
(
'should handle now/w'
,
()
=>
{
var
info
=
rangeUtil
.
describeTextRange
(
'now/w'
);
const
info
=
rangeUtil
.
describeTextRange
(
'now/w'
);
expect
(
info
.
display
).
toBe
(
'This week so far'
);
expect
(
info
.
display
).
toBe
(
'This week so far'
);
});
});
it
(
'should handle now/M'
,
()
=>
{
it
(
'should handle now/M'
,
()
=>
{
var
info
=
rangeUtil
.
describeTextRange
(
'now/M'
);
const
info
=
rangeUtil
.
describeTextRange
(
'now/M'
);
expect
(
info
.
display
).
toBe
(
'This month so far'
);
expect
(
info
.
display
).
toBe
(
'This month so far'
);
});
});
it
(
'should handle now/y'
,
()
=>
{
it
(
'should handle now/y'
,
()
=>
{
var
info
=
rangeUtil
.
describeTextRange
(
'now/y'
);
const
info
=
rangeUtil
.
describeTextRange
(
'now/y'
);
expect
(
info
.
display
).
toBe
(
'This year so far'
);
expect
(
info
.
display
).
toBe
(
'This year so far'
);
});
});
});
});
describe
(
'Can get date range described'
,
()
=>
{
describe
(
'Can get date range described'
,
()
=>
{
it
(
'Date range with simple ranges'
,
()
=>
{
it
(
'Date range with simple ranges'
,
()
=>
{
var
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now-1h'
,
to
:
'now'
});
const
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now-1h'
,
to
:
'now'
});
expect
(
text
).
toBe
(
'Last 1 hour'
);
expect
(
text
).
toBe
(
'Last 1 hour'
);
});
});
it
(
'Date range with rounding ranges'
,
()
=>
{
it
(
'Date range with rounding ranges'
,
()
=>
{
var
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now/d+6h'
,
to
:
'now'
});
const
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now/d+6h'
,
to
:
'now'
});
expect
(
text
).
toBe
(
'now/d+6h to now'
);
expect
(
text
).
toBe
(
'now/d+6h to now'
);
});
});
it
(
'Date range with absolute to now'
,
()
=>
{
it
(
'Date range with absolute to now'
,
()
=>
{
var
text
=
rangeUtil
.
describeTimeRange
({
const
text
=
rangeUtil
.
describeTimeRange
({
from
:
moment
([
2014
,
10
,
10
,
2
,
3
,
4
]),
from
:
moment
([
2014
,
10
,
10
,
2
,
3
,
4
]),
to
:
'now'
,
to
:
'now'
,
});
});
...
@@ -76,7 +76,7 @@ describe('rangeUtil', () => {
...
@@ -76,7 +76,7 @@ describe('rangeUtil', () => {
});
});
it
(
'Date range with absolute to relative'
,
()
=>
{
it
(
'Date range with absolute to relative'
,
()
=>
{
var
text
=
rangeUtil
.
describeTimeRange
({
const
text
=
rangeUtil
.
describeTimeRange
({
from
:
moment
([
2014
,
10
,
10
,
2
,
3
,
4
]),
from
:
moment
([
2014
,
10
,
10
,
2
,
3
,
4
]),
to
:
'now-1d'
,
to
:
'now-1d'
,
});
});
...
@@ -84,7 +84,7 @@ describe('rangeUtil', () => {
...
@@ -84,7 +84,7 @@ describe('rangeUtil', () => {
});
});
it
(
'Date range with relative to absolute'
,
()
=>
{
it
(
'Date range with relative to absolute'
,
()
=>
{
var
text
=
rangeUtil
.
describeTimeRange
({
const
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now-7d'
,
from
:
'now-7d'
,
to
:
moment
([
2014
,
10
,
10
,
2
,
3
,
4
]),
to
:
moment
([
2014
,
10
,
10
,
2
,
3
,
4
]),
});
});
...
@@ -92,17 +92,17 @@ describe('rangeUtil', () => {
...
@@ -92,17 +92,17 @@ describe('rangeUtil', () => {
});
});
it
(
'Date range with non matching default ranges'
,
()
=>
{
it
(
'Date range with non matching default ranges'
,
()
=>
{
var
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now-13h'
,
to
:
'now'
});
const
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now-13h'
,
to
:
'now'
});
expect
(
text
).
toBe
(
'Last 13 hours'
);
expect
(
text
).
toBe
(
'Last 13 hours'
);
});
});
it
(
'Date range with from and to both are in now-* format'
,
()
=>
{
it
(
'Date range with from and to both are in now-* format'
,
()
=>
{
var
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now-6h'
,
to
:
'now-3h'
});
const
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now-6h'
,
to
:
'now-3h'
});
expect
(
text
).
toBe
(
'now-6h to now-3h'
);
expect
(
text
).
toBe
(
'now-6h to now-3h'
);
});
});
it
(
'Date range with from and to both are either in now-* or now/* format'
,
()
=>
{
it
(
'Date range with from and to both are either in now-* or now/* format'
,
()
=>
{
var
text
=
rangeUtil
.
describeTimeRange
({
const
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now/d+6h'
,
from
:
'now/d+6h'
,
to
:
'now-3h'
,
to
:
'now-3h'
,
});
});
...
@@ -110,7 +110,7 @@ describe('rangeUtil', () => {
...
@@ -110,7 +110,7 @@ describe('rangeUtil', () => {
});
});
it
(
'Date range with from and to both are either in now-* or now+* format'
,
()
=>
{
it
(
'Date range with from and to both are either in now-* or now+* format'
,
()
=>
{
var
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now-6h'
,
to
:
'now+1h'
});
const
text
=
rangeUtil
.
describeTimeRange
({
from
:
'now-6h'
,
to
:
'now+1h'
});
expect
(
text
).
toBe
(
'now-6h to now+1h'
);
expect
(
text
).
toBe
(
'now-6h to now+1h'
);
});
});
});
});
...
...
public/app/core/specs/table_model.test.ts
View file @
e1beaaa0
import
TableModel
from
'app/core/table_model'
;
import
TableModel
from
'app/core/table_model'
;
describe
(
'when sorting table desc'
,
()
=>
{
describe
(
'when sorting table desc'
,
()
=>
{
var
table
;
let
table
;
var
panel
=
{
const
panel
=
{
sort
:
{
col
:
0
,
desc
:
true
},
sort
:
{
col
:
0
,
desc
:
true
},
};
};
...
@@ -27,7 +27,7 @@ describe('when sorting table desc', () => {
...
@@ -27,7 +27,7 @@ describe('when sorting table desc', () => {
describe
(
'when sorting table asc'
,
()
=>
{
describe
(
'when sorting table asc'
,
()
=>
{
var
table
;
var
table
;
var
panel
=
{
const
panel
=
{
sort
:
{
col
:
1
,
desc
:
false
},
sort
:
{
col
:
1
,
desc
:
false
},
};
};
...
...
public/app/core/specs/time_series.test.ts
View file @
e1beaaa0
...
@@ -2,9 +2,9 @@ import TimeSeries from 'app/core/time_series2';
...
@@ -2,9 +2,9 @@ import TimeSeries from 'app/core/time_series2';
import
{
updateLegendValues
}
from
'app/core/time_series2'
;
import
{
updateLegendValues
}
from
'app/core/time_series2'
;
describe
(
'TimeSeries'
,
function
()
{
describe
(
'TimeSeries'
,
function
()
{
var
points
,
series
;
let
points
,
series
;
var
yAxisFormats
=
[
'short'
,
'ms'
];
const
yAxisFormats
=
[
'short'
,
'ms'
];
var
testData
;
let
testData
;
beforeEach
(
function
()
{
beforeEach
(
function
()
{
testData
=
{
testData
=
{
...
...
public/app/core/utils/css_loader.ts
View file @
e1beaaa0
var
waitSeconds
=
100
;
const
waitSeconds
=
100
;
var
head
=
document
.
getElementsByTagName
(
'head'
)[
0
];
const
head
=
document
.
getElementsByTagName
(
'head'
)[
0
];
// get all link tags in the page
// get all link tags in the page
var
links
=
document
.
getElementsByTagName
(
'link'
);
const
links
=
document
.
getElementsByTagName
(
'link'
);
var
linkHrefs
=
[];
const
linkHrefs
=
[];
for
(
var
i
=
0
;
i
<
links
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
links
.
length
;
i
++
)
{
linkHrefs
.
push
(
links
[
i
].
href
);
linkHrefs
.
push
(
links
[
i
].
href
);
}
}
var
isWebkit
=
!!
window
.
navigator
.
userAgent
.
match
(
/AppleWebKit
\/([^
;
]
*
)
/
);
const
isWebkit
=
!!
window
.
navigator
.
userAgent
.
match
(
/AppleWebKit
\/([^
;
]
*
)
/
);
var
webkitLoadCheck
=
function
(
link
,
callback
)
{
const
webkitLoadCheck
=
function
(
link
,
callback
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
for
(
var
i
=
0
;
i
<
document
.
styleSheets
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
document
.
styleSheets
.
length
;
i
++
)
{
var
sheet
=
document
.
styleSheets
[
i
];
const
sheet
=
document
.
styleSheets
[
i
];
if
(
sheet
.
href
===
link
.
href
)
{
if
(
sheet
.
href
===
link
.
href
)
{
return
callback
();
return
callback
();
}
}
...
@@ -21,16 +21,16 @@ var webkitLoadCheck = function(link, callback) {
...
@@ -21,16 +21,16 @@ var webkitLoadCheck = function(link, callback) {
},
10
);
},
10
);
};
};
var
noop
=
function
()
{};
const
noop
=
function
()
{};
var
loadCSS
=
function
(
url
)
{
const
loadCSS
=
function
(
url
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
link
=
document
.
createElement
(
'link'
);
const
link
=
document
.
createElement
(
'link'
);
var
timeout
=
setTimeout
(
function
()
{
const
timeout
=
setTimeout
(
function
()
{
reject
(
'Unable to load CSS'
);
reject
(
'Unable to load CSS'
);
},
waitSeconds
*
1000
);
},
waitSeconds
*
1000
);
var
_callback
=
function
(
error
)
{
const
_callback
=
function
(
error
)
{
clearTimeout
(
timeout
);
clearTimeout
(
timeout
);
link
.
onload
=
link
.
onerror
=
noop
;
link
.
onload
=
link
.
onerror
=
noop
;
setTimeout
(
function
()
{
setTimeout
(
function
()
{
...
...
public/app/core/utils/flatten.ts
View file @
e1beaaa0
...
@@ -4,19 +4,19 @@
...
@@ -4,19 +4,19 @@
export
default
function
flatten
(
target
,
opts
):
any
{
export
default
function
flatten
(
target
,
opts
):
any
{
opts
=
opts
||
{};
opts
=
opts
||
{};
var
delimiter
=
opts
.
delimiter
||
'.'
;
const
delimiter
=
opts
.
delimiter
||
'.'
;
var
maxDepth
=
opts
.
maxDepth
||
3
;
let
maxDepth
=
opts
.
maxDepth
||
3
;
var
currentDepth
=
1
;
let
currentDepth
=
1
;
var
output
=
{};
const
output
=
{};
function
step
(
object
,
prev
)
{
function
step
(
object
,
prev
)
{
Object
.
keys
(
object
).
forEach
(
function
(
key
)
{
Object
.
keys
(
object
).
forEach
(
function
(
key
)
{
var
value
=
object
[
key
];
const
value
=
object
[
key
];
var
isarray
=
opts
.
safe
&&
Array
.
isArray
(
value
);
const
isarray
=
opts
.
safe
&&
Array
.
isArray
(
value
);
var
type
=
Object
.
prototype
.
toString
.
call
(
value
);
const
type
=
Object
.
prototype
.
toString
.
call
(
value
);
var
isobject
=
type
===
'[object Object]'
;
const
isobject
=
type
===
'[object Object]'
;
var
newKey
=
prev
?
prev
+
delimiter
+
key
:
key
;
const
newKey
=
prev
?
prev
+
delimiter
+
key
:
key
;
if
(
!
opts
.
maxDepth
)
{
if
(
!
opts
.
maxDepth
)
{
maxDepth
=
currentDepth
+
1
;
maxDepth
=
currentDepth
+
1
;
...
...
public/app/core/utils/kbn.ts
View file @
e1beaaa0
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
var
kbn
:
any
=
{};
const
kbn
:
any
=
{};
kbn
.
valueFormats
=
{};
kbn
.
valueFormats
=
{};
...
@@ -103,27 +103,27 @@ kbn.round_interval = function(interval) {
...
@@ -103,27 +103,27 @@ kbn.round_interval = function(interval) {
};
};
kbn
.
secondsToHms
=
function
(
seconds
)
{
kbn
.
secondsToHms
=
function
(
seconds
)
{
var
numyears
=
Math
.
floor
(
seconds
/
31536000
);
const
numyears
=
Math
.
floor
(
seconds
/
31536000
);
if
(
numyears
)
{
if
(
numyears
)
{
return
numyears
+
'y'
;
return
numyears
+
'y'
;
}
}
var
numdays
=
Math
.
floor
((
seconds
%
31536000
)
/
86400
);
const
numdays
=
Math
.
floor
((
seconds
%
31536000
)
/
86400
);
if
(
numdays
)
{
if
(
numdays
)
{
return
numdays
+
'd'
;
return
numdays
+
'd'
;
}
}
var
numhours
=
Math
.
floor
(((
seconds
%
31536000
)
%
86400
)
/
3600
);
const
numhours
=
Math
.
floor
(((
seconds
%
31536000
)
%
86400
)
/
3600
);
if
(
numhours
)
{
if
(
numhours
)
{
return
numhours
+
'h'
;
return
numhours
+
'h'
;
}
}
var
numminutes
=
Math
.
floor
((((
seconds
%
31536000
)
%
86400
)
%
3600
)
/
60
);
const
numminutes
=
Math
.
floor
((((
seconds
%
31536000
)
%
86400
)
%
3600
)
/
60
);
if
(
numminutes
)
{
if
(
numminutes
)
{
return
numminutes
+
'm'
;
return
numminutes
+
'm'
;
}
}
var
numseconds
=
Math
.
floor
((((
seconds
%
31536000
)
%
86400
)
%
3600
)
%
60
);
const
numseconds
=
Math
.
floor
((((
seconds
%
31536000
)
%
86400
)
%
3600
)
%
60
);
if
(
numseconds
)
{
if
(
numseconds
)
{
return
numseconds
+
's'
;
return
numseconds
+
's'
;
}
}
var
nummilliseconds
=
Math
.
floor
(
seconds
*
1000.0
);
const
nummilliseconds
=
Math
.
floor
(
seconds
*
1000.0
);
if
(
nummilliseconds
)
{
if
(
nummilliseconds
)
{
return
nummilliseconds
+
'ms'
;
return
nummilliseconds
+
'ms'
;
}
}
...
@@ -132,10 +132,10 @@ kbn.secondsToHms = function(seconds) {
...
@@ -132,10 +132,10 @@ kbn.secondsToHms = function(seconds) {
};
};
kbn
.
secondsToHhmmss
=
function
(
seconds
)
{
kbn
.
secondsToHhmmss
=
function
(
seconds
)
{
var
strings
=
[];
const
strings
=
[];
var
numhours
=
Math
.
floor
(
seconds
/
3600
);
const
numhours
=
Math
.
floor
(
seconds
/
3600
);
var
numminutes
=
Math
.
floor
((
seconds
%
3600
)
/
60
);
const
numminutes
=
Math
.
floor
((
seconds
%
3600
)
/
60
);
var
numseconds
=
Math
.
floor
((
seconds
%
3600
)
%
60
);
const
numseconds
=
Math
.
floor
((
seconds
%
3600
)
%
60
);
numhours
>
9
?
strings
.
push
(
''
+
numhours
)
:
strings
.
push
(
'0'
+
numhours
);
numhours
>
9
?
strings
.
push
(
''
+
numhours
)
:
strings
.
push
(
'0'
+
numhours
);
numminutes
>
9
?
strings
.
push
(
''
+
numminutes
)
:
strings
.
push
(
'0'
+
numminutes
);
numminutes
>
9
?
strings
.
push
(
''
+
numminutes
)
:
strings
.
push
(
'0'
+
numminutes
);
numseconds
>
9
?
strings
.
push
(
''
+
numseconds
)
:
strings
.
push
(
'0'
+
numseconds
);
numseconds
>
9
?
strings
.
push
(
''
+
numseconds
)
:
strings
.
push
(
'0'
+
numseconds
);
...
@@ -191,7 +191,7 @@ kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
...
@@ -191,7 +191,7 @@ kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
};
};
kbn.describe_interval = function(str) {
kbn.describe_interval = function(str) {
var
matches = str.match(kbn.interval_regex);
const
matches = str.match(kbn.interval_regex);
if (!matches || !_.has(kbn.intervals_in_seconds, matches[2])) {
if (!matches || !_.has(kbn.intervals_in_seconds, matches[2])) {
throw new Error('Invalid interval string, expecting a number followed by one of "
Mwdhmsy
"');
throw new Error('Invalid interval string, expecting a number followed by one of "
Mwdhmsy
"');
} else {
} else {
...
@@ -204,12 +204,12 @@ kbn.describe_interval = function(str) {
...
@@ -204,12 +204,12 @@ kbn.describe_interval = function(str) {
};
};
kbn.interval_to_ms = function(str) {
kbn.interval_to_ms = function(str) {
var
info = kbn.describe_interval(str);
const
info = kbn.describe_interval(str);
return info.sec * 1000 * info.count;
return info.sec * 1000 * info.count;
};
};
kbn.interval_to_seconds = function(str) {
kbn.interval_to_seconds = function(str) {
var
info = kbn.describe_interval(str);
const
info = kbn.describe_interval(str);
return info.sec * info.count;
return info.sec * info.count;
};
};
...
@@ -233,7 +233,7 @@ kbn.stringToJsRegex = function(str) {
...
@@ -233,7 +233,7 @@ kbn.stringToJsRegex = function(str) {
return new RegExp('^' + str + '$');
return new RegExp('^' + str + '$');
}
}
var
match = str.match(new RegExp('^/(.*?)/(g?i?m?y?)$'));
const
match = str.match(new RegExp('^/(.*?)/(g?i?m?y?)$'));
return new RegExp(match[1], match[2]);
return new RegExp(match[1], match[2]);
};
};
...
@@ -242,8 +242,8 @@ kbn.toFixed = function(value, decimals) {
...
@@ -242,8 +242,8 @@ kbn.toFixed = function(value, decimals) {
return '';
return '';
}
}
var
factor = decimals ? Math.pow(10, Math.max(0, decimals)) : 1;
const
factor = decimals ? Math.pow(10, Math.max(0, decimals)) : 1;
var
formatted = String(Math.round(value * factor) / factor);
const
formatted = String(Math.round(value * factor) / factor);
// if exponent return directly
// if exponent return directly
if (formatted.indexOf('e') !== -1 || value === 0) {
if (formatted.indexOf('e') !== -1 || value === 0) {
...
@@ -253,8 +253,8 @@ kbn.toFixed = function(value, decimals) {
...
@@ -253,8 +253,8 @@ kbn.toFixed = function(value, decimals) {
// If tickDecimals was specified, ensure that we have exactly that
// If tickDecimals was specified, ensure that we have exactly that
// much precision; otherwise default to the value's own precision.
// much precision; otherwise default to the value's own precision.
if (decimals != null) {
if (decimals != null) {
var
decimalPos = formatted.indexOf('.');
const
decimalPos = formatted.indexOf('.');
var
precision = decimalPos === -1 ? 0 : formatted.length - decimalPos - 1;
const
precision = decimalPos === -1 ? 0 : formatted.length - decimalPos - 1;
if (precision < decimals) {
if (precision < decimals) {
return (precision ? formatted : formatted + '.') + String(factor).substr(1, decimals - precision);
return (precision ? formatted : formatted + '.') + String(factor).substr(1, decimals - precision);
}
}
...
@@ -275,8 +275,8 @@ kbn.roundValue = function(num, decimals) {
...
@@ -275,8 +275,8 @@ kbn.roundValue = function(num, decimals) {
if (num === null) {
if (num === null) {
return null;
return null;
}
}
var
n = Math.pow(10, decimals);
const
n = Math.pow(10, decimals);
var
formatted = (n * num).toFixed(decimals);
const
formatted = (n * num).toFixed(decimals);
return Math.round(parseFloat(formatted)) / n;
return Math.round(parseFloat(formatted)) / n;
};
};
...
@@ -305,7 +305,7 @@ kbn.formatBuilders.scaledUnits = function(factor, extArray) {
...
@@ -305,7 +305,7 @@ kbn.formatBuilders.scaledUnits = function(factor, extArray) {
}
}
var steps = 0;
var steps = 0;
var
limit = extArray.length;
const
limit = extArray.length;
while (Math.abs(size) >= factor) {
while (Math.abs(size) >= factor) {
steps++;
steps++;
...
@@ -330,7 +330,7 @@ kbn.formatBuilders.scaledUnits = function(factor, extArray) {
...
@@ -330,7 +330,7 @@ kbn.formatBuilders.scaledUnits = function(factor, extArray) {
kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
var prefixes = ['n', 'µ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
var prefixes = ['n', 'µ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
prefixes = prefixes.slice(3 + (offset || 0));
prefixes = prefixes.slice(3 + (offset || 0));
var
units = prefixes.map(function(p) {
const
units = prefixes.map(function(p) {
return ' ' + p + unit;
return ' ' + p + unit;
});
});
return kbn.formatBuilders.scaledUnits(1000, units);
return kbn.formatBuilders.scaledUnits(1000, units);
...
@@ -340,8 +340,8 @@ kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
...
@@ -340,8 +340,8 @@ kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
// offset is given, it starts the units at the given prefix; otherwise, the
// offset is given, it starts the units at the given prefix; otherwise, the
// offset defaults to zero and the initial unit is not prefixed.
// offset defaults to zero and the initial unit is not prefixed.
kbn.formatBuilders.binarySIPrefix = function(unit, offset) {
kbn.formatBuilders.binarySIPrefix = function(unit, offset) {
var
prefixes = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'].slice(offset);
const
prefixes = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'].slice(offset);
var
units = prefixes.map(function(p) {
const
units = prefixes.map(function(p) {
return ' ' + p + unit;
return ' ' + p + unit;
});
});
return kbn.formatBuilders.scaledUnits(1024, units);
return kbn.formatBuilders.scaledUnits(1024, units);
...
@@ -350,25 +350,25 @@ kbn.formatBuilders.binarySIPrefix = function(unit, offset) {
...
@@ -350,25 +350,25 @@ kbn.formatBuilders.binarySIPrefix = function(unit, offset) {
// Currency formatter for prefixing a symbol onto a number. Supports scaling
// Currency formatter for prefixing a symbol onto a number. Supports scaling
// up to the trillions.
// up to the trillions.
kbn.formatBuilders.currency = function(symbol) {
kbn.formatBuilders.currency = function(symbol) {
var
units = ['', 'K', 'M', 'B', 'T'];
const
units = ['', 'K', 'M', 'B', 'T'];
var
scaler = kbn.formatBuilders.scaledUnits(1000, units);
const
scaler = kbn.formatBuilders.scaledUnits(1000, units);
return function(size, decimals, scaledDecimals) {
return function(size, decimals, scaledDecimals) {
if (size === null) {
if (size === null) {
return '';
return '';
}
}
var
scaled = scaler(size, decimals, scaledDecimals);
const
scaled = scaler(size, decimals, scaledDecimals);
return symbol + scaled;
return symbol + scaled;
};
};
};
};
kbn.formatBuilders.simpleCountUnit = function(symbol) {
kbn.formatBuilders.simpleCountUnit = function(symbol) {
var
units = ['', 'K', 'M', 'B', 'T'];
const
units = ['', 'K', 'M', 'B', 'T'];
var
scaler = kbn.formatBuilders.scaledUnits(1000, units);
const
scaler = kbn.formatBuilders.scaledUnits(1000, units);
return function(size, decimals, scaledDecimals) {
return function(size, decimals, scaledDecimals) {
if (size === null) {
if (size === null) {
return '';
return '';
}
}
var
scaled = scaler(size, decimals, scaledDecimals);
const
scaled = scaler(size, decimals, scaledDecimals);
return scaled + ' ' + symbol;
return scaled + ' ' + symbol;
};
};
};
};
...
@@ -420,7 +420,7 @@ kbn.valueFormats.hex0x = function(value, decimals) {
...
@@ -420,7 +420,7 @@ kbn.valueFormats.hex0x = function(value, decimals) {
if (value == null) {
if (value == null) {
return '';
return '';
}
}
var
hexString = kbn.valueFormats.hex(value, decimals);
const
hexString = kbn.valueFormats.hex(value, decimals);
if (hexString.substring(0, 1) === '-') {
if (hexString.substring(0, 1) === '-') {
return '-0x' + hexString.substring(1);
return '-0x' + hexString.substring(1);
}
}
...
@@ -769,7 +769,7 @@ kbn.toDuration = function(size, decimals, timeScale) {
...
@@ -769,7 +769,7 @@ kbn.toDuration = function(size, decimals, timeScale) {
return kbn.toDuration(-size, decimals, timeScale) + '
ago
';
return kbn.toDuration(-size, decimals, timeScale) + '
ago
';
}
}
var
units = [
const
units = [
{ short: '
y
', long: '
year
' },
{ short: '
y
', long: '
year
' },
{ short: '
M
', long: '
month
' },
{ short: '
M
', long: '
month
' },
{ short: '
w
', long: '
week
' },
{ short: '
w
', long: '
week
' },
...
@@ -788,16 +788,16 @@ kbn.toDuration = function(size, decimals, timeScale) {
...
@@ -788,16 +788,16 @@ kbn.toDuration = function(size, decimals, timeScale) {
}).short
}).short
] * 1000;
] * 1000;
var
strings = [];
const
strings = [];
// after first value >= 1 print only $decimals more
// after first value >= 1 print only $decimals more
var decrementDecimals = false;
var decrementDecimals = false;
for (var i = 0; i < units.length && decimals >= 0; i++) {
for (var i = 0; i < units.length && decimals >= 0; i++) {
var
interval = kbn.intervals_in_seconds[units[i].short] * 1000;
const
interval = kbn.intervals_in_seconds[units[i].short] * 1000;
var
value = size / interval;
const
value = size / interval;
if (value >= 1 || decrementDecimals) {
if (value >= 1 || decrementDecimals) {
decrementDecimals = true;
decrementDecimals = true;
var
floor = Math.floor(value);
const
floor = Math.floor(value);
var
unit = units[i].long + (floor !== 1 ? '
s
' : '');
const
unit = units[i].long + (floor !== 1 ? '
s
' : '');
strings.push(floor + '
' + unit);
strings.push(floor + '
' + unit);
size = size % interval;
size = size % interval;
decimals--;
decimals--;
...
@@ -824,7 +824,7 @@ kbn.valueFormats.timeticks = function(size, decimals, scaledDecimals) {
...
@@ -824,7 +824,7 @@ kbn.valueFormats.timeticks = function(size, decimals, scaledDecimals) {
};
};
kbn.valueFormats.dateTimeAsIso = function(epoch, isUtc) {
kbn.valueFormats.dateTimeAsIso = function(epoch, isUtc) {
var
time = isUtc ? moment.utc(epoch) : moment(epoch);
const
time = isUtc ? moment.utc(epoch) : moment(epoch);
if (moment().isSame(epoch, '
day
')) {
if (moment().isSame(epoch, '
day
')) {
return time.format('
HH
:
mm
:
ss
');
return time.format('
HH
:
mm
:
ss
');
...
@@ -833,7 +833,7 @@ kbn.valueFormats.dateTimeAsIso = function(epoch, isUtc) {
...
@@ -833,7 +833,7 @@ kbn.valueFormats.dateTimeAsIso = function(epoch, isUtc) {
};
};
kbn.valueFormats.dateTimeAsUS = function(epoch, isUtc) {
kbn.valueFormats.dateTimeAsUS = function(epoch, isUtc) {
var
time = isUtc ? moment.utc(epoch) : moment(epoch);
const
time = isUtc ? moment.utc(epoch) : moment(epoch);
if (moment().isSame(epoch, '
day
')) {
if (moment().isSame(epoch, '
day
')) {
return time.format('
h
:
mm
:
ss
a
');
return time.format('
h
:
mm
:
ss
a
');
...
@@ -842,7 +842,7 @@ kbn.valueFormats.dateTimeAsUS = function(epoch, isUtc) {
...
@@ -842,7 +842,7 @@ kbn.valueFormats.dateTimeAsUS = function(epoch, isUtc) {
};
};
kbn.valueFormats.dateTimeFromNow = function(epoch, isUtc) {
kbn.valueFormats.dateTimeFromNow = function(epoch, isUtc) {
var
time = isUtc ? moment.utc(epoch) : moment(epoch);
const
time = isUtc ? moment.utc(epoch) : moment(epoch);
return time.fromNow();
return time.fromNow();
};
};
...
...
public/app/core/utils/rangeutil.ts
View file @
e1beaaa0
...
@@ -2,7 +2,7 @@ import _ from 'lodash';
...
@@ -2,7 +2,7 @@ import _ from 'lodash';
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
*
as
dateMath
from
'./datemath'
;
import
*
as
dateMath
from
'./datemath'
;
var
spans
=
{
const
spans
=
{
s
:
{
display
:
'second'
},
s
:
{
display
:
'second'
},
m
:
{
display
:
'minute'
},
m
:
{
display
:
'minute'
},
h
:
{
display
:
'hour'
},
h
:
{
display
:
'hour'
},
...
@@ -12,7 +12,7 @@ var spans = {
...
@@ -12,7 +12,7 @@ var spans = {
y
:
{
display
:
'year'
},
y
:
{
display
:
'year'
},
};
};
var
rangeOptions
=
[
const
rangeOptions
=
[
{
from
:
'now/d'
,
to
:
'now/d'
,
display
:
'Today'
,
section
:
2
},
{
from
:
'now/d'
,
to
:
'now/d'
,
display
:
'Today'
,
section
:
2
},
{
from
:
'now/d'
,
to
:
'now'
,
display
:
'Today so far'
,
section
:
2
},
{
from
:
'now/d'
,
to
:
'now'
,
display
:
'Today so far'
,
section
:
2
},
{
from
:
'now/w'
,
to
:
'now/w'
,
display
:
'This week'
,
section
:
2
},
{
from
:
'now/w'
,
to
:
'now/w'
,
display
:
'This week'
,
section
:
2
},
...
@@ -58,15 +58,15 @@ var rangeOptions = [
...
@@ -58,15 +58,15 @@ var rangeOptions = [
{
from
:
'now-5y'
,
to
:
'now'
,
display
:
'Last 5 years'
,
section
:
0
},
{
from
:
'now-5y'
,
to
:
'now'
,
display
:
'Last 5 years'
,
section
:
0
},
];
];
var
absoluteFormat
=
'MMM D, YYYY HH:mm:ss'
;
const
absoluteFormat
=
'MMM D, YYYY HH:mm:ss'
;
var
rangeIndex
=
{};
const
rangeIndex
=
{};
_
.
each
(
rangeOptions
,
function
(
frame
)
{
_
.
each
(
rangeOptions
,
function
(
frame
)
{
rangeIndex
[
frame
.
from
+
' to '
+
frame
.
to
]
=
frame
;
rangeIndex
[
frame
.
from
+
' to '
+
frame
.
to
]
=
frame
;
});
});
export
function
getRelativeTimesList
(
timepickerSettings
,
currentDisplay
)
{
export
function
getRelativeTimesList
(
timepickerSettings
,
currentDisplay
)
{
var
groups
=
_
.
groupBy
(
rangeOptions
,
(
option
:
any
)
=>
{
const
groups
=
_
.
groupBy
(
rangeOptions
,
(
option
:
any
)
=>
{
option
.
active
=
option
.
display
===
currentDisplay
;
option
.
active
=
option
.
display
===
currentDisplay
;
return
option
.
section
;
return
option
.
section
;
});
});
...
@@ -130,7 +130,7 @@ export function describeTextRange(expr: any) {
...
@@ -130,7 +130,7 @@ export function describeTextRange(expr: any) {
}
}
export
function
describeTimeRange
(
range
)
{
export
function
describeTimeRange
(
range
)
{
var
option
=
rangeIndex
[
range
.
from
.
toString
()
+
' to '
+
range
.
to
.
toString
()];
const
option
=
rangeIndex
[
range
.
from
.
toString
()
+
' to '
+
range
.
to
.
toString
()];
if
(
option
)
{
if
(
option
)
{
return
option
.
display
;
return
option
.
display
;
}
}
...
@@ -140,17 +140,17 @@ export function describeTimeRange(range) {
...
@@ -140,17 +140,17 @@ export function describeTimeRange(range) {
}
}
if
(
moment
.
isMoment
(
range
.
from
))
{
if
(
moment
.
isMoment
(
range
.
from
))
{
var
toMoment
=
dateMath
.
parse
(
range
.
to
,
true
);
const
toMoment
=
dateMath
.
parse
(
range
.
to
,
true
);
return
formatDate
(
range
.
from
)
+
' to '
+
toMoment
.
fromNow
();
return
formatDate
(
range
.
from
)
+
' to '
+
toMoment
.
fromNow
();
}
}
if
(
moment
.
isMoment
(
range
.
to
))
{
if
(
moment
.
isMoment
(
range
.
to
))
{
var
from
=
dateMath
.
parse
(
range
.
from
,
false
);
const
from
=
dateMath
.
parse
(
range
.
from
,
false
);
return
from
.
fromNow
()
+
' to '
+
formatDate
(
range
.
to
);
return
from
.
fromNow
()
+
' to '
+
formatDate
(
range
.
to
);
}
}
if
(
range
.
to
.
toString
()
===
'now'
)
{
if
(
range
.
to
.
toString
()
===
'now'
)
{
var
res
=
describeTextRange
(
range
.
from
);
const
res
=
describeTextRange
(
range
.
from
);
return
res
.
display
;
return
res
.
display
;
}
}
...
...
public/app/features/dashboard/dashboard_ctrl.ts
View file @
e1beaaa0
...
@@ -106,7 +106,7 @@ export class DashboardCtrl implements PanelContainer {
...
@@ -106,7 +106,7 @@ export class DashboardCtrl implements PanelContainer {
}
}
showJsonEditor
(
evt
,
options
)
{
showJsonEditor
(
evt
,
options
)
{
var
editScope
=
this
.
$rootScope
.
$new
();
const
editScope
=
this
.
$rootScope
.
$new
();
editScope
.
object
=
options
.
object
;
editScope
.
object
=
options
.
object
;
editScope
.
updateHandler
=
options
.
updateHandler
;
editScope
.
updateHandler
=
options
.
updateHandler
;
this
.
$scope
.
appEvent
(
'show-dash-editor'
,
{
this
.
$scope
.
appEvent
(
'show-dash-editor'
,
{
...
@@ -137,7 +137,7 @@ export class DashboardCtrl implements PanelContainer {
...
@@ -137,7 +137,7 @@ export class DashboardCtrl implements PanelContainer {
return
;
return
;
}
}
var
panelInfo
=
this
.
dashboard
.
getPanelInfoById
(
options
.
panelId
);
const
panelInfo
=
this
.
dashboard
.
getPanelInfoById
(
options
.
panelId
);
this
.
removePanel
(
panelInfo
.
panel
,
true
);
this
.
removePanel
(
panelInfo
.
panel
,
true
);
}
}
...
...
public/app/features/dashboard/dashboard_loader_srv.ts
View file @
e1beaaa0
...
@@ -71,7 +71,7 @@ export class DashboardLoaderSrv {
...
@@ -71,7 +71,7 @@ export class DashboardLoaderSrv {
}
}
_loadScriptedDashboard
(
file
)
{
_loadScriptedDashboard
(
file
)
{
var
url
=
'public/dashboards/'
+
file
.
replace
(
/
\.(?!
js
)
/
,
'/'
)
+
'?'
+
new
Date
().
getTime
();
const
url
=
'public/dashboards/'
+
file
.
replace
(
/
\.(?!
js
)
/
,
'/'
)
+
'?'
+
new
Date
().
getTime
();
return
this
.
$http
({
url
:
url
,
method
:
'GET'
})
return
this
.
$http
({
url
:
url
,
method
:
'GET'
})
.
then
(
this
.
_executeScript
.
bind
(
this
))
.
then
(
this
.
_executeScript
.
bind
(
this
))
...
@@ -99,14 +99,14 @@ export class DashboardLoaderSrv {
...
@@ -99,14 +99,14 @@ export class DashboardLoaderSrv {
}
}
_executeScript
(
result
)
{
_executeScript
(
result
)
{
var
services
=
{
const
services
=
{
dashboardSrv
:
this
.
dashboardSrv
,
dashboardSrv
:
this
.
dashboardSrv
,
datasourceSrv
:
this
.
datasourceSrv
,
datasourceSrv
:
this
.
datasourceSrv
,
$q
:
this
.
$q
,
$q
:
this
.
$q
,
};
};
/*jshint -W054 */
/*jshint -W054 */
var
script_func
=
new
Function
(
const
script_func
=
new
Function
(
'ARGS'
,
'ARGS'
,
'kbn'
,
'kbn'
,
'dateMath'
,
'dateMath'
,
...
@@ -119,11 +119,11 @@ export class DashboardLoaderSrv {
...
@@ -119,11 +119,11 @@ export class DashboardLoaderSrv {
'services'
,
'services'
,
result
.
data
result
.
data
);
);
var
script_result
=
script_func
(
this
.
$routeParams
,
kbn
,
dateMath
,
_
,
moment
,
window
,
document
,
$
,
$
,
services
);
const
script_result
=
script_func
(
this
.
$routeParams
,
kbn
,
dateMath
,
_
,
moment
,
window
,
document
,
$
,
$
,
services
);
// Handle async dashboard scripts
// Handle async dashboard scripts
if
(
_
.
isFunction
(
script_result
))
{
if
(
_
.
isFunction
(
script_result
))
{
var
deferred
=
this
.
$q
.
defer
();
const
deferred
=
this
.
$q
.
defer
();
script_result
(
dashboard
=>
{
script_result
(
dashboard
=>
{
this
.
$timeout
(()
=>
{
this
.
$timeout
(()
=>
{
deferred
.
resolve
({
data
:
dashboard
});
deferred
.
resolve
({
data
:
dashboard
});
...
...
public/app/features/dashboard/dashgrid/PanelLoader.ts
View file @
e1beaaa0
...
@@ -10,8 +10,8 @@ export class PanelLoader {
...
@@ -10,8 +10,8 @@ export class PanelLoader {
constructor
(
private
$compile
,
private
$rootScope
)
{}
constructor
(
private
$compile
,
private
$rootScope
)
{}
load
(
elem
,
panel
,
dashboard
):
AttachedPanel
{
load
(
elem
,
panel
,
dashboard
):
AttachedPanel
{
var
template
=
'<plugin-component type="panel" class="panel-height-helper"></plugin-component>'
;
const
template
=
'<plugin-component type="panel" class="panel-height-helper"></plugin-component>'
;
var
panelScope
=
this
.
$rootScope
.
$new
();
const
panelScope
=
this
.
$rootScope
.
$new
();
panelScope
.
panel
=
panel
;
panelScope
.
panel
=
panel
;
panelScope
.
dashboard
=
dashboard
;
panelScope
.
dashboard
=
dashboard
;
...
...
public/app/features/dashboard/dashnav/dashnav.ts
View file @
e1beaaa0
...
@@ -13,7 +13,7 @@ export class DashNavCtrl {
...
@@ -13,7 +13,7 @@ export class DashNavCtrl {
appEvents
.
on
(
'save-dashboard'
,
this
.
saveDashboard
.
bind
(
this
),
$scope
);
appEvents
.
on
(
'save-dashboard'
,
this
.
saveDashboard
.
bind
(
this
),
$scope
);
if
(
this
.
dashboard
.
meta
.
isSnapshot
)
{
if
(
this
.
dashboard
.
meta
.
isSnapshot
)
{
var
meta
=
this
.
dashboard
.
meta
;
const
meta
=
this
.
dashboard
.
meta
;
this
.
titleTooltip
=
'Created: '
+
moment
(
meta
.
created
).
calendar
();
this
.
titleTooltip
=
'Created: '
+
moment
(
meta
.
created
).
calendar
();
if
(
meta
.
expires
)
{
if
(
meta
.
expires
)
{
this
.
titleTooltip
+=
'<br>Expires: '
+
moment
(
meta
.
expires
).
fromNow
()
+
'<br>'
;
this
.
titleTooltip
+=
'<br>Expires: '
+
moment
(
meta
.
expires
).
fromNow
()
+
'<br>'
;
...
@@ -49,7 +49,7 @@ export class DashNavCtrl {
...
@@ -49,7 +49,7 @@ export class DashNavCtrl {
}
}
shareDashboard
(
tabIndex
)
{
shareDashboard
(
tabIndex
)
{
var
modalScope
=
this
.
$scope
.
$new
();
const
modalScope
=
this
.
$scope
.
$new
();
modalScope
.
tabIndex
=
tabIndex
;
modalScope
.
tabIndex
=
tabIndex
;
modalScope
.
dashboard
=
this
.
dashboard
;
modalScope
.
dashboard
=
this
.
dashboard
;
...
...
public/app/features/dashboard/save_as_modal.ts
View file @
e1beaaa0
...
@@ -46,7 +46,7 @@ export class SaveDashboardAsModalCtrl {
...
@@ -46,7 +46,7 @@ export class SaveDashboardAsModalCtrl {
/** @ngInject */
/** @ngInject */
constructor
(
private
dashboardSrv
)
{
constructor
(
private
dashboardSrv
)
{
var
dashboard
=
this
.
dashboardSrv
.
getCurrent
();
const
dashboard
=
this
.
dashboardSrv
.
getCurrent
();
this
.
clone
=
dashboard
.
getSaveModelClone
();
this
.
clone
=
dashboard
.
getSaveModelClone
();
this
.
clone
.
id
=
null
;
this
.
clone
.
id
=
null
;
this
.
clone
.
uid
=
''
;
this
.
clone
.
uid
=
''
;
...
...
public/app/features/dashboard/save_modal.ts
View file @
e1beaaa0
...
@@ -94,14 +94,14 @@ export class SaveDashboardModalCtrl {
...
@@ -94,14 +94,14 @@ export class SaveDashboardModalCtrl {
return
;
return
;
}
}
var
options
=
{
const
options
=
{
saveVariables
:
this
.
saveVariables
,
saveVariables
:
this
.
saveVariables
,
saveTimerange
:
this
.
saveTimerange
,
saveTimerange
:
this
.
saveTimerange
,
message
:
this
.
message
,
message
:
this
.
message
,
};
};
var
dashboard
=
this
.
dashboardSrv
.
getCurrent
();
const
dashboard
=
this
.
dashboardSrv
.
getCurrent
();
var
saveModel
=
dashboard
.
getSaveModelClone
(
options
);
const
saveModel
=
dashboard
.
getSaveModelClone
(
options
);
this
.
isSaving
=
true
;
this
.
isSaving
=
true
;
...
...
public/app/features/dashboard/save_provisioned_modal.ts
View file @
e1beaaa0
...
@@ -52,7 +52,7 @@ export class SaveProvisionedDashboardModalCtrl {
...
@@ -52,7 +52,7 @@ export class SaveProvisionedDashboardModalCtrl {
}
}
save
()
{
save
()
{
var
blob
=
new
Blob
([
angular
.
toJson
(
this
.
dash
,
true
)],
{
const
blob
=
new
Blob
([
angular
.
toJson
(
this
.
dash
,
true
)],
{
type
:
'application/json;charset=utf-8'
,
type
:
'application/json;charset=utf-8'
,
});
});
saveAs
(
blob
,
this
.
dash
.
title
+
'-'
+
new
Date
().
getTime
()
+
'.json'
);
saveAs
(
blob
,
this
.
dash
.
title
+
'-'
+
new
Date
().
getTime
()
+
'.json'
);
...
...
public/app/features/dashboard/shareModalCtrl.ts
View file @
e1beaaa0
...
@@ -36,15 +36,15 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv,
...
@@ -36,15 +36,15 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv,
$scope
.
buildUrl
=
function
()
{
$scope
.
buildUrl
=
function
()
{
var
baseUrl
=
$location
.
absUrl
();
var
baseUrl
=
$location
.
absUrl
();
var
queryStart
=
baseUrl
.
indexOf
(
'?'
);
const
queryStart
=
baseUrl
.
indexOf
(
'?'
);
if
(
queryStart
!==
-
1
)
{
if
(
queryStart
!==
-
1
)
{
baseUrl
=
baseUrl
.
substring
(
0
,
queryStart
);
baseUrl
=
baseUrl
.
substring
(
0
,
queryStart
);
}
}
var
params
=
angular
.
copy
(
$location
.
search
());
const
params
=
angular
.
copy
(
$location
.
search
());
var
range
=
timeSrv
.
timeRange
();
const
range
=
timeSrv
.
timeRange
();
params
.
from
=
range
.
from
.
valueOf
();
params
.
from
=
range
.
from
.
valueOf
();
params
.
to
=
range
.
to
.
valueOf
();
params
.
to
=
range
.
to
.
valueOf
();
params
.
orgId
=
config
.
bootData
.
user
.
orgId
;
params
.
orgId
=
config
.
bootData
.
user
.
orgId
;
...
...
public/app/features/dashboard/share_snapshot_ctrl.ts
View file @
e1beaaa0
...
@@ -55,16 +55,16 @@ export class ShareSnapshotCtrl {
...
@@ -55,16 +55,16 @@ export class ShareSnapshotCtrl {
};
};
$scope
.
saveSnapshot
=
function
(
external
)
{
$scope
.
saveSnapshot
=
function
(
external
)
{
var
dash
=
$scope
.
dashboard
.
getSaveModelClone
();
const
dash
=
$scope
.
dashboard
.
getSaveModelClone
();
$scope
.
scrubDashboard
(
dash
);
$scope
.
scrubDashboard
(
dash
);
var
cmdData
=
{
const
cmdData
=
{
dashboard
:
dash
,
dashboard
:
dash
,
name
:
dash
.
title
,
name
:
dash
.
title
,
expires
:
$scope
.
snapshot
.
expires
,
expires
:
$scope
.
snapshot
.
expires
,
};
};
var
postUrl
=
external
?
$scope
.
externalUrl
+
$scope
.
apiUrl
:
$scope
.
apiUrl
;
const
postUrl
=
external
?
$scope
.
externalUrl
+
$scope
.
apiUrl
:
$scope
.
apiUrl
;
backendSrv
.
post
(
postUrl
,
cmdData
).
then
(
backendSrv
.
post
(
postUrl
,
cmdData
).
then
(
function
(
results
)
{
function
(
results
)
{
...
@@ -75,8 +75,8 @@ export class ShareSnapshotCtrl {
...
@@ -75,8 +75,8 @@ export class ShareSnapshotCtrl {
$scope
.
snapshotUrl
=
results
.
url
;
$scope
.
snapshotUrl
=
results
.
url
;
$scope
.
saveExternalSnapshotRef
(
cmdData
,
results
);
$scope
.
saveExternalSnapshotRef
(
cmdData
,
results
);
}
else
{
}
else
{
var
url
=
$location
.
url
();
const
url
=
$location
.
url
();
var
baseUrl
=
$location
.
absUrl
();
let
baseUrl
=
$location
.
absUrl
();
if
(
url
!==
'/'
)
{
if
(
url
!==
'/'
)
{
baseUrl
=
baseUrl
.
replace
(
url
,
''
)
+
'/'
;
baseUrl
=
baseUrl
.
replace
(
url
,
''
)
+
'/'
;
...
@@ -139,7 +139,7 @@ export class ShareSnapshotCtrl {
...
@@ -139,7 +139,7 @@ export class ShareSnapshotCtrl {
// snapshot single panel
// snapshot single panel
if
(
$scope
.
modeSharePanel
)
{
if
(
$scope
.
modeSharePanel
)
{
var
singlePanel
=
$scope
.
panel
.
getSaveModel
();
const
singlePanel
=
$scope
.
panel
.
getSaveModel
();
singlePanel
.
gridPos
.
w
=
24
;
singlePanel
.
gridPos
.
w
=
24
;
singlePanel
.
gridPos
.
x
=
0
;
singlePanel
.
gridPos
.
x
=
0
;
singlePanel
.
gridPos
.
y
=
0
;
singlePanel
.
gridPos
.
y
=
0
;
...
...
public/app/features/dashboard/submenu/submenu.ts
View file @
e1beaaa0
...
@@ -21,7 +21,7 @@ export class SubmenuCtrl {
...
@@ -21,7 +21,7 @@ export class SubmenuCtrl {
}
}
openEditView
(
editview
)
{
openEditView
(
editview
)
{
var
search
=
_
.
extend
(
this
.
$location
.
search
(),
{
editview
:
editview
});
const
search
=
_
.
extend
(
this
.
$location
.
search
(),
{
editview
:
editview
});
this
.
$location
.
search
(
search
);
this
.
$location
.
search
(
search
);
}
}
}
}
...
...
public/app/features/dashboard/view_state_srv.ts
View file @
e1beaaa0
...
@@ -16,14 +16,14 @@ export class DashboardViewState {
...
@@ -16,14 +16,14 @@ export class DashboardViewState {
/** @ngInject */
/** @ngInject */
constructor
(
$scope
,
private
$location
,
private
$timeout
,
private
$rootScope
)
{
constructor
(
$scope
,
private
$location
,
private
$timeout
,
private
$rootScope
)
{
var
self
=
this
;
const
self
=
this
;
self
.
state
=
{};
self
.
state
=
{};
self
.
panelScopes
=
[];
self
.
panelScopes
=
[];
self
.
$scope
=
$scope
;
self
.
$scope
=
$scope
;
self
.
dashboard
=
$scope
.
dashboard
;
self
.
dashboard
=
$scope
.
dashboard
;
$scope
.
onAppEvent
(
'$routeUpdate'
,
function
()
{
$scope
.
onAppEvent
(
'$routeUpdate'
,
function
()
{
var
urlState
=
self
.
getQueryStringState
();
const
urlState
=
self
.
getQueryStringState
();
if
(
self
.
needsSync
(
urlState
))
{
if
(
self
.
needsSync
(
urlState
))
{
self
.
update
(
urlState
,
true
);
self
.
update
(
urlState
,
true
);
}
}
...
@@ -48,7 +48,7 @@ export class DashboardViewState {
...
@@ -48,7 +48,7 @@ export class DashboardViewState {
}
}
getQueryStringState
()
{
getQueryStringState
()
{
var
state
=
this
.
$location
.
search
();
const
state
=
this
.
$location
.
search
();
state
.
panelId
=
parseInt
(
state
.
panelId
)
||
null
;
state
.
panelId
=
parseInt
(
state
.
panelId
)
||
null
;
state
.
fullscreen
=
state
.
fullscreen
?
true
:
null
;
state
.
fullscreen
=
state
.
fullscreen
?
true
:
null
;
state
.
edit
=
state
.
edit
===
'true'
||
state
.
edit
===
true
||
null
;
state
.
edit
=
state
.
edit
===
'true'
||
state
.
edit
===
true
||
null
;
...
@@ -58,7 +58,7 @@ export class DashboardViewState {
...
@@ -58,7 +58,7 @@ export class DashboardViewState {
}
}
serializeToUrl
()
{
serializeToUrl
()
{
var
urlState
=
_
.
clone
(
this
.
state
);
const
urlState
=
_
.
clone
(
this
.
state
);
urlState
.
fullscreen
=
this
.
state
.
fullscreen
?
true
:
null
;
urlState
.
fullscreen
=
this
.
state
.
fullscreen
?
true
:
null
;
urlState
.
edit
=
this
.
state
.
edit
?
true
:
null
;
urlState
.
edit
=
this
.
state
.
edit
?
true
:
null
;
return
urlState
;
return
urlState
;
...
@@ -129,7 +129,7 @@ export class DashboardViewState {
...
@@ -129,7 +129,7 @@ export class DashboardViewState {
}
}
if
(
this
.
dashboard
.
meta
.
fullscreen
)
{
if
(
this
.
dashboard
.
meta
.
fullscreen
)
{
var
panelScope
=
this
.
getPanelScope
(
this
.
state
.
panelId
);
const
panelScope
=
this
.
getPanelScope
(
this
.
state
.
panelId
);
if
(
!
panelScope
)
{
if
(
!
panelScope
)
{
return
;
return
;
}
}
...
@@ -162,8 +162,8 @@ export class DashboardViewState {
...
@@ -162,8 +162,8 @@ export class DashboardViewState {
}
}
leaveFullscreen
(
render
)
{
leaveFullscreen
(
render
)
{
var
self
=
this
;
const
self
=
this
;
var
ctrl
=
self
.
fullscreenPanel
.
ctrl
;
const
ctrl
=
self
.
fullscreenPanel
.
ctrl
;
ctrl
.
editMode
=
false
;
ctrl
.
editMode
=
false
;
ctrl
.
fullscreen
=
false
;
ctrl
.
fullscreen
=
false
;
...
@@ -188,7 +188,7 @@ export class DashboardViewState {
...
@@ -188,7 +188,7 @@ export class DashboardViewState {
}
}
enterFullscreen
(
panelScope
)
{
enterFullscreen
(
panelScope
)
{
var
ctrl
=
panelScope
.
ctrl
;
const
ctrl
=
panelScope
.
ctrl
;
ctrl
.
editMode
=
this
.
state
.
edit
&&
this
.
dashboard
.
meta
.
canEdit
;
ctrl
.
editMode
=
this
.
state
.
edit
&&
this
.
dashboard
.
meta
.
canEdit
;
ctrl
.
fullscreen
=
true
;
ctrl
.
fullscreen
=
true
;
...
@@ -203,7 +203,7 @@ export class DashboardViewState {
...
@@ -203,7 +203,7 @@ export class DashboardViewState {
}
}
registerPanel
(
panelScope
)
{
registerPanel
(
panelScope
)
{
var
self
=
this
;
const
self
=
this
;
self
.
panelScopes
.
push
(
panelScope
);
self
.
panelScopes
.
push
(
panelScope
);
if
(
!
self
.
dashboard
.
meta
.
soloMode
)
{
if
(
!
self
.
dashboard
.
meta
.
soloMode
)
{
...
@@ -216,7 +216,7 @@ export class DashboardViewState {
...
@@ -216,7 +216,7 @@ export class DashboardViewState {
}
}
}
}
var
unbind
=
panelScope
.
$on
(
'$destroy'
,
function
()
{
const
unbind
=
panelScope
.
$on
(
'$destroy'
,
function
()
{
self
.
panelScopes
=
_
.
without
(
self
.
panelScopes
,
panelScope
);
self
.
panelScopes
=
_
.
without
(
self
.
panelScopes
,
panelScope
);
unbind
();
unbind
();
});
});
...
...
public/app/features/dashlinks/module.ts
View file @
e1beaaa0
...
@@ -19,7 +19,7 @@ function dashLink($compile, $sanitize, linkSrv) {
...
@@ -19,7 +19,7 @@ function dashLink($compile, $sanitize, linkSrv) {
return
{
return
{
restrict
:
'E'
,
restrict
:
'E'
,
link
:
function
(
scope
,
elem
)
{
link
:
function
(
scope
,
elem
)
{
var
link
=
scope
.
link
;
const
link
=
scope
.
link
;
var
template
=
var
template
=
'<div class="gf-form">'
+
'<div class="gf-form">'
+
'<a class="pointer gf-form-label" data-placement="bottom"'
+
'<a class="pointer gf-form-label" data-placement="bottom"'
+
...
@@ -42,7 +42,7 @@ function dashLink($compile, $sanitize, linkSrv) {
...
@@ -42,7 +42,7 @@ function dashLink($compile, $sanitize, linkSrv) {
$compile
(
elem
.
contents
())(
scope
);
$compile
(
elem
.
contents
())(
scope
);
function
update
()
{
function
update
()
{
var
linkInfo
=
linkSrv
.
getAnchorInfo
(
link
);
const
linkInfo
=
linkSrv
.
getAnchorInfo
(
link
);
const
anchor
=
elem
.
find
(
'a'
);
const
anchor
=
elem
.
find
(
'a'
);
const
span
=
elem
.
find
(
'span'
);
const
span
=
elem
.
find
(
'span'
);
...
@@ -84,7 +84,7 @@ function dashLink($compile, $sanitize, linkSrv) {
...
@@ -84,7 +84,7 @@ function dashLink($compile, $sanitize, linkSrv) {
export
class
DashLinksContainerCtrl
{
export
class
DashLinksContainerCtrl
{
/** @ngInject */
/** @ngInject */
constructor
(
$scope
,
$rootScope
,
$q
,
backendSrv
,
dashboardSrv
,
linkSrv
)
{
constructor
(
$scope
,
$rootScope
,
$q
,
backendSrv
,
dashboardSrv
,
linkSrv
)
{
var
currentDashId
=
dashboardSrv
.
getCurrent
().
id
;
const
currentDashId
=
dashboardSrv
.
getCurrent
().
id
;
function
buildLinks
(
linkDef
)
{
function
buildLinks
(
linkDef
)
{
if
(
linkDef
.
type
===
'dashboards'
)
{
if
(
linkDef
.
type
===
'dashboards'
)
{
...
@@ -128,7 +128,7 @@ export class DashLinksContainerCtrl {
...
@@ -128,7 +128,7 @@ export class DashLinksContainerCtrl {
}
}
function
updateDashLinks
()
{
function
updateDashLinks
()
{
var
promises
=
_
.
map
(
$scope
.
links
,
buildLinks
);
const
promises
=
_
.
map
(
$scope
.
links
,
buildLinks
);
$q
.
all
(
promises
).
then
(
function
(
results
)
{
$q
.
all
(
promises
).
then
(
function
(
results
)
{
$scope
.
generatedLinks
=
_
.
flatten
(
results
);
$scope
.
generatedLinks
=
_
.
flatten
(
results
);
...
...
public/app/features/panellinks/module.ts
View file @
e1beaaa0
...
@@ -27,7 +27,7 @@ export class PanelLinksEditorCtrl {
...
@@ -27,7 +27,7 @@ export class PanelLinksEditorCtrl {
$scope
.
searchDashboards
=
function
(
queryStr
,
callback
)
{
$scope
.
searchDashboards
=
function
(
queryStr
,
callback
)
{
backendSrv
.
search
({
query
:
queryStr
}).
then
(
function
(
hits
)
{
backendSrv
.
search
({
query
:
queryStr
}).
then
(
function
(
hits
)
{
var
dashboards
=
_
.
map
(
hits
,
function
(
dash
)
{
const
dashboards
=
_
.
map
(
hits
,
function
(
dash
)
{
return
dash
.
title
;
return
dash
.
title
;
});
});
...
@@ -37,7 +37,7 @@ export class PanelLinksEditorCtrl {
...
@@ -37,7 +37,7 @@ export class PanelLinksEditorCtrl {
$scope
.
dashboardChanged
=
function
(
link
)
{
$scope
.
dashboardChanged
=
function
(
link
)
{
backendSrv
.
search
({
query
:
link
.
dashboard
}).
then
(
function
(
hits
)
{
backendSrv
.
search
({
query
:
link
.
dashboard
}).
then
(
function
(
hits
)
{
var
dashboard
=
_
.
find
(
hits
,
{
title
:
link
.
dashboard
});
const
dashboard
=
_
.
find
(
hits
,
{
title
:
link
.
dashboard
});
if
(
dashboard
)
{
if
(
dashboard
)
{
if
(
dashboard
.
url
)
{
if
(
dashboard
.
url
)
{
link
.
url
=
dashboard
.
url
;
link
.
url
=
dashboard
.
url
;
...
...
public/app/features/plugins/ds_edit_ctrl.ts
View file @
e1beaaa0
...
@@ -6,7 +6,7 @@ import { store } from 'app/stores/store';
...
@@ -6,7 +6,7 @@ import { store } from 'app/stores/store';
var
datasourceTypes
=
[];
var
datasourceTypes
=
[];
var
defaults
=
{
const
defaults
=
{
name
:
''
,
name
:
''
,
type
:
'graphite'
,
type
:
'graphite'
,
url
:
''
,
url
:
''
,
...
...
public/app/features/plugins/import_list/import_list.ts
View file @
e1beaaa0
...
@@ -45,7 +45,7 @@ export class DashImportListCtrl {
...
@@ -45,7 +45,7 @@ export class DashImportListCtrl {
}
}
import
(
dash
,
overwrite
)
{
import
(
dash
,
overwrite
)
{
var
installCmd
=
{
const
installCmd
=
{
pluginId
:
this
.
plugin
.
id
,
pluginId
:
this
.
plugin
.
id
,
path
:
dash
.
path
,
path
:
dash
.
path
,
overwrite
:
overwrite
,
overwrite
:
overwrite
,
...
...
public/app/features/plugins/plugin_component.ts
View file @
e1beaaa0
...
@@ -13,7 +13,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
...
@@ -13,7 +13,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
if
(
component
.
template
)
{
if
(
component
.
template
)
{
return
$q
.
when
(
component
.
template
);
return
$q
.
when
(
component
.
template
);
}
}
var
cached
=
$templateCache
.
get
(
component
.
templateUrl
);
const
cached
=
$templateCache
.
get
(
component
.
templateUrl
);
if
(
cached
)
{
if
(
cached
)
{
return
$q
.
when
(
cached
);
return
$q
.
when
(
cached
);
}
}
...
@@ -58,7 +58,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
...
@@ -58,7 +58,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
}
}
function
loadPanelComponentInfo
(
scope
,
attrs
)
{
function
loadPanelComponentInfo
(
scope
,
attrs
)
{
var
componentInfo
:
any
=
{
const
componentInfo
:
any
=
{
name
:
'panel-plugin-'
+
scope
.
panel
.
type
,
name
:
'panel-plugin-'
+
scope
.
panel
.
type
,
bindings
:
{
dashboard
:
'='
,
panel
:
'='
,
row
:
'='
},
bindings
:
{
dashboard
:
'='
,
panel
:
'='
,
row
:
'='
},
attrs
:
{
attrs
:
{
...
@@ -143,7 +143,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
...
@@ -143,7 +143,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
}
}
// Datasource ConfigCtrl
// Datasource ConfigCtrl
case
'datasource-config-ctrl'
:
{
case
'datasource-config-ctrl'
:
{
var
dsMeta
=
scope
.
ctrl
.
datasourceMeta
;
const
dsMeta
=
scope
.
ctrl
.
datasourceMeta
;
return
importPluginModule
(
dsMeta
.
module
).
then
(
function
(
dsModule
):
any
{
return
importPluginModule
(
dsMeta
.
module
).
then
(
function
(
dsModule
):
any
{
if
(
!
dsModule
.
ConfigCtrl
)
{
if
(
!
dsModule
.
ConfigCtrl
)
{
return
{
notFound
:
true
};
return
{
notFound
:
true
};
...
@@ -197,7 +197,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
...
@@ -197,7 +197,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
}
}
function
appendAndCompile
(
scope
,
elem
,
componentInfo
)
{
function
appendAndCompile
(
scope
,
elem
,
componentInfo
)
{
var
child
=
angular
.
element
(
document
.
createElement
(
componentInfo
.
name
));
const
child
=
angular
.
element
(
document
.
createElement
(
componentInfo
.
name
));
_
.
each
(
componentInfo
.
attrs
,
(
value
,
key
)
=>
{
_
.
each
(
componentInfo
.
attrs
,
(
value
,
key
)
=>
{
child
.
attr
(
key
,
value
);
child
.
attr
(
key
,
value
);
});
});
...
@@ -228,8 +228,8 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
...
@@ -228,8 +228,8 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
}
}
if
(
!
componentInfo
.
Component
.
registered
)
{
if
(
!
componentInfo
.
Component
.
registered
)
{
var
directiveName
=
attrs
.
$normalize
(
componentInfo
.
name
);
const
directiveName
=
attrs
.
$normalize
(
componentInfo
.
name
);
var
directiveFn
=
getPluginComponentDirective
(
componentInfo
);
const
directiveFn
=
getPluginComponentDirective
(
componentInfo
);
coreModule
.
directive
(
directiveName
,
directiveFn
);
coreModule
.
directive
(
directiveName
,
directiveFn
);
componentInfo
.
Component
.
registered
=
true
;
componentInfo
.
Component
.
registered
=
true
;
}
}
...
...
public/app/features/plugins/plugin_edit_ctrl.ts
View file @
e1beaaa0
...
@@ -97,7 +97,7 @@ export class PluginEditCtrl {
...
@@ -97,7 +97,7 @@ export class PluginEditCtrl {
initReadme
()
{
initReadme
()
{
return
this
.
backendSrv
.
get
(
`/api/plugins/
${
this
.
pluginId
}
/markdown/readme`
).
then
(
res
=>
{
return
this
.
backendSrv
.
get
(
`/api/plugins/
${
this
.
pluginId
}
/markdown/readme`
).
then
(
res
=>
{
var
md
=
new
Remarkable
({
const
md
=
new
Remarkable
({
linkify
:
true
,
linkify
:
true
,
});
});
this
.
readmeHtml
=
this
.
$sce
.
trustAsHtml
(
md
.
render
(
res
));
this
.
readmeHtml
=
this
.
$sce
.
trustAsHtml
(
md
.
render
(
res
));
...
@@ -124,7 +124,7 @@ export class PluginEditCtrl {
...
@@ -124,7 +124,7 @@ export class PluginEditCtrl {
update
()
{
update
()
{
this
.
preUpdateHook
()
this
.
preUpdateHook
()
.
then
(()
=>
{
.
then
(()
=>
{
var
updateCmd
=
_
.
extend
(
const
updateCmd
=
_
.
extend
(
{
{
enabled
:
this
.
model
.
enabled
,
enabled
:
this
.
model
.
enabled
,
pinned
:
this
.
model
.
pinned
,
pinned
:
this
.
model
.
pinned
,
...
@@ -154,7 +154,7 @@ export class PluginEditCtrl {
...
@@ -154,7 +154,7 @@ export class PluginEditCtrl {
}
}
updateAvailable
()
{
updateAvailable
()
{
var
modalScope
=
this
.
$scope
.
$new
(
true
);
const
modalScope
=
this
.
$scope
.
$new
(
true
);
modalScope
.
plugin
=
this
.
model
;
modalScope
.
plugin
=
this
.
model
;
this
.
$rootScope
.
appEvent
(
'show-modal'
,
{
this
.
$rootScope
.
appEvent
(
'show-modal'
,
{
...
...
public/app/features/plugins/plugin_page_ctrl.ts
View file @
e1beaaa0
import
angular
from
'angular'
;
import
angular
from
'angular'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
var
pluginInfoCache
=
{};
const
pluginInfoCache
=
{};
export
class
AppPageCtrl
{
export
class
AppPageCtrl
{
page
:
any
;
page
:
any
;
...
...
public/app/features/templating/adhoc_variable.ts
View file @
e1beaaa0
...
@@ -43,7 +43,7 @@ export class AdhocVariable implements Variable {
...
@@ -43,7 +43,7 @@ export class AdhocVariable implements Variable {
}
}
this
.
filters
=
urlValue
.
map
(
item
=>
{
this
.
filters
=
urlValue
.
map
(
item
=>
{
var
values
=
item
.
split
(
'|'
).
map
(
value
=>
{
const
values
=
item
.
split
(
'|'
).
map
(
value
=>
{
return
this
.
unescapeDelimiter
(
value
);
return
this
.
unescapeDelimiter
(
value
);
});
});
return
{
return
{
...
...
public/app/features/templating/datasource_variable.ts
View file @
e1beaaa0
...
@@ -41,8 +41,8 @@ export class DatasourceVariable implements Variable {
...
@@ -41,8 +41,8 @@ export class DatasourceVariable implements Variable {
}
}
updateOptions
()
{
updateOptions
()
{
var
options
=
[];
const
options
=
[];
var
sources
=
this
.
datasourceSrv
.
getMetricSources
({
skipVariables
:
true
});
const
sources
=
this
.
datasourceSrv
.
getMetricSources
({
skipVariables
:
true
});
var
regex
;
var
regex
;
if
(
this
.
regex
)
{
if
(
this
.
regex
)
{
...
@@ -51,7 +51,7 @@ export class DatasourceVariable implements Variable {
...
@@ -51,7 +51,7 @@ export class DatasourceVariable implements Variable {
}
}
for
(
var
i
=
0
;
i
<
sources
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
sources
.
length
;
i
++
)
{
var
source
=
sources
[
i
];
const
source
=
sources
[
i
];
// must match on type
// must match on type
if
(
source
.
meta
.
id
!==
this
.
query
)
{
if
(
source
.
meta
.
id
!==
this
.
query
)
{
continue
;
continue
;
...
...
public/app/features/templating/editor_ctrl.ts
View file @
e1beaaa0
...
@@ -64,7 +64,7 @@ export class VariableEditorCtrl {
...
@@ -64,7 +64,7 @@ export class VariableEditorCtrl {
return
false
;
return
false
;
}
}
var
sameName
=
_
.
find
(
$scope
.
variables
,
{
name
:
$scope
.
current
.
name
});
const
sameName
=
_
.
find
(
$scope
.
variables
,
{
name
:
$scope
.
current
.
name
});
if
(
sameName
&&
sameName
!==
$scope
.
current
)
{
if
(
sameName
&&
sameName
!==
$scope
.
current
)
{
appEvents
.
emit
(
'alert-warning'
,
[
'Validation'
,
'Variable with the same name already exists'
]);
appEvents
.
emit
(
'alert-warning'
,
[
'Validation'
,
'Variable with the same name already exists'
]);
return
false
;
return
false
;
...
@@ -114,7 +114,7 @@ export class VariableEditorCtrl {
...
@@ -114,7 +114,7 @@ export class VariableEditorCtrl {
};
};
$scope
.
duplicate
=
function
(
variable
)
{
$scope
.
duplicate
=
function
(
variable
)
{
var
clone
=
_
.
cloneDeep
(
variable
.
getSaveModel
());
const
clone
=
_
.
cloneDeep
(
variable
.
getSaveModel
());
$scope
.
current
=
variableSrv
.
createVariableFromModel
(
clone
);
$scope
.
current
=
variableSrv
.
createVariableFromModel
(
clone
);
$scope
.
current
.
name
=
'copy_of_'
+
variable
.
name
;
$scope
.
current
.
name
=
'copy_of_'
+
variable
.
name
;
variableSrv
.
addVariable
(
$scope
.
current
);
variableSrv
.
addVariable
(
$scope
.
current
);
...
@@ -148,7 +148,7 @@ export class VariableEditorCtrl {
...
@@ -148,7 +148,7 @@ export class VariableEditorCtrl {
};
};
$scope
.
typeChanged
=
function
()
{
$scope
.
typeChanged
=
function
()
{
var
old
=
$scope
.
current
;
const
old
=
$scope
.
current
;
$scope
.
current
=
variableSrv
.
createVariableFromModel
({
$scope
.
current
=
variableSrv
.
createVariableFromModel
({
type
:
$scope
.
current
.
type
,
type
:
$scope
.
current
.
type
,
});
});
...
@@ -156,7 +156,7 @@ export class VariableEditorCtrl {
...
@@ -156,7 +156,7 @@ export class VariableEditorCtrl {
$scope
.
current
.
hide
=
old
.
hide
;
$scope
.
current
.
hide
=
old
.
hide
;
$scope
.
current
.
label
=
old
.
label
;
$scope
.
current
.
label
=
old
.
label
;
var
oldIndex
=
_
.
indexOf
(
this
.
variables
,
old
);
const
oldIndex
=
_
.
indexOf
(
this
.
variables
,
old
);
if
(
oldIndex
!==
-
1
)
{
if
(
oldIndex
!==
-
1
)
{
this
.
variables
[
oldIndex
]
=
$scope
.
current
;
this
.
variables
[
oldIndex
]
=
$scope
.
current
;
}
}
...
...
public/app/features/templating/interval_variable.ts
View file @
e1beaaa0
...
@@ -57,7 +57,7 @@ export class IntervalVariable implements Variable {
...
@@ -57,7 +57,7 @@ export class IntervalVariable implements Variable {
});
});
}
}
var
res
=
kbn
.
calculateInterval
(
this
.
timeSrv
.
timeRange
(),
this
.
auto_count
,
this
.
auto_min
);
const
res
=
kbn
.
calculateInterval
(
this
.
timeSrv
.
timeRange
(),
this
.
auto_count
,
this
.
auto_min
);
this
.
templateSrv
.
setGrafanaVariable
(
'$__auto_interval_'
+
this
.
name
,
res
.
interval
);
this
.
templateSrv
.
setGrafanaVariable
(
'$__auto_interval_'
+
this
.
name
,
res
.
interval
);
// for backward compatibility, to be removed eventually
// for backward compatibility, to be removed eventually
this
.
templateSrv
.
setGrafanaVariable
(
'$__auto_interval'
,
res
.
interval
);
this
.
templateSrv
.
setGrafanaVariable
(
'$__auto_interval'
,
res
.
interval
);
...
...
public/app/features/templating/query_variable.ts
View file @
e1beaaa0
...
@@ -105,7 +105,7 @@ export class QueryVariable implements Variable {
...
@@ -105,7 +105,7 @@ export class QueryVariable implements Variable {
getValuesForTag
(
tagKey
)
{
getValuesForTag
(
tagKey
)
{
return
this
.
datasourceSrv
.
get
(
this
.
datasource
).
then
(
datasource
=>
{
return
this
.
datasourceSrv
.
get
(
this
.
datasource
).
then
(
datasource
=>
{
var
query
=
this
.
tagValuesQuery
.
replace
(
'$tag'
,
tagKey
);
const
query
=
this
.
tagValuesQuery
.
replace
(
'$tag'
,
tagKey
);
return
this
.
metricFindQuery
(
datasource
,
query
).
then
(
function
(
results
)
{
return
this
.
metricFindQuery
(
datasource
,
query
).
then
(
function
(
results
)
{
return
_
.
map
(
results
,
function
(
value
)
{
return
_
.
map
(
results
,
function
(
value
)
{
return
value
.
text
;
return
value
.
text
;
...
@@ -128,7 +128,7 @@ export class QueryVariable implements Variable {
...
@@ -128,7 +128,7 @@ export class QueryVariable implements Variable {
}
}
metricFindQuery
(
datasource
,
query
)
{
metricFindQuery
(
datasource
,
query
)
{
var
options
=
{
range
:
undefined
,
variable
:
this
};
const
options
=
{
range
:
undefined
,
variable
:
this
};
if
(
this
.
refresh
===
2
)
{
if
(
this
.
refresh
===
2
)
{
options
.
range
=
this
.
timeSrv
.
timeRange
();
options
.
range
=
this
.
timeSrv
.
timeRange
();
...
@@ -149,7 +149,7 @@ export class QueryVariable implements Variable {
...
@@ -149,7 +149,7 @@ export class QueryVariable implements Variable {
regex
=
kbn
.
stringToJsRegex
(
this
.
templateSrv
.
replace
(
this
.
regex
,
{},
'regex'
));
regex
=
kbn
.
stringToJsRegex
(
this
.
templateSrv
.
replace
(
this
.
regex
,
{},
'regex'
));
}
}
for
(
i
=
0
;
i
<
metricNames
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
metricNames
.
length
;
i
++
)
{
var
item
=
metricNames
[
i
];
const
item
=
metricNames
[
i
];
var
text
=
item
.
text
===
undefined
||
item
.
text
===
null
?
item
.
value
:
item
.
text
;
var
text
=
item
.
text
===
undefined
||
item
.
text
===
null
?
item
.
value
:
item
.
text
;
var
value
=
item
.
value
===
undefined
||
item
.
value
===
null
?
item
.
text
:
item
.
value
;
var
value
=
item
.
value
===
undefined
||
item
.
value
===
null
?
item
.
text
:
item
.
value
;
...
@@ -185,14 +185,14 @@ export class QueryVariable implements Variable {
...
@@ -185,14 +185,14 @@ export class QueryVariable implements Variable {
return
options
;
return
options
;
}
}
var
sortType
=
Math
.
ceil
(
sortOrder
/
2
);
const
sortType
=
Math
.
ceil
(
sortOrder
/
2
);
var
reverseSort
=
sortOrder
%
2
===
0
;
const
reverseSort
=
sortOrder
%
2
===
0
;
if
(
sortType
===
1
)
{
if
(
sortType
===
1
)
{
options
=
_
.
sortBy
(
options
,
'text'
);
options
=
_
.
sortBy
(
options
,
'text'
);
}
else
if
(
sortType
===
2
)
{
}
else
if
(
sortType
===
2
)
{
options
=
_
.
sortBy
(
options
,
opt
=>
{
options
=
_
.
sortBy
(
options
,
opt
=>
{
var
matches
=
opt
.
text
.
match
(
/.*
?(\d
+
)
.*/
);
const
matches
=
opt
.
text
.
match
(
/.*
?(\d
+
)
.*/
);
if
(
!
matches
||
matches
.
length
<
2
)
{
if
(
!
matches
||
matches
.
length
<
2
)
{
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
...
public/app/features/templating/template_srv.ts
View file @
e1beaaa0
...
@@ -33,7 +33,7 @@ export class TemplateSrv {
...
@@ -33,7 +33,7 @@ export class TemplateSrv {
this
.
index
=
{};
this
.
index
=
{};
for
(
var
i
=
0
;
i
<
this
.
variables
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
this
.
variables
.
length
;
i
++
)
{
var
variable
=
this
.
variables
[
i
];
const
variable
=
this
.
variables
[
i
];
if
(
!
variable
.
current
||
(
!
variable
.
current
.
isNone
&&
!
variable
.
current
.
value
))
{
if
(
!
variable
.
current
||
(
!
variable
.
current
.
isNone
&&
!
variable
.
current
.
value
))
{
continue
;
continue
;
...
@@ -51,7 +51,7 @@ export class TemplateSrv {
...
@@ -51,7 +51,7 @@ export class TemplateSrv {
var
filters
=
[];
var
filters
=
[];
for
(
var
i
=
0
;
i
<
this
.
variables
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
this
.
variables
.
length
;
i
++
)
{
var
variable
=
this
.
variables
[
i
];
const
variable
=
this
.
variables
[
i
];
if
(
variable
.
type
!==
'adhoc'
)
{
if
(
variable
.
type
!==
'adhoc'
)
{
continue
;
continue
;
}
}
...
@@ -77,7 +77,7 @@ export class TemplateSrv {
...
@@ -77,7 +77,7 @@ export class TemplateSrv {
if
(
value
instanceof
Array
&&
value
.
length
===
0
)
{
if
(
value
instanceof
Array
&&
value
.
length
===
0
)
{
return
'__empty__'
;
return
'__empty__'
;
}
}
var
quotedValues
=
_
.
map
(
value
,
function
(
val
)
{
const
quotedValues
=
_
.
map
(
value
,
function
(
val
)
{
return
'"'
+
luceneEscape
(
val
)
+
'"'
;
return
'"'
+
luceneEscape
(
val
)
+
'"'
;
});
});
return
'('
+
quotedValues
.
join
(
' OR '
)
+
')'
;
return
'('
+
quotedValues
.
join
(
' OR '
)
+
')'
;
...
@@ -97,7 +97,7 @@ export class TemplateSrv {
...
@@ -97,7 +97,7 @@ export class TemplateSrv {
return
kbn
.
regexEscape
(
value
);
return
kbn
.
regexEscape
(
value
);
}
}
var
escapedValues
=
_
.
map
(
value
,
kbn
.
regexEscape
);
const
escapedValues
=
_
.
map
(
value
,
kbn
.
regexEscape
);
if
(
escapedValues
.
length
===
1
)
{
if
(
escapedValues
.
length
===
1
)
{
return
escapedValues
[
0
];
return
escapedValues
[
0
];
}
}
...
@@ -139,7 +139,7 @@ export class TemplateSrv {
...
@@ -139,7 +139,7 @@ export class TemplateSrv {
getVariableName
(
expression
)
{
getVariableName
(
expression
)
{
this
.
regex
.
lastIndex
=
0
;
this
.
regex
.
lastIndex
=
0
;
var
match
=
this
.
regex
.
exec
(
expression
);
const
match
=
this
.
regex
.
exec
(
expression
);
if
(
!
match
)
{
if
(
!
match
)
{
return
null
;
return
null
;
}
}
...
@@ -147,7 +147,7 @@ export class TemplateSrv {
...
@@ -147,7 +147,7 @@ export class TemplateSrv {
}
}
variableExists
(
expression
)
{
variableExists
(
expression
)
{
var
name
=
this
.
getVariableName
(
expression
);
const
name
=
this
.
getVariableName
(
expression
);
return
name
&&
this
.
index
[
name
]
!==
void
0
;
return
name
&&
this
.
index
[
name
]
!==
void
0
;
}
}
...
@@ -170,7 +170,7 @@ export class TemplateSrv {
...
@@ -170,7 +170,7 @@ export class TemplateSrv {
if
(
variable
.
allValue
)
{
if
(
variable
.
allValue
)
{
return
variable
.
allValue
;
return
variable
.
allValue
;
}
}
var
values
=
[];
const
values
=
[];
for
(
var
i
=
1
;
i
<
variable
.
options
.
length
;
i
++
)
{
for
(
var
i
=
1
;
i
<
variable
.
options
.
length
;
i
++
)
{
values
.
push
(
variable
.
options
[
i
].
value
);
values
.
push
(
variable
.
options
[
i
].
value
);
}
}
...
@@ -213,7 +213,7 @@ export class TemplateSrv {
...
@@ -213,7 +213,7 @@ export class TemplateSrv {
}
}
}
}
var
res
=
this
.
formatValue
(
value
,
fmt
,
variable
);
const
res
=
this
.
formatValue
(
value
,
fmt
,
variable
);
return
res
;
return
res
;
});
});
}
}
...
@@ -232,7 +232,7 @@ export class TemplateSrv {
...
@@ -232,7 +232,7 @@ export class TemplateSrv {
return
target
.
replace
(
this
.
regex
,
(
match
,
var1
,
var2
,
fmt2
,
var3
)
=>
{
return
target
.
replace
(
this
.
regex
,
(
match
,
var1
,
var2
,
fmt2
,
var3
)
=>
{
if
(
scopedVars
)
{
if
(
scopedVars
)
{
var
option
=
scopedVars
[
var1
||
var2
||
var3
];
const
option
=
scopedVars
[
var1
||
var2
||
var3
];
if
(
option
)
{
if
(
option
)
{
return
option
.
text
;
return
option
.
text
;
}
}
...
...
public/app/features/templating/variable_srv.ts
View file @
e1beaaa0
...
@@ -27,7 +27,7 @@ export class VariableSrv {
...
@@ -27,7 +27,7 @@ export class VariableSrv {
variable
.
initLock
=
this
.
$q
.
defer
();
variable
.
initLock
=
this
.
$q
.
defer
();
}
}
var
queryParams
=
this
.
$location
.
search
();
const
queryParams
=
this
.
$location
.
search
();
return
this
.
$q
return
this
.
$q
.
all
(
.
all
(
this
.
variables
.
map
(
variable
=>
{
this
.
variables
.
map
(
variable
=>
{
...
@@ -44,8 +44,8 @@ export class VariableSrv {
...
@@ -44,8 +44,8 @@ export class VariableSrv {
return
Promise
.
resolve
({});
return
Promise
.
resolve
({});
}
}
var
promises
=
this
.
variables
.
filter
(
variable
=>
variable
.
refresh
===
2
).
map
(
variable
=>
{
const
promises
=
this
.
variables
.
filter
(
variable
=>
variable
.
refresh
===
2
).
map
(
variable
=>
{
var
previousOptions
=
variable
.
options
.
slice
();
const
previousOptions
=
variable
.
options
.
slice
();
return
variable
.
updateOptions
().
then
(()
=>
{
return
variable
.
updateOptions
().
then
(()
=>
{
if
(
angular
.
toJson
(
previousOptions
)
!==
angular
.
toJson
(
variable
.
options
))
{
if
(
angular
.
toJson
(
previousOptions
)
!==
angular
.
toJson
(
variable
.
options
))
{
...
@@ -58,7 +58,7 @@ export class VariableSrv {
...
@@ -58,7 +58,7 @@ export class VariableSrv {
}
}
processVariable
(
variable
,
queryParams
)
{
processVariable
(
variable
,
queryParams
)
{
var
dependencies
=
[];
const
dependencies
=
[];
for
(
const
otherVariable
of
this
.
variables
)
{
for
(
const
otherVariable
of
this
.
variables
)
{
if
(
variable
.
dependsOn
(
otherVariable
))
{
if
(
variable
.
dependsOn
(
otherVariable
))
{
...
@@ -69,7 +69,7 @@ export class VariableSrv {
...
@@ -69,7 +69,7 @@ export class VariableSrv {
return
this
.
$q
return
this
.
$q
.
all
(
dependencies
)
.
all
(
dependencies
)
.
then
(()
=>
{
.
then
(()
=>
{
var
urlValue
=
queryParams
[
'var-'
+
variable
.
name
];
const
urlValue
=
queryParams
[
'var-'
+
variable
.
name
];
if
(
urlValue
!==
void
0
)
{
if
(
urlValue
!==
void
0
)
{
return
variable
.
setValueFromUrl
(
urlValue
).
then
(
variable
.
initLock
.
resolve
);
return
variable
.
setValueFromUrl
(
urlValue
).
then
(
variable
.
initLock
.
resolve
);
}
}
...
@@ -87,14 +87,14 @@ export class VariableSrv {
...
@@ -87,14 +87,14 @@ export class VariableSrv {
}
}
createVariableFromModel
(
model
)
{
createVariableFromModel
(
model
)
{
var
ctor
=
variableTypes
[
model
.
type
].
ctor
;
const
ctor
=
variableTypes
[
model
.
type
].
ctor
;
if
(
!
ctor
)
{
if
(
!
ctor
)
{
throw
{
throw
{
message
:
'Unable to find variable constructor for '
+
model
.
type
,
message
:
'Unable to find variable constructor for '
+
model
.
type
,
};
};
}
}
var
variable
=
this
.
$injector
.
instantiate
(
ctor
,
{
model
:
model
});
const
variable
=
this
.
$injector
.
instantiate
(
ctor
,
{
model
:
model
});
return
variable
;
return
variable
;
}
}
...
@@ -105,7 +105,7 @@ export class VariableSrv {
...
@@ -105,7 +105,7 @@ export class VariableSrv {
}
}
removeVariable
(
variable
)
{
removeVariable
(
variable
)
{
var
index
=
_
.
indexOf
(
this
.
variables
,
variable
);
const
index
=
_
.
indexOf
(
this
.
variables
,
variable
);
this
.
variables
.
splice
(
index
,
1
);
this
.
variables
.
splice
(
index
,
1
);
this
.
templateSrv
.
updateTemplateData
();
this
.
templateSrv
.
updateTemplateData
();
this
.
dashboard
.
updateSubmenuVisibility
();
this
.
dashboard
.
updateSubmenuVisibility
();
...
@@ -139,7 +139,7 @@ export class VariableSrv {
...
@@ -139,7 +139,7 @@ export class VariableSrv {
selectOptionsForCurrentValue
(
variable
)
{
selectOptionsForCurrentValue
(
variable
)
{
var
i
,
y
,
value
,
option
;
var
i
,
y
,
value
,
option
;
var
selected
:
any
=
[];
const
selected
:
any
=
[];
for
(
i
=
0
;
i
<
variable
.
options
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
variable
.
options
.
length
;
i
++
)
{
option
=
variable
.
options
[
i
];
option
=
variable
.
options
[
i
];
...
@@ -185,7 +185,7 @@ export class VariableSrv {
...
@@ -185,7 +185,7 @@ export class VariableSrv {
return
variable
.
setValue
(
selected
);
return
variable
.
setValue
(
selected
);
}
else
{
}
else
{
var
currentOption
=
_
.
find
(
variable
.
options
,
{
const
currentOption
=
_
.
find
(
variable
.
options
,
{
text
:
variable
.
current
.
text
,
text
:
variable
.
current
.
text
,
});
});
if
(
currentOption
)
{
if
(
currentOption
)
{
...
@@ -246,7 +246,7 @@ export class VariableSrv {
...
@@ -246,7 +246,7 @@ export class VariableSrv {
updateUrlParamsWithCurrentVariables
()
{
updateUrlParamsWithCurrentVariables
()
{
// update url
// update url
var
params
=
this
.
$location
.
search
();
const
params
=
this
.
$location
.
search
();
// remove variable params
// remove variable params
_
.
each
(
params
,
function
(
value
,
key
)
{
_
.
each
(
params
,
function
(
value
,
key
)
{
...
...
public/app/routes/dashboard_loaders.ts
View file @
e1beaaa0
...
@@ -11,7 +11,7 @@ export class LoadDashboardCtrl {
...
@@ -11,7 +11,7 @@ export class LoadDashboardCtrl {
if
(
homeDash
.
redirectUri
)
{
if
(
homeDash
.
redirectUri
)
{
$location
.
path
(
homeDash
.
redirectUri
);
$location
.
path
(
homeDash
.
redirectUri
);
}
else
{
}
else
{
var
meta
=
homeDash
.
meta
;
const
meta
=
homeDash
.
meta
;
meta
.
canSave
=
meta
.
canShare
=
meta
.
canStar
=
false
;
meta
.
canSave
=
meta
.
canShare
=
meta
.
canStar
=
false
;
$scope
.
initDashboard
(
homeDash
,
$scope
);
$scope
.
initDashboard
(
homeDash
,
$scope
);
}
}
...
...
public/test/lib/common.ts
View file @
e1beaaa0
var
_global
=
<
any
>
(
window
)
;
const
_global
=
<
any
>
window
;
var
beforeEach
=
_global
.
beforeEach
;
const
beforeEach
=
_global
.
beforeEach
;
var
afterEach
=
_global
.
afterEach
;
const
afterEach
=
_global
.
afterEach
;
var
before
=
_global
.
before
;
const
before
=
_global
.
before
;
var
describe
=
_global
.
describe
;
const
describe
=
_global
.
describe
;
var
it
=
_global
.
it
;
const
it
=
_global
.
it
;
var
sinon
=
_global
.
sinon
;
const
sinon
=
_global
.
sinon
;
var
expect
=
_global
.
expect
;
const
expect
=
_global
.
expect
;
var
angularMocks
=
{
const
angularMocks
=
{
module
:
_global
.
module
,
module
:
_global
.
module
,
inject
:
_global
.
inject
,
inject
:
_global
.
inject
,
};
};
export
{
export
{
beforeEach
,
afterEach
,
before
,
describe
,
it
,
sinon
,
expect
,
angularMocks
};
beforeEach
,
afterEach
,
before
,
describe
,
it
,
sinon
,
expect
,
angularMocks
,
};
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