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
25f13bd3
Commit
25f13bd3
authored
Sep 05, 2018
by
Patrick O'Carroll
Committed by
Torkel Ödegaard
Sep 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added only-arrow-functions rule and changed files to follow new rule (#13154)
parent
275f6130
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
30 deletions
+31
-30
public/app/core/components/sql_part/sql_part_editor.ts
+10
-10
public/app/core/services/analytics.ts
+1
-1
public/app/core/services/ng_react.ts
+1
-1
public/app/plugins/datasource/postgres/query_ctrl.ts
+6
-6
public/app/plugins/datasource/postgres/specs/postgres_query.test.ts
+12
-12
tslint.json
+1
-0
No files found.
public/app/core/components/sql_part/sql_part_editor.ts
View file @
25f13bd3
...
...
@@ -55,7 +55,7 @@ export function sqlPartEditorDirective($compile, templateSrv) {
}
function
inputBlur
(
$input
,
paramIndex
)
{
cancelBlur
=
setTimeout
(
function
()
{
cancelBlur
=
setTimeout
(
()
=>
{
switchToLink
(
$input
,
paramIndex
);
},
200
);
}
...
...
@@ -95,20 +95,20 @@ export function sqlPartEditorDirective($compile, templateSrv) {
return
;
}
const
typeaheadSource
=
function
(
query
,
callback
)
{
const
typeaheadSource
=
(
query
,
callback
)
=>
{
if
(
param
.
options
)
{
let
options
=
param
.
options
;
if
(
param
.
type
===
'int'
)
{
options
=
_
.
map
(
options
,
function
(
val
)
{
options
=
_
.
map
(
options
,
val
=>
{
return
val
.
toString
();
});
}
return
options
;
}
$scope
.
$apply
(
function
()
{
$scope
.
handleEvent
({
$event
:
{
name
:
'get-param-options'
,
param
:
param
}
}).
then
(
function
(
result
)
{
const
dynamicOptions
=
_
.
map
(
result
,
function
(
op
)
{
$scope
.
$apply
(
()
=>
{
$scope
.
handleEvent
({
$event
:
{
name
:
'get-param-options'
,
param
:
param
}
}).
then
(
result
=>
{
const
dynamicOptions
=
_
.
map
(
result
,
op
=>
{
return
op
.
value
;
});
...
...
@@ -128,7 +128,7 @@ export function sqlPartEditorDirective($compile, templateSrv) {
source
:
typeaheadSource
,
minLength
:
0
,
items
:
1000
,
updater
:
function
(
value
)
{
updater
:
value
=>
{
if
(
value
===
part
.
params
[
paramIndex
])
{
clearTimeout
(
cancelBlur
);
$input
.
focus
();
...
...
@@ -150,18 +150,18 @@ export function sqlPartEditorDirective($compile, templateSrv) {
}
}
$scope
.
showActionsMenu
=
function
()
{
$scope
.
showActionsMenu
=
()
=>
{
$scope
.
handleEvent
({
$event
:
{
name
:
'get-part-actions'
}
}).
then
(
res
=>
{
$scope
.
partActions
=
res
;
});
};
$scope
.
triggerPartAction
=
function
(
action
)
{
$scope
.
triggerPartAction
=
action
=>
{
$scope
.
handleEvent
({
$event
:
{
name
:
'action'
,
action
:
action
}
});
};
function
addElementsAndCompile
()
{
_
.
each
(
partDef
.
params
,
function
(
param
,
index
)
{
_
.
each
(
partDef
.
params
,
(
param
,
index
)
=>
{
if
(
param
.
optional
&&
part
.
params
.
length
<=
index
)
{
return
;
}
...
...
public/app/core/services/analytics.ts
View file @
25f13bd3
...
...
@@ -14,8 +14,8 @@ export class Analytics {
});
const
ga
=
((
window
as
any
).
ga
=
(
window
as
any
).
ga
||
//tslint:disable-next-line:only-arrow-functions
function
()
{
//tslint:disable-line:only-arrow-functions
(
ga
.
q
=
ga
.
q
||
[]).
push
(
arguments
);
});
ga
.
l
=
+
new
Date
();
...
...
public/app/core/services/ng_react.ts
View file @
25f13bd3
...
...
@@ -52,8 +52,8 @@ function applied(fn, scope) {
if
(
fn
.
wrappedInApply
)
{
return
fn
;
}
//tslint:disable-next-line:only-arrow-functions
const
wrapped
:
any
=
function
()
{
//tslint:disable-line:only-arrow-functions
const
args
=
arguments
;
const
phase
=
scope
.
$root
.
$$phase
;
if
(
phase
===
'$apply'
||
phase
===
'$digest'
)
{
...
...
public/app/plugins/datasource/postgres/query_ctrl.ts
View file @
25f13bd3
...
...
@@ -96,7 +96,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
}
updateProjection
()
{
this
.
selectParts
=
_
.
map
(
this
.
target
.
select
,
function
(
parts
:
any
)
{
this
.
selectParts
=
_
.
map
(
this
.
target
.
select
,
(
parts
:
any
)
=>
{
return
_
.
map
(
parts
,
sqlPart
.
create
).
filter
(
n
=>
n
);
});
this
.
whereParts
=
_
.
map
(
this
.
target
.
where
,
sqlPart
.
create
).
filter
(
n
=>
n
);
...
...
@@ -104,15 +104,15 @@ export class PostgresQueryCtrl extends QueryCtrl {
}
updatePersistedParts
()
{
this
.
target
.
select
=
_
.
map
(
this
.
selectParts
,
function
(
selectParts
)
{
return
_
.
map
(
selectParts
,
function
(
part
:
any
)
{
this
.
target
.
select
=
_
.
map
(
this
.
selectParts
,
selectParts
=>
{
return
_
.
map
(
selectParts
,
(
part
:
any
)
=>
{
return
{
type
:
part
.
def
.
type
,
datatype
:
part
.
datatype
,
params
:
part
.
params
};
});
});
this
.
target
.
where
=
_
.
map
(
this
.
whereParts
,
function
(
part
:
any
)
{
this
.
target
.
where
=
_
.
map
(
this
.
whereParts
,
(
part
:
any
)
=>
{
return
{
type
:
part
.
def
.
type
,
datatype
:
part
.
datatype
,
name
:
part
.
name
,
params
:
part
.
params
};
});
this
.
target
.
group
=
_
.
map
(
this
.
groupParts
,
function
(
part
:
any
)
{
this
.
target
.
group
=
_
.
map
(
this
.
groupParts
,
(
part
:
any
)
=>
{
return
{
type
:
part
.
def
.
type
,
datatype
:
part
.
datatype
,
params
:
part
.
params
};
});
}
...
...
@@ -355,7 +355,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
switch
(
partType
)
{
case
'column'
:
const
parts
=
_
.
map
(
selectParts
,
function
(
part
:
any
)
{
const
parts
=
_
.
map
(
selectParts
,
(
part
:
any
)
=>
{
return
sqlPart
.
create
({
type
:
part
.
def
.
type
,
params
:
_
.
clone
(
part
.
params
)
});
});
this
.
selectParts
.
push
(
parts
);
...
...
public/app/plugins/datasource/postgres/specs/postgres_query.test.ts
View file @
25f13bd3
import
PostgresQuery
from
'../postgres_query'
;
describe
(
'PostgresQuery'
,
function
()
{
describe
(
'PostgresQuery'
,
()
=>
{
const
templateSrv
=
{
replace
:
jest
.
fn
(
text
=>
text
),
};
describe
(
'When initializing'
,
function
()
{
it
(
'should not be in SQL mode'
,
function
()
{
describe
(
'When initializing'
,
()
=>
{
it
(
'should not be in SQL mode'
,
()
=>
{
const
query
=
new
PostgresQuery
({},
templateSrv
);
expect
(
query
.
target
.
rawQuery
).
toBe
(
false
);
});
it
(
'should be in SQL mode for pre query builder queries'
,
function
()
{
it
(
'should be in SQL mode for pre query builder queries'
,
()
=>
{
const
query
=
new
PostgresQuery
({
rawSql
:
'SELECT 1'
},
templateSrv
);
expect
(
query
.
target
.
rawQuery
).
toBe
(
true
);
});
});
describe
(
'When generating time column SQL'
,
function
()
{
describe
(
'When generating time column SQL'
,
()
=>
{
const
query
=
new
PostgresQuery
({},
templateSrv
);
query
.
target
.
timeColumn
=
'time'
;
...
...
@@ -25,7 +25,7 @@ describe('PostgresQuery', function() {
expect
(
query
.
buildTimeColumn
()).
toBe
(
'"time" AS "time"'
);
});
describe
(
'When generating time column SQL with group by time'
,
function
()
{
describe
(
'When generating time column SQL with group by time'
,
()
=>
{
let
query
=
new
PostgresQuery
(
{
timeColumn
:
'time'
,
group
:
[{
type
:
'time'
,
params
:
[
'5m'
,
'none'
]
}]
},
templateSrv
...
...
@@ -44,7 +44,7 @@ describe('PostgresQuery', function() {
expect
(
query
.
buildTimeColumn
(
false
)).
toBe
(
'$__unixEpochGroup(time,5m)'
);
});
describe
(
'When generating metric column SQL'
,
function
()
{
describe
(
'When generating metric column SQL'
,
()
=>
{
const
query
=
new
PostgresQuery
({},
templateSrv
);
query
.
target
.
metricColumn
=
'host'
;
...
...
@@ -53,7 +53,7 @@ describe('PostgresQuery', function() {
expect
(
query
.
buildMetricColumn
()).
toBe
(
'"host" AS metric'
);
});
describe
(
'When generating value column SQL'
,
function
()
{
describe
(
'When generating value column SQL'
,
()
=>
{
const
query
=
new
PostgresQuery
({},
templateSrv
);
let
column
=
[{
type
:
'column'
,
params
:
[
'value'
]
}];
...
...
@@ -76,7 +76,7 @@ describe('PostgresQuery', function() {
);
});
describe
(
'When generating value column SQL with metric column'
,
function
()
{
describe
(
'When generating value column SQL with metric column'
,
()
=>
{
const
query
=
new
PostgresQuery
({},
templateSrv
);
query
.
target
.
metricColumn
=
'host'
;
...
...
@@ -110,7 +110,7 @@ describe('PostgresQuery', function() {
);
});
describe
(
'When generating WHERE clause'
,
function
()
{
describe
(
'When generating WHERE clause'
,
()
=>
{
const
query
=
new
PostgresQuery
({
where
:
[]
},
templateSrv
);
expect
(
query
.
buildWhereClause
()).
toBe
(
''
);
...
...
@@ -126,7 +126,7 @@ describe('PostgresQuery', function() {
expect
(
query
.
buildWhereClause
()).
toBe
(
'
\
nWHERE
\
n $__timeFilter(t) AND
\
n v = 1'
);
});
describe
(
'When generating GROUP BY clause'
,
function
()
{
describe
(
'When generating GROUP BY clause'
,
()
=>
{
const
query
=
new
PostgresQuery
({
group
:
[],
metricColumn
:
'none'
},
templateSrv
);
expect
(
query
.
buildGroupClause
()).
toBe
(
''
);
...
...
@@ -136,7 +136,7 @@ describe('PostgresQuery', function() {
expect
(
query
.
buildGroupClause
()).
toBe
(
'
\
nGROUP BY 1,2'
);
});
describe
(
'When generating complete statement'
,
function
()
{
describe
(
'When generating complete statement'
,
()
=>
{
const
target
=
{
timeColumn
:
't'
,
table
:
'table'
,
...
...
tslint.json
View file @
25f13bd3
...
...
@@ -49,6 +49,7 @@
"no-var-keyword"
:
true
,
"object-literal-sort-keys"
:
false
,
"one-line"
:
[
true
,
"check-open-brace"
,
"check-catch"
,
"check-else"
],
"only-arrow-functions"
:
[
true
,
"allow-declarations"
,
"allow-named-functions"
],
"prefer-const"
:
true
,
"radix"
:
false
,
"typedef-whitespace"
:
[
...
...
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