Skip to content

Commit d481eb7

Browse files
committed
Merge pull request #64 from vincent99/machine
Show pending machines as pseudo hosts
2 parents 2894801 + ea7f504 commit d481eb7

19 files changed

Lines changed: 313 additions & 81 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "vendor/term.js"]
22
path = vendor/term.js
33
url = https://github.com/chjj/term.js.git
4+
[submodule "vendor/jquery.initialize"]
5+
path = vendor/jquery.initialize
6+
url = https://github.com/AdamPietrasiak/jquery.initialize.git

Brocfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ app.import('bower_components/d3/d3.js');
5252
app.import('bower_components/c3/c3.js');
5353
app.import('bower_components/c3/c3.css');
5454
app.import('vendor/term.js/src/term.js');
55+
app.import('vendor/jquery.initialize/jquery.initialize.js');
5556
app.import('bower_components/bootstrap-multiselect/dist/js/bootstrap-multiselect.js');
5657
app.import('bower_components/bootstrap-multiselect/dist/css/bootstrap-multiselect.css');
5758
app.import('bower_components/bootstrap-switch/dist/js/bootstrap-switch.js');

app/pods/authenticated/route.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,21 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
162162
},
163163
*/
164164

165+
machineChanged: function(change) {
166+
console.log('machine changed:',change);
167+
},
168+
169+
hostChanged: function(change) {
170+
// If the host has a physicalHostId, ensure it is in the machine's hosts array.
171+
var host = change.data.resource;
172+
var machine = this.get('store').getById('machine', host.get('physicalHostId'));
173+
if ( machine )
174+
{
175+
machine.get('hosts').addObject(host);
176+
}
177+
console.log('host changed:',change);
178+
},
179+
165180
containerChanged: function(change) {
166181
this._instanceChanged(change);
167182
},

app/pods/components/host-widget/component.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ import HoverActions from 'ui/mixins/hover-actions';
44
export default Ember.Component.extend(HoverActions,{
55
model: null,
66
classNames: ['host','resource-action-hover'],
7-
classNameBindings: ['stateBorder'],
7+
classNameBindings: ['stateBorder','isMachine:machine-host'],
88

99
actions: {
1010
newContainer: function() {
1111
this.get('model').send('newContainer');
1212
},
1313
},
1414

15+
isMachine: Ember.computed.equal('model.type','machine'),
16+
isActive: Ember.computed.equal('model.state','active'),
17+
18+
showAdd: function() {
19+
return this.get('isActive') && !this.get('isMachine');
20+
}.property('isActive','isMachine'),
21+
1522
stateBackground: function() {
1623
return this.get('model.stateColor').replace("text-","bg-");
1724
}.property('model.stateColor'),

app/pods/components/host-widget/template.hbs

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,51 @@
33

44
<div {{bind-attr class=":host-state stateBackground"}}>{{model.displayState}}</div>
55
<div class="host-icon"><i {{bind-attr class=":fa :fa-lg model.stateIcon iconColor"}}></i></div>
6-
<div class="host-name">{{#link-to "host" model.id}}{{model.displayName}}{{/link-to}}</div>
6+
<div class="host-name">
7+
{{#if isMachine}}
8+
{{model.displayName}}
9+
{{else}}
10+
{{#link-to "host" model.id}}{{model.displayName}}{{/link-to}}
11+
{{/if}}
12+
</div>
13+
{{#if model.isTransitioning}}
14+
<div class="progress progress-striped active">
15+
<div class="progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" {{bind-attr aria-valuenow=model.displayProgress style=model.progressStyle}}>
16+
<span class="sr-only">{{model.displayProgress}}% Complete</span>
17+
</div>
18+
</div>
19+
{{/if}}
720
</div>
821

9-
<div class="host-info clearfix">
10-
<div class="host-info-item"><i class="ss-link"></i> {{model.displayIp}}</div>
11-
</div>
22+
{{#if isMachine}}
23+
<div class="machine-info">
24+
<i class="fa fa-spinner fa-spin"></i>
25+
{{#if isActive}}
26+
Waiting for host to check in&hellip;
27+
{{else}}
28+
Setting up machine&hellip;
29+
{{/if}}
30+
</div>
31+
{{else}}
32+
<div class="host-info clearfix">
33+
<div class="host-info-item"><i class="ss-link"></i> {{model.displayIp}}</div>
34+
{{#if model.machine}}
35+
<div class="host-info-item"><i class="ss-microwave"></i> {{model.machine.driver}}</div>
36+
{{/if}}
37+
</div>
1238

13-
<div class="clearfix no-resource-action-hover">
14-
{{#if dot}}
15-
{{#each item in model.arrangedInstances itemController="container"}}
16-
{{container-dot model=item}}
17-
{{/each}}
18-
{{else}}
19-
{{#each item in model.arrangedInstances itemController="container"}}
20-
{{container-widget model=item}}
21-
{{/each}}
22-
{{add-container-widget action="newContainer"}}
23-
{{/if}}
24-
</div>
39+
<div class="clearfix no-resource-action-hover">
40+
{{#if dot}}
41+
{{#each item in model.arrangedInstances itemController="container"}}
42+
{{container-dot model=item}}
43+
{{/each}}
44+
{{else}}
45+
{{#each item in model.arrangedInstances itemController="container"}}
46+
{{container-widget model=item}}
47+
{{/each}}
48+
{{#if showAdd}}
49+
{{add-container-widget action="newContainer"}}
50+
{{/if}}
51+
{{/if}}
52+
</div>
53+
{{/if}}

app/pods/container/logs/template.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
{{else}}
99
<ul class="nav nav-tabs">
1010
<li role="presentation" {{bind-attr class="view.isCombined:active"}}><a {{action "changeShow" "combined" target="view"}}>Combined</a></li>
11-
<li role="presentation" {{bind-attr class="view.isStdOut:active"}}><a {{action "changeShow" "stdout" target="view"}}>StdOut</a></li>
12-
<li role="presentation" {{bind-attr class="view.isStdErr:active"}}><a {{action "changeShow" "stderr" target="view"}}>StdErr</a></li>
11+
<li role="presentation" {{bind-attr class="view.isStdOut:active"}}><a {{action "changeShow" "stdout" target="view"}}>Standard Out</a></li>
12+
<li role="presentation" {{bind-attr class="view.isStdErr:active"}}><a {{action "changeShow" "stderr" target="view"}}>Standard Error</a></li>
1313
</ul>
1414
{{/if}}
1515
<pre {{bind-attr class=":log-body view.stdErrVisible::hide-stderr view.stdOutVisible::hide-stdout"}}>

app/pods/host/controller.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ var HostController = Cattle.TransitioningResourceController.extend({
1212
},
1313

1414
delete: function() {
15-
return this.delete();
15+
var machine = this.get('machine');
16+
if ( machine )
17+
{
18+
return machine.delete();
19+
}
20+
else
21+
{
22+
return this.delete();
23+
}
1624
},
1725

1826
purge: function() {
@@ -51,6 +59,10 @@ var HostController = Cattle.TransitioningResourceController.extend({
5159
{
5260
return obj.get('address');
5361
}
62+
else if ( this.hasLink('ipAddresses') )
63+
{
64+
this.importLink('ipAddresses');
65+
}
5466

5567
return null;
5668
}.property('ipAddresses','ipAddresses.[]'),
@@ -61,6 +73,17 @@ var HostController = Cattle.TransitioningResourceController.extend({
6173
sortProperties: ['name','id']
6274
});
6375
}.property('instances.[]','instances.@each.{name,id}'),
76+
77+
machine: function() {
78+
var phid = this.get('physicalHostId');
79+
if ( !phid )
80+
{
81+
return null;
82+
}
83+
84+
var machine = this.get('store').getById('machine', phid);
85+
return machine;
86+
}.property('physicalHostId')
6487
});
6588

6689
HostController.reopenClass({

app/pods/hosts/index/controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Cattle from 'ui/utils/cattle';
1+
import Ember from 'ember';
22

3-
export default Cattle.CollectionController.extend({
3+
export default Ember.ObjectController.extend({
44
dot: false,
55
queryParams: ['dot'],
66
});

app/pods/hosts/index/route.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ import Ember from 'ember';
22

33
export default Ember.Route.extend({
44
model: function() {
5-
return this.modelFor('hosts');
5+
var hosts = this.modelFor('hosts');
6+
return this.get('store').find('machine').then((machines) => {
7+
return {
8+
hosts: hosts,
9+
machines: machines
10+
};
11+
}).catch(() => {
12+
return {
13+
hosts: hosts,
14+
machines: []
15+
};
16+
});
617
},
718

819
activate: function() {

app/pods/hosts/index/template.hbs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
{{#each col in view.columns}}
22
<div class="host-column">
3-
{{#each host in col itemController="host"}}
4-
{{#if host.isNewHostPlaceHolder}}
3+
{{#each item in col}}
4+
{{#if item.isNewHostPlaceHolder}}
55
{{add-host-widget currentController=controller}}
66
{{else}}
7-
{{host-widget model=host dot=dot}}
7+
{{#if item.isPendingMachine}}
8+
{{#with item.machine as machine controller="machine"}}
9+
{{host-widget model=machine dot=dot}}
10+
{{/with}}
11+
{{else}}
12+
{{#with item as host controller="host"}}
13+
{{host-widget model=host dot=dot}}
14+
{{/with}}
15+
{{/if}}
816
{{/if}}
917
{{/each}}
1018
</div>

0 commit comments

Comments
 (0)