Skip to content

Commit 741a9d8

Browse files
authored
Merge pull request #6 from Exelord/landing-page
Landing page
2 parents 2f9a404 + 05e2738 commit 741a9d8

File tree

33 files changed

+1618
-78
lines changed

33 files changed

+1618
-78
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Ember Custom Actions is a package for defining custom API actions, dedicated for
99

1010
# Getting started
1111

12+
## Demo
13+
Before you will start with documentation check our demo app: [Ember-Custom-Actions Website][43255946]
14+
[43255946]: https://exelord.github.io/ember-custom-actions/ "Website - Demo App"
15+
1216
## Installation
1317

1418
`ember install ember-custom-actions`

addon/actions/action.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/* eslint ember-suave/no-direct-property-access:1 */
22

33
import Ember from 'ember';
4-
import DS from 'ember-data';
54

65
import UrlBuilder from '../utils/url-builder';
76
import normalizePayload from '../utils/normalize-payload';
87
import defaultConfig from '../config';
98

10-
const { assign, getOwner, computed, Object } = Ember;
9+
const { assign, getOwner, computed, Object, ObjectProxy, ArrayProxy, PromiseProxyMixin } = Ember;
1110

1211
const promiseTypes = {
13-
array: DS.PromiseArray,
14-
object: DS.PromiseObject
12+
array: ArrayProxy.extend(PromiseProxyMixin),
13+
object: ObjectProxy.extend(PromiseProxyMixin)
1514
};
1615

1716
export default Object.extend({

bower.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"name": "ember-custom-actions",
3-
"dependencies": {}
3+
"devDependencies": {
4+
"bootstrap": "^3.3.7"
5+
}
46
}

ember-cli-build.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
/*jshint node:true*/
1+
/* eslint no-var:0*/
22
/* global require, module */
3+
34
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
45

56
module.exports = function(defaults) {
7+
var config = defaults.project.config(EmberAddon.env());
8+
69
var app = new EmberAddon(defaults, {
7-
// Add options here
10+
sassOptions: {
11+
extension: 'sass'
12+
},
13+
favicons: {
14+
faviconsConfig: {
15+
appName: 'Ember Custom Actions',
16+
appDescription: 'Trigger custom API actions for Ember 2 applications and communicate with non-CRUD API servers',
17+
developerName: 'Exelord',
18+
developerURL: 'www.macsour.com',
19+
background: '#ffffff',
20+
path: config.rootURL, // Path for overriding default icons path. `string`
21+
url: 'https://exelord.github.io/ember-custom-actions/images/og-image.jpg' // Absolute URL for OpenGraph image. `string`
22+
}
23+
}
824
});
925

1026
/*
@@ -14,5 +30,6 @@ module.exports = function(defaults) {
1430
behave. You most likely want to be modifying `./index.js` or app's build file
1531
*/
1632

33+
app.import('bower_components/bootstrap/dist/js/bootstrap.min.js');
1734
return app.toTree();
1835
};

package.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,51 @@
2929
"ember-cli-babel": "^5.1.7"
3030
},
3131
"devDependencies": {
32+
"bootstrap-sass": "^3.3.7",
3233
"broccoli-asset-rev": "^2.4.5",
3334
"ember-ajax": "^2.4.1",
35+
"ember-bootstrap": "1.0.0-alpha.4",
36+
"ember-browserify": "1.1.13",
3437
"ember-cli": "2.11.0",
3538
"ember-cli-app-version": "^2.0.0",
3639
"ember-cli-dependency-checker": "^1.3.0",
3740
"ember-cli-eslint": "3.0.0",
41+
"ember-cli-favicon": "1.0.0-beta.4",
42+
"ember-cli-github-pages": "0.1.2",
3843
"ember-cli-htmlbars": "^1.1.1",
3944
"ember-cli-htmlbars-inline-precompile": "^0.3.3",
4045
"ember-cli-inject-live-reload": "^1.4.1",
4146
"ember-cli-pretender": "1.0.1",
4247
"ember-cli-qunit": "^3.0.1",
4348
"ember-cli-release": "^0.2.9",
49+
"ember-cli-sass": "6.1.1",
4450
"ember-cli-shims": "^1.0.2",
4551
"ember-cli-sri": "^2.1.0",
4652
"ember-cli-test-loader": "^1.1.0",
4753
"ember-cli-uglify": "^1.2.0",
4854
"ember-data": "^2.11.0",
4955
"ember-disable-prototype-extensions": "^1.1.0",
5056
"ember-export-application-global": "^1.0.5",
57+
"ember-font-awesome": "3.0.3",
58+
"ember-initials": "2.2.0",
5159
"ember-load-initializers": "^0.6.0",
5260
"ember-resolver": "^2.0.3",
61+
"ember-scroll-to": "0.5.4",
5362
"ember-source": "^2.11.0",
5463
"ember-suave": "4.0.1",
5564
"eslint-plugin-ember-suave": "^1.0.0",
5665
"express": "^4.14.1",
66+
"faker": "^3.1.0",
5767
"glob": "^4.5.3",
5868
"loader.js": "^4.0.10",
59-
"morgan": "^1.8.0"
69+
"morgan": "^1.8.0",
70+
"pretender": "1.4.2"
6071
},
6172
"engines": {
6273
"node": ">= 0.12.0"
6374
},
6475
"ember-addon": {
65-
"configPath": "tests/dummy/config"
76+
"configPath": "tests/dummy/config",
77+
"demoURL": "https://exelord.github.io/ember-custom-actions/"
6678
}
6779
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div id="documentation" class="examples">
2+
<div class="container">
3+
<div class="section-heading">
4+
<h1 data-wow-delay=".3s" class="title wow fadeInDown" style="visibility: visible; animation-delay: 0.3s; animation-name: fadeInDown;">
5+
Documentation & Configuration
6+
</h1>
7+
<div data-wow-delay=".5s" class="wow fadeInUp" style="visibility: visible; animation-delay: 0.5s; animation-name: fadeInUp;">
8+
<h2 class="lead">An advanced way to get to know ember-custom-acions better</h2>
9+
<a class="btn btn-lg btn-outline btn-default" href="https://github.com/Exelord/ember-custom-actions">d{{fa-icon 'github'}}cumentati{{fa-icon 'github'}}n</a>
10+
</div>
11+
</div>
12+
</div>
13+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import Ember from 'ember';
2+
3+
const { Component, computed, inject, run, observer } = Ember;
4+
5+
export default Component.extend({
6+
tagName: 'tr',
7+
classNames: 'action',
8+
store: inject.service(),
9+
server: inject.service(),
10+
11+
init() {
12+
this._super(...arguments);
13+
14+
this.get('server').server.get('/bridges/burn', () => {
15+
return [200, { }, '{}'];
16+
});
17+
},
18+
19+
bridge: computed('store', function() {
20+
return this.get('store').createRecord('bridge');
21+
}),
22+
23+
burnedObserver: observer('burned', function() {
24+
if (this.get('burned') == true) {
25+
run.later(() => {
26+
this.set('burned', false);
27+
}, 3000);
28+
}
29+
}),
30+
31+
actions: {
32+
burn() {
33+
this.set('pending', true);
34+
35+
run.later(() => {
36+
this.get('bridge').burnAll().then(() => {
37+
this.set('burned', true);
38+
this.set('pending', false);
39+
});
40+
}, 500);
41+
}
42+
}
43+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<td>
2+
<a class="btn btn-lg btn-outline btn-ember {{if burned 'disabled'}}" {{action 'burn'}}>Burn all bridges</a>
3+
</td>
4+
<td>
5+
{{#if pending}}
6+
<p class="status text-warning">Pending</p>
7+
{{else}}
8+
<p class="status text-success">Waiting</p>
9+
{{/if}}
10+
<h4 class="request">bridges/burn</h4>
11+
</td>
12+
<td>
13+
{{#if burned}}
14+
<div class="{{if burned 'show-result'}}">
15+
<span class="h4 text-danger">Bridges Burned</span>
16+
</div>
17+
{{else}}
18+
<span class="text-muted call-to-action">Call custom action</span>
19+
{{/if}}
20+
</td>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import Ember from 'ember';
2+
3+
const { Component, computed, inject, run, observer } = Ember;
4+
5+
export default Component.extend({
6+
tagName: 'tr',
7+
classNames: 'action',
8+
store: inject.service(),
9+
server: inject.service(),
10+
11+
init() {
12+
this._super(...arguments);
13+
14+
this.get('server').server.put('/posts/:id/publish', (request) => {
15+
let post = this.get('store').peekRecord('post', request.params.id);
16+
let data = post.serialize({ includeId: true });
17+
data.data.attributes.published = true;
18+
19+
return [200, { }, JSON.stringify(data)];
20+
});
21+
},
22+
23+
post: computed('store', function() {
24+
return this.get('store').createRecord('post', { id: 1 });
25+
}),
26+
27+
publishedObserver: observer('post.published', function() {
28+
if (this.get('post.published') == true) {
29+
run.later(() => {
30+
this.get('store').push({
31+
data: {
32+
id: '1',
33+
type: 'post',
34+
attributes: {
35+
published: false
36+
}
37+
}
38+
});
39+
}, 3000);
40+
}
41+
}),
42+
43+
actions: {
44+
publish(post) {
45+
this.set('pending', true);
46+
47+
run.later(() => {
48+
post.publish().then(() => {
49+
this.set('pending', false);
50+
});
51+
}, 500);
52+
}
53+
}
54+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<td>
2+
<a class="btn btn-lg btn-outline btn-ember {{if post.published 'disabled'}}" {{action 'publish' post}}>Publish post</a>
3+
</td>
4+
<td>
5+
{{#if pending}}
6+
<p class="status text-warning">Pending</p>
7+
{{else}}
8+
<p class="status text-success">Waiting</p>
9+
{{/if}}
10+
<h4 class="request">posts/1/publish</h4>
11+
</td>
12+
<td>
13+
{{#if post.published}}
14+
<div class="{{if post.published 'show-result'}}">
15+
<span class="text-muted">Published:</span> <span class="h4 text-success">{{post.published}}</span>
16+
</div>
17+
{{else}}
18+
<span class="text-muted call-to-action">Call custom action</span>
19+
{{/if}}
20+
</td>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div id="examples">
2+
<div class="container">
3+
<div class="section-heading">
4+
<h1 data-wow-delay=".3s" class="title wow fadeInDown" style="visibility: visible; animation-delay: 0.3s; animation-name: fadeInDown;">Live Examples</h1>
5+
</div>
6+
7+
<div class="table-responsive">
8+
<table class="table">
9+
<thead>
10+
<tr>
11+
<th class="col-sm-4">Custom Actions</th>
12+
<th class="col-sm-4">Requests</th>
13+
<th class="col-sm-4">Results</th>
14+
</tr>
15+
</thead>
16+
<tbody>
17+
{{page-sections/examples/post-action}}
18+
{{page-sections/examples/burn-action}}
19+
{{page-sections/examples/user-action}}
20+
</tbody>
21+
</table>
22+
</div>
23+
</div>
24+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import Ember from 'ember';
2+
import Faker from 'npm:faker';
3+
4+
const { Component, computed, inject, run, observer } = Ember;
5+
6+
export default Component.extend({
7+
tagName: 'tr',
8+
classNames: 'action',
9+
store: inject.service(),
10+
server: inject.service(),
11+
12+
init() {
13+
this._super(...arguments);
14+
15+
this.get('server').server.get('/users/:id/profile', (request) => {
16+
let user = this.get('store').peekRecord('user', request.params.id);
17+
let data = user.serialize({ includeId: true });
18+
data.data.attributes.name = Faker.name.findName();
19+
// debugger;
20+
return [200, { }, JSON.stringify(data)];
21+
});
22+
},
23+
24+
user: computed('store', function() {
25+
return this.get('store').createRecord('user', { id: 1 });
26+
}),
27+
28+
nameObserver: observer('user.name', function() {
29+
if (this.get('user.name')) {
30+
run.later(() => {
31+
this.get('store').push({
32+
data: {
33+
id: '1',
34+
type: 'user',
35+
attributes: {
36+
name: null
37+
}
38+
}
39+
});
40+
}, 3000);
41+
}
42+
}),
43+
44+
actions: {
45+
generate(user) {
46+
this.set('pending', true);
47+
48+
run.later(() => {
49+
user.profile().then(() => {
50+
this.set('pending', false);
51+
});
52+
}, 500);
53+
}
54+
}
55+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<td>
2+
<a class="btn btn-lg btn-outline btn-ember {{if user.name 'disabled'}}" {{action 'generate' user}}>Generate Profile</a>
3+
</td>
4+
<td>
5+
{{#if pending}}
6+
<p class="status text-warning">Pending</p>
7+
{{else}}
8+
<p class="status text-success">Waiting</p>
9+
{{/if}}
10+
<h4 class="request">users/1/generate</h4>
11+
</td>
12+
<td>
13+
{{#if user.name}}
14+
<div class="{{if user.name 'show-result'}}">
15+
{{ember-initials name=user.name class="img-circle"}} <span class="h4">{{user.name}}</span>
16+
</div>
17+
{{else}}
18+
<span class="text-muted call-to-action">Call custom action</span>
19+
{{/if}}
20+
</td>

0 commit comments

Comments
 (0)