mirror of https://github.com/rancher/ui.git
Update logging
This commit is contained in:
parent
1c72bda7ce
commit
39ad24ea2b
|
|
@ -128,6 +128,18 @@ export default Ember.Component.extend(NewOrEdit, {
|
||||||
}.property('originalModel.{id,targetType}', 'targetType'),
|
}.property('originalModel.{id,targetType}', 'targetType'),
|
||||||
|
|
||||||
|
|
||||||
|
validate() {
|
||||||
|
const targetType = get(this, 'targetType');
|
||||||
|
const config = get(this, `primaryResource.${targetType}Config`);
|
||||||
|
const errors = config.validationErrors();
|
||||||
|
if (errors.get('length')) {
|
||||||
|
set(this, 'errors', errors);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
set(this, 'errors', null);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save(cb) {
|
save(cb) {
|
||||||
const targetType = get(this, 'targetType');
|
const targetType = get(this, 'targetType');
|
||||||
|
|
@ -148,15 +160,26 @@ export default Ember.Component.extend(NewOrEdit, {
|
||||||
}
|
}
|
||||||
// set kafka config
|
// set kafka config
|
||||||
if (targetType === 'kafka') {
|
if (targetType === 'kafka') {
|
||||||
const kt = get(model, 'kafka.config.brokerType');
|
let kt;
|
||||||
|
const brokerEndpoints = get(model, 'kafka.config.brokerEndpoints');
|
||||||
|
const zookeeperEndpoint = get(model, 'kafka.config.zookeeperEndpoint');
|
||||||
|
if (brokerEndpoints && brokerEndpoints.length > 0) {
|
||||||
|
kt = 'broker';
|
||||||
|
} else if (zookeeperEndpoint) {
|
||||||
|
kt = 'zookeeper';
|
||||||
|
} else {
|
||||||
|
set(this, 'errors', ['"Endpoint" is required']);
|
||||||
|
cb();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (kt === 'broker') {
|
if (kt === 'broker') {
|
||||||
set(model, 'kafkaConfig', {
|
set(model, 'kafkaConfig', {
|
||||||
zookeeperEndpoint: null,
|
zookeeperEndpoint: null,
|
||||||
brokerEndpoints: get(model, 'kafka.config.brokerEndpoints'),
|
brokerEndpoints,
|
||||||
});
|
});
|
||||||
} else if (kt === 'zookeeper') {
|
} else if (kt === 'zookeeper') {
|
||||||
set(model, 'kafkaConfig', {
|
set(model, 'kafkaConfig', {
|
||||||
zookeeperEndpoint: get(model, 'kafka.config.zookeeperEndpoint'),
|
zookeeperEndpoint,
|
||||||
brokerEndpoints: null,
|
brokerEndpoints: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -175,20 +198,11 @@ export default Ember.Component.extend(NewOrEdit, {
|
||||||
set(model, `${targetType}Config`, get(model, `${targetType}.config`));
|
set(model, `${targetType}Config`, get(model, `${targetType}.config`));
|
||||||
|
|
||||||
this._super(cb);
|
this._super(cb);
|
||||||
// model.save().then(nue => {
|
|
||||||
// this.setProperties({
|
|
||||||
// model: nue,
|
|
||||||
// originalModel: nue.clone(),
|
|
||||||
// });
|
|
||||||
// cb(true);
|
|
||||||
// }).catch(err => {
|
|
||||||
// console.log(err);
|
|
||||||
// cb();
|
|
||||||
// });
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
doneSaving(nue) {
|
doneSaving(nue) {
|
||||||
|
set(this, 'model', nue.patch());
|
||||||
return this.pollLogging();
|
return this.pollLogging();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,15 @@ export default Component.extend({
|
||||||
brokerType: 'zookeeper',
|
brokerType: 'zookeeper',
|
||||||
brokerEndpoints: null,
|
brokerEndpoints: null,
|
||||||
cachedBrokerEndpoints: null,
|
cachedBrokerEndpoints: null,
|
||||||
cachedZookeeper: null,
|
cachedZookeeperEndpoint: null,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super();
|
this._super();
|
||||||
const endpoints = get(this, 'config.brokerEndpoints');
|
|
||||||
if (endpoints) {
|
|
||||||
set(this, 'brokerEndpoints', endpoints.map(endpoint => ({endpoint})));
|
|
||||||
}
|
|
||||||
const brokerEndpoints = get(this, 'config.brokerEndpoints');
|
const brokerEndpoints = get(this, 'config.brokerEndpoints');
|
||||||
const zookeeperEndpoint = get(this, 'config.zookeeperEndpoint')
|
|
||||||
if (brokerEndpoints) {
|
if (brokerEndpoints) {
|
||||||
set(this, 'brokerType', 'broker')
|
set(this, 'brokerType', 'broker');
|
||||||
}
|
set(this, 'brokerEndpoints', brokerEndpoints.map(endpoint => ({endpoint})));
|
||||||
if (zookeeperEndpoint) {
|
} else {
|
||||||
set(this, 'brokerType', 'zookeeper');
|
set(this, 'brokerType', 'zookeeper');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -56,22 +51,21 @@ ${str}
|
||||||
brokerTypeChange: function() {
|
brokerTypeChange: function() {
|
||||||
const t = get(this, 'brokerType');
|
const t = get(this, 'brokerType');
|
||||||
const brokerEndpoints = get(this, 'brokerEndpoints');
|
const brokerEndpoints = get(this, 'brokerEndpoints');
|
||||||
const zookeeper = get(this, 'config.zookeeper');
|
const zookeeperEndpoint = get(this, 'config.zookeeperEndpoint');
|
||||||
const cachedZookeeper = get(this, 'cachedZookeeper');
|
const cachedZookeeperEndpoint = get(this, 'cachedZookeeperEndpoint');
|
||||||
const cachedBrokerEndpoint = get(this, 'cachedBrokerEndpoints');
|
const cachedBrokerEndpoints = get(this, 'cachedBrokerEndpoints');
|
||||||
set(this, 'config.brokerType', t);
|
|
||||||
if (t === 'zookeeper') {
|
if (t === 'zookeeper') {
|
||||||
set(this, 'cachedBrokerEndpoints', brokerEndpoints);
|
set(this, 'cachedBrokerEndpoints', brokerEndpoints);
|
||||||
set(this, 'config.zookeeper', cachedZookeeper);
|
set(this, 'config.zookeeperEndpoint', cachedZookeeperEndpoint);
|
||||||
set(this, 'brokerEndpoints', null);
|
set(this, 'brokerEndpoints', null);
|
||||||
} else if (t === 'broker') {
|
} else if (t === 'broker') {
|
||||||
if (!cachedBrokerEndpoint) {
|
if (!cachedBrokerEndpoints) {
|
||||||
this.send('add');
|
this.send('add');
|
||||||
} else {
|
} else {
|
||||||
set(this, 'brokerEndpoints', cachedBrokerEndpoint);
|
set(this, 'brokerEndpoints', cachedBrokerEndpoints);
|
||||||
}
|
}
|
||||||
set(this, 'cachedZookeeper', zookeeper);
|
set(this, 'cachedZookeeperEndpoint', zookeeperEndpoint);
|
||||||
set(this, 'config.zookeeper', null);
|
set(this, 'config.zookeeperEndpoint', null);
|
||||||
}
|
}
|
||||||
}.observes('brokerType'),
|
}.observes('brokerType'),
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,14 @@
|
||||||
</div>
|
</div>
|
||||||
<p class="text-info text-small mb-0">{{t 'loggingPage.kafka.zookeeperHelpText'}}</p>
|
<p class="text-info text-small mb-0">{{t 'loggingPage.kafka.zookeeperHelpText'}}</p>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#each brokerEndpoints as |item|}}
|
{{#each brokerEndpoints as |item idx|}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col span-11">
|
<div class="col span-11">
|
||||||
<label class="acc-label" for="">{{t 'loggingPage.endpoint'}}{{field-required}}</label>
|
<label class="acc-label" for="">{{t 'loggingPage.endpoint'}}
|
||||||
|
{{#if (eq idx 0)}}
|
||||||
|
{{field-required}}
|
||||||
|
{{/if}}
|
||||||
|
</label>
|
||||||
{{input
|
{{input
|
||||||
type="text"
|
type="text"
|
||||||
value=item.endpoint
|
value=item.endpoint
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { get, set } from '@ember/object'
|
||||||
const SEVERITIES = [
|
const SEVERITIES = [
|
||||||
{value: 'emerg', label: 'emergency'},
|
{value: 'emerg', label: 'emergency'},
|
||||||
{value: 'alert', label: 'alert'},
|
{value: 'alert', label: 'alert'},
|
||||||
{value: 'critical', label: 'critical'},
|
{value: 'crit', label: 'critical'},
|
||||||
{value: 'err', label: 'error'},
|
{value: 'err', label: 'error'},
|
||||||
{value: 'warning', label: 'warning'},
|
{value: 'warning', label: 'warning'},
|
||||||
{value: 'notice', label: 'notice'},
|
{value: 'notice', label: 'notice'},
|
||||||
|
|
|
||||||
|
|
@ -22,45 +22,6 @@ export default Route.extend({
|
||||||
return newLogging;
|
return newLogging;
|
||||||
},
|
},
|
||||||
|
|
||||||
// patchLogging(logging) {
|
|
||||||
// const t = get(logging, 'targetType');
|
|
||||||
// const gs = get(this, 'globalStore');
|
|
||||||
|
|
||||||
// const nue = gs.createRecord({
|
|
||||||
// type: logging.get('type'),
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const loggingTagets = [
|
|
||||||
// 'embedded',
|
|
||||||
// 'kafka',
|
|
||||||
// 'elasticsearch',
|
|
||||||
// 'splunk',
|
|
||||||
// 'syslog',
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// const map = {};
|
|
||||||
// loggingTagets.forEach(key => {
|
|
||||||
// const config = gs.createRecord({
|
|
||||||
// type: `${key}Config`
|
|
||||||
// });
|
|
||||||
// const clone = nue.clone();
|
|
||||||
// clone.set('config', config);
|
|
||||||
// map[key] = clone;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // why can't set props on logging ???????????????
|
|
||||||
// logging.set('a', 1);
|
|
||||||
// logging.get('a') // ===> undefined
|
|
||||||
// logging.setProperties(map);
|
|
||||||
// if (t && t !== 'none') {
|
|
||||||
// set(logging, `${t}.config`, get(logging, `${t}Config`));
|
|
||||||
// set(logging, `${t}.outputFlushInterval`, get(logging, 'outputFlushInterval'));
|
|
||||||
// set(logging, `${t}.outputTags`, get(logging, 'outputTags'));
|
|
||||||
// }
|
|
||||||
// console.log('------logging', logging);
|
|
||||||
// return logging;
|
|
||||||
// },
|
|
||||||
|
|
||||||
model(/*params, transition*/) {
|
model(/*params, transition*/) {
|
||||||
const globalStore = this.get('globalStore');
|
const globalStore = this.get('globalStore');
|
||||||
const pageScope = this.get('pageScope');
|
const pageScope = this.get('pageScope');
|
||||||
|
|
@ -77,6 +38,7 @@ export default Route.extend({
|
||||||
logging = this.createLogging('clusterlogging');
|
logging = this.createLogging('clusterlogging');
|
||||||
}
|
}
|
||||||
const originalLogging = logging.clone();
|
const originalLogging = logging.clone();
|
||||||
|
logging = logging.clone().patch();
|
||||||
return {
|
return {
|
||||||
logging,
|
logging,
|
||||||
originalLogging,
|
originalLogging,
|
||||||
|
|
@ -104,6 +66,7 @@ export default Route.extend({
|
||||||
logging = this.createLogging('projectlogging');
|
logging = this.createLogging('projectlogging');
|
||||||
}
|
}
|
||||||
const originalLogging = logging.clone();
|
const originalLogging = logging.clone();
|
||||||
|
logging = logging.clone().patch();
|
||||||
const clusterLogging = hash.clusterLogging.get('firstObject');
|
const clusterLogging = hash.clusterLogging.get('firstObject');
|
||||||
return {
|
return {
|
||||||
logging,
|
logging,
|
||||||
|
|
|
||||||
|
|
@ -1,84 +1,44 @@
|
||||||
import { get, set } from '@ember/object'
|
import { get, set } from '@ember/object'
|
||||||
import { inject as service } from '@ember/service'
|
|
||||||
import { alias } from '@ember/object/computed'
|
|
||||||
import Mixin from '@ember/object/mixin';
|
import Mixin from '@ember/object/mixin';
|
||||||
|
|
||||||
const DEFAULT_TARGET_TYPE = 'none';
|
const DEFAULT_TARGET_TYPE = 'none';
|
||||||
export default Mixin.create({
|
export default Mixin.create({
|
||||||
// needs to override this type
|
// needs to override the type props
|
||||||
|
type: null,
|
||||||
|
|
||||||
scope: service(),
|
patch() {
|
||||||
globalStore: service(),
|
|
||||||
pageScope: alias('scope.currentPageScope'),
|
|
||||||
cluster: alias('scope.currentCluster'),
|
|
||||||
project: alias('scope.currentProject'),
|
|
||||||
modalService: service('modal'),
|
|
||||||
|
|
||||||
|
|
||||||
init(...args) {
|
|
||||||
this._super(...args);
|
|
||||||
const t = get(this, 'targetType');
|
const t = get(this, 'targetType');
|
||||||
|
const store = get(this, 'store');
|
||||||
|
|
||||||
const kafka = {
|
const nue = store.createRecord({
|
||||||
outputTags: null,
|
type: this.get('type'),
|
||||||
outputFlushInterval: 3,
|
|
||||||
config: {
|
|
||||||
topic: null,
|
|
||||||
// comma separated enpoints string
|
|
||||||
brokerEndpoints: null,
|
|
||||||
zookeeperEndpoint: null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const elasticsearch = {
|
|
||||||
outputTags: null,
|
|
||||||
outputFlushInterval: 3,
|
|
||||||
config: {
|
|
||||||
authUsername: null,
|
|
||||||
authPassword: null,
|
|
||||||
dateFormat: 'YYYY-MM-DD',
|
|
||||||
indexPrefix: null,
|
|
||||||
endpoint: null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const splunk = {
|
|
||||||
outputTags: null,
|
|
||||||
outputFlushInterval: 3,
|
|
||||||
config: {
|
|
||||||
endpoint: null,
|
|
||||||
source: null,
|
|
||||||
token: null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const embedded = {
|
|
||||||
outputTags: null,
|
|
||||||
outputFlushInterval: 3,
|
|
||||||
config: {
|
|
||||||
dateFormat: 'YYYY-MM-DD',
|
|
||||||
indexPrefix: null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const syslog = {
|
|
||||||
outputTags: null,
|
|
||||||
outputFlushInterval: 3,
|
|
||||||
config: {
|
|
||||||
severity: 'info',
|
|
||||||
program: null,
|
|
||||||
endpoint: null,
|
|
||||||
protocol: 'tcp',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
this.setProperties({
|
|
||||||
embedded,
|
|
||||||
elasticsearch,
|
|
||||||
splunk,
|
|
||||||
kafka,
|
|
||||||
syslog,
|
|
||||||
});
|
});
|
||||||
if (t && get(this, t)) {
|
|
||||||
|
const loggingTagets = [
|
||||||
|
'embedded',
|
||||||
|
'kafka',
|
||||||
|
'elasticsearch',
|
||||||
|
'splunk',
|
||||||
|
'syslog',
|
||||||
|
];
|
||||||
|
|
||||||
|
const map = {};
|
||||||
|
loggingTagets.forEach(key => {
|
||||||
|
const config = store.createRecord({
|
||||||
|
type: `${key}Config`
|
||||||
|
});
|
||||||
|
const clone = nue.clone();
|
||||||
|
clone.set('config', config);
|
||||||
|
map[key] = clone;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setProperties(map);
|
||||||
|
if (t && t !== 'none') {
|
||||||
set(this, `${t}.config`, get(this, `${t}Config`));
|
set(this, `${t}.config`, get(this, `${t}Config`));
|
||||||
set(this, `${t}.outputFlushInterval`, get(this, 'outputFlushInterval'));
|
set(this, `${t}.outputFlushInterval`, get(this, 'outputFlushInterval'));
|
||||||
set(this, `${t}.outputTags`, get(this, 'outputTags'));
|
set(this, `${t}.outputTags`, get(this, 'outputTags'));
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
targetType: function() {
|
targetType: function() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue