mirror of
https://github.com/valitydev/redash.git
synced 2024-11-06 17:15:17 +00:00
switch underscore usages to lodash
There's still one usage of `numberFormat` from `underscore.string`.
This commit is contained in:
parent
c47ad93eb2
commit
d6011ede0c
@ -1,4 +1,4 @@
|
||||
import { contains, without, compact } from 'underscore';
|
||||
import { includes, without, compact } from 'lodash';
|
||||
import template from './alert-subscriptions.html';
|
||||
|
||||
function controller($scope, $q, $sce, currentUser, AlertSubscription, Destination, toastr) {
|
||||
@ -23,9 +23,9 @@ function controller($scope, $q, $sce, currentUser, AlertSubscription, Destinatio
|
||||
|
||||
const subscribedUsers = compact(subscribers.map(s => !s.destination && s.user.id));
|
||||
|
||||
$scope.destinations = destinations.filter(d => !contains(subscribedDestinations, d.id));
|
||||
$scope.destinations = destinations.filter(d => !includes(subscribedDestinations, d.id));
|
||||
|
||||
if (!contains(subscribedUsers, currentUser.id)) {
|
||||
if (!includes(subscribedUsers, currentUser.id)) {
|
||||
$scope.destinations.unshift({ user: { name: currentUser.name } });
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { debounce } from 'underscore';
|
||||
import { debounce } from 'lodash';
|
||||
import template from './add-widget-dialog.html';
|
||||
import './add-widget-dialog.less';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isEmpty } from 'underscore';
|
||||
import { isEmpty } from 'lodash';
|
||||
import template from './edit-dashboard-dialog.html';
|
||||
|
||||
const EditDashboardDialog = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import $ from 'jquery';
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import 'jquery-ui/ui/widgets/draggable';
|
||||
import 'jquery-ui/ui/widgets/droppable';
|
||||
import 'jquery-ui/ui/widgets/resizable';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import $ from 'jquery';
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import './gridstack';
|
||||
import './gridstack.less';
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { isUndefined, each, contains } from 'underscore';
|
||||
import endsWith from 'underscore.string/endsWith';
|
||||
import { isUndefined, each, includes } from 'lodash';
|
||||
import template from './dynamic-form.html';
|
||||
|
||||
function orderedInputs(properties, order) {
|
||||
@ -22,7 +21,7 @@ function normalizeSchema(configurationSchema) {
|
||||
prop.type = 'password';
|
||||
}
|
||||
|
||||
if (endsWith(name, 'File')) {
|
||||
if (name.endsWith('File')) {
|
||||
prop.type = 'file';
|
||||
}
|
||||
|
||||
@ -30,7 +29,7 @@ function normalizeSchema(configurationSchema) {
|
||||
prop.type = 'checkbox';
|
||||
}
|
||||
|
||||
prop.required = contains(configurationSchema.required, name);
|
||||
prop.required = includes(configurationSchema.required, name);
|
||||
});
|
||||
|
||||
configurationSchema.order = configurationSchema.order || [];
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { contains, identity } from 'underscore';
|
||||
import { includes, identity } from 'lodash';
|
||||
import { renderDefault, renderImage, renderLink } from './utils';
|
||||
import template from './template.html';
|
||||
|
||||
@ -26,7 +26,7 @@ export default function init(ngModule) {
|
||||
if ($scope.column.displayAs === 'string') {
|
||||
$scope.allowHTML = $scope.column.allowHTML;
|
||||
} else {
|
||||
$scope.allowHTML = contains(['image', 'link'], $scope.column.displayAs);
|
||||
$scope.allowHTML = includes(['image', 'link'], $scope.column.displayAs);
|
||||
}
|
||||
|
||||
const sanitize = $scope.allowHTML ? $sanitize : identity;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isFunction, extend } from 'underscore';
|
||||
import { isFunction, extend } from 'lodash';
|
||||
import { formatSimpleTemplate } from '@/lib/value-format';
|
||||
|
||||
function trim(str) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isFunction } from 'underscore';
|
||||
import { isFunction } from 'lodash';
|
||||
|
||||
export default function init(ngModule) {
|
||||
ngModule.directive('dynamicTableRow', () => ({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { find, filter, map, each } from 'underscore';
|
||||
import { find, filter, map, each } from 'lodash';
|
||||
import template from './dynamic-table.html';
|
||||
import './dynamic-table.less';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isUndefined, isString } from 'underscore';
|
||||
import { isUndefined, isString } from 'lodash';
|
||||
import renderJsonView from './json-view-interactive';
|
||||
import template from './template.html';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isFunction, isArray, isObject, isString, isNumber, isUndefined, each, keys, filter } from 'underscore';
|
||||
import { isFunction, isArray, isObject, isString, isNumber, isUndefined, each, keys, filter } from 'lodash';
|
||||
import $ from 'jquery';
|
||||
import './json-view-interactive.less';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import $ from 'jquery';
|
||||
import { isEmpty } from 'underscore';
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
// From: http://jsfiddle.net/joshdmiller/NDFHg/
|
||||
function EditInPlace() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { find } from 'underscore';
|
||||
import { find } from 'lodash';
|
||||
import template from './parameters.html';
|
||||
import queryBasedParameterTemplate from './query-based-parameter.html';
|
||||
import parameterSettingsTemplate from './parameter-settings.html';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { contains, each } from 'underscore';
|
||||
import { includes, each } from 'lodash';
|
||||
import template from './permissions-editor.html';
|
||||
|
||||
const PermissionsEditorComponent = {
|
||||
@ -40,7 +40,7 @@ const PermissionsEditorComponent = {
|
||||
if (this.foundUsers === undefined) {
|
||||
User.query((users) => {
|
||||
const existingIds = this.grantees.map(m => m.id);
|
||||
users.forEach((user) => { user.alreadyGrantee = contains(existingIds, user.id); });
|
||||
users.forEach((user) => { user.alreadyGrantee = includes(existingIds, user.id); });
|
||||
this.foundUsers = users;
|
||||
});
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import 'brace/mode/python';
|
||||
import 'brace/mode/sql';
|
||||
import 'brace/mode/json';
|
||||
import 'brace/ext/language_tools';
|
||||
import { map } from 'underscore';
|
||||
import { map } from 'lodash';
|
||||
|
||||
// By default Ace will try to load snippet files for the different modes and fail.
|
||||
// We don't need them, so we use these placeholders until we define our own.
|
||||
|
@ -1,5 +1,5 @@
|
||||
import moment from 'moment';
|
||||
import { map, range, partial, each, isArray } from 'underscore';
|
||||
import { map, range, partial, each, isArray } from 'lodash';
|
||||
import { durationHumanize } from '@/filters';
|
||||
|
||||
import template from './schedule-dialog.html';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { find } from 'underscore';
|
||||
import { find } from 'lodash';
|
||||
import logoUrl from '@/assets/images/redash_icon_small.png';
|
||||
import template from './visualization-embed.html';
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import settingsMenu from '@/lib/settings-menu';
|
||||
import startsWith from 'underscore.string/startsWith';
|
||||
import { isFunction } from 'underscore';
|
||||
import { isFunction } from 'lodash';
|
||||
import template from './settings-screen.html';
|
||||
|
||||
export default function init(ngModule) {
|
||||
@ -13,7 +12,7 @@ export default function init(ngModule) {
|
||||
if (isFunction(menuItem.isActive)) {
|
||||
return menuItem.isActive($location);
|
||||
}
|
||||
return startsWith($location.path(), menuItem.pathPrefix);
|
||||
return $location.path().startsWith(menuItem.pathPrefix);
|
||||
};
|
||||
this.isAvailable = permission => permission === undefined || currentUser.hasPermission(permission);
|
||||
},
|
||||
|
@ -1,11 +1,9 @@
|
||||
import startsWith from 'underscore.string/startsWith';
|
||||
|
||||
function controller($location) {
|
||||
this.tabs.forEach((tab) => {
|
||||
if (tab.isActive) {
|
||||
tab.active = tab.isActive($location.path());
|
||||
} else {
|
||||
tab.active = startsWith($location.path(), `/${tab.path}`);
|
||||
tab.active = $location.path().startsWith(`/${tab.path}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import 'angular-moment';
|
||||
import 'brace';
|
||||
import 'angular-ui-ace';
|
||||
import 'angular-resizable';
|
||||
import { each, isFunction, extend } from 'underscore';
|
||||
import { each, isFunction, extend } from 'lodash';
|
||||
|
||||
import '@/lib/sortable';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { find } from 'underscore';
|
||||
import { find } from 'lodash';
|
||||
|
||||
function sameNumber(a, b) {
|
||||
return (isNaN(a) && isNaN(b)) || (a === b);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as _ from 'underscore';
|
||||
import { findIndex } from 'lodash';
|
||||
|
||||
const items = new Map();
|
||||
|
||||
@ -35,7 +35,7 @@ function resizeEvent() {
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', () => {
|
||||
const index = _.findIndex(items, item => item.node === node);
|
||||
const index = findIndex(items, item => item.node === node);
|
||||
if (index >= 0) {
|
||||
items.splice(index, 1); // remove item
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import moment from 'moment';
|
||||
import _capitalize from 'underscore.string/capitalize';
|
||||
import { isEmpty } from 'underscore';
|
||||
import { capitalize as _capitalize, isEmpty } from 'lodash';
|
||||
|
||||
export function durationHumanize(duration) {
|
||||
let humanized = '';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { sortBy } from 'underscore';
|
||||
import { sortBy } from 'lodash';
|
||||
|
||||
export default class Paginator {
|
||||
constructor(rows, { page = 1, itemsPerPage = 20, totalCount = undefined } = {}) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { sortBy } from 'underscore';
|
||||
import { sortBy } from 'lodash';
|
||||
|
||||
const settingsMenu = {
|
||||
menus: [],
|
||||
|
@ -1,6 +1,6 @@
|
||||
import moment from 'moment/moment';
|
||||
import numeral from 'numeral';
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
|
||||
numeral.options.scalePercentBy100 = false;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import angular from 'angular';
|
||||
|
||||
const exitNode = '<<<Exit>>>';
|
||||
@ -285,7 +285,7 @@ function Sunburst(scope, element) {
|
||||
return {
|
||||
size: value[0].value,
|
||||
sequence: value[0].sequence,
|
||||
nodes: _.pluck(sorted, 'node'),
|
||||
nodes: _.map(sorted, i => i.node),
|
||||
};
|
||||
});
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { template as templateBuilder } from 'underscore';
|
||||
import { template as templateBuilder } from 'lodash';
|
||||
import template from './alert.html';
|
||||
|
||||
function AlertCtrl($routeParams, $location, $sce, toastr, currentUser, Query, Events, Alert) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { Paginator } from '@/lib/pagination';
|
||||
import template from './dashboard-list.html';
|
||||
@ -45,7 +45,7 @@ function DashboardListCtrl(Dashboard, $location) {
|
||||
this.showEmptyState = true;
|
||||
}
|
||||
const out = data.map(dashboard => dashboard.name.match(TAGS_REGEX));
|
||||
this.allTags = _.unique(_.flatten(out)).filter(e => e).map(tag => tag.replace(/:$/, ''));
|
||||
this.allTags = _.uniq(_.flatten(out)).filter(e => e).map(tag => tag.replace(/:$/, ''));
|
||||
this.allTags.sort();
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as _ from 'underscore';
|
||||
import * as _ from 'lodash';
|
||||
import PromiseRejectionError from '@/lib/promise-rejection-error';
|
||||
import { durationHumanize } from '@/filters';
|
||||
import template from './dashboard.html';
|
||||
|
@ -1,4 +1,3 @@
|
||||
import * as _ from 'underscore';
|
||||
import logoUrl from '@/assets/images/redash_icon_small.png';
|
||||
import template from './public-dashboard-page.html';
|
||||
import './dashboard.less';
|
||||
@ -11,7 +10,7 @@ const PublicDashboardPage = {
|
||||
controller(dashboardGridOptions, Dashboard) {
|
||||
'ngInject';
|
||||
|
||||
this.dashboardGridOptions = _.extend({}, dashboardGridOptions, {
|
||||
this.dashboardGridOptions = Object.assign({}, dashboardGridOptions, {
|
||||
resizable: { enabled: false },
|
||||
draggable: { enabled: false },
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { findWhere } from 'underscore';
|
||||
import { find } from 'lodash';
|
||||
import debug from 'debug';
|
||||
import template from './show.html';
|
||||
|
||||
@ -13,7 +13,7 @@ function DataSourceCtrl(
|
||||
$scope.dataSource = $route.current.locals.dataSource;
|
||||
$scope.dataSourceId = $routeParams.dataSourceId;
|
||||
$scope.types = $route.current.locals.types;
|
||||
$scope.type = findWhere($scope.types, { type: $scope.dataSource.type });
|
||||
$scope.type = find($scope.types, { type: $scope.dataSource.type });
|
||||
$scope.canChangeType = $scope.dataSource.id === undefined;
|
||||
|
||||
$scope.helpLinks = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import debug from 'debug';
|
||||
import { findWhere } from 'underscore';
|
||||
import { find } from 'lodash';
|
||||
import template from './show.html';
|
||||
|
||||
const logger = debug('redash:http');
|
||||
@ -13,7 +13,7 @@ function DestinationCtrl(
|
||||
$scope.destination = $route.current.locals.destination;
|
||||
$scope.destinationId = $routeParams.destinationId;
|
||||
$scope.types = $route.current.locals.types;
|
||||
$scope.type = findWhere($scope.types, { type: $scope.destination.type });
|
||||
$scope.type = find($scope.types, { type: $scope.destination.type });
|
||||
$scope.canChangeType = $scope.destination.id === undefined;
|
||||
|
||||
$scope.$watch('destination.id', (id) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { contains } from 'underscore';
|
||||
import { includes } from 'lodash';
|
||||
import template from './data-sources.html';
|
||||
|
||||
function GroupDataSourcesCtrl($scope, $routeParams, $http, Events, Group, DataSource) {
|
||||
@ -11,7 +11,7 @@ function GroupDataSourcesCtrl($scope, $routeParams, $http, Events, Group, DataSo
|
||||
if ($scope.foundDataSources === undefined) {
|
||||
DataSource.query((dataSources) => {
|
||||
const existingIds = $scope.dataSources.map(m => m.id);
|
||||
$scope.foundDataSources = dataSources.filter(ds => !contains(existingIds, ds.id));
|
||||
$scope.foundDataSources = dataSources.filter(ds => !includes(existingIds, ds.id));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { contains } from 'underscore';
|
||||
import { includes } from 'lodash';
|
||||
import template from './show.html';
|
||||
|
||||
function GroupCtrl($scope, $routeParams, $http, currentUser, Events, Group, User) {
|
||||
@ -17,7 +17,7 @@ function GroupCtrl($scope, $routeParams, $http, currentUser, Events, Group, User
|
||||
if ($scope.foundUsers === undefined) {
|
||||
User.query((users) => {
|
||||
const existingIds = $scope.members.map(m => m.id);
|
||||
users.forEach((user) => { user.alreadyMember = contains(existingIds, user.id); });
|
||||
users.forEach((user) => { user.alreadyMember = includes(existingIds, user.id); });
|
||||
$scope.foundUsers = users;
|
||||
});
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import moment from 'moment';
|
||||
import { isString } from 'underscore';
|
||||
import { isString } from 'lodash';
|
||||
|
||||
import { Paginator } from '@/lib/pagination';
|
||||
import template from './queries-search-results-page.html';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { pick, any, some, find, min, isObject } from 'underscore';
|
||||
import { pick, some, find, minBy, isObject } from 'lodash';
|
||||
import { SCHEMA_NOT_SUPPORTED, SCHEMA_LOAD_ERROR } from '@/services/data-source';
|
||||
import template from './query.html';
|
||||
|
||||
@ -98,7 +98,7 @@ function QueryViewCtrl(
|
||||
|
||||
$scope.dataSource = find(dataSources, ds => ds.id === $scope.query.data_source_id);
|
||||
|
||||
$scope.canCreateQuery = any(dataSources, ds => !ds.view_only);
|
||||
$scope.canCreateQuery = some(dataSources, ds => !ds.view_only);
|
||||
|
||||
getSchema();
|
||||
}
|
||||
@ -443,7 +443,7 @@ function QueryViewCtrl(
|
||||
(hash) => {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
const exists = find($scope.query.visualizations, item => item.id == hash);
|
||||
let visualization = min($scope.query.visualizations, viz => viz.id);
|
||||
let visualization = minBy($scope.query.visualizations, viz => viz.id);
|
||||
if (!isObject(visualization)) {
|
||||
visualization = {};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { filter } from 'underscore';
|
||||
import startsWith from 'underscore.string/startsWith';
|
||||
import settingsMenu from '@/lib/settings-menu';
|
||||
import { Paginator } from '@/lib/pagination';
|
||||
import template from './list.html';
|
||||
@ -51,7 +50,7 @@ export default function init(ngModule) {
|
||||
permission: 'list_users',
|
||||
title: 'Users',
|
||||
path: 'users',
|
||||
isActive: $location => startsWith($location.path(), '/users') && $location.path() !== '/users/me',
|
||||
isActive: $location => $location.path().startsWith('/users') && $location.path() !== '/users/me',
|
||||
order: 2,
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { each } from 'underscore';
|
||||
import { each } from 'lodash';
|
||||
import settingsMenu from '@/lib/settings-menu';
|
||||
import { absoluteUrl } from '@/services/utils';
|
||||
import template from './show.html';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
|
||||
function prepareWidgetsForDashboard(widgets) {
|
||||
// Default height for auto-height widgets.
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { debounce } from 'underscore';
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
function Events($http) {
|
||||
this.events = [];
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { each } from 'underscore';
|
||||
import { each } from 'lodash';
|
||||
import Mousetrap from 'mousetrap';
|
||||
import 'mousetrap/plugins/global-bind/mousetrap-global-bind';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import debug from 'debug';
|
||||
import moment from 'moment';
|
||||
import { sortBy, uniq, contains, values, some, each, isArray, isNumber, isString, includes } from 'underscore';
|
||||
import { sortBy, uniq, values, some, each, isArray, isNumber, isString, includes } from 'lodash';
|
||||
|
||||
const logger = debug('redash:services:QueryResult');
|
||||
const filterTypes = ['filter', 'multi-filter', 'multiFilter'];
|
||||
@ -23,7 +23,7 @@ function getColumnNameWithoutType(column) {
|
||||
return parts[1];
|
||||
}
|
||||
|
||||
if (!contains(filterTypes, parts[1])) {
|
||||
if (!includes(filterTypes, parts[1])) {
|
||||
return column;
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ function QueryResultService($resource, $timeout, $q) {
|
||||
this.getColumns().forEach((col) => {
|
||||
const name = col.name;
|
||||
const type = name.split('::')[1] || name.split('__')[1];
|
||||
if (contains(filterTypes, type)) {
|
||||
if (includes(filterTypes, type)) {
|
||||
// filter found
|
||||
const filter = {
|
||||
name,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import moment from 'moment';
|
||||
import debug from 'debug';
|
||||
import Mustache from 'mustache';
|
||||
import { each, object, isEmpty, pluck, filter, contains, union, uniq, has } from 'underscore';
|
||||
import { each, zipObject, isEmpty, map, filter, includes, union, uniq, has } from 'lodash';
|
||||
|
||||
const logger = debug('redash:services:query');
|
||||
|
||||
@ -103,7 +103,7 @@ class Parameters {
|
||||
} catch (e) {
|
||||
logger('Failed parsing parameters: ', e);
|
||||
// Return current parameters so we don't reset the list
|
||||
parameters = pluck(this.query.options.parameters, 'name');
|
||||
parameters = map(this.query.options.parameters, i => i.name);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
@ -135,7 +135,7 @@ class Parameters {
|
||||
}
|
||||
});
|
||||
|
||||
const parameterExists = p => contains(parameterNames, p.name);
|
||||
const parameterExists = p => includes(parameterNames, p.name);
|
||||
this.query.options.parameters = this.query.options.parameters
|
||||
.filter(parameterExists)
|
||||
.map(p => new Parameter(p));
|
||||
@ -156,7 +156,7 @@ class Parameters {
|
||||
}
|
||||
|
||||
getMissing() {
|
||||
return pluck(filter(this.get(), p => p.value === null || p.value === ''), 'title');
|
||||
return map(filter(this.get(), p => p.value === null || p.value === ''), i => i.title);
|
||||
}
|
||||
|
||||
isRequired() {
|
||||
@ -165,7 +165,7 @@ class Parameters {
|
||||
|
||||
getValues() {
|
||||
const params = this.get();
|
||||
return object(pluck(params, 'name'), pluck(params, 'value'));
|
||||
return zipObject(map(params, i => i.name), map(params, i => i.value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isArray, isString } from 'underscore';
|
||||
import { isArray, isString } from 'lodash';
|
||||
|
||||
function transformSingle(user) {
|
||||
if (user.groups !== undefined) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import moment from 'moment';
|
||||
import { truncate } from 'underscore.string';
|
||||
import { each, pick, extend, isObject } from 'underscore';
|
||||
import { each, pick, extend, isObject, truncate } from 'lodash';
|
||||
|
||||
function calculatePositionOptions(Visualization, dashboardGridOptions, widget) {
|
||||
widget.width = 1; // Backward compatibility, user on back-end
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {
|
||||
some, extend, defaults, has, partial, intersection, without, contains, isUndefined,
|
||||
sortBy, each, pluck, keys, difference,
|
||||
} from 'underscore';
|
||||
some, extend, defaults, has, partial, intersection, without, includes, isUndefined,
|
||||
sortBy, each, map, keys, difference,
|
||||
} from 'lodash';
|
||||
import template from './chart.html';
|
||||
import editorTemplate from './chart-editor.html';
|
||||
|
||||
@ -131,7 +131,7 @@ function ChartEditor(ColorPalette, clientConfig) {
|
||||
|
||||
function refreshColumns() {
|
||||
scope.columns = scope.queryResult.getColumns();
|
||||
scope.columnNames = pluck(scope.columns, 'name');
|
||||
scope.columnNames = map(scope.columns, i => i.name);
|
||||
if (scope.columnNames.length > 0) {
|
||||
each(difference(keys(scope.options.columnMapping), scope.columnNames), (column) => {
|
||||
delete scope.options.columnMapping[column];
|
||||
@ -147,16 +147,16 @@ function ChartEditor(ColorPalette, clientConfig) {
|
||||
return;
|
||||
}
|
||||
scope.form.yAxisColumns = intersection(scope.form.yAxisColumns, scope.columnNames);
|
||||
if (!contains(scope.columnNames, scope.form.xAxisColumn)) {
|
||||
if (!includes(scope.columnNames, scope.form.xAxisColumn)) {
|
||||
scope.form.xAxisColumn = undefined;
|
||||
}
|
||||
if (!contains(scope.columnNames, scope.form.groupby)) {
|
||||
if (!includes(scope.columnNames, scope.form.groupby)) {
|
||||
scope.form.groupby = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function refreshSeries() {
|
||||
const seriesNames = pluck(scope.queryResult.getChartData(scope.options.columnMapping), 'name');
|
||||
const seriesNames = map(scope.queryResult.getChartData(scope.options.columnMapping), i => i.name);
|
||||
const existing = keys(scope.options.seriesOptions);
|
||||
each(difference(seriesNames, existing), (name) => {
|
||||
scope.options.seriesOptions[name] = {
|
||||
@ -256,7 +256,7 @@ function ChartEditor(ColorPalette, clientConfig) {
|
||||
|
||||
if (scope.columnNames) {
|
||||
each(scope.options.columnMapping, (value, key) => {
|
||||
if (scope.columnNames.length > 0 && !contains(scope.columnNames, key)) {
|
||||
if (scope.columnNames.length > 0 && !includes(scope.columnNames, key)) {
|
||||
return;
|
||||
}
|
||||
if (value === 'x') {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { each, debounce, isArray, isObject } from 'underscore';
|
||||
import { each, debounce, isArray, isObject } from 'lodash';
|
||||
|
||||
import Plotly from 'plotly.js/lib/core';
|
||||
import bar from 'plotly.js/lib/bar';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {
|
||||
isArray, isNumber, isString, isUndefined, contains, min, max, has, find,
|
||||
each, values, sortBy, pluck, identity, filter, map, extend, reduce,
|
||||
} from 'underscore';
|
||||
isArray, isNumber, isString, isUndefined, includes, min, max, has, find,
|
||||
each, values, sortBy, identity, filter, map, extend, reduce,
|
||||
} from 'lodash';
|
||||
import moment from 'moment';
|
||||
import { createFormatter, formatSimpleTemplate } from '@/lib/value-format';
|
||||
|
||||
@ -177,7 +177,7 @@ function calculateDimensions(series, options) {
|
||||
const xPadding = 0.02;
|
||||
const yPadding = 0.1;
|
||||
|
||||
const hasX = contains(values(options.columnMapping), 'x');
|
||||
const hasX = includes(values(options.columnMapping), 'x');
|
||||
const hasY2 = !!find(series, (serie) => {
|
||||
const seriesOptions = options.seriesOptions[serie.name] || { type: options.globalSeriesType };
|
||||
return (seriesOptions.yAxis === 1) && (
|
||||
@ -251,7 +251,7 @@ function preparePieData(seriesList, options) {
|
||||
});
|
||||
|
||||
return {
|
||||
values: pluck(serie.data, 'y'),
|
||||
values: map(serie.data, i => i.y),
|
||||
labels: map(serie.data, row => (hasX ? normalizeValue(row.x) : `Slice ${index}`)),
|
||||
type: 'pie',
|
||||
hole: 0.4,
|
||||
@ -356,7 +356,7 @@ function prepareChartData(seriesList, options) {
|
||||
|
||||
if (seriesOptions.type === 'bubble') {
|
||||
plotlySeries.marker = {
|
||||
size: pluck(data, 'size'),
|
||||
size: map(data, i => i.size),
|
||||
};
|
||||
} else if (seriesOptions.type === 'box') {
|
||||
plotlySeries.boxpoints = 'outliers';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import L from 'leaflet';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import { formatSimpleTemplate } from '@/lib/value-format';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import chroma from 'chroma-js';
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import { createFormatter } from '@/lib/value-format';
|
||||
|
||||
export const AdditionalColors = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* global Cornelius */
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
import 'cornelius/src/cornelius';
|
||||
import 'cornelius/src/cornelius.css';
|
||||
@ -43,7 +43,7 @@ function groupData(sortedData) {
|
||||
function prepareDiagonalData(sortedData, options) {
|
||||
const timeInterval = options.timeInterval;
|
||||
const grouped = groupData(sortedData);
|
||||
const firstStage = _.min(_.pluck(sortedData, 'stage'));
|
||||
const firstStage = _.min(_.map(sortedData, i => i.stage));
|
||||
const stageCount = moment(_.last(grouped).date).diff(_.first(grouped).date, momentInterval[timeInterval]);
|
||||
let lastStage = firstStage + stageCount;
|
||||
|
||||
@ -83,7 +83,7 @@ function prepareDiagonalData(sortedData, options) {
|
||||
function prepareSimpleData(sortedData, options) {
|
||||
const timeInterval = options.timeInterval;
|
||||
const grouped = groupData(sortedData);
|
||||
const stages = _.pluck(sortedData, 'stage');
|
||||
const stages = _.map(sortedData, i => i.stage);
|
||||
const firstStage = _.min(stages);
|
||||
const lastStage = _.max(stages);
|
||||
|
||||
@ -150,12 +150,12 @@ function cohortRenderer() {
|
||||
return;
|
||||
}
|
||||
|
||||
const columnNames = _.pluck($scope.queryResult.getColumns(), 'name');
|
||||
const columnNames = _.map($scope.queryResult.getColumns(), i => i.name);
|
||||
if (
|
||||
!_.contains(columnNames, $scope.options.dateColumn) ||
|
||||
!_.contains(columnNames, $scope.options.stageColumn) ||
|
||||
!_.contains(columnNames, $scope.options.totalColumn) ||
|
||||
!_.contains(columnNames, $scope.options.valueColumn)
|
||||
!_.includes(columnNames, $scope.options.dateColumn) ||
|
||||
!_.includes(columnNames, $scope.options.stageColumn) ||
|
||||
!_.includes(columnNames, $scope.options.totalColumn) ||
|
||||
!_.includes(columnNames, $scope.options.valueColumn)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@ -199,7 +199,7 @@ function cohortEditor() {
|
||||
|
||||
function refreshColumns() {
|
||||
$scope.columns = $scope.queryResult.getColumns();
|
||||
$scope.columnNames = _.pluck($scope.columns, 'name');
|
||||
$scope.columnNames = _.map($scope.columns, i => i.name);
|
||||
}
|
||||
|
||||
refreshColumns();
|
||||
|
@ -1,5 +1,5 @@
|
||||
import numberFormat from 'underscore.string/numberFormat';
|
||||
import * as _ from 'underscore';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import counterTemplate from './counter.html';
|
||||
import counterEditorTemplate from './counter-editor.html';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { pluck } from 'underscore';
|
||||
import { map } from 'lodash';
|
||||
import { copy } from 'angular';
|
||||
import template from './edit-visualization-dialog.html';
|
||||
|
||||
@ -60,7 +60,7 @@ const EditVisualizationDialog = {
|
||||
Visualization.save(this.visualization, (result) => {
|
||||
toastr.success('Visualization saved');
|
||||
|
||||
const visIds = pluck(this.query.visualizations, 'id');
|
||||
const visIds = map(this.query.visualizations, i => i.id);
|
||||
const index = visIds.indexOf(result.id);
|
||||
if (index > -1) {
|
||||
this.query.visualizations[index] = result;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { debounce, sortBy, isNumber, every, difference } from 'underscore';
|
||||
import { debounce, sortBy, isNumber, every, difference } from 'lodash';
|
||||
import d3 from 'd3';
|
||||
import angular from 'angular';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import moment from 'moment';
|
||||
import { isArray, reduce } from 'underscore';
|
||||
import { isArray, reduce } from 'lodash';
|
||||
|
||||
function VisualizationProvider() {
|
||||
this.visualizations = {};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import d3 from 'd3';
|
||||
import L from 'leaflet';
|
||||
import 'leaflet.markercluster';
|
||||
@ -193,7 +193,7 @@ function mapRenderer() {
|
||||
return { color: colorScale(group) };
|
||||
});
|
||||
|
||||
$scope.visualization.options.groups = _.object(groupNames, options);
|
||||
$scope.visualization.options.groups = _.zipObject(groupNames, options);
|
||||
|
||||
_.each(layers, (v) => {
|
||||
removeLayer(v);
|
||||
@ -224,7 +224,7 @@ function mapEditor() {
|
||||
link($scope) {
|
||||
$scope.currentTab = 'general';
|
||||
$scope.columns = $scope.queryResult.getColumns();
|
||||
$scope.columnNames = _.pluck($scope.columns, 'name');
|
||||
$scope.columnNames = _.map($scope.columns, i => i.name);
|
||||
$scope.classify_columns = $scope.columnNames.concat('none');
|
||||
$scope.mapTiles = [
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
import angular from 'angular';
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import d3 from 'd3';
|
||||
|
||||
import d3sankey from '@/lib/visualizations/d3sankey';
|
||||
@ -169,20 +169,20 @@ function createSankey(element, data) {
|
||||
|
||||
function nodeMouseOver(currentNode) {
|
||||
let nodes = getConnectedNodes(currentNode);
|
||||
nodes = _.pluck(nodes, 'id');
|
||||
nodes = _.map(nodes, i => i.id);
|
||||
node.filter((d) => {
|
||||
if (d === currentNode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_.contains(nodes, d.id)) {
|
||||
if (_.includes(nodes, d.id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}).style('opacity', 0.2);
|
||||
link.filter(l =>
|
||||
!(_.include(currentNode.sourceLinks, l) || _.include(currentNode.targetLinks, l))).style('opacity', 0.2);
|
||||
!(_.includes(currentNode.sourceLinks, l) || _.includes(currentNode.targetLinks, l))).style('opacity', 0.2);
|
||||
}
|
||||
|
||||
function nodeMouseOut() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { debounce } from 'underscore';
|
||||
import { debounce } from 'lodash';
|
||||
import Sunburst from '@/lib/visualizations/sunburst';
|
||||
import editorTemplate from './sunburst-sequence-editor.html';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import { getColumnCleanName } from '@/services/query-result';
|
||||
import { createFormatter } from '@/lib/value-format';
|
||||
import template from './table.html';
|
||||
@ -104,12 +104,12 @@ function getColumnsOptions(columns, visualizationColumns) {
|
||||
const options = getDefaultColumnsOptions(columns);
|
||||
|
||||
if ((wereColumnsReordered(columns, visualizationColumns))) {
|
||||
visualizationColumns = _.object(_.map(
|
||||
visualizationColumns = _.fromPairs(_.map(
|
||||
visualizationColumns,
|
||||
(col, index) => [col.name, _.extend({}, col, { order: index })],
|
||||
));
|
||||
} else {
|
||||
visualizationColumns = _.object(_.map(
|
||||
visualizationColumns = _.fromPairs(_.map(
|
||||
visualizationColumns,
|
||||
col => [col.name, _.omit(col, 'order')],
|
||||
));
|
||||
@ -121,7 +121,7 @@ function getColumnsOptions(columns, visualizationColumns) {
|
||||
}
|
||||
|
||||
function getColumnsToDisplay(columns, options, clientConfig) {
|
||||
columns = _.object(_.map(columns, col => [col.name, col]));
|
||||
columns = _.fromPairs(_.map(columns, col => [col.name, col]));
|
||||
let result = _.map(options, col => _.extend(
|
||||
getDefaultFormatOptions(col, clientConfig),
|
||||
col,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import d3 from 'd3';
|
||||
import angular from 'angular';
|
||||
import cloud from 'd3-cloud';
|
||||
import { each } from 'underscore';
|
||||
import { each } from 'lodash';
|
||||
|
||||
import editorTemplate from './word-cloud-editor.html';
|
||||
|
||||
|
@ -72,7 +72,6 @@
|
||||
"react-dom": "^16.3.2",
|
||||
"react2angular": "^3.2.1",
|
||||
"ui-select": "^0.19.8",
|
||||
"underscore": "^1.8.3",
|
||||
"underscore.string": "^3.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user