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
b71e7f33
Commit
b71e7f33
authored
Sep 05, 2018
by
Erik Sundell
Committed by
Daniel Lee
Sep 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved user experience
parent
4fa4c275
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
7 deletions
+86
-7
public/app/features/dashboard/upload.ts
+2
-1
public/app/plugins/datasource/stackdriver/config_ctrl.ts
+57
-0
public/app/plugins/datasource/stackdriver/partials/config.html
+27
-6
No files found.
public/app/features/dashboard/upload.ts
View file @
b71e7f33
import
coreModule
from
'app/core/core_module'
;
import
coreModule
from
'app/core/core_module'
;
import
appEvents
from
'app/core/app_events'
;
const
template
=
`
const
template
=
`
<input type="file" id="dashupload" name="dashupload" class="hide" onchange="angular.element(this).scope().file_selected"/>
<input type="file" id="dashupload" name="dashupload" class="hide" onchange="angular.element(this).scope().file_selected"/>
...
@@ -26,7 +27,7 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
...
@@ -26,7 +27,7 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
dash
=
JSON
.
parse
(
e
.
target
.
result
);
dash
=
JSON
.
parse
(
e
.
target
.
result
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
log
(
err
);
scope
.
appEven
t
(
'alert-error'
,
[
'Import failed'
,
'JSON -> JS Serialization failed: '
+
err
.
message
]);
appEvents
.
emi
t
(
'alert-error'
,
[
'Import failed'
,
'JSON -> JS Serialization failed: '
+
err
.
message
]);
return
;
return
;
}
}
...
...
public/app/plugins/datasource/stackdriver/config_ctrl.ts
View file @
b71e7f33
...
@@ -2,10 +2,67 @@ export class StackdriverConfigCtrl {
...
@@ -2,10 +2,67 @@ export class StackdriverConfigCtrl {
static
templateUrl
=
'public/app/plugins/datasource/stackdriver/partials/config.html'
;
static
templateUrl
=
'public/app/plugins/datasource/stackdriver/partials/config.html'
;
datasourceSrv
:
any
;
datasourceSrv
:
any
;
current
:
any
;
current
:
any
;
jsonText
:
string
;
validationErrors
:
string
[]
=
[];
inputDataValid
:
boolean
;
/** @ngInject */
/** @ngInject */
constructor
(
$scope
,
datasourceSrv
)
{
constructor
(
$scope
,
datasourceSrv
)
{
this
.
datasourceSrv
=
datasourceSrv
;
this
.
datasourceSrv
=
datasourceSrv
;
this
.
current
.
jsonData
=
this
.
current
.
jsonData
||
{};
this
.
current
.
jsonData
=
this
.
current
.
jsonData
||
{};
this
.
current
.
secureJsonData
=
this
.
current
.
secureJsonData
||
{};
}
save
(
jwt
)
{
this
.
current
.
secureJsonData
.
privateKey
=
jwt
.
private_key
;
this
.
current
.
jsonData
.
tokenUri
=
jwt
.
token_uri
;
this
.
current
.
jsonData
.
clientEmail
=
jwt
.
client_email
;
}
validateJwt
(
jwt
)
{
this
.
resetValidationMessages
();
if
(
!
jwt
.
private_key
||
jwt
.
private_key
.
length
===
0
)
{
this
.
validationErrors
.
push
(
'Private key field missing in JWT file.'
);
}
if
(
!
jwt
.
token_uri
||
jwt
.
token_uri
.
length
===
0
)
{
this
.
validationErrors
.
push
(
'Token URI field missing in JWT file.'
);
}
if
(
!
jwt
.
client_email
||
jwt
.
client_email
.
length
===
0
)
{
this
.
validationErrors
.
push
(
'Client Email field missing in JWT file.'
);
}
if
(
this
.
validationErrors
.
length
===
0
)
{
this
.
inputDataValid
=
true
;
return
true
;
}
else
{
return
false
;
}
}
onUpload
(
json
)
{
this
.
jsonText
=
''
;
if
(
this
.
validateJwt
(
json
))
{
this
.
save
(
json
);
}
}
onPasteJwt
(
e
)
{
try
{
const
json
=
JSON
.
parse
(
e
.
originalEvent
.
clipboardData
.
getData
(
'text/plain'
)
||
this
.
jsonText
);
if
(
this
.
validateJwt
(
json
))
{
this
.
save
(
json
);
}
}
catch
(
error
)
{
this
.
resetValidationMessages
();
this
.
validationErrors
.
push
(
`Invalid json:
${
error
.
message
}
`
);
}
}
resetValidationMessages
()
{
this
.
validationErrors
=
[];
this
.
inputDataValid
=
false
;
this
.
jsonText
=
''
;
}
}
}
}
public/app/plugins/datasource/stackdriver/partials/config.html
View file @
b71e7f33
<datasource-http-settings
<h3>
Stackdriver Authentication
</h3>
current=
"ctrl.current"
<div
class=
"gf-form-group"
ng-if=
"!ctrl.inputDataValid"
>
suggest-url=
"http://localhost:8080"
>
<div
class=
"gf-form"
>
</datasource-http-settings>
<form>
<dash-upload
on-upload=
"ctrl.onUpload(dash)"
></dash-upload>
<h3
class=
"page-heading"
>
Hello Stackdriver
</h3>
</form>
</div>
</div>
<div
class=
"gf-form-group"
>
<h5
class=
"section-heading"
ng-if=
"!ctrl.inputDataValid"
>
Or paste JSON
</h5>
<div
class=
"gf-form"
ng-if=
"!ctrl.inputDataValid"
>
<textarea
rows=
"10"
data-share-panel-url=
""
class=
"gf-form-input"
ng-model=
"ctrl.jsonText"
ng-paste=
"ctrl.onPasteJwt($event)"
></textarea>
</div>
<div
ng-repeat=
"valError in ctrl.validationErrors"
class=
"text-error p-l-1"
>
<i
class=
"fa fa-warning"
></i>
{{valError}}
</div>
<div
ng-if=
"ctrl.inputDataValid"
>
<div
class=
"text-success p-l-1"
>
<i
class=
"fa fa-info"
></i>
Successfully validated input format
</div>
<br
/>
<a
class=
"btn btn-secondary gf-form-btn"
href=
"#"
ng-click=
"ctrl.resetValidationMessages()"
>
Reset form
</a>
</div>
</div>
\ No newline at end of file
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