mirror of https://github.com/rancher/dashboard.git
destination dropdown is namespace specific
This commit is contained in:
parent
9bb4ed1155
commit
2e2292e9ca
|
|
@ -11,6 +11,10 @@ export default {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
namespace: {
|
||||||
|
type: String,
|
||||||
|
default: 'default'
|
||||||
|
},
|
||||||
isWeighted: {
|
isWeighted: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
|
@ -32,17 +36,15 @@ export default {
|
||||||
default: () => ['App', 'Version', 'Port', 'Weight']
|
default: () => ['App', 'Version', 'Port', 'Weight']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
const {
|
const {
|
||||||
namespace = 'default', port = '', app = '', uuid, version = ''
|
port = '', app = '', uuid, version = ''
|
||||||
} = this.spec;
|
} = this.spec;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
services: [],
|
||||||
version,
|
version,
|
||||||
uuid,
|
uuid,
|
||||||
apps: [],
|
|
||||||
namespace,
|
|
||||||
port,
|
port,
|
||||||
app,
|
app,
|
||||||
weight: '',
|
weight: '',
|
||||||
|
|
@ -60,30 +62,25 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
versions() {
|
versions() {
|
||||||
if (this.app && !isEmpty(this.apps)) {
|
if (this.app && !isEmpty(this.appsInNS)) {
|
||||||
return this.apps[this.app].map(service => service.version);
|
return this.appsInNS[this.app].map(service => service.version);
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
servicesInNS() {
|
||||||
mounted() {
|
if (!this.services) {
|
||||||
this.getServices();
|
return [];
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async getServices() {
|
|
||||||
const services = await this.$store.dispatch('cluster/findAll', { type: RIO.SERVICE });
|
|
||||||
const servicesinNS = [];
|
|
||||||
|
|
||||||
services.forEach((service) => {
|
|
||||||
if ( get(service, 'metadata.namespace') === this.namespace) {
|
|
||||||
servicesinNS.push(service);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
return this.services.filter((service) => {
|
||||||
|
return service.metadata.namespace === this.namespace;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
appsInNS() {
|
||||||
const apps = {};
|
const apps = {};
|
||||||
|
|
||||||
servicesinNS.forEach((service) => {
|
this.servicesInNS.forEach((service) => {
|
||||||
if (!apps[service.app]) {
|
if (!apps[service.app]) {
|
||||||
apps[service.app] = [service];
|
apps[service.app] = [service];
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -91,7 +88,17 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.apps = apps;
|
return apps;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getServices();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async getServices() {
|
||||||
|
const services = await this.$store.dispatch('cluster/findAll', { type: RIO.SERVICE });
|
||||||
|
|
||||||
|
this.services = services;
|
||||||
},
|
},
|
||||||
setApp(app) {
|
setApp(app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
@ -112,7 +119,7 @@ export default {
|
||||||
class="inline"
|
class="inline"
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
:value="app"
|
:value="app"
|
||||||
:options="Object.keys(apps)"
|
:options="Object.keys(appsInNS)"
|
||||||
:placeholder="showPlaceholders ? placeholders[0] : null"
|
:placeholder="showPlaceholders ? placeholders[0] : null"
|
||||||
@input="setApp"
|
@input="setApp"
|
||||||
></v-select>
|
></v-select>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,10 @@ export default {
|
||||||
default: () => {
|
default: () => {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
namespace: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -167,6 +171,7 @@ export default {
|
||||||
<Destination
|
<Destination
|
||||||
v-for="(destination, i) in to"
|
v-for="(destination, i) in to"
|
||||||
:key="destination.uuid"
|
:key="destination.uuid"
|
||||||
|
:namespace="namespace"
|
||||||
:is-weighted="to.length>1"
|
:is-weighted="to.length>1"
|
||||||
:spec="destination"
|
:spec="destination"
|
||||||
:can-remove="to.length>1"
|
:can-remove="to.length>1"
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ export default {
|
||||||
<Rule
|
<Rule
|
||||||
v-for="(route, i) in routes"
|
v-for="(route, i) in routes"
|
||||||
:key="route.uuid"
|
:key="route.uuid"
|
||||||
|
:namespace="value.metadata.namespace"
|
||||||
:position="i"
|
:position="i"
|
||||||
class="col span-12"
|
class="col span-12"
|
||||||
:spec="route"
|
:spec="route"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue