mirror of https://github.com/rancher/ui.git
Merge pull request #1388 from westlywright/tech-preview
kube popout shell
This commit is contained in:
commit
fb6117b16e
|
|
@ -28,6 +28,7 @@ jsconfig.json
|
|||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
*.code-workspace
|
||||
|
||||
|
||||
*.swp
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ export default Ember.Component.extend(NewOrEdit, {
|
|||
|
||||
if ( !this.get('launchConfig.metadata') ) {
|
||||
this.set('launchConfig.metadata', {});
|
||||
};
|
||||
}
|
||||
|
||||
if ( this.get('isService') && !this.get('isSidekick') ) {
|
||||
this.setProperties({
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@ import Ember from 'ember';
|
|||
import Console from 'ui/mixins/console';
|
||||
|
||||
export default Ember.Controller.extend(Console, {
|
||||
command: null,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,33 @@
|
|||
import Ember from 'ember';
|
||||
import C from 'ui/utils/constants';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
projects: Ember.inject.service(),
|
||||
k8s: Ember.inject.service(),
|
||||
model: function(params) {
|
||||
let store = this.get('store');
|
||||
if (params.kubernetes) {
|
||||
return this.get('k8s').getInstanceToConnect();
|
||||
}
|
||||
|
||||
return store.find('container', params.instanceId).then((response) => {
|
||||
return response;
|
||||
});
|
||||
},
|
||||
setupController(controller, model) {
|
||||
this._super(controller, model);
|
||||
if (controller.get('kubernetes')) {
|
||||
controller.set('command', Ember.computed('model.labels', function() {
|
||||
var labels = this.get('model.labels')||{};
|
||||
if ( labels[C.LABEL.K8S_TOKEN]+'' === 'true' ) {
|
||||
return [
|
||||
'kubectl-shell.sh',
|
||||
this.get('cookies').get(C.COOKIE.TOKEN) || 'unauthorized'
|
||||
];
|
||||
} else {
|
||||
return ['/bin/bash','-l','-c','echo "# Run kubectl commands inside here\n# e.g. kubectl get rc\n"; TERM=xterm-256color /bin/bash'];
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<div class="shell-popup">
|
||||
{{#container-shell
|
||||
instance=model
|
||||
command=command
|
||||
showProtip=false
|
||||
cols=80
|
||||
rows=24
|
||||
|
|
|
|||
|
|
@ -30,8 +30,15 @@ export default Ember.Controller.extend({
|
|||
window.open(this.get('k8s.kubernetesDashboard'),'_blank');
|
||||
},
|
||||
|
||||
kubectl() {
|
||||
kubectl(e) {
|
||||
if (e.metaKey) {
|
||||
let proj = this.get('projects.current.id');
|
||||
Ember.run.later(() => {
|
||||
window.open(`//${window.location.host}/env/${proj}/infra/console?kubernetes=true&isPopup=true`, '_blank', "toolbars=0,width=900,height=700,left=200,top=200");
|
||||
});
|
||||
} else {
|
||||
this.get('modalService').toggleModal('modal-kubectl');
|
||||
}
|
||||
},
|
||||
|
||||
kubeconfig() {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@
|
|||
<p>{{t 'k8sAdvancedTab.shell.detail' htmlSafe=true}}</p>
|
||||
|
||||
<div class="links" style="top: auto; bottom: 47px;">
|
||||
<button class="btn bg-primary icon-btn ml-10" {{action "kubectl"}}>
|
||||
<button class="btn bg-primary icon-btn ml-10" onClick={{action "kubectl" allowedKeys="meta"}}>
|
||||
|
||||
<span class="darken"><i class="icon icon-terminal"></i></span>
|
||||
<span>{{t 'k8sAdvancedTab.shell.button'}}</span>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import Ember from 'ember';
|
|||
|
||||
export default Ember.Mixin.create({
|
||||
application : Ember.inject.controller(),
|
||||
queryParams : ['instanceId'],
|
||||
queryParams : ['instanceId', 'kubernetes'],
|
||||
instanceId : null,
|
||||
model : null,
|
||||
|
||||
|
|
|
|||
|
|
@ -180,12 +180,18 @@ var Stack = Resource.extend(StateCounts, {
|
|||
return false;
|
||||
}
|
||||
|
||||
var count = this.get('services.length') || 0;
|
||||
if ( count === 0 ) {
|
||||
var services = this.get('services');
|
||||
var containers = this.get('instances').filter((inst) => {
|
||||
return inst.get('serviceId') === null;
|
||||
});
|
||||
var countS = (services.length || 0);
|
||||
var countC = (containers.length || 0);
|
||||
|
||||
if ( (countS + countC) === 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.get('services').filterBy('actionLinks.deactivate').get('length') > 0;
|
||||
return services.filterBy('actionLinks.deactivate').get('length') > 0 && containers.filterBy('actionLinks.stop').get('length');
|
||||
}.property('services.@each.state','actionLinks.stopall'),
|
||||
|
||||
canViewConfig: function() {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export default Ember.Controller.extend(NewOrEdit, {
|
|||
},
|
||||
},
|
||||
|
||||
testNames: function(el, idx, ary) {
|
||||
testNames: function(el/*, idx , ary */) {
|
||||
let error = false;
|
||||
if (el.includes('compose')) {
|
||||
if (el !== 'rancher-compose.yml' || el !== 'docker-compose.yml') {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import C from 'ui/utils/constants';
|
|||
|
||||
export default Ember.Service.extend({
|
||||
store: Ember.inject.service('store'),
|
||||
userStore: Ember.inject.service('user-store'),
|
||||
projects: Ember.inject.service(),
|
||||
|
||||
kubernetesDashboard: function() {
|
||||
|
|
@ -54,4 +55,29 @@ export default Ember.Service.extend({
|
|||
message: err.body.stdErr.split(/\n/),
|
||||
});
|
||||
},
|
||||
|
||||
getInstanceToConnect() {
|
||||
let systemProject = this.get('projects.current.cluster.systemProject');
|
||||
let inst;
|
||||
|
||||
if ( !systemProject ) {
|
||||
return Ember.RSVP.reject('Unable to locate system environment');
|
||||
}
|
||||
|
||||
return this.get('userStore').rawRequest({
|
||||
url: systemProject.links.instances,
|
||||
}).then((res) => {
|
||||
inst = res.body.data.find((c) => {
|
||||
return c.state === 'running'
|
||||
&& c.labels
|
||||
&& c.labels[C.LABEL.K8S_KUBECTL]+'' === 'true';
|
||||
});
|
||||
|
||||
if ( inst ) {
|
||||
return this.get('store').createRecord(inst);
|
||||
} else {
|
||||
return Ember.RSVP.reject('Unable to find running kubectl container');
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue