Compare commits

...

15 Commits

Author SHA1 Message Date
d7ff80bf4f resolved merge conflicts 2020-04-23 13:56:11 -07:00
6170b51548 replaced flatten, throttle with native implementation, added linter for unnecessary lodash methods 2020-04-23 13:54:35 -07:00
c1d0a6b4f3 implemented find, findIndex natively 2020-04-23 08:36:19 -07:00
eb5050b8ef added you-dont-need-lodash linter 2020-04-22 16:23:04 -07:00
b66a599c69 Merge branch 'lodash-upgrade-test' of https://github.com/nasa/openmct into lodash-upgrade-test 2020-04-22 15:26:56 -07:00
835bcbcb5a native implementations as requested 2020-04-22 15:26:08 -07:00
40c9546415 Merge branch 'master' into lodash-upgrade-test 2020-04-21 10:51:15 -07:00
0622dbe78c added lodash/prefer-is-nil linter restriction and reverted changes to PlotYAxisFormController 2020-04-09 13:02:14 -07:00
2b96a8994c Merge branch 'lodash-upgrade-test' of https://github.com/nasa/openmct into lodash-upgrade-test 2020-04-09 11:54:52 -07:00
5efa7f69e4 added lodash/prefer-get exclusion 2020-04-09 11:54:00 -07:00
33bb1c202e Merge branch 'master' into lodash-upgrade-test 2020-04-09 11:49:39 -07:00
d73e9f6dae fixed issues cuaght by circle-ci 2020-04-08 15:52:59 -07:00
691742d8f0 working on circle-ci lint errors 2020-04-08 14:19:31 -07:00
ef4312e29a completed changes to support upgrade to lodash v4.17.12 2020-04-07 16:21:49 -07:00
09cfe4f99a upgraded lodash, changed method names 2020-04-07 12:02:49 -07:00
12 changed files with 59 additions and 25 deletions

View File

@ -12,7 +12,8 @@ module.exports = {
"extends": [
"eslint:recommended",
"plugin:vue/recommended",
"plugin:lodash/recommended"
"plugin:lodash/recommended",
"plugin:you-dont-need-lodash-underscore/compatible"
],
"parser": "vue-eslint-parser",
"parserOptions": {
@ -24,6 +25,7 @@ module.exports = {
}
},
"rules": {
"you-dont-need-lodash-underscore/omit": "off",
"lodash/prefer-lodash-method": "off",
"lodash/prefer-lodash-typecheck": "off",
"lodash/prefer-constant": "off",

View File

@ -25,6 +25,7 @@
"eslint": "5.2.0",
"eslint-plugin-lodash": "^6.0.0",
"eslint-plugin-vue": "^6.0.0",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.10.0",
"eventemitter3": "^1.2.0",
"exports-loader": "^0.7.0",
"express": "^4.13.1",

View File

@ -20,7 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['lodash'], function (_) {
define([], function (_) {
/**
* The ExportAsJSONAction is available from context menus and allows a user
@ -121,8 +121,8 @@ define(['lodash'], function (_) {
*/
ExportAsJSONAction.prototype.rewriteLink = function (child, parent) {
this.externalIdentifiers.push(this.getId(child));
var index = _.findIndex(parent.composition, function (id) {
return _.isEqual(child.identifier, id);
var index = parent.composition.findIndex(function (id) {
return JSON.stringify(child.identifier) === JSON.stringify(id);
});
var copyOfChild = this.copyObject(child);
copyOfChild.identifier.key = this.identifierService.generate();

View File

@ -25,8 +25,7 @@
* Module defining GenericSearchProvider. Created by shale on 07/16/2015.
*/
define([
'../../../../src/api/objects/object-utils',
'lodash'
'../../../../src/api/objects/object-utils'
], function (
objectUtils,
_
@ -191,9 +190,7 @@ define([
}
var domainObject = objectUtils.toNewFormat(model, id);
var composition = _.find(this.openmct.composition.registry, function (p) {
return p.appliesTo(domainObject);
});
var composition = this.openmct.composition.registry.find(p => p.appliesTo(domainObject));
if (!composition) {
return;

View File

@ -75,7 +75,7 @@ export default {
this.items.push(item);
},
removeItem(identifier) {
let index = _.findIndex(this.items, (item) => this.openmct.objects.makeKeyString(identifier) === item.key);
let index = this.items.findIndex(item => this.openmct.objects.makeKeyString(identifier) === item.key);
this.items.splice(index, 1);
},

View File

@ -102,7 +102,7 @@ export default {
this.compositions.push({composition, addCallback, removeCallback});
},
removePrimary(identifier) {
let index = _.findIndex(this.primaryTelemetryObjects, (primary) => this.openmct.objects.makeKeyString(identifier) === primary.key),
let index = this.primaryTelemetryObjects.findIndex(primary => this.openmct.objects.makeKeyString(identifier) === primary.key),
primary = this.primaryTelemetryObjects[index];
this.$set(this.secondaryTelemetryObjects, primary.key, undefined);
@ -130,7 +130,7 @@ export default {
removeSecondary(primary) {
return (identifier) => {
let array = this.secondaryTelemetryObjects[primary.key],
index = _.findIndex(array, (secondary) => this.openmct.objects.makeKeyString(identifier) === secondary.key);
index = array.findIndex(secondary => this.openmct.objects.makeKeyString(identifier) === secondary.key);
array.splice(index, 1);

View File

@ -197,7 +197,7 @@ export default {
this.$emit('telemetryUpdated', this.telemetryObjs);
},
removeTelemetryObject(identifier) {
let index = _.findIndex(this.telemetryObjs, (obj) => {
let index = this.telemetryObjs.findIndex(obj => {
let objId = this.openmct.objects.makeKeyString(obj.identifier);
let id = this.openmct.objects.makeKeyString(identifier);
return objId === id;

View File

@ -68,7 +68,6 @@
<script>
import uuid from 'uuid';
import SubobjectView from './SubobjectView.vue'
import TelemetryView from './TelemetryView.vue'
import BoxView from './BoxView.vue'
@ -375,7 +374,9 @@ export default {
indices.push(selectedItem[0].context.index);
this.untrackItem(selectedItem[0].context.layoutItem);
});
_.pullAt(this.layoutItems, indices);
while(indices.length) {
this.layoutItems.splice(indices.pop(), 1);
}
this.mutate("configuration.items", this.layoutItems);
this.$el.click();
},
@ -512,7 +513,7 @@ export default {
}
},
updateTelemetryFormat(item, format) {
let index = _.findIndex(this.layoutItems, item);
let index = this.layoutItems.findIndex(item);
item.format = format;
this.mutate(`configuration.items[${index}]`, item);
}

View File

@ -55,6 +55,7 @@ export default {
},
computed: {
hasActiveFilters() {
console.log('hasActiveFilters');
// Should be true when the user has entered any filter values.
return Object.values(this.persistedFilters).some(filters => {
return Object.values(filters).some(comparator => {
@ -63,6 +64,7 @@ export default {
});
},
hasMixedFilters() {
console.log('hasMixedFilters')
// Should be true when filter values are mixed.
let filtersToCompare = _.omit(this.persistedFilters[Object.keys(this.persistedFilters)[0]], [USE_GLOBAL]);
return Object.values(this.persistedFilters).some(filters => {
@ -70,6 +72,7 @@ export default {
});
},
label() {
console.log('label');
if (this.hasActiveFilters) {
if (this.hasMixedFilters) {
return FILTER_VIEW_TITLE_MIXED;

View File

@ -111,7 +111,6 @@ import SearchResults from './search-results.vue';
import Sidebar from './sidebar.vue';
import { clearDefaultNotebook, getDefaultNotebook, setDefaultNotebook, setDefaultNotebookSection, setDefaultNotebookPage } from '../utils/notebook-storage';
import { addNotebookEntry, createNewEmbed, getNotebookEntries } from '../utils/notebook-entries';
import { throttle } from 'lodash';
const DEFAULT_CLASS = 'is-notebook-default';
@ -175,7 +174,7 @@ export default {
watch: {
},
beforeMount() {
this.throttledSearchItem = throttle(this.searchItem, 500);
this.throttledSearchItem = this.throttle(this.searchItem, 500);
},
mounted() {
this.unlisten = this.openmct.objects.observe(this.internalDomainObject, '*', this.updateInternalDomainObject);
@ -195,6 +194,16 @@ export default {
})
},
methods: {
throttle(func, timeFrame) {
let lastTime = 0;
return function () {
let now = new Date();
if (now - lastTime >= timeFrame) {
func();
lastTime = now;
}
};
},
addDefaultClass() {
const classList = this.internalDomainObject.classList || [];
if (classList.includes(DEFAULT_CLASS)) {

View File

@ -77,7 +77,7 @@ export default {
}
});
names = _.flatten(names);
names.reduce((a, b) => a.concat(b), []);
this.filterNames = names.length === 0 ? names : Array.from(new Set(names));
});
},
@ -99,7 +99,7 @@ export default {
}
});
return _.flatten(filterNames);
return filterNames.reduce((a, b) => a.concat(b), []);
},
getFilterLabels(filterObject, metadatum,) {
let filterLabels = [];

View File

@ -260,7 +260,6 @@ import search from '../../../ui/components/search.vue';
import TableColumnHeader from './table-column-header.vue';
import TelemetryFilterIndicator from './TelemetryFilterIndicator.vue';
import CSVExporter from '../../../exporters/CSVExporter.js';
import _ from 'lodash';
import ToggleSwitch from '../../../ui/components/ToggleSwitch.vue';
const VISIBLE_ROW_COUNT = 100;
@ -378,13 +377,13 @@ export default {
}
},
created() {
this.filterChanged = _.debounce(this.filterChanged, 500);
this.filterChanged = this.debounce(this.filterChanged, 500);
},
mounted() {
this.csvExporter = new CSVExporter();
this.rowsAdded = _.throttle(this.rowsAdded, 200);
this.rowsRemoved = _.throttle(this.rowsRemoved, 200);
this.scroll = _.throttle(this.scroll, 100);
this.rowsAdded = this.throttle(this.rowsAdded, 200);
this.rowsRemoved = this.throttle(this.rowsRemoved, 200);
this.scroll = this.throttle(this.scroll, 100);
this.table.on('object-added', this.addObject);
this.table.on('object-removed', this.removeObject);
@ -432,6 +431,28 @@ export default {
this.table.destroy();
},
methods: {
debounce(func, wait, immediate) {
let timeout;
return function () {
let context = this, args = arguments;
clearTimeout(timeout);
timeout = setTimeout(function () {
timeout = null;
if (!immediate) { func.apply(context, args) }
}, wait);
if (immediate && !timeout) { func.apply(context, args) }
};
},
throttle(func, timeFrame) {
let lastTime = 0;
return function () {
let now = new Date();
if (now - lastTime >= timeFrame) {
func();
lastTime = now;
}
};
},
updateVisibleRows() {
if (!this.updatingView) {
this.updatingView = true;