mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Fix up new setup code
No issue - Prevent download count ajax request from running forever, even after setup is complete. - Remove unneeded setup routes and controllers. - Refactor to use ES6-imported ajax. - Refactor to use injected services.
This commit is contained in:
parent
3c2a625e07
commit
def2e8e146
10 changed files with 62 additions and 78 deletions
|
@ -1,15 +1,12 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
var ActivatingListItem = Ember.Component.extend({
|
|
||||||
|
export default Ember.Component.extend({
|
||||||
tagName: 'li',
|
tagName: 'li',
|
||||||
classNameBindings: ['active'],
|
classNameBindings: ['active'],
|
||||||
active: false,
|
active: false,
|
||||||
linkClasses: Ember.computed('linkClass', function () {
|
linkClasses: null,
|
||||||
return this.get('linkClass');
|
|
||||||
}),
|
|
||||||
|
|
||||||
unfocusLink: function () {
|
unfocusLink: function () {
|
||||||
this.$('a').blur();
|
this.$('a').blur();
|
||||||
}.on('click')
|
}.on('click')
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ActivatingListItem;
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
import Ember from 'ember';
|
|
||||||
import ajax from 'ghost/utils/ajax';
|
|
||||||
|
|
||||||
var SetupOneController = Ember.Controller.extend({
|
|
||||||
|
|
||||||
count: 'many, many',
|
|
||||||
|
|
||||||
downloadCounter: function () {
|
|
||||||
var self = this,
|
|
||||||
interval = 3000;
|
|
||||||
|
|
||||||
Ember.run.later(this, function () {
|
|
||||||
ajax({
|
|
||||||
url: self.get('ghostPaths.count'),
|
|
||||||
type: 'GET'
|
|
||||||
}).then(function (data) {
|
|
||||||
self.set('count', data.count.toLocaleString());
|
|
||||||
}).catch(function () {
|
|
||||||
self.set('count', 'many, many');
|
|
||||||
});
|
|
||||||
|
|
||||||
this.downloadCounter();
|
|
||||||
}, interval);
|
|
||||||
}.on('init')
|
|
||||||
});
|
|
||||||
|
|
||||||
export default SetupOneController;
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* global md5 */
|
/* global md5 */
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import ajax from 'ghost/utils/ajax';
|
import {request as ajax} from 'ic-ajax';
|
||||||
import ValidationEngine from 'ghost/mixins/validation-engine';
|
import ValidationEngine from 'ghost/mixins/validation-engine';
|
||||||
|
|
||||||
var SetupTwoController = Ember.Controller.extend(ValidationEngine, {
|
export default Ember.Controller.extend(ValidationEngine, {
|
||||||
size: 90,
|
size: 90,
|
||||||
blogTitle: null,
|
blogTitle: null,
|
||||||
name: null,
|
name: null,
|
||||||
|
@ -12,6 +12,9 @@ var SetupTwoController = Ember.Controller.extend(ValidationEngine, {
|
||||||
image: null,
|
image: null,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
|
|
||||||
|
ghostPaths: Ember.inject.service('ghost-paths'),
|
||||||
|
notifications: Ember.inject.service(),
|
||||||
|
|
||||||
gravatarUrl: Ember.computed('email', function () {
|
gravatarUrl: Ember.computed('email', function () {
|
||||||
var email = this.get('email'),
|
var email = this.get('email'),
|
||||||
size = this.get('size');
|
size = this.get('size');
|
||||||
|
@ -33,9 +36,10 @@ var SetupTwoController = Ember.Controller.extend(ValidationEngine, {
|
||||||
actions: {
|
actions: {
|
||||||
setup: function () {
|
setup: function () {
|
||||||
var self = this,
|
var self = this,
|
||||||
|
notifications = this.get('notifications'),
|
||||||
data = self.getProperties('blogTitle', 'name', 'email', 'password');
|
data = self.getProperties('blogTitle', 'name', 'email', 'password');
|
||||||
|
|
||||||
self.notifications.closePassive();
|
notifications.closePassive();
|
||||||
|
|
||||||
this.toggleProperty('submitting');
|
this.toggleProperty('submitting');
|
||||||
this.validate({format: false}).then(function () {
|
this.validate({format: false}).then(function () {
|
||||||
|
@ -57,14 +61,12 @@ var SetupTwoController = Ember.Controller.extend(ValidationEngine, {
|
||||||
});
|
});
|
||||||
}).catch(function (resp) {
|
}).catch(function (resp) {
|
||||||
self.toggleProperty('submitting');
|
self.toggleProperty('submitting');
|
||||||
self.notifications.showAPIError(resp);
|
notifications.showAPIError(resp);
|
||||||
});
|
});
|
||||||
}).catch(function (errors) {
|
}).catch(function (errors) {
|
||||||
self.toggleProperty('submitting');
|
self.toggleProperty('submitting');
|
||||||
self.notifications.showErrors(errors);
|
notifications.showErrors(errors);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default SetupTwoController;
|
|
||||||
|
|
|
@ -39,11 +39,11 @@ export default Ember.Controller.extend(ValidationEngine, {
|
||||||
identification: self.get('model.email'),
|
identification: self.get('model.email'),
|
||||||
password: self.get('model.password')
|
password: self.get('model.password')
|
||||||
});
|
});
|
||||||
}, function (resp) {
|
}).catch(function (resp) {
|
||||||
self.toggleProperty('submitting');
|
self.toggleProperty('submitting');
|
||||||
notifications.showAPIError(resp);
|
notifications.showAPIError(resp);
|
||||||
});
|
});
|
||||||
}, function (errors) {
|
}).catch(function (errors) {
|
||||||
self.toggleProperty('submitting');
|
self.toggleProperty('submitting');
|
||||||
notifications.showErrors(errors);
|
notifications.showErrors(errors);
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ var Router = Ember.Router.extend({
|
||||||
documentTitle();
|
documentTitle();
|
||||||
|
|
||||||
Router.map(function () {
|
Router.map(function () {
|
||||||
this.resource('setup', function () {
|
this.route('setup', function () {
|
||||||
this.route('one');
|
this.route('one');
|
||||||
this.route('two');
|
this.route('two');
|
||||||
this.route('three');
|
this.route('three');
|
||||||
|
|
|
@ -1,24 +1,50 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import ajax from 'ghost/utils/ajax';
|
import {request as ajax} from 'ic-ajax';
|
||||||
|
|
||||||
var SetupOneRoute = Ember.Route.extend({
|
var DownloadCountPoller = Ember.Object.extend({
|
||||||
titleToken: 'Setup',
|
url: null,
|
||||||
beforeModel: function () {
|
count: 'many, many',
|
||||||
var self = this,
|
runId: null,
|
||||||
ctrl = this.controllerFor('setup.one');
|
|
||||||
|
|
||||||
if (!ctrl) {
|
init: function () {
|
||||||
this.generateController('setup.one');
|
this.downloadCounter();
|
||||||
ctrl = this.controllerFor('setup.one');
|
this.poll();
|
||||||
}
|
},
|
||||||
|
|
||||||
return ajax({
|
poll: function () {
|
||||||
url: self.get('ghostPaths.count'),
|
var interval = 3000,
|
||||||
type: 'GET'
|
runId;
|
||||||
}).then(function (data) {
|
|
||||||
ctrl.set('count', data.count.toLocaleString());
|
runId = Ember.run.later(this, function () {
|
||||||
}).catch(function () { /* Do nothing */ });
|
this.downloadCounter();
|
||||||
|
this.poll();
|
||||||
|
}, interval);
|
||||||
|
|
||||||
|
this.set('runId', runId);
|
||||||
|
},
|
||||||
|
|
||||||
|
downloadCounter: function () {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
ajax(this.get('url')).then(function (data) {
|
||||||
|
self.set('count', data.count.toLocaleString());
|
||||||
|
}).catch(function () {
|
||||||
|
self.set('count', 'many, many');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default SetupOneRoute;
|
export default Ember.Route.extend({
|
||||||
|
ghostPaths: Ember.inject.service('ghost-paths'),
|
||||||
|
|
||||||
|
model: function () {
|
||||||
|
return DownloadCountPoller.create({url: this.get('ghostPaths.count')});
|
||||||
|
},
|
||||||
|
|
||||||
|
resetController: function (controller, isExiting) {
|
||||||
|
if (isExiting) {
|
||||||
|
Ember.run.cancel(controller.get('model.runId'));
|
||||||
|
controller.set('model', null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
import Ember from 'ember';
|
|
||||||
|
|
||||||
var SetupTwoRoute = Ember.Route.extend({
|
|
||||||
titleToken: 'Setup'
|
|
||||||
});
|
|
||||||
|
|
||||||
export default SetupTwoRoute;
|
|
|
@ -1,7 +0,0 @@
|
||||||
import Ember from 'ember';
|
|
||||||
|
|
||||||
var SetupTwoRoute = Ember.Route.extend({
|
|
||||||
titleToken: 'Setup'
|
|
||||||
});
|
|
||||||
|
|
||||||
export default SetupTwoRoute;
|
|
|
@ -5,15 +5,15 @@
|
||||||
{{!-- TODO: this should only appear on screens 2 & 3 --}}
|
{{!-- TODO: this should only appear on screens 2 & 3 --}}
|
||||||
<a class="gh-flow-back" href="#"><i class="icon-arrow-left"></i> Back</a>
|
<a class="gh-flow-back" href="#"><i class="icon-arrow-left"></i> Back</a>
|
||||||
<ol>
|
<ol>
|
||||||
{{#gh-activating-list-item route="setup.one" linkClass="step"}}
|
{{#gh-activating-list-item route="setup.one" linkClasses="step"}}
|
||||||
<i class="icon-check"></i><span class="num">1</span>
|
<i class="icon-check"></i><span class="num">1</span>
|
||||||
{{/gh-activating-list-item}}
|
{{/gh-activating-list-item}}
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
{{#gh-activating-list-item route="setup.two" linkClass="step"}}
|
{{#gh-activating-list-item route="setup.two" linkClasses="step"}}
|
||||||
<i class="icon-check"></i><span class="num">2</span>
|
<i class="icon-check"></i><span class="num">2</span>
|
||||||
{{/gh-activating-list-item}}
|
{{/gh-activating-list-item}}
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
{{#gh-activating-list-item route="setup.three" linkClass="step"}}
|
{{#gh-activating-list-item route="setup.three" linkClasses="step"}}
|
||||||
<i class="icon-check"></i><span class="num">3</span>
|
<i class="icon-check"></i><span class="num">3</span>
|
||||||
{{/gh-activating-list-item}}
|
{{/gh-activating-list-item}}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<section class="gh-flow-content">
|
<section class="gh-flow-content">
|
||||||
<header>
|
<header>
|
||||||
<h1>Welcome to <strong>Ghost</strong>!</h1>
|
<h1>Welcome to <strong>Ghost</strong>!</h1>
|
||||||
<p>So far there have been <em>{{count}}</em> Ghost blogs made by people all over the world. Today we’re making yours.</p>
|
<p>So far there have been <em>{{model.count}}</em> Ghost blogs made by people all over the world. Today we’re making yours.</p>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<img class="gh-flow-screenshot" src="{{gh-path 'admin' 'img/install-welcome.png'}}" alt="Ghost screenshot" />
|
<img class="gh-flow-screenshot" src="{{gh-path 'admin' 'img/install-welcome.png'}}" alt="Ghost screenshot" />
|
||||||
|
|
Loading…
Add table
Reference in a new issue