Skip to content

Commit

Permalink
Fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalita-lbl committed Dec 19, 2024
1 parent 6fa5340 commit 5358296
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 122 deletions.
2 changes: 1 addition & 1 deletion src/components/go-light-modal/light-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class LightModal {
// }

render() {
let classes = "modal-card";
const classes = "modal-card";
let styles = {};
if (this.x != -1 && this.y != -1) {
styles = { top: this.y + "px", left: this.x + "px" };
Expand Down
22 changes: 11 additions & 11 deletions src/components/go-ribbon-cell/ribbon-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class RibbonCell {
@Prop() hovered = false;

cellColor(nbClasses, nbAnnotations) {
var levels =
const levels =
this.colorBy == COLOR_BY.CLASS_COUNT ? nbClasses : nbAnnotations;
let newColor = heatColor(
levels,
Expand All @@ -106,8 +106,8 @@ export class RibbonCell {
this.binaryColor,
);
if (this.hovered) {
let tmp = newColor.replace(/[^\d,]/g, "").split(",");
let val = darken(tmp, 0.4);
const tmp = newColor.replace(/[^\d,]/g, "").split(",");
const val = darken(tmp, 0.4);
newColor = "rgb(" + val.join(",") + ")";
}
return newColor;
Expand All @@ -117,9 +117,9 @@ export class RibbonCell {
if (this.group.type == "GlobalAll") {
return this.subject.nb_classes;
}
let cellid =
const cellid =
this.group.id + (this.group.type == CELL_TYPES.OTHER ? "-other" : "");
let cell =
const cell =
cellid in this.subject.groups ? this.subject.groups[cellid] : undefined;
return cell ? cell["ALL"]["nb_classes"] : 0;
}
Expand All @@ -128,9 +128,9 @@ export class RibbonCell {
if (this.group.type == "GlobalAll") {
return this.subject.nb_annotations;
}
let cellid =
const cellid =
this.group.id + (this.group.type == CELL_TYPES.OTHER ? "-other" : "");
let cell =
const cell =
cellid in this.subject.groups ? this.subject.groups[cellid] : undefined;
return cell ? cell["ALL"]["nb_annotations"] : 0;
}
Expand All @@ -151,18 +151,18 @@ export class RibbonCell {

render() {
if (!this.available) {
let title =
const title =
this.subject.label + " can not have data for " + this.group.label;
let classes = "ribbon__subject--cell unavailable";
const classes = "ribbon__subject--cell unavailable";
return (
<td title={title} class={classes}>
{" "}
</td>
);
}

let nbClasses = this.getNbClasses();
let nbAnnotations = this.getNbAnnotations();
const nbClasses = this.getNbClasses();
const nbAnnotations = this.getNbAnnotations();

let title =
"Subject: " +
Expand Down
6 changes: 3 additions & 3 deletions src/components/go-ribbon-cell/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function darken(color, factor) {
var newColor = [...color];
const newColor = [...color];
for (let i = 0; i < newColor.length; i++) {
if (newColor[i] < 255) {
newColor[i] = Math.round(Math.max(0, newColor[i] * (1 - factor)));
Expand Down Expand Up @@ -34,11 +34,11 @@ export function heatColor(

// this is the log version for interpolation (better highlight the most annotated classes)
// note: safari needs integer and not float for rgb function
let fraction =
const fraction =
Math.min(10 * Math.log(level + 1), maxHeatLevel) / maxHeatLevel;

// there are some annotations and we want a continuous color (r, g, b)
let itemColor = []; // [r,g,b]
const itemColor = []; // [r,g,b]
itemColor[0] = Math.round(
minColor[0] + fraction * (maxColor[0] - minColor[0]),
);
Expand Down
91 changes: 47 additions & 44 deletions src/components/go-ribbon-strips/ribbon-strips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ export class RibbonStrips {
getGroup(group_id) {
if (!this.ribbonSummary) return null;
if (group_id == "all") return this.groupAll;
for (let cat of this.ribbonSummary.categories) {
for (let gp of cat.groups) {
for (const cat of this.ribbonSummary.categories) {
for (const gp of cat.groups) {
if (gp.id == group_id) return gp;
}
}
Expand Down Expand Up @@ -346,11 +346,11 @@ export class RibbonStrips {
this.formerColors = new Map();

// change header style
let el = this.ribbonElement.querySelector("#" + groupKey(group));
const el = this.ribbonElement.querySelector("#" + groupKey(group));
el.classList.add("selected");

for (let subject of subjects) {
let el = this.ribbonElement.querySelector(
for (const subject of subjects) {
const el = this.ribbonElement.querySelector(
"#" + subjectGroupKey(subject, group),
);
el.hovered = true;
Expand Down Expand Up @@ -386,18 +386,18 @@ export class RibbonStrips {
el.classList.add("selected");
}
}
let event: RibbonCellEvent = { subjects: subjects, group: group };
const event: RibbonCellEvent = { subjects: subjects, group: group };
this.cellEnter.emit(event);
}

onCellLeave(subjects, group) {
if (subjects instanceof Array) {
// change the header style
let el = this.ribbonElement.querySelector("#" + groupKey(group));
const el = this.ribbonElement.querySelector("#" + groupKey(group));
el.classList.remove("selected");

for (let subject of subjects) {
let el = this.ribbonElement.querySelector(
for (const subject of subjects) {
const el = this.ribbonElement.querySelector(
"#" + subjectGroupKey(subject, group),
);
el.hovered = false;
Expand All @@ -414,7 +414,7 @@ export class RibbonStrips {
el = this.ribbonElement.querySelector("#" + groupKey(group));
el.classList.remove("selected");
}
let event: RibbonCellEvent = { subjects: subjects, group: group };
const event: RibbonCellEvent = { subjects: subjects, group: group };
this.cellLeave.emit(event);
}

Expand All @@ -424,24 +424,24 @@ export class RibbonStrips {
subjects = [subjects];
}

let subs = subjects.map(
const subs = subjects.map(
(elt) => elt.id + "@" + group.id + "@" + group.type,
);
let prevSubs = this.previouslyHovered.map(
const prevSubs = this.previouslyHovered.map(
(elt) => elt.subject.id + "@" + elt.group.id + "@" + elt.group.type,
);
let same = sameArray(subs, prevSubs);
const same = sameArray(subs, prevSubs);

if (!same) {
for (let cell of this.previouslyHovered) {
for (const cell of this.previouslyHovered) {
cell.hovered = false;
}
}
this.previouslyHovered = [];

let hovered: boolean[] = [];
for (let subject of subjects) {
let cell = this.ribbonElement.querySelector(
const hovered: boolean[] = [];
for (const subject of subjects) {
const cell = this.ribbonElement.querySelector(
"#" + subjectGroupKey(subject, group),
);
cell.hovered = !cell.hovered;
Expand All @@ -457,25 +457,25 @@ export class RibbonStrips {
subjects = [subjects];
}

let subs = subjects.map(
const subs = subjects.map(
(elt) => elt.id + "@" + group.id + "@" + group.type,
);
let prevSubs = this.previouslySelected.map(
const prevSubs = this.previouslySelected.map(
(elt) => elt.subject.id + "@" + elt.group.id + "@" + elt.group.type,
);
let same = sameArray(subs, prevSubs);
const same = sameArray(subs, prevSubs);

if (!same) {
for (let cell of this.previouslySelected) {
for (const cell of this.previouslySelected) {
cell.selected = false;
}
}
this.previouslySelected = [];

let selected: boolean[] = [];
const selected: boolean[] = [];
let lastCell;
for (let subject of subjects) {
let cell = this.ribbonElement.querySelector(
for (const subject of subjects) {
const cell = this.ribbonElement.querySelector(
"#" + subjectGroupKey(subject, group),
);
cell.selected = toggle ? !cell.selected : true;
Expand All @@ -501,15 +501,15 @@ export class RibbonStrips {
let hasAnnotations = false;
// if single cell selection, check if it has annotations
if (this.selectionMode == SELECTION.CELL) {
let keys = Object.keys(subjects[0].groups);
for (let key of keys) {
const keys = Object.keys(subjects[0].groups);
for (const key of keys) {
if (subjects[0].groups[key]["ALL"].nb_annotations > 0)
hasAnnotations = true;
}

// if multiple cells selection, check if at least one has annotations
} else {
for (let sub of subjects) {
for (const sub of subjects) {
if (group.id == "all") {
hasAnnotations = hasAnnotations || sub.nb_annotations > 0;
} else {
Expand All @@ -525,9 +525,9 @@ export class RibbonStrips {
}
}

let selected = this.selectCells(subjects, group);
const selected = this.selectCells(subjects, group);

let event: RibbonCellClick = {
const event: RibbonCellClick = {
subjects: subjects,
group: group,
selected: selected,
Expand All @@ -537,13 +537,13 @@ export class RibbonStrips {

onGroupClick(category, group) {
this.selectCells(this.ribbonSummary.subjects, group);
let event = { category: category, group: group };
const event = { category: category, group: group };
this.groupClick.emit(event);
}

onGroupEnter(category, group) {
this.overCells(this.ribbonSummary.subjects, group);
let event: RibbonGroupEvent = {
const event: RibbonGroupEvent = {
subjects: this.ribbonSummary.subjects,
category: category,
group: group,
Expand All @@ -553,7 +553,7 @@ export class RibbonStrips {

onGroupLeave(category, group) {
this.overCells(this.ribbonSummary.subjects, group);
let event: RibbonGroupEvent = {
const event: RibbonGroupEvent = {
subjects: this.ribbonSummary.subjects,
category: category,
group: group,
Expand All @@ -562,14 +562,14 @@ export class RibbonStrips {
}

applyCategoryStyling(category) {
let cc0 = truncate(category, this.groupMaxLabelSize, "...");
let cc1 = this.applyCategoryCase(cc0);
let cc2 = this.applyCategoryBold(cc1);
const cc0 = truncate(category, this.groupMaxLabelSize, "...");
const cc1 = this.applyCategoryCase(cc0);
const cc2 = this.applyCategoryBold(cc1);
return cc2;
}

applyCategoryBold(category) {
let lc = category.toLowerCase();
const lc = category.toLowerCase();
if (lc.startsWith("all") && this.categoryAllStyle == FONT_STYLE.BOLD) {
return <b>{category}</b>;
}
Expand All @@ -592,7 +592,7 @@ export class RibbonStrips {
async selectGroup(group_id) {
setTimeout(() => {
if (group_id && this.ribbonSummary) {
let gp = this.getGroup(group_id);
const gp = this.getGroup(group_id);
if (gp) {
this.selectCells(this.ribbonSummary.subjects, gp, false);
} else {
Expand Down Expand Up @@ -623,7 +623,7 @@ export class RibbonStrips {
}

// API request done but not subject retrieved
let nbSubjects: number = this.ribbonSummary.subjects.length;
const nbSubjects: number = this.ribbonSummary.subjects.length;
if (nbSubjects == 0) {
return <div>Must provide at least one subject</div>;
}
Expand Down Expand Up @@ -683,7 +683,7 @@ export class RibbonStrips {
return;
}

let classes = this.groupClickable
const classes = this.groupClickable
? "ribbon__category--cell clickable"
: "ribbon__category--cell";
return (
Expand Down Expand Up @@ -725,7 +725,7 @@ export class RibbonStrips {

renderSubjects() {
return this.ribbonSummary.subjects.map((subject: RibbonSubject) => {
let subjects =
const subjects =
this.selectionMode == SELECTION.CELL
? subject
: this.ribbonSummary.subjects;
Expand Down Expand Up @@ -767,18 +767,21 @@ export class RibbonStrips {
return [
<td class="ribbon__subject--separator"></td>,
category.groups.map((group: RibbonGroup) => {
let cellid =
const cellid =
group.id + (group.type == CELL_TYPES.OTHER ? "-other" : "");
let cell =
const cell =
cellid in subject.groups ? subject.groups[cellid] : undefined;

let nbAnnotations = cell ? cell["ALL"]["nb_annotations"] : 0;
const nbAnnotations = cell ? cell["ALL"]["nb_annotations"] : 0;

// by default the group should be available
let available = true;

// if a value was given, then override the default value
if (cell && cell.hasOwnProperty("available")) {
if (
cell &&
Object.prototype.hasOwnProperty.call(cell, "available")
) {
available = cell.available;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/go-ribbon-subject/ribbon-subject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class RibbonSubject {
subjectClick: EventEmitter;

onSubjectClick(event, subject) {
let ev = { originalEvent: event, subject: subject };
const ev = { originalEvent: event, subject: subject };
this.subjectClick.emit(ev);
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/go-ribbon-subject/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function formatTaxonLabel(species) {
let split = species.split(" ");
const split = species.split(" ");
return split[0].substring(0, 1) + split[1].substring(0, 2);
}
Loading

0 comments on commit 5358296

Please sign in to comment.