Skip to content

Commit d7f9519

Browse files
committed
Merge pull request #86 from vincent99/add-container
Add Container redesign
2 parents 4e5d762 + 2bce5ff commit d7f9519

26 files changed

+796
-632
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{!view "select" class="form-control" content=view.choices selection=view.selection multiple="true" optionValuePath="content.value" optionLabelPath="content.label"}}
1+
{{view "select" class="form-control" content=view.choices selection=view.selection multiple="true" optionValuePath="content.value" optionLabelPath="content.label"}}

app/pods/container/edit/new-or-edit.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,31 @@ export default Ember.Mixin.create(Cattle.NewOrEditMixin, {
7070
},
7171

7272
// Links
73+
allHosts: function() {
74+
return this.get('store').all('host');
75+
}.property(),
76+
7377
containerChoices: function() {
7478
var list = [];
7579
var id = this.get('id');
76-
this.get('controllers.hosts').forEach(function(host) {
80+
81+
this.get('allHosts').map((host) => {
7782
var containers = (host.get('instances')||[]).filter(function(instance) {
7883
// You can't link to yourself, or to other types of instances
7984
return instance.get('id') !== id && instance.get('kind') === 'container';
8085
});
8186

8287
list.pushObjects(containers.map(function(container) {
8388
return {
84-
group: host.get('displayName'),
89+
group: host.get('name') || '('+host.get('id')+')',
8590
id: container.get('id'),
8691
name: container.get('name')
8792
};
8893
}));
8994
});
9095

91-
return list;
92-
}.property('controllers.hosts.@each.[]','controllers.hosts[email protected]').volatile(),
96+
return list.sortBy('group','name','id');
97+
}.property('allHosts[email protected]').volatile(),
9398

9499
linksArray: null,
95100
linksAsStrArray: null,
Lines changed: 25 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1>{{#if editing}}Edit{{else}}Add{{/if}} Container</h1>
1+
<h1>Edit Container</h1>
22

33
{{#if error}}
44
<div class="alert alert-danger">
@@ -7,75 +7,40 @@
77
</div>
88
{{/if}}
99

10-
<div class="row">
11-
<div class="col-md-6">
12-
<div class="form-group">
13-
<label for="name">Name</label>
14-
{{input id="name" type="text" value=name classNames="form-control" placeholder="e.g. web01"}}
15-
</div>
16-
<div class="form-group">
17-
<label for="description">Description</label>
18-
{{textarea id="description" value=description classNames="form-control no-resize" rows="5" placeholder="e.g. It serves the webs"}}
19-
</div>
20-
</div>
21-
22-
<div class="col-md-6">
23-
{{#if editing}}
24-
<label>Port Bindings</label>
25-
<div class="well">
26-
{{partial "container/edit-ports"}}
27-
</div>
28-
29-
<label>Links</label>
30-
<div class="well">
31-
{{partial "container/edit-links"}}
10+
<form>
11+
<div class="row">
12+
<div class="col-md-6">
13+
<div class="form-group">
14+
<label for="name">Name</label>
15+
{{input id="name" type="text" value=name classNames="form-control" placeholder="e.g. web01"}}
3216
</div>
33-
{{else}}
3417
<div class="form-group">
35-
<label for="networkId"><i class="ss-headphones"></i> Network</label>
36-
{{view "select"
37-
class="form-control"
38-
disabled=editing
39-
id="networkId"
40-
content=networks
41-
optionLabelPath="content.displayName"
42-
optionValuePath="content.id"
43-
value=networkId
44-
prompt="Select a Network to join the Instance to..."
45-
}}
18+
<label for="description">Description</label>
19+
{{textarea id="description" value=description classNames="form-control no-resize" rows="5" placeholder="e.g. It serves the webs"}}
4620
</div>
47-
{{partial "container/edit-image"}}
48-
{{/if}}
49-
</div>
50-
</div>
51-
52-
{{#unless editing}}
53-
<div class="row">
54-
<div class="col-md-6">
55-
{{partial "container/edit-ports"}}
5621
</div>
5722

5823
<div class="col-md-6">
59-
{{partial "container/edit-links"}}
60-
</div>
61-
</div>
62-
63-
<div class="advanced-toggle">
64-
<a href="#" {{action "showAdvanced" target=view}}>Advanced options</a>
65-
</div>
66-
<div class="advanced" style="display: none">
67-
<div class="row">
68-
69-
<div class="col-md-6">
70-
{{partial "container/edit-command"}}
24+
<label>Port Bindings</label>
25+
<div class="well">
26+
{{#if portsArray.length}}
27+
{{partial "container/edit-ports"}}
28+
{{else}}
29+
<span class="text-muted">This container has no ports.</span>
30+
{{/if}}
7131
</div>
7232

73-
<div class="col-md-6">
74-
{{partial "container/edit-environment"}}
33+
<label>Links</label>
34+
<div class="well">
35+
{{#if linksArray.length}}
36+
{{partial "container/edit-links"}}
37+
{{else}}
38+
<span class="text-muted">This container has no links.</span>
39+
{{/if}}
7540
</div>
7641
</div>
7742
</div>
78-
{{/unless}}
7943

80-
{{partial "save-cancel"}}
44+
{{partial "save-cancel"}}
45+
</form>
8146
{{partial "overlay-close"}}

app/pods/containers/new/controller.js

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import NewOrEditContainer from 'ui/pods/container/edit/new-or-edit';
33

44
export default Ember.ObjectController.extend(NewOrEditContainer, {
55
queryParams: ['tab','hostId'],
6-
tab: 'basic',
6+
tab: 'command',
77
hostId: null,
88
editing: false,
99
saving: false,
@@ -279,30 +279,27 @@ export default Ember.ObjectController.extend(NewOrEditContainer, {
279279

280280
// Volumes From
281281
hostContainerChoices: function() {
282-
var self = this;
283282
var list = [];
284283

285-
this.get('controllers.hosts').forEach(function(host) {
286-
// You can only mount volumes from the host the container will go on
287-
if ( host.get('id') === self.get('requestedHostId'))
288-
{
289-
var containers = (host.get('instances')||[]).filter(function(instance) {
290-
// You can't mount volumes from other types of instances
291-
return instance.get('type') === 'container';
292-
});
293-
294-
list.pushObjects(containers.map(function(container) {
295-
return {
296-
group: host.get('displayName'),
297-
id: container.get('id'),
298-
name: container.get('name')
299-
};
300-
}));
301-
}
284+
this.get('allHosts').filter((host) => {
285+
return host.get('id') === this.get('requestedHostId');
286+
}).map((host) => {
287+
var containers = (host.get('instances')||[]).filter(function(instance) {
288+
// You can't mount volumes from other types of instances
289+
return instance.get('type') === 'container';
290+
});
291+
292+
list.pushObjects(containers.map(function(container) {
293+
return {
294+
group: host.get('name') || '('+host.get('id')+')',
295+
id: container.get('id'),
296+
name: container.get('name')
297+
};
298+
}));
302299
});
303300

304-
return list.sortBy('group','container.name','container.id');
305-
}.property('controllers.hosts.@each.[]','controllers.hosts[email protected]').volatile(),
301+
return list.sortBy('group','name','id');
302+
}.property('allHosts[email protected]').volatile(),
306303

307304
volumesFromArray: null,
308305
initVolumesFrom: function() {
@@ -388,12 +385,6 @@ export default Ember.ObjectController.extend(NewOrEditContainer, {
388385

389386
// Terminal
390387
terminal: 'both',
391-
terminalChoices: [
392-
{label: 'Yes (-i and -t)', value: 'both'},
393-
{label: 'Interactive (-i)', value: 'interactive'},
394-
{label: 'TTY (-t)', value: 'terminal'},
395-
{label: 'No', value: 'none'},
396-
],
397388
terminalDidChange: function() {
398389
var val = this.get('terminal');
399390
var stdinOpen = ( val === 'interactive' || val === 'both' );

app/pods/containers/new/route.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import Ember from 'ember';
2-
import OverlayRoute from 'ui/pods/overlay/route';
32

4-
export default OverlayRoute.extend({
3+
export default Ember.Route.extend({
4+
activate: function() {
5+
this.send('setPageLayout', {label: 'Back', backPrevious: true});
6+
},
7+
58
actions: {
69
cancel: function() {
710
this.send('goToPrevious');
@@ -12,7 +15,8 @@ export default OverlayRoute.extend({
1215
var self = this;
1316

1417
var dependencies = [
15-
this.get('store').find('network')
18+
this.get('store').find('network'),
19+
this.get('store').find('host')
1620
];
1721

1822
return Ember.RSVP.all(dependencies, 'Load container dependencies').then(function(results) {
@@ -52,8 +56,4 @@ export default OverlayRoute.extend({
5256
controller.set('model', model);
5357
controller.initFields();
5458
},
55-
56-
renderTemplate: function() {
57-
this.render('containers/new', {into: 'application', outlet: 'overlay'});
58-
},
5959
});

0 commit comments

Comments
 (0)