From cc41ab5f9fdab22c1959fbd72a00764ef0485a1b Mon Sep 17 00:00:00 2001 From: futa-ikeda Date: Tue, 12 Nov 2024 12:16:12 -0500 Subject: [PATCH] Remove old components --- .../departments-panel/component.ts | 75 ------------------- .../-components/departments-panel/styles.scss | 16 ---- .../departments-panel/template.hbs | 20 ----- .../-components/projects-panel/component.ts | 47 ------------ .../-components/projects-panel/styles.scss | 13 ---- .../-components/projects-panel/template.hbs | 25 ------- 6 files changed, 196 deletions(-) delete mode 100644 app/institutions/dashboard/-components/departments-panel/component.ts delete mode 100644 app/institutions/dashboard/-components/departments-panel/styles.scss delete mode 100644 app/institutions/dashboard/-components/departments-panel/template.hbs delete mode 100644 app/institutions/dashboard/-components/projects-panel/component.ts delete mode 100644 app/institutions/dashboard/-components/projects-panel/styles.scss delete mode 100644 app/institutions/dashboard/-components/projects-panel/template.hbs diff --git a/app/institutions/dashboard/-components/departments-panel/component.ts b/app/institutions/dashboard/-components/departments-panel/component.ts deleted file mode 100644 index b40dd29b687..00000000000 --- a/app/institutions/dashboard/-components/departments-panel/component.ts +++ /dev/null @@ -1,75 +0,0 @@ -import Component from '@ember/component'; -import { action, computed } from '@ember/object'; -import { inject as service } from '@ember/service'; -import { ChartData, ChartOptions, Shape } from 'ember-cli-chart'; -import Intl from 'ember-intl/services/intl'; -import { Department } from 'ember-osf-web/models/institution'; -import InstitutionDepartmentsModel from 'ember-osf-web/models/institution-department'; - -export default class DepartmentsPanel extends Component { - @service intl!: Intl; - - topDepartments!: InstitutionDepartmentsModel[]; - totalUsers!: number; - - chartHoverIndex = 0; - - get chartOptions(): ChartOptions { - return { - aspectRatio: 1, - legend: { - display: false, - }, - onHover: this.onChartHover, - }; - } - - @action - onChartHover(_: MouseEvent, shapes: Shape[]) { - if (shapes.length === 0 || this.chartHoverIndex === shapes[0]._index) { - return; - } - this.set('chartHoverIndex', shapes[0]._index); - } - - @computed('topDepartments', 'totalUsers') - get displayDepartments() { - const departments = this.topDepartments.map(({ name, numberOfUsers }) => ({ name, numberOfUsers })); - const departmentNumbers = this.topDepartments.map(x => x.numberOfUsers); - const otherDepartmentNumber = this.totalUsers - departmentNumbers.reduce((a, b) => a + b); - - return [...departments, { name: this.intl.t('general.other'), numberOfUsers: otherDepartmentNumber }]; - } - - @computed('chartHoverIndex', 'displayDepartments.[]') - get chartData(): ChartData { - const backgroundColors = this.displayDepartments.map((_, i) => { - if (i === this.chartHoverIndex) { - return '#15a5eb'; - } - return '#a5b3bd'; - }); - const displayDepartmentNames = this.displayDepartments.map(({ name }) => name); - const displayDepartmentNumbers = this.displayDepartments.map(({ numberOfUsers }) => numberOfUsers); - - return { - labels: displayDepartmentNames, - datasets: [{ - data: displayDepartmentNumbers, - backgroundColor: backgroundColors, - }], - }; - } - - @computed('chartHoverIndex', 'displayDepartments.[]') - get activeDepartment(): Department { - return this.displayDepartments[this.chartHoverIndex]; - } - - @computed('activeDepartment.numberOfUsers', 'displayDepartments') - get activeDepartmentPercentage(): string { - const numUsersArray = this.displayDepartments.map(({ numberOfUsers }) => numberOfUsers); - const count = numUsersArray.reduce((a, b) => a + b); - return ((this.activeDepartment.numberOfUsers / count) * 100).toFixed(2); - } -} diff --git a/app/institutions/dashboard/-components/departments-panel/styles.scss b/app/institutions/dashboard/-components/departments-panel/styles.scss deleted file mode 100644 index 6d16df12aa5..00000000000 --- a/app/institutions/dashboard/-components/departments-panel/styles.scss +++ /dev/null @@ -1,16 +0,0 @@ -.ember-chart { - max-width: 200px; - max-height: 200px; - margin: 0 auto 15px; -} - -.department { - font-size: 16px; - - h3 { - margin: 0 0 10px; - font-size: 24px; - font-weight: bold; - } -} - diff --git a/app/institutions/dashboard/-components/departments-panel/template.hbs b/app/institutions/dashboard/-components/departments-panel/template.hbs deleted file mode 100644 index b07bd993c49..00000000000 --- a/app/institutions/dashboard/-components/departments-panel/template.hbs +++ /dev/null @@ -1,20 +0,0 @@ -{{#if this.topDepartments}} -
- -
-
-

{{this.activeDepartment.name}}

-

- {{this.activeDepartmentPercentage}}%: {{this.activeDepartment.numberOfUsers}} {{t 'institutions.dashboard.users'}} -

-
-{{else}} - {{t 'institutions.dashboard.empty'}} -{{/if}} \ No newline at end of file diff --git a/app/institutions/dashboard/-components/projects-panel/component.ts b/app/institutions/dashboard/-components/projects-panel/component.ts deleted file mode 100644 index 1e30b36108f..00000000000 --- a/app/institutions/dashboard/-components/projects-panel/component.ts +++ /dev/null @@ -1,47 +0,0 @@ -import Component from '@ember/component'; -import { computed } from '@ember/object'; -import { alias } from '@ember/object/computed'; -import { inject as service } from '@ember/service'; -import { ChartData, ChartOptions } from 'ember-cli-chart'; -import Intl from 'ember-intl/services/intl'; - -import InstitutionSummaryMetricModel from 'ember-osf-web/models/institution-summary-metric'; - -export default class ProjectsPanel extends Component { - summaryMetrics!: InstitutionSummaryMetricModel; - @alias('summaryMetrics.privateProjectCount') numPrivateProjects!: number; - @alias('summaryMetrics.publicProjectCount') numPublicProjects!: number; - @service intl!: Intl; - - chartOptions: ChartOptions = { - aspectRatio: 1, - legend: { - display: false, - }, - }; - - @computed('numPrivateProjects', 'numPublicProjects') - get numProjects(): number { - return this.numPublicProjects + this.numPrivateProjects; - } - - @computed('numPrivateProjects', 'numPublicProjects') - get chartData(): ChartData { - return { - labels: [ - this.intl.t('institutions.dashboard.public'), - this.intl.t('institutions.dashboard.private'), - ], - datasets: [{ - data: [ - this.numPublicProjects, - this.numPrivateProjects, - ], - backgroundColor: [ - '#36b183', - '#a5b3bd', - ], - }], - }; - } -} diff --git a/app/institutions/dashboard/-components/projects-panel/styles.scss b/app/institutions/dashboard/-components/projects-panel/styles.scss deleted file mode 100644 index 51603b6aad1..00000000000 --- a/app/institutions/dashboard/-components/projects-panel/styles.scss +++ /dev/null @@ -1,13 +0,0 @@ -.ember-chart { - max-width: 200px; - max-height: 200px; - margin: 0 auto 15px; -} - -.projects-count { - font-size: 16px; - - span:first-of-type { - margin-right: 15px; - } -} diff --git a/app/institutions/dashboard/-components/projects-panel/template.hbs b/app/institutions/dashboard/-components/projects-panel/template.hbs deleted file mode 100644 index a9a5bc68fd6..00000000000 --- a/app/institutions/dashboard/-components/projects-panel/template.hbs +++ /dev/null @@ -1,25 +0,0 @@ -{{#if this.summaryMetrics}} -
- -
-

{{this.numProjects}}

-
- - {{this.numPublicProjects}} - {{t 'institutions.dashboard.public'}} - - - {{this.numPrivateProjects}} - {{t 'institutions.dashboard.private'}} - -
-{{else}} - {{t 'institutions.dashboard.empty'}} -{{/if}} \ No newline at end of file