Skip to content

Commit

Permalink
Merge pull request #131 from baminteractive/1.0.2
Browse files Browse the repository at this point in the history
1.0.2 Release
  • Loading branch information
ryanbillingsley committed Apr 29, 2015
2 parents d2a70c9 + 3cc6a09 commit a6f89f4
Show file tree
Hide file tree
Showing 20 changed files with 376 additions and 235 deletions.
2 changes: 1 addition & 1 deletion app/components/download-archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default Ember.Component.extend({
archiveLink: '',
initialMessage: 'Generate Package',
buildingMessage: 'Building Package…',
tagName: 'li',
tagName: 'span',
linkMessage: function() {
var message = '';
if(this.isBuilding){
Expand Down
26 changes: 26 additions & 0 deletions app/components/generator-start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Ember from 'ember';

export default Ember.Component.extend({
siteUrl: null,
file: null,
fileName: null,
message: '',
isSaving: false,
actions:{
startComplete: function(){
var siteUrl = this.get('siteUrl');
var file = this.get('file');
if(!siteUrl && !file){
this.set('message', 'Please provide a URL or manifest file.');
} else {
this.set('message', '');
this.sendAction('action', siteUrl, file);
}
},
uploadFile: function(file) {
this.set('file', file);
this.set('fileName', file.name);
this.sendAction('upload', file);
}
}
});
2 changes: 1 addition & 1 deletion app/components/generator-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default Ember.Component.extend({
nextStep: null,
isShowingBody: false,
showNextStep: true,
allowToggle: false,
allowToggle: true,
tagName: 'li',
classNames: ['step'],
classNameBindings: ['stepId', 'isEnabled'],
Expand Down
1 change: 0 additions & 1 deletion app/components/manifest-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default Ember.Component.extend({
},
actions:{
uploadManifest: function(file) {
console.log(file);
var self = this;
var data = this.generateFormData(file);
this.$(".upload-file").attr("value", file.name);
Expand Down
37 changes: 25 additions & 12 deletions app/controllers/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
import Ember from 'ember';

export default Ember.Controller.extend({
step1Complete: false,
startReady: false,
startComplete: function(){
var startReady = this.get('startReady');
var manifestId = this.get('model.manifestId');
return startReady && manifestId;
}.property('startReady','model.isSaving', 'model.manifestId'),
formattedManifest: function () {
var model = this.get('model');
var code = model.get('manifest');
return new Ember.Handlebars.SafeString('<code class=\'language-javascript\'>' + JSON.stringify(code, null, 2) + '</code>');
}.property('model.manifest'),
isProcessing: function() {
var model = this.get('model');
return model.get('isBuilding') || model.get('isSaving');
}.property('model.isBuilding', 'model.isSaving'),
steps: Ember.Object.create({
step1: {
name: 'step1',
Expand All @@ -15,14 +29,11 @@ export default Ember.Controller.extend({
step3: {
name: 'step3',
isCurrent: false
},
step4: {
name: 'step4',
isCurrent: false
}
}),
selectedDisplay: null,
selectedOrientation: null,
buildReady: false,
valueOrEmptyString: function (value) {
if(value) {
return value;
Expand All @@ -48,24 +59,26 @@ export default Ember.Controller.extend({
};
return data;
});

return customProps;
}.property('model'),
actions: {
updateStep: function(currentStep, nextStep) {
if(currentStep) {
ga('send', 'event', 'item', 'click', 'generator-step-'+currentStep);
this.set('steps.step'+currentStep+'.isCurrent', false);
if(currentStep === '1') {
this.set('step1Complete',true);
this.model.create();
} else {
this.model.save();
}
this.model.save();
}
if(nextStep){
this.set('steps.step'+nextStep+'.isCurrent', true);
}
},
startOver: function(){
this.set('startReady', false);
return true;
},
startComplete: function() {
this.set('startReady', true);
return true;
}
}
});
Expand Down
106 changes: 51 additions & 55 deletions app/models/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ export default Ember.Object.extend({
orientation: {
names: ['any', 'natural', 'landscape', 'portrait', 'portrait-primary', 'portrait-secondary', 'landscape-primary', 'landscape-secondary']
},
formattedManifest: function () {
return new Ember.Handlebars.SafeString("<code class='language-javascript'>"+JSON.stringify(this.get('manifest'), null, ' ')+"</code>");
}.property('manifest'),
save: function () {
this.set('isSaving', true);
if(!this.manifestId) {
Expand All @@ -49,6 +46,24 @@ export default Ember.Object.extend({
this.update();
}
},
processResult: function(result){
this.set('manifest', result.content);
this.set('manifestId', result.id);
this.set('manifest.display', 'fullscreen');
this.set('manifest.orientation', 'any');
if(!this.get('manifest.icons')) {
this.set('manifest.icons',[]);
}
if(result.suggestions) {
this.set('suggestions', result.suggestions);
}
if(result.warnings) {
this.set('warnings', result.warnings);
}
if(result.errors) {
this.set('errors', result.errors);
}
},
create: function(){
var self = this;
ajax({
Expand All @@ -58,74 +73,32 @@ export default Ember.Object.extend({
dataType: 'json',
contentType: 'application/json; charset=utf-8'
}).then(function(result) {
self.set('manifest', result.content);
self.set('manifestId', result.id);

//Set Defaults
self.set('manifest.display', 'fullscreen');
self.set('manifest.orientation', 'any');

if(!self.get('manifest.icons')) {
self.set('manifest.icons',[]);
}

if(result.suggestions) {
self.set('suggestions', result.suggestions);
}

if(result.warnings) {
self.set('warnings', result.warnings);
}

if(result.errors) {
self.set('errors', result.errors);
}

self.save();

self.processResult(result);
self.set('isSaving', false);

}).catch(function(){
self.set('isSaving', false);
});
},
update: function(){
var self = this,
manifest = self.get('manifest');

var self = this;
var manifest = self.get('manifest');
manifest = _.omit(manifest,function(prop){
if(_.isString(prop)){
return _.isEmpty(prop);
}else if(_.isObject(prop)){
return _.isUndefined(prop);
}

return false;
if(_.isString(prop)){
return _.isEmpty(prop);
}else if(_.isObject(prop)){
return _.isUndefined(prop);
}
return false;
});

ajax({
url: config.APP.API_URL + '/manifests/' + this.get('manifestId'),
type: 'PUT',
data: JSON.stringify(manifest),
dataType: 'json',
contentType: 'application/json; charset=utf-8'
}).then(function(result) {
self.set('manifest',result.content);

if(result.suggestions){
self.set('suggestions', result.suggestions);
}

if(result.warnings){
self.set('warnings', result.warnings);
}

if(result.errors) {
self.set('errors', result.errors);
}

self.processResult(result);
self.set('isSaving', false);

}).catch(function(){
self.set('isSaving', false);
});
Expand All @@ -142,5 +115,28 @@ export default Ember.Object.extend({
}).catch(function(){
self.set('isBuilding', false);
});
},
generateFormData: function(file) {
var formData = new FormData();
formData.append('file', file);
return formData;
},
upload: function(file) {
var self = this;
var data = this.generateFormData(file);
this.set('isSaving', true);
ajax({
url: config.APP.API_URL + '/manifests',
type: 'POST',
data: data,
contentType: false,
processData: false,
cache: false
}).then(function(result) {
self.processResult(result);
self.set('isSaving', false);
}).catch(function(){
self.set('isSaving', false);
});
}
});
33 changes: 14 additions & 19 deletions app/routes/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ export default Ember.Route.extend({
Ember.$('footer').removeClass('is-small');
},
actions: {
startComplete: function(siteUrl, file) {
var model = this.modelFor('generator');
if(siteUrl){
model.set('siteUrl', siteUrl);
model.save();
} else if (file) {
model.upload(file);
}
},
updateLogos: function(logos) {
var model = this.modelFor('generator');
model.set('manifest.icons',logos);
Expand All @@ -30,28 +39,11 @@ export default Ember.Route.extend({
model.build();
},
downloadArchive: function(archiveLink){
var controller = this.controllerFor('generator');
controller.set('buildReady', true);
ga('send', 'event', 'item', 'click', 'generator-build-download');
window.location.href = archiveLink;
},
updateManifest: function (result) {
var model = this.modelFor('generator');
var controller = this.controllerFor('generator');
controller.set('step1Complete', true);
model.set('manifestId', result.id);
model.set('manifest', result.content);
if(result.content.display === undefined) {
model.set('manifest.display', 'fullscreen');
}
if(!result.content.orientation) {
model.set('manifest.orientation', 'any');
}

if(!model.get('manifest.icons')) {
model.set('manifest.icons',[]);
}

model.save();
},
updateModelProperty: function(name, value) {
var model = this.modelFor('generator');
model.set('manifest.'+ name, value);
Expand All @@ -73,6 +65,9 @@ export default Ember.Route.extend({
updateModel: function(){
var model = this.modelFor('generator');
model.save();
},
startOver: function(){
this.refresh();
}
}
});
3 changes: 2 additions & 1 deletion app/styles/_base/_b-elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ button, .btn {
background:$primary-accent;
border:none;
color:#fff;
margin: 0;
padding: .5em 1.125em;
border-radius: 5px;
line-height:1.2em;
Expand Down Expand Up @@ -173,4 +174,4 @@ hr {

.hidden {
display: none;
}
}
Loading

0 comments on commit a6f89f4

Please sign in to comment.