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
fdfcd5cb
Commit
fdfcd5cb
authored
Jun 05, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring:: dashboard save modal and save as modal needed an update
parent
f3980504
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
193 additions
and
219 deletions
+193
-219
public/app/core/services/backend_srv.ts
+6
-2
public/app/features/dashboard/all.js
+2
-3
public/app/features/dashboard/dash_list_ctrl.ts
+0
-11
public/app/features/dashboard/dashboard_srv.ts
+8
-11
public/app/features/dashboard/dashnav/dashnav.ts
+3
-3
public/app/features/dashboard/partials/dash_list.html
+0
-10
public/app/features/dashboard/partials/graphiteImport.html
+0
-35
public/app/features/dashboard/partials/saveDashboardAs.html
+0
-27
public/app/features/dashboard/partials/saveDashboardMessage.html
+0
-49
public/app/features/dashboard/saveDashboardAsCtrl.js
+0
-39
public/app/features/dashboard/saveDashboardMessageCtrl.js
+0
-29
public/app/features/dashboard/save_as_modal.ts
+79
-0
public/app/features/dashboard/save_modal.ts
+95
-0
No files found.
public/app/core/services/backend_srv.ts
View file @
fdfcd5cb
...
...
@@ -202,8 +202,12 @@ export class BackendSrv {
saveDashboard
(
dash
,
options
)
{
options
=
(
options
||
{});
const
message
=
options
.
message
||
''
;
return
this
.
post
(
'/api/dashboards/db/'
,
{
dashboard
:
dash
,
overwrite
:
options
.
overwrite
===
true
,
message
});
return
this
.
post
(
'/api/dashboards/db/'
,
{
dashboard
:
dash
,
overwrite
:
options
.
overwrite
===
true
,
message
:
options
.
message
||
''
,
});
}
}
...
...
public/app/features/dashboard/all.js
View file @
fdfcd5cb
...
...
@@ -5,8 +5,8 @@ define([
'./dashboardLoaderSrv'
,
'./dashnav/dashnav'
,
'./submenu/submenu'
,
'./save
DashboardAsCtr
l'
,
'./save
DashboardMessageCtr
l'
,
'./save
_as_moda
l'
,
'./save
_moda
l'
,
'./shareModalCtrl'
,
'./shareSnapshotCtrl'
,
'./dashboard_srv'
,
...
...
@@ -20,7 +20,6 @@ define([
'./import/dash_import'
,
'./export/export_modal'
,
'./export_data/export_data_modal'
,
'./dash_list_ctrl'
,
'./ad_hoc_filters'
,
'./row/row_ctrl'
,
'./repeat_option/repeat_option'
,
...
...
public/app/features/dashboard/dash_list_ctrl.ts
deleted
100644 → 0
View file @
f3980504
///<reference path="../../headers/common.d.ts" />
import
coreModule
from
'app/core/core_module'
;
export
class
DashListCtrl
{
/** @ngInject */
constructor
()
{
}
}
coreModule
.
controller
(
'DashListCtrl'
,
DashListCtrl
);
public/app/features/dashboard/dashboard_srv.ts
View file @
fdfcd5cb
...
...
@@ -65,7 +65,7 @@ export class DashboardSrv {
icon
:
"fa-warning"
,
altActionText
:
"Save As"
,
onAltAction
:
()
=>
{
this
.
s
aveDashboardAs
();
this
.
s
howSaveAsModal
();
},
onConfirm
:
()
=>
{
this
.
saveDashboard
({
overwrite
:
true
},
clone
);
...
...
@@ -102,36 +102,33 @@ export class DashboardSrv {
}
if
(
this
.
dash
.
title
===
'New dashboard'
)
{
return
this
.
s
aveDashboardAs
();
return
this
.
s
howSaveAsModal
();
}
if
(
this
.
dash
.
version
>
0
)
{
return
this
.
s
aveDashboardMessage
();
return
this
.
s
howSaveModal
();
}
return
this
.
save
(
this
.
dash
.
getSaveModelClone
(),
options
);
}
s
aveDashboardAs
()
{
s
howSaveAsModal
()
{
var
newScope
=
this
.
$rootScope
.
$new
();
newScope
.
clone
=
this
.
dash
.
getSaveModelClone
();
newScope
.
clone
.
editable
=
true
;
newScope
.
clone
.
hideControls
=
false
;
this
.
$rootScope
.
appEvent
(
'show-modal'
,
{
src
:
'public/app/features/dashboard/partials/saveDashboardAs.html
'
,
templateHtml
:
'<save-dashboard-as-modal dismiss="dismiss()"></save-dashboard-as-modal>
'
,
scope
:
newScope
,
modalClass
:
'modal--narrow'
});
}
saveDashboardMessage
()
{
var
newScope
=
this
.
$rootScope
.
$new
();
newScope
.
clone
=
this
.
dash
.
getSaveModelClone
();
showSaveModal
()
{
this
.
$rootScope
.
appEvent
(
'show-modal'
,
{
src
:
'public/app/features/dashboard/partials/saveDashboardMessage.html
'
,
scope
:
newScope
,
templateHtml
:
'<save-dashboard-modal dismiss="dismiss()"></save-dashboard-modal>"
'
,
scope
:
this
.
$rootScope
.
$new
()
,
modalClass
:
'modal--narrow'
});
}
...
...
public/app/features/dashboard/dashnav/dashnav.ts
View file @
fdfcd5cb
...
...
@@ -87,8 +87,8 @@ export class DashNavCtrl {
this
.
$rootScope
.
appEvent
(
'panel-change-view'
,
{
fullscreen
:
false
,
edit
:
false
});
}
saveDashboard
(
options
)
{
return
this
.
dashboardSrv
.
saveDashboard
(
options
);
saveDashboard
()
{
return
this
.
dashboardSrv
.
saveDashboard
();
}
deleteDashboard
()
{
...
...
@@ -126,7 +126,7 @@ export class DashNavCtrl {
}
saveDashboardAs
()
{
return
this
.
dashboardSrv
.
s
aveDashboardAs
();
return
this
.
dashboardSrv
.
s
howSaveAsModal
();
}
viewJson
()
{
...
...
public/app/features/dashboard/partials/dash_list.html
deleted
100644 → 0
View file @
f3980504
<navbar
title=
"Dashboards"
title-url=
"dashboards"
icon=
"icon-gf icon-gf-dashboard"
>
</navbar>
<div
class=
"page-container"
>
<div
class=
"page-header"
>
<h1>
Dashboards
</h1>
</div>
</div>
public/app/features/dashboard/partials/graphiteImport.html
deleted
100644 → 0
View file @
f3980504
<div
ng-controller=
"GraphiteImportCtrl"
ng-init=
"init()"
>
<div
ng-if=
"datasources.length > 0"
>
<h2
class=
"page-heading"
>
Load dashboard from Graphite-Web
</h2>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
Data source
</span>
</div>
<div
class=
"gf-form"
>
<div
class=
"gf-form-select-wrapper"
>
<select
type=
"text"
ng-model=
"options.sourceName"
class=
"gf-form-input gf-size-auto"
ng-options=
"f for f in datasources"
>
</select>
</div>
</div>
<div
class=
"gf-form"
>
<button
class=
"btn btn-success pull-right"
ng-click=
"listAll()"
>
List dashboards
</button>
</div>
</div>
</div>
<table
class=
"grafana-options-table"
style=
"margin-top: 20px;"
>
<tr
ng-repeat=
"dash in dashboards"
>
<td
style=
""
>
{{dash.name}}
</td>
<td>
<button
class=
"btn btn-inverse pull-right"
ng-click=
"import(dash.name)"
>
Load
</button>
</td>
</tr>
</table>
</div>
</div>
public/app/features/dashboard/partials/saveDashboardAs.html
deleted
100644 → 0
View file @
f3980504
<div
class=
"modal-body"
ng-controller=
"SaveDashboardAsCtrl"
ng-init=
"init();"
>
<div
class=
"modal-header"
>
<h2
class=
"modal-header-title"
>
<i
class=
"fa fa-copy"
></i>
<span
class=
"p-l-1"
>
Save As...
</span>
</h2>
<a
class=
"modal-header-close"
ng-click=
"dismiss();"
>
<i
class=
"fa fa-remove"
></i>
</a>
</div>
<div
class=
"modal-content"
>
<div
class=
"p-t-2"
>
<div
class=
"gf-form"
>
<label
class=
"gf-form-label"
>
New name
</label>
<input
type=
"text"
class=
"gf-form-input"
ng-model=
"clone.title"
give-focus=
"true"
ng-keydown=
"keyDown($event)"
>
</div>
</div>
<div
class=
"gf-form-button-row text-center"
>
<a
class=
"btn btn-success"
ng-click=
"saveClone();"
>
Save
</a>
<a
class=
"btn-text"
ng-click=
"dismiss();"
>
Cancel
</a>
</div>
</div>
</div>
public/app/features/dashboard/partials/saveDashboardMessage.html
deleted
100644 → 0
View file @
f3980504
<div
class=
"modal-body"
ng-controller=
"SaveDashboardMessageCtrl"
ng-init=
"init();"
>
<div
class=
"modal-header"
>
<h2
class=
"modal-header-title"
>
<i
class=
"fa fa-save"
></i>
<span
class=
"p-l-1"
>
Save Dashboard
</span>
</h2>
<a
class=
"modal-header-close"
ng-click=
"dismiss();"
>
<i
class=
"fa fa-remove"
></i>
</a>
</div>
<form
name=
"saveMessage"
ng-submit=
"saveVersion(saveMessage.$valid)"
class=
"modal-content"
novalidate
>
<h6
class=
"text-center"
>
Add a note to describe the changes in this version
</h6>
<div
class=
"p-t-2"
>
<div
class=
"gf-form"
>
<label
class=
"gf-form-hint"
>
<input
type=
"text"
name=
"message"
class=
"gf-form-input"
placeholder=
"Updates to …"
give-focus=
"true"
ng-model=
"clone.message"
ng-model-options=
"{allowInvalid: true}"
ng-keydown=
"keyDown($event)"
ng-maxlength=
"clone.max"
autocomplete=
"off"
required
/>
<small
class=
"gf-form-hint-text muted"
ng-cloak
>
<span
ng-class=
"{'text-error': saveMessage.message.$invalid && saveMessage.message.$dirty }"
>
{{clone.message.length || 0}}
</span>
/ {{clone.max}} characters
</small>
</label>
</div>
</div>
<div
class=
"gf-form-button-row text-center"
>
<button
type=
"submit"
class=
"btn btn-success"
ng-disabled=
"saveMessage.$invalid"
>
Save
</button>
<button
class=
"btn btn-inverse"
ng-click=
"dismiss();"
>
Cancel
</button>
</div>
</form>
</div>
public/app/features/dashboard/saveDashboardAsCtrl.js
deleted
100644 → 0
View file @
f3980504
define
([
'angular'
,
],
function
(
angular
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'SaveDashboardAsCtrl'
,
function
(
$scope
,
dashboardSrv
)
{
$scope
.
init
=
function
()
{
$scope
.
clone
.
id
=
null
;
$scope
.
clone
.
editable
=
true
;
$scope
.
clone
.
title
=
$scope
.
clone
.
title
+
" Copy"
;
// remove alerts
$scope
.
clone
.
rows
.
forEach
(
function
(
row
)
{
row
.
panels
.
forEach
(
function
(
panel
)
{
delete
panel
.
alert
;
});
});
// remove auto update
delete
$scope
.
clone
.
autoUpdate
;
};
$scope
.
keyDown
=
function
(
evt
)
{
if
(
evt
.
keyCode
===
13
)
{
$scope
.
saveClone
();
}
};
$scope
.
saveClone
=
function
()
{
return
dashboardSrv
.
save
(
$scope
.
clone
,
{
overwrite
:
false
})
.
then
(
function
()
{
$scope
.
dismiss
();
});
};
});
});
public/app/features/dashboard/saveDashboardMessageCtrl.js
deleted
100644 → 0
View file @
f3980504
define
([
'angular'
,
],
function
(
angular
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'SaveDashboardMessageCtrl'
,
function
(
$scope
,
dashboardSrv
)
{
$scope
.
init
=
function
()
{
$scope
.
clone
.
message
=
''
;
$scope
.
clone
.
max
=
64
;
};
function
saveDashboard
(
options
)
{
options
.
message
=
$scope
.
clone
.
message
;
return
dashboardSrv
.
save
(
$scope
.
clone
,
options
)
.
then
(
function
()
{
$scope
.
dismiss
();
});
}
$scope
.
saveVersion
=
function
(
isValid
)
{
if
(
!
isValid
)
{
return
;
}
saveDashboard
({
overwrite
:
false
});
};
});
});
public/app/features/dashboard/save_as_modal.ts
0 → 100644
View file @
fdfcd5cb
///<reference path="../../headers/common.d.ts" />
import
coreModule
from
'app/core/core_module'
;
const
template
=
`
<div class="modal-body">
<div class="modal-header">
<h2 class="modal-header-title">
<i class="fa fa-copy"></i>
<span class="p-l-1">Save As...</span>
</h2>
<a class="modal-header-close" ng-click="ctrl.dismiss();">
<i class="fa fa-remove"></i>
</a>
</div>
<div class="modal-content">
<div class="p-t-2">
<div class="gf-form">
<label class="gf-form-label">New name</label>
<input type="text" class="gf-form-input" ng-model="ctrl.clone.title" give-focus="true" ng-keydown="ctrl.keyDown($event)">
</div>
</div>
<div class="gf-form-button-row text-center">
<a class="btn btn-success" ng-click="ctrl.save();">Save</a>
<a class="btn-text" ng-click="ctrl.dismiss();">Cancel</a>
</div>
</div>
</div>
`
;
export
class
SaveDashboardAsModalCtrl
{
clone
:
any
;
dismiss
:
()
=>
void
;
/** @ngInject */
constructor
(
private
$scope
,
private
dashboardSrv
)
{
var
dashboard
=
this
.
dashboardSrv
.
getCurrent
();
this
.
clone
=
dashboard
.
getSaveModelClone
();
this
.
clone
.
id
=
null
;
this
.
clone
.
title
+=
' Copy'
;
this
.
clone
.
editable
=
true
;
this
.
clone
.
hideControls
=
false
;
// remove alerts
this
.
clone
.
rows
.
forEach
(
row
=>
{
row
.
panels
.
forEach
(
panel
=>
{
delete
panel
.
alert
;
});
});
delete
this
.
clone
.
autoUpdate
;
}
save
()
{
return
this
.
dashboardSrv
.
save
(
this
.
clone
).
then
(
this
.
dismiss
);
}
keyDown
(
evt
)
{
if
(
evt
.
keyCode
===
13
)
{
this
.
save
();
}
}
}
export
function
saveDashboardAsDirective
()
{
return
{
restrict
:
'E'
,
template
:
template
,
controller
:
SaveDashboardAsModalCtrl
,
bindToController
:
true
,
controllerAs
:
'ctrl'
,
scope
:
{
dismiss
:
"&"
}
};
}
coreModule
.
directive
(
'saveDashboardAsModal'
,
saveDashboardAsDirective
);
public/app/features/dashboard/save_modal.ts
0 → 100644
View file @
fdfcd5cb
///<reference path="../../headers/common.d.ts" />
import
coreModule
from
'app/core/core_module'
;
const
template
=
`
<div class="modal-body">
<div class="modal-header">
<h2 class="modal-header-title">
<i class="fa fa-save"></i>
<span class="p-l-1">Save Dashboard</span>
</h2>
<a class="modal-header-close" ng-click="ctrl.dismiss();">
<i class="fa fa-remove"></i>
</a>
</div>
<form name="ctrl.saveForm" ng-submit="ctrl.save()" class="modal-content" novalidate>
<h6 class="text-center">Add a note to describe your changes</h6>
<div class="p-t-2">
<div class="gf-form">
<label class="gf-form-hint">
<input
type="text"
name="message"
class="gf-form-input"
placeholder="Updates to …"
give-focus="true"
ng-model="ctrl.message"
ng-model-options="{allowInvalid: true}"
ng-maxlength="this.max"
ng-keydown="ctrl.keyDown($event)"
autocomplete="off"
required />
<small class="gf-form-hint-text muted" ng-cloak>
<span ng-class="{'text-error': ctrl.saveForm.message.$invalid && ctrl.saveForm.message.$dirty }">
{{ctrl.message.length || 0}}
</span>
/ {{ctrl.max}} characters
</small>
</label>
</div>
</div>
<div class="gf-form-button-row text-center">
<button type="submit" class="btn btn-success" ng-disabled="ctrl.saveForm.$invalid">Save</button>
<button class="btn btn-inverse" ng-click="ctrl.dismiss();">Cancel</button>
</div>
</form>
</div>
`
;
export
class
SaveDashboardModalCtrl
{
message
:
string
;
max
:
number
;
saveForm
:
any
;
dismiss
:
()
=>
void
;
/** @ngInject */
constructor
(
private
$scope
,
private
dashboardSrv
)
{
this
.
message
=
''
;
this
.
max
=
64
;
}
save
()
{
if
(
!
this
.
saveForm
.
$valid
)
{
return
;
}
var
dashboard
=
this
.
dashboardSrv
.
getCurrent
();
var
saveModel
=
dashboard
.
getSaveModelClone
();
var
options
=
{
message
:
this
.
message
};
return
this
.
dashboardSrv
.
save
(
saveModel
,
options
).
then
(
this
.
dismiss
);
}
keyDown
(
evt
)
{
if
(
evt
.
keyCode
===
13
)
{
this
.
save
();
}
}
}
export
function
saveDashboardModalDirective
()
{
return
{
restrict
:
'E'
,
template
:
template
,
controller
:
SaveDashboardModalCtrl
,
bindToController
:
true
,
controllerAs
:
'ctrl'
,
scope
:
{
dismiss
:
"&"
}
};
}
coreModule
.
directive
(
'saveDashboardModal'
,
saveDashboardModalDirective
);
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