const format_various_diff = (diff, attrs) => ( `<table border="1"> <tr><th>Champ modifié</th><th>Ancienne valeur</th><th>Nouvelle valeur</th></tr> ` + map(diff, ({ prev, current }, key) => { const opts = { ...client_conf.default_attrs_opts[key], ...attrs[key] }; return ' <tr>' + [opts && opts.title || key, prev || '<i>aucune</i>', current || '<i>supprimée</i>'].map(s => `<td>${s}</td>`).join('') + '</tr>' }).join("\n") + ` </table>` );
return _.flatten(_.map(a, function(x) { return _.map(b, function(y) { return _.concat(x,[y]); }); }), true);
_.map(old.rows, row => { return _.map(row.panels, 'id'); })
const responseTransform = result => { return _.map(result, value => { return { text: value }; }); };
.map(indices=>_.map(indices,i=>obj[i]))
addHistogram(data) { const xBucket = this.scope.ctrl.data.buckets[data.x]; const yBucketSize = this.scope.ctrl.data.yBucketSize; let min, max, ticks; if (this.scope.ctrl.data.tsBuckets) { min = 0; max = this.scope.ctrl.data.tsBuckets.length - 1; ticks = this.scope.ctrl.data.tsBuckets.length; } else { min = this.scope.ctrl.data.yAxis.min; max = this.scope.ctrl.data.yAxis.max; ticks = this.scope.ctrl.data.yAxis.ticks; } let histogramData = _.map(xBucket.buckets, bucket => { const count = bucket.count !== undefined ? bucket.count : bucket.values.length; return [bucket.bounds.bottom, count]; }); histogramData = _.filter(histogramData, d => { return d[0] >= min && d[0] <= max; }); const scale = this.scope.yScale.copy(); const histXScale = scale.domain([min, max]).range([0, HISTOGRAM_WIDTH]); let barWidth; if (this.panel.yAxis.logBase === 1) { barWidth = Math.floor(HISTOGRAM_WIDTH / (max - min) * yBucketSize * 0.9); } else { const barNumberFactor = yBucketSize ? yBucketSize : 1; barWidth = Math.floor(HISTOGRAM_WIDTH / ticks / barNumberFactor * 0.9); } barWidth = Math.max(barWidth, 1); // Normalize histogram Y axis const histogramDomain = _.reduce(_.map(histogramData, d => d[1]), (sum, val) => sum + val, 0); const histYScale = d3 .scaleLinear() .domain([0, histogramDomain]) .range([0, HISTOGRAM_HEIGHT]); const histogram = this.tooltip .select('.heatmap-histogram') .append('svg') .attr('width', HISTOGRAM_WIDTH) .attr('height', HISTOGRAM_HEIGHT); histogram .selectAll('.bar') .data(histogramData) .enter() .append('rect') .attr('x', d => { return histXScale(d[0]); }) .attr('width', barWidth) .attr('y', d => { return HISTOGRAM_HEIGHT - histYScale(d[1]); }) .attr('height', d => { return histYScale(d[1]); }); }
controller: function($scope, $uibModalInstance, Oppiaineet, OsanMuokkausHelper) { $scope.kohdealueet = _.map( _.clone(OsanMuokkausHelper.getOppiaine().kohdealueet) || [], function(ka: any) { ka.$vanhaNimi = _.clone(ka.nimi); return ka; } ); $scope.poistaKohdealue = function(ka) { Oppiaineet.poistaKohdealue( { perusteId: ProxyService.get("perusteId"), osanId: OsanMuokkausHelper.getOppiaine().id, kohdealueId: ka.id }, function() { _.remove($scope.kohdealueet, ka); }, Notifikaatiot.serverCb ); }; $scope.lisaaKohdealue = function() { Oppiaineet.lisaaKohdealue( { perusteId: ProxyService.get("perusteId"), osanId: OsanMuokkausHelper.getOppiaine().id }, { nimi: { fi: "Uusi tavoitealue" } }, function(res) { $scope.kohdealueet.push(res); } ); }; $scope.ok = function(kohdealueet) { $q .all( _(kohdealueet) .reject(function(ka) { return _.isEqual(ka.nimi, ka.$vanhaNimi); }) .map(function(ka) { return Oppiaineet.lisaaKohdealue( { perusteId: ProxyService.get("perusteId"), osanId: OsanMuokkausHelper.getOppiaine().id }, ka ).$promise; }) .value() ) .then( Oppiaineet.kohdealueet( { perusteId: ProxyService.get("perusteId"), osanId: OsanMuokkausHelper.getOppiaine().id }, $uibModalInstance.close ) ); }; }
return this.get('/_mapping').then(function(result) { var typeMap = { 'float': 'number', 'double': 'number', 'integer': 'number', 'long': 'number', 'date': 'date', 'string': 'string', 'text': 'string', 'scaled_float': 'number', 'nested': 'nested' }; function shouldAddField(obj, key, query) { if (key[0] === '_') { return false; } if (!query.type) { return true; } // equal query type filter, or via typemap translation return query.type === obj.type || query.type === typeMap[obj.type]; } // Store subfield names: [system, process, cpu, total] -> system.process.cpu.total var fieldNameParts = []; var fields = {}; function getFieldsRecursively(obj) { for (var key in obj) { var subObj = obj[key]; // Check mapping field for nested fields if (_.isObject(subObj.properties)) { fieldNameParts.push(key); getFieldsRecursively(subObj.properties); } if (_.isObject(subObj.fields)) { fieldNameParts.push(key); getFieldsRecursively(subObj.fields); } if (_.isString(subObj.type)) { var fieldName = fieldNameParts.concat(key).join('.'); // Hide meta-fields and check field type if (shouldAddField(subObj, key, query)) { fields[fieldName] = { text: fieldName, type: subObj.type }; } } } fieldNameParts.pop(); } for (var indexName in result) { var index = result[indexName]; if (index && index.mappings) { var mappings = index.mappings; for (var typeName in mappings) { var properties = mappings[typeName].properties; getFieldsRecursively(properties); } } } // transform to array return _.map(fields, function(value) { return value; }); });
var ticks = _.map(data, function(series, seriesIndex) { return _.map(series.datapoints, function(point, pointIndex) { var tickIndex = seriesIndex * series.datapoints.length + pointIndex; return [tickIndex + 1, point[1]]; }); });
// Get minimum non zero value. function getMinLog(series) { let values = _.compact(_.map(series.datapoints, p => p[0])); return _.min(values); }