Merge pull request #1636 from vincent99/master

Stuffs
This commit is contained in:
Vincent Fiduccia 2018-02-13 20:39:48 -07:00 committed by GitHub
commit 6b49fc6eeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 50 additions and 298 deletions

View File

@ -1,4 +1,5 @@
import { scheduleOnce } from '@ember/runloop'; import { scheduleOnce } from '@ember/runloop';
import { alias } from '@ember/object/computed';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
import Controller from '@ember/controller'; import Controller from '@ember/controller';
import C from 'ui/utils/constants'; import C from 'ui/utils/constants';
@ -16,13 +17,12 @@ export default Controller.extend({
group: NAMESPACE, group: NAMESPACE,
queryParams: ['tags','group'], queryParams: ['tags','group'],
namespaces: null, namespaces: alias('scope.currentProject.namespaces'),
nodes: null, nodes: null,
expandedInstances: null, expandedInstances: null,
init() { init() {
this._super(...arguments); this._super(...arguments);
this.set('namespaces', this.get('store').all('namespace'));
this.set('nodes', this.get('store').all('node')); this.set('nodes', this.get('store').all('node'));
this.set('expandedInstances',[]); this.set('expandedInstances',[]);
}, },
@ -50,15 +50,6 @@ export default Controller.extend({
return this.get('scope.currentCluster.state') === 'inactive' && !this.get('nodes.length'); return this.get('scope.currentCluster.state') === 'inactive' && !this.get('nodes.length');
}.property('scope.currentCluster.state','nodes.[]'), }.property('scope.currentCluster.state','nodes.[]'),
simpleMode: false,
/*
simpleMode: function() {
let list = this.get('namespaces');
let bad = list.findBy('isDefault', false);
return !bad;
}.property('namespaces.@each.{system,isDefault}'),
*/
groupTableBy: function() { groupTableBy: function() {
if ( this.get('group') === NAMESPACE && !this.get('simpleMode') ) { if ( this.get('group') === NAMESPACE && !this.get('simpleMode') ) {
return 'namespace'; return 'namespace';
@ -81,6 +72,7 @@ export default Controller.extend({
let out = {}; let out = {};
let ok; let ok;
this.get('namespaces').forEach((obj) => { this.get('namespaces').forEach((obj) => {
ok = true; ok = true;

View File

@ -13,8 +13,12 @@ export default Route.extend(Preload,{
model(params, transition) { model(params, transition) {
return get(this, 'globalStore').find('project', params.project_id).then((project) => { return get(this, 'globalStore').find('project', params.project_id).then((project) => {
return get(this,'scope').startSwitchToProject(project).then(() => { return get(this,'scope').startSwitchToProject(project).then(() => {
return this.loadSchemas('store').then(() => { return PromiseAll([
this.loadSchemas('clusterStore'),
this.loadSchemas('store'),
]).then(() => {
return PromiseAll([ return PromiseAll([
this.preload('namespace','clusterStore'),
this.preload('pod'), this.preload('pod'),
this.preload('workload'), this.preload('workload'),
this.preload('dnsRecord'), this.preload('dnsRecord'),

View File

@ -8,6 +8,7 @@ export default Route.extend({
modalService: service('modal'), modalService: service('modal'),
catalog: service(), catalog: service(),
scope: service(), scope: service(),
clusterStore: service(),
parentRoute: 'catalog-tab', parentRoute: 'catalog-tab',
@ -18,6 +19,7 @@ export default Route.extend({
}, },
model: function(params/*, transition*/) { model: function(params/*, transition*/) {
var store = get(this, 'store'); var store = get(this, 'store');
var clusterStore = get(this, 'clusterStore');
var dependencies = { var dependencies = {
tpl: get(this, 'catalog').fetchTemplate(params.template), tpl: get(this, 'catalog').fetchTemplate(params.template),
@ -30,13 +32,13 @@ export default Route.extend({
if ( params.namespaceId ) if ( params.namespaceId )
{ {
dependencies.namespace = store.find('namespace', params.namespaceId); dependencies.namespace = clusterStore.find('namespace', params.namespaceId);
} }
return hash(dependencies, 'Load dependencies').then((results) => { return hash(dependencies, 'Load dependencies').then((results) => {
if ( !results.namespace ) if ( !results.namespace )
{ {
results.namespace = store.createRecord({ results.namespace = clusterStore.createRecord({
type: 'namespace', type: 'namespace',
name: results.tpl.get('defaultName'), name: results.tpl.get('defaultName'),
answers: {}, answers: {},

View File

@ -32,7 +32,6 @@ export default Route.extend({
this._super(...arguments); this._super(...arguments);
return hash({ return hash({
namespaces: this.get('store').findAll('namespace'),
catalogs: this.get('catalog').fetchCatalogs({ catalogs: this.get('catalog').fetchCatalogs({
headers: { headers: {
[C.HEADER.PROJECT_ID]: this.get('scope.currentProject.id') [C.HEADER.PROJECT_ID]: this.get('scope.currentProject.id')
@ -40,21 +39,21 @@ export default Route.extend({
}), }),
}).then((hash) => { }).then((hash) => {
this.set('catalogs', hash.catalogs); this.set('catalogs', hash.catalogs);
this.set('namespaces', hash.namespaces);
}); });
}, },
model(params) { model(params) {
const project = this.get('scope.currentProject');
if (params.launchCluster) { if (params.launchCluster) {
params.plusInfra = true; params.plusInfra = true;
} else { } else {
params.plusInfra = this.get('scope.currentProject.clusterOwner') === true; params.plusInfra = project.get('clusterOwner') === true;
} }
let namespaces = this.get('namespaces');
return this.get('catalog').fetchTemplates(params).then((res) => { return this.get('catalog').fetchTemplates(params).then((res) => {
res.catalog.forEach((tpl) => { res.catalog.forEach((tpl) => {
let exists = namespaces.findBy('externalIdInfo.templateId', tpl.get('id')); let exists = this.get('project.namespaces').findBy('externalIdInfo.templateId', tpl.get('id'));
tpl.set('exists', !!exists); tpl.set('exists', !!exists);
}); });
res.catalogs = this.get('catalogs'); res.catalogs = this.get('catalogs');

View File

@ -7,6 +7,7 @@ import C from 'ui/utils/constants';
export default Route.extend({ export default Route.extend({
prefs: service(), prefs: service(),
clusterStore: service(),
queryParams: { queryParams: {
containerName: { containerName: {
@ -125,15 +126,15 @@ export default Route.extend({
}, },
getNamespaceId(params) { getNamespaceId(params) {
const store = this.get('store'); const clusterStore = this.get('clusterStore');
let ns = null; let ns = null;
if ( params.namespaceId ) { if ( params.namespaceId ) {
ns = store.getById('namespace', params.namespaceId); ns = clusterStore.getById('namespace', params.namespaceId);
} }
if ( !ns ) { if ( !ns ) {
ns = store.getById('namespace', this.get(`prefs.${C.PREFS.LAST_NAMESPACE}`)); ns = clusterStore.getById('namespace', this.get(`prefs.${C.PREFS.LAST_NAMESPACE}`));
} }
let namespaceId = null; let namespaceId = null;

View File

@ -57,8 +57,8 @@ var Namespace = Resource.extend(StateCounts, {
router: service(), router: service(),
globalStore: service(), globalStore: service(),
pods: hasMany('id', 'pod', 'namespaceId'), pods: hasMany('id', 'pod', 'namespaceId', 'store'),
workloads: hasMany('id', 'workload', 'namespaceId'), workloads: hasMany('id', 'workload', 'namespaceId', 'store'),
project: reference('projectId', 'project', 'globalStore'), project: reference('projectId', 'project', 'globalStore'),
init() { init() {

View File

@ -13,6 +13,7 @@ export default Resource.extend({
settings: service(), settings: service(),
modalService: service('modal'), modalService: service('modal'),
router: service(), router: service(),
clusterStore: service(),
type: 'project', type: 'project',
name: null, name: null,
@ -22,6 +23,8 @@ export default Resource.extend({
projectRoleTemplateBindings: hasMany('id', 'projectRoleTemplateBinding', 'projectId'), // 2.0 bug projectId is wrong in the ptrb should be <cluster-id>:<project-id> instead of just <project-id> projectRoleTemplateBindings: hasMany('id', 'projectRoleTemplateBinding', 'projectId'), // 2.0 bug projectId is wrong in the ptrb should be <cluster-id>:<project-id> instead of just <project-id>
roleTemplateBindings: alias('projectRoleTemplateBindings'), roleTemplateBindings: alias('projectRoleTemplateBindings'),
namespaces: hasMany('id', 'namespace', 'projectId', 'clusterStore'),
actions: { actions: {
edit: function () { edit: function () {
get(this,'router').transitionTo('authenticated.cluster.projects.edit', get(this,'id')); get(this,'router').transitionTo('authenticated.cluster.projects.edit', get(this,'id'));

View File

@ -119,6 +119,10 @@
background-image: url('images/providers/custom-registry.svg'); background-image: url('images/providers/custom-registry.svg');
} }
@mixin import {
background-image: url('images/providers/custom-import.svg');
}
@mixin generic { @mixin generic {
background-image: url('images/providers/generic-driver.svg'); background-image: url('images/providers/generic-driver.svg');
} }

View File

@ -54,6 +54,7 @@
&.vmwarevsphere { @include vmwarevsphere; } &.vmwarevsphere { @include vmwarevsphere; }
&.other { @include other; } &.other { @include other; }
&.custom { @include custom; } &.custom { @include custom; }
&.import { @include import; }
&.aliyunecs { @include aliyunecs; } &.aliyunecs { @include aliyunecs; }
&.amazoneks { @include amazoneks; } &.amazoneks { @include amazoneks; }
&.azureaks { @include azureaks; } &.azureaks { @include azureaks; }
@ -74,7 +75,7 @@
justify-content: center; justify-content: center;
& > .nav-box-item { & > .nav-box-item {
min-height : 110px; min-height : 150px;
flex : 0 1 auto; flex : 0 1 auto;
position : relative; position : relative;
outline : 0; outline : 0;
@ -196,47 +197,3 @@ ol > li::before {
.host-blurb { .host-blurb {
margin-right: 10px; margin-right: 10px;
} }
.hosts-cloud-add {
.addtl-info {
.nav-boxes {
.nav-box-item {
height: 250px;
width: 250px;
border: none;
}
}
.price {
font-size: 4em;
line-height: 1em;
color:$success;
.addon {
font-size: .3em;
white-space: nowrap;
}
}
}
}
.hosts-cloud-new {
padding-bottom: 0px;
margin-bottom: 0px;
.tabs {
ul.tab-header {
li.active {
a {
background-color: transparent;
border-bottom: 2px solid $link-color;
}
}
li {
a {
font-size: 18px;
border: 0px;
background-color: transparent;
}
}
}
}
}

View File

@ -5,7 +5,7 @@ import { getOwner } from '@ember/application';
const headers = [ const headers = [
{ {
name: 'state', name: 'state',
sort: ['stateSort','name','id'], sort: ['sortState','name','id'],
translationKey: 'generic.state', translationKey: 'generic.state',
width: 125, width: 125,
}, },

View File

@ -24,17 +24,18 @@
<tr class="main-row"> <tr class="main-row">
<td data-title="{{dt.prefix}}"> <td data-title="{{dt.prefix}}">
<div class="mr-20"> <div class="mr-20">
{{input value=node.prefix}} {{input class="input-sm" value=node.prefix}}
</div> </div>
</td> </td>
<td data-title="{{dt.count}}"> <td data-title="{{dt.count}}">
<div class="input-group mr-20"> <div class="input-group mr-20">
{{input type="number" min="1" value=node.count}} {{input class="input-sm" type="number" min="1" value=node.count}}
<span class="input-group-addon bg-default">x</span> <span class="input-group-addon bg-default">x</span>
</div> </div>
</td> </td>
<td data-title="{{dt.nodeTemplate}}"> <td data-title="{{dt.nodeTemplate}}">
{{new-select {{new-select
class="input-sm"
content=model.nodeTemplates content=model.nodeTemplates
optionLabelPath="displayName" optionLabelPath="displayName"
optionValuePath="id" optionValuePath="id"

View File

@ -1,55 +0,0 @@
import { alias } from '@ember/object/computed';
import Component from '@ember/component';
import Driver from 'shared/mixins/host-driver';
import layout from './template';
import { inject as service } from '@ember/service';
import { get, set, setProperties } from '@ember/object';
export default Component.extend(Driver, {
layout,
globalStore: service(),
router: service(),
errors: null,
host: null,
clonedModel: null,
hostOptions: null,
expandAll: null,
canAddOptions: false,
labelResource: alias('primaryResource'),
primaryResource: alias('clonedModel'),
requestedClusterId: alias('clonedModel.requestedClusterId'),
role: alias('clonedModel.role'),
inModal: false,
didReceiveAttrs() {
this._super(...arguments);
if (!this.get('expandFn')) {
this.set('expandFn', function(item) {
item.toggleProperty('expanded');
});
}
if (!get(this, 'router.currentRouteName').includes('clusters')) {
set(this, 'canAddOptions', true);
}
let cm = get(this, 'globalStore').createRecord({type: 'node'});
set(cm, 'nodeTemplateId', get(this, 'nodeTemplate.id'));
setProperties(this, {
hostOptions: get(this, `nodeTemplate.${this.get('nodeTemplate.driver')}Config`),
// @@TODO@@ - 11-28-17 - not sure we should be doing this this way how the heck do we know which host to clone labels from?
// clonedModel: this.get('host').clone(),
clonedModel: cm,
});
},
doneSaving: function(neu) {
if (get(this, 'inModal')){
set(this, 'clusterNodes', neu);
}
return this._super(...arguments);
},
});

View File

@ -1,80 +0,0 @@
<div class="hosts-cloud-add">
<section class="header clearfix">
<div class="row">
<div class="mb-0">
<h1>
{{t 'hostsPage.cloudHostsPage.addPage.header'}}
</h1>
</div>
</div>
</section>
<section class="mt-20">
<form>
<div class="row addtl-info">
<div class="col span-4">
<div class="nav-boxes driver">
{{#if driver.hasUi}}
<div class="nav-box-item driver machine-driver active {{parse-host-icon machineTemplate.driver}}"></div>
{{else}}
<div class="nav-box-item driver machine-driver active other"></div>
{{/if}}
</div>
</div>
<div class="col span-8 box">
<div>
<label class="acc-label pt-10" for="">{{t 'hostsPage.cloudHostsPage.addPage.template'}}</label>
{{machineTemplate.name}}
</div>
<hr/>
{{#if driver.hasUi}}
{{component (concat 'host-template-' machineTemplate.driver) machineTemplate=model.template hostOptions=hostOptions}}
{{else}}
{{component 'host-template-other' machineTemplate=model.template}}
{{/if}}
</div>
</div>
<div class="row">
<div class="col span-11-of-23 mt-0 mb-0">
{{form-name-description
name=prefix
nameRequired=true
nameLabel="hostsPage.cloudHostsPage.addPage.name.label"
namePlaceholder="hostsPage.cloudHostsPage.addPage.name.placeholder"
nameHelpText=nameCountLabel
descriptionShown=true
}}
</div>
<div class="col span-11-of-23 mt-0 mb-0 offset-1-of-23">
{{form-count
initialScale=1
setScale=(action (mut count))
}}
</div>
</div>
<hr />
{{#if canAddOptions}}
<div class="row">
{{form-cluster-select
classNames="mt-20 mb-20"
machine=clonedModel
clusters=clusters
hasCluster=cluster
requestedClusterId=requestedClusterId
role=role
}}
</div>
{{/if}}
{{!-- @@TODO@@ - 11-28-17 - not sure we should be doing this this way how the heck do we know which host to clone labels from? --}}
{{form-user-labels initialLabels=clonedModel.labels setLabels=(action 'setLabels') detailKey="formUserLabels.nodeDetail" expandAll=null}}
{{top-errors errors=errors}}
{{save-cancel save="save" cancel="cancel" createLabel='hostsPage.cloudHostsPage.addPage.launch'}}
</form>
</section>
</div>

View File

@ -1,16 +0,0 @@
import { alias, notEmpty } from '@ember/object/computed';
import Component from '@ember/component';
import layout from './template';
import { inject as service } from '@ember/service'
export default Component.extend({
layout,
scope: service(),
settings: service(),
cluster: alias('scope.currentCluster'),
canCreate: notEmpty('cluster.registrationToken.hostCommand'),
canImport: notEmpty('cluster.registrationToken.clusterCommand'),
header: true,
});

View File

@ -1,60 +0,0 @@
{{#if header}}
<section class="header">
<h1>{{t 'clusterWelcome.welcome'}}</h1>
<p>{{t 'clusterWelcome.noHost'}}</p>
</section>
{{/if}}
<div class="row">
<div class="col span-5 offset-1 text-center option option-primary {{unless canCreate 'option-disabled'}}">
<h2>{{t 'clusterWelcome.addHost'}}</h2>
<div class="box">
{{t 'clusterWelcome.embeddedDescription' appName=settings.appName htmlSafe=true}}
{{#if canCreate}}
<div class="links" style="top: auto; bottom: 30px;">
{{#link-to "authenticated.host-templates" (query-params clusterId=scope.currentCluster.id) class="btn bg-primary"}}{{t 'clusterWelcome.select'}}{{/link-to}}
</div>
{{/if}}
</div>
<div class="bubble bg-body round p-10"><img src="{{app.baseAssets}}assets/images/environment-standard.svg" class="mt-5" /></div>
</div>
{{!-- Import --}}
<div class="col span-5 text-center option {{unless canImport 'option-disabled'}}">
<h2>{{t 'clusterWelcome.importCluster'}}</h2>
<div class="box">
{{t 'clusterWelcome.importClusterDescription' appName=settings.appName htmlSafe=true}}
<div class="row">
<div class="col span-6 text-center">
<a class="block mb-5" target="_blank" rel="nofollow noreferrer" href="https://cloud.google.com/container-engine/">
<img src="{{app.baseAssets}}assets/images/providers/gke.svg" width="150" height="auto" />
</a>
</div>
<div class="col span-6 text-center">
<a class="block" target="_blank" rel="nofollow noreferrer" href="https://www.ibm.com/cloud-computing/bluemix/containers">
<img src="{{app.baseAssets}}assets/images/providers/bluemix.svg" width="150" height="auto" /><br/>
</a>
</div>
</div>
<div class="row">
<div class="col span-6 text-center">
<a class="block mb-5" target="_blank" rel="nofollow noreferrer" href="https://azure.microsoft.com/en-us/services/container-service/">
<img src="{{app.baseAssets}}assets/images/providers/acs.svg" width="150" height="auto" /><br/>
</a>
</div>
<div class="col span-6 text-center">
<a class="block mb-5" target="_blank" rel="nofollow noreferrer" href="https://www.ubuntu.com/kubernetes">
<img src="{{app.baseAssets}}assets/images/providers/ubuntu.svg" width="150" height="auto" />
</a>
</div>
</div>
{{#if canImport}}
<div class="links" style="top: auto; bottom: 30px;">
{{#link-to "authenticated.cluster.import" scope.currentCluster.id class="btn bg-primary"}}{{t 'clusterWelcome.select'}}{{/link-to}}
</div>
{{/if}}
</div>
<div class="bubble bg-body round p-10"><img src="{{app.baseAssets}}assets/images/environment-import.svg" class="mt-5" /></div>
</div>
</div>

View File

@ -12,6 +12,7 @@ import layout from './template';
export default Component.extend(NewOrEdit, { export default Component.extend(NewOrEdit, {
layout, layout,
clusterStore: service(),
intl: service(), intl: service(),
prefs: service(), prefs: service(),
settings: service(), settings: service(),
@ -131,7 +132,7 @@ export default Component.extend(NewOrEdit, {
} }
if ( namespaceId ) { if ( namespaceId ) {
let namespace = this.get('store').getById('namespace', namespaceId); let namespace = this.get('clusterStore').getById('namespace', namespaceId);
if ( namespace ) { if ( namespace ) {
this.set('namespace', namespace); this.set('namespace', namespace);
} }

View File

@ -1,6 +1,7 @@
import { observer, get } from '@ember/object'; import { observer, get } from '@ember/object';
import { next } from '@ember/runloop'; import { next } from '@ember/runloop';
import { equal } from '@ember/object/computed'; import { alias, equal } from '@ember/object/computed';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
import Component from '@ember/component'; import Component from '@ember/component';
import layout from './template'; import layout from './template';
@ -11,6 +12,7 @@ const CREATE = 'create';
export default Component.extend({ export default Component.extend({
layout, layout,
intl: service(), intl: service(),
scope: service(),
// Outputs // Outputs
namespace: null, namespace: null,
@ -25,14 +27,13 @@ export default Component.extend({
isReuse: equal('mode', REUSE), isReuse: equal('mode', REUSE),
classNames: ['inline-form'], classNames: ['inline-form'],
choices: null, choices: alias('scope.currentProject.namespaces'),
init() { init() {
this._super(...arguments); this._super(...arguments);
let all = this.get('store').all('namespace'); let all = this.get('choices');
this.set('choices', all);
this.set('createNamespace', this.get('store').createRecord({ this.set('createNamespace', this.get('clusterStore').createRecord({
type: 'namespace', type: 'namespace',
name: '', name: '',
})); }));

View File

@ -1 +0,0 @@
export { default } from 'shared/components/cloud-host-add-or-edit/component';

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1905,10 +1905,10 @@ formIngress:
workload: Workload workload: Workload
service: DNS Record service: DNS Record
formIngressBackends: formIngressBackends:
label: Target Backends label: Target Backend
noRules: No Backends noRules: No Backends
addServiceLabel: Add a DNS Record addServiceLabel: Service
addWorkloadLabel: Add a Service addWorkloadLabel: Workload
service: service:
label: service label: service
workload: workload:
@ -4227,10 +4227,10 @@ schema:
inputHost: inputHost:
label: Choose a Host... label: Choose a Host...
inputService: inputService:
prompt: Choose a Service... prompt: Choose a Workload...
custom: Custom custom: Custom
inputDnsRecord: inputDnsRecord:
prompt: Choose a DNS Record... prompt: Choose a Service...
inputSecret: inputSecret:
prompt: Choose a Secret... prompt: Choose a Secret...
@ -4454,10 +4454,9 @@ nav:
containers: containers:
tab: Workloads tab: Workloads
systemTab: System systemTab: System
balancers: Balancers ingresses: Load Balancing
ingresses: Ingresses
containers: Workloads containers: Workloads
dns: DNS dns: Service Discovery
volumes: Volumes volumes: Volumes
k8s: Advanced k8s: Advanced
deploy: Deploy deploy: Deploy