Skip to content

Commit 437b880

Browse files
committed
feat(plugins): work on setup wizard started
1 parent 319b934 commit 437b880

File tree

7 files changed

+174
-48
lines changed

7 files changed

+174
-48
lines changed

public/app/core/components/grafana_app.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import store from 'app/core/store';
55
import _ from 'lodash';
66
import angular from 'angular';
77
import $ from 'jquery';
8+
89
import coreModule from 'app/core/core_module';
10+
import appEvents from 'app/core/app_events';
911

1012
export class GrafanaCtrl {
1113

@@ -47,6 +49,7 @@ export class GrafanaCtrl {
4749

4850
$rootScope.appEvent = function(name, payload) {
4951
$rootScope.$emit(name, payload);
52+
appEvents.emit(name, payload);
5053
};
5154

5255
$rootScope.colors = [

public/app/core/services/util_srv.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

public/app/core/services/util_srv.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
///<reference path="../../headers/common.d.ts" />
2+
3+
import config from 'app/core/config';
4+
import _ from 'lodash';
5+
import $ from 'jquery';
6+
7+
import coreModule from 'app/core/core_module';
8+
import appEvents from 'app/core/app_events';
9+
10+
export class UtilSrv {
11+
12+
/** @ngInject */
13+
constructor(private $rootScope, private $modal) {
14+
}
15+
16+
init() {
17+
appEvents.on('show-modal', this.showModal.bind(this), this.$rootScope);
18+
}
19+
20+
showModal(options) {
21+
if (options.model) {
22+
options.scope = this.$rootScope.$new();
23+
options.scope.model = options.model;
24+
}
25+
26+
var modal = this.$modal({
27+
modalClass: options.modalClass,
28+
template: options.src,
29+
persist: false,
30+
show: false,
31+
scope: options.scope,
32+
keyboard: false
33+
});
34+
35+
Promise.resolve(modal).then(function(modalEl) {
36+
modalEl.modal('show');
37+
});
38+
}
39+
}
40+
41+
coreModule.service('utilSrv', UtilSrv);

public/app/features/plugins/import_list/import_list.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,3 @@ export function dashboardImportList() {
8888
}
8989

9090
coreModule.directive('dashboardImportList', dashboardImportList);
91-
92-
93-
94-
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<div class="modal-body">
2+
<div class="modal-header">
3+
<h2 class="modal-header-title">
4+
<i class="fa fa-cog fa-spin"></i>
5+
<span class="p-l-1">{{model.name}}</span>
6+
</h2>
7+
8+
<a class="modal-header-close" ng-click="dismiss();">
9+
<i class="fa fa-remove"></i>
10+
</a>
11+
</div>
12+
13+
<div class="modal-content">
14+
15+
<table class="filter-table">
16+
<tbody>
17+
<tr ng-repeat="step in model.steps">
18+
<td>{{step.name}}</td>
19+
<td>{{step.status}}</td>
20+
<td width="1%">
21+
<i class="fa fa-check" style="color: #39A039"></i>
22+
</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
</div>
28+
29+
</div>
30+

public/app/features/plugins/plugin_edit_ctrl.ts

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import angular from 'angular';
44
import _ from 'lodash';
55
import appEvents from 'app/core/app_events';
66

7+
import {WizardFlow} from './wizard';
8+
79
export class PluginEditCtrl {
810
model: any;
911
pluginIcon: string;
@@ -79,20 +81,58 @@ export class PluginEditCtrl {
7981
}
8082

8183
update() {
82-
this.preUpdateHook().then(() => {
83-
var updateCmd = _.extend({
84-
enabled: this.model.enabled,
85-
pinned: this.model.pinned,
86-
jsonData: this.model.jsonData,
87-
secureJsonData: this.model.secureJsonData,
88-
}, {});
89-
90-
return this.backendSrv.post(`/api/plugins/${this.pluginId}/settings`, updateCmd);
91-
})
92-
.then(this.postUpdateHook)
93-
.then((res) => {
94-
window.location.href = window.location.href;
84+
var wizard = new WizardFlow("Application Setup");
85+
86+
wizard.addStep("Validating form", () => {
87+
return new Promise((resolve) => {
88+
setTimeout(resolve, 2000);
89+
});
90+
});
91+
92+
wizard.addStep("Saving application config", () => {
93+
return new Promise((resolve) => {
94+
setTimeout(resolve, 2000);
95+
});
9596
});
97+
98+
wizard.addStep("Validing key", () => {
99+
return new Promise((resolve) => {
100+
setTimeout(resolve, 2000);
101+
});
102+
});
103+
104+
wizard.addStep("Adding Raintank metric data source", () => {
105+
return new Promise((resolve) => {
106+
setTimeout(resolve, 2000);
107+
});
108+
});
109+
110+
wizard.addStep("Adding Raintank event data source", () => {
111+
return new Promise((resolve) => {
112+
setTimeout(resolve, 2000);
113+
});
114+
});
115+
116+
wizard.addStep("Importing worldPing dashboards", () => {
117+
return new Promise((resolve) => {
118+
setTimeout(resolve, 2000);
119+
});
120+
});
121+
122+
wizard.start();
123+
// this.preUpdateHook().then(() => {
124+
// var updateCmd = _.extend({
125+
// enabled: this.model.enabled,
126+
// pinned: this.model.pinned,
127+
// jsonData: this.model.jsonData,
128+
// secureJsonData: this.model.secureJsonData,
129+
// }, {});
130+
// return this.backendSrv.post(`/api/plugins/${this.pluginId}/settings`, updateCmd);
131+
// })
132+
// .then(this.postUpdateHook)
133+
// .then((res) => {
134+
// window.location.href = window.location.href;
135+
// });
96136
}
97137

98138
importDashboards() {

public/app/features/plugins/wizard.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
///<reference path="../../headers/common.d.ts" />
2+
3+
import config from 'app/core/config';
4+
import _ from 'lodash';
5+
import $ from 'jquery';
6+
7+
import coreModule from 'app/core/core_module';
8+
import appEvents from 'app/core/app_events';
9+
10+
export class WizardSrv {
11+
12+
/** @ngInject */
13+
constructor() {
14+
}
15+
16+
}
17+
18+
export class WizardStep {
19+
name: string;
20+
fn: any;
21+
}
22+
23+
export class WizardFlow {
24+
name: string;
25+
steps: WizardStep[];
26+
27+
constructor(name) {
28+
this.name = name;
29+
this.steps = [];
30+
}
31+
32+
addStep(name, stepFn) {
33+
this.steps.push({
34+
name: name,
35+
fn: stepFn
36+
});
37+
}
38+
39+
start() {
40+
appEvents.emit('show-modal', {
41+
src: 'public/app/features/plugins/partials/wizard.html',
42+
model: this
43+
});
44+
}
45+
}
46+
47+
coreModule.service('wizardSrv', WizardSrv);

0 commit comments

Comments
 (0)