mirror of https://github.com/rancher/ui.git
Catalog icon for project templates
This commit is contained in:
parent
b561e70a4b
commit
d02b497c79
|
|
@ -94,7 +94,7 @@ export default Ember.Component.extend(NewOrEdit, Sortable, {
|
|||
];
|
||||
|
||||
this.get('projectTemplates').forEach((tpl) => {
|
||||
choices.push({id: tpl.id, name: tpl.name, image: tpl.links.icon});
|
||||
choices.push({id: tpl.id, name: tpl.name, image: tpl.get('orchestrationIcon')});
|
||||
});
|
||||
|
||||
choices.forEach(function(driver) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
import Resource from 'ember-api-store/models/resource';
|
||||
import { parseExternalId } from 'ui/utils/parse-externalid';
|
||||
import C from 'ui/utils/constants';
|
||||
|
||||
export default Resource.extend({
|
||||
catalog: Ember.inject.service(),
|
||||
|
||||
type: 'catalogTemplate',
|
||||
|
||||
externalId: function() {
|
||||
|
|
@ -15,4 +18,23 @@ export default Resource.extend({
|
|||
externalIdInfo: function() {
|
||||
return parseExternalId(this.get('externalId'));
|
||||
}.property('externalId'),
|
||||
|
||||
// These only works if the templates have already been loaded elsewhere...
|
||||
catalogTemplate: function() {
|
||||
return this.get('catalog').getTemplateFromCache(this.get('externalIdInfo.templateId'));
|
||||
}.property('externalIdInfo.templateId'),
|
||||
|
||||
icon: function() {
|
||||
let tpl = this.get('catalogTemplate');
|
||||
if ( tpl ) {
|
||||
return tpl.linkFor('icon');
|
||||
}
|
||||
}.property('catalogTemplate'),
|
||||
|
||||
category: function() {
|
||||
let tpl = this.get('catalogTemplate');
|
||||
if ( tpl ) {
|
||||
return tpl.get('category');
|
||||
}
|
||||
}.property('catalogTemplate'),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -33,6 +33,32 @@ var ProjectTemplate = Resource.extend(PolledResource, {
|
|||
}.property('canEdit'),
|
||||
|
||||
icon: 'icon icon-file',
|
||||
|
||||
summary: function() {
|
||||
let map = {
|
||||
'Orchestration': [],
|
||||
};
|
||||
|
||||
this.get('stacks').forEach((stack) => {
|
||||
let category = stack.get('category');
|
||||
if ( !map[category] ) {
|
||||
map[category] = [];
|
||||
}
|
||||
|
||||
map[category].push(stack.get('catalogTemplate.name'));
|
||||
});
|
||||
|
||||
return map;
|
||||
}.property('stacks.[]'),
|
||||
|
||||
orchestrationIcon: function() {
|
||||
let orch = this.get('stacks').findBy('catalogTemplate.category','Orchestration');
|
||||
if ( orch ) {
|
||||
return orch.get('icon');
|
||||
} else {
|
||||
return `${this.get('app.baseAssets')}assets/images/logos/provider-orchestration.svg`;
|
||||
}
|
||||
}.property('stacks.[]'),
|
||||
});
|
||||
|
||||
// Projects don't get pushed by /subscribe WS, so refresh more often
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ export default Ember.Service.extend({
|
|||
return this.get('store').request({url: `${this.get('app.catalogEndpoint')}/catalogs`});
|
||||
},
|
||||
|
||||
getTemplateFromCache(id) {
|
||||
return this.get('store').getById('template', id);
|
||||
},
|
||||
|
||||
fetchTemplate(id, upgrade=false) {
|
||||
let type = 'templates';
|
||||
if ( upgrade === true ) {
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@ import C from 'ui/utils/constants';
|
|||
|
||||
export default Ember.Route.extend({
|
||||
access: Ember.inject.service(),
|
||||
catalog: Ember.inject.service(),
|
||||
|
||||
model: function(/*params, transition*/) {
|
||||
var userStore = this.get('userStore');
|
||||
return Ember.RSVP.hash({
|
||||
all: userStore.findAllUnremoved('project'),
|
||||
projectTemplates: userStore.findAll('projectTemplate'),
|
||||
catalogTemplates: this.get('catalog').fetchTemplates({templateBase: C.EXTERNAL_ID.KIND_INFRA}),
|
||||
}).then((hash) => {
|
||||
var project = userStore.createRecord({
|
||||
type: 'project',
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
|
||||
<cross-domain-policy>
|
||||
<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
|
||||
|
||||
<!-- Most restrictive policy: -->
|
||||
<site-control permitted-cross-domain-policies="none"/>
|
||||
|
||||
<!-- Least restrictive policy: -->
|
||||
<!--
|
||||
<site-control permitted-cross-domain-policies="all"/>
|
||||
<allow-access-from domain="*" to-ports="*" secure="false"/>
|
||||
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
|
||||
-->
|
||||
</cross-domain-policy>
|
||||
Loading…
Reference in New Issue