From 8558a25b7bf505d40cbc88fe94677a3e2aea036b Mon Sep 17 00:00:00 2001 From: "myrto.koukouli" Date: Mon, 19 Mar 2018 09:07:06 +0000 Subject: [PATCH] changed a few things in statistics component git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@51324 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/statistics/statistics.component.html | 151 +++++++++++-------- src/app/statistics/statistics.component.ts | 50 ++++-- src/app/statistics/statisticsEntities.ts | 2 +- 3 files changed, 122 insertions(+), 81 deletions(-) diff --git a/src/app/statistics/statistics.component.html b/src/app/statistics/statistics.component.html index a59aeb1..50f236c 100644 --- a/src/app/statistics/statistics.component.html +++ b/src/app/statistics/statistics.component.html @@ -6,83 +6,104 @@
No statistics are available for {{ communityId.toUpperCase() }}
-
+
    -
  • -
    -

    {{ getCamelCaseString(entity) }}{{ entity == 'software' ? '' : 's' }} statistics

    -
    - {{statisticsSum[entity + (entity == 'software' ? '' : 's')].total}} {{ entity + (entity == 'software' ? '' : 's') }} from {{statisticsSum.total_projects}} projects.
    - {{statisticsSum[entity + (entity == 'software' ? '' : 's')].open_access}} are OA - , - {{statisticsSum[entity + (entity == 'software' ? '' : 's')].restricted}} are restricted - - - and {{statisticsSum[entity + (entity == 'software' ? '' : 's')].embargo}} are still in embargo - -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -
    -

    {{ communityId }} {{ entity }}{{ entity == 'software' ? '' : 's' }} per project

    -
    -
    - -
      -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    -
    -
    -
    No {{ entity }}{{ entity == 'software' ? '' : 's' }} available
    + +
    +
    +

    {{ getCamelCaseString(entity) }}{{ entity == 'software' ? '' : 's' }} statistics

    +
    + {{statisticsSum[entity + (entity == 'software' ? '' : 's')].total}} {{ entity + (entity == 'software' ? '' : 's') }} from {{statisticsSum.total_projects}} projects.
    + {{statisticsSum[entity + (entity == 'software' ? '' : 's')].open_access}} are OA + , + {{statisticsSum[entity + (entity == 'software' ? '' : 's')].restricted}} are restricted + + + and {{statisticsSum[entity + (entity == 'software' ? '' : 's')].embargo}} are still in embargo + +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    +

    {{ communityId }} {{ entity }}{{ entity == 'software' ? '' : 's' }} per project

    +
    +
    + +
      +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    +
    +
    +
diff --git a/src/app/statistics/statistics.component.ts b/src/app/statistics/statistics.component.ts index 400358a..2b05133 100644 --- a/src/app/statistics/statistics.component.ts +++ b/src/app/statistics/statistics.component.ts @@ -36,13 +36,11 @@ export class StatisticsComponent { public communityInfo = null; entitiesList: string[] = availableEntities; - entitiesForCommunity: string[] = []; chartCatsList: string[] = availableCharts; allowedCharts: string[] = []; statisticsSum: StatisticsSummary; statisticsDisplay: StatisticsDisplay; - charts: Map> = new Map>(); chartsUrlMap: {}; public displayedTimeline: string; @@ -135,37 +133,38 @@ export class StatisticsComponent { console.log(error) }, () => { - this.createCharts(); + this.createChartUrlMap(); + this.initializeDisplayedCharts('showInMonitor'); } ); } - /* checks which charts exist and which the admin has chosen to display in connect monitor */ +/* /!* checks which charts exist and which the admin has chosen to display in connect monitor *!/ private createCharts() { this.createChartUrlMap(); - /* for each entity find the statistics display information + /!* for each entity find the statistics display information from apiUrl/statistics/communityId - */ + *!/ for ( let entity of this.entitiesList ) { let displayOptionsForEntity = this.statisticsDisplay.entities[entity]; - /* if the community has produced such entities */ + /!* if the community has produced such entities *!/ if (displayOptionsForEntity && this.statisticsSum[entity+(entity=='software'?'':'s')]['total'] ) { - /* create a map of charts to be displayed */ + /!* create a map of charts to be displayed *!/ let chartsMap: Map = new Map(); - /* for each chart category find which charts exist + /!* for each chart category find which charts exist and which the admin has chosen to be displayed here - */ + *!/ for (let chart of this.chartCatsList) { - /* current chart is */ + /!* current chart is *!/ let displayOptionsForCharts = this.statisticsDisplay.entities[entity].charts.map[chart]; - /* in the future we probably won't need to check if the url exists */ - /* currently the url titles are created using the entity name and the chart name in camelcase */ + /!* in the future we probably won't need to check if the url exists *!/ + /!* currently the url titles are created using the entity name and the chart name in camelcase *!/ let urlString = this.chartsUrlMap[entity + this.getCamelCaseString(chart)]; if (displayOptionsForCharts && displayOptionsForCharts.showInMonitor && urlString ) { @@ -174,14 +173,35 @@ export class StatisticsComponent { } } - /* add the entity's charts to the charts map */ + /!* add the entity's charts to the charts map *!/ this.charts.set(entity, chartsMap); - /* add the entity in the available entities for the current community */ + /!* add the entity in the available entities for the current community *!/ this.entitiesForCommunity.push(entity); } } this.onChangeEntity(this.entitiesForCommunity[0]); + }*/ + + initializeDisplayedCharts(mode: string) { + let firstEntity: string; + for (let entity of this.entitiesList) { + if (this.statisticsDisplay.entities[entity]) { + + for (let chart of this.chartCatsList){ + if (this.statisticsDisplay.entities[entity].charts.map[chart] && + this.statisticsDisplay.entities[entity].charts.map[chart][mode] && + this.chartsUrlMap[entity + this.getCamelCaseString(chart)]) { + + this.allowedCharts.push(entity + this.getCamelCaseString(chart)); + } + } + if (!firstEntity){ + firstEntity = entity; + this.onChangeEntity(entity); + } + } + } } createChartUrlMap() { diff --git a/src/app/statistics/statisticsEntities.ts b/src/app/statistics/statisticsEntities.ts index d2b4416..53699a4 100644 --- a/src/app/statistics/statisticsEntities.ts +++ b/src/app/statistics/statisticsEntities.ts @@ -16,7 +16,7 @@ export const availableNumbers = [ export const availableEntities = [ 'publication', - 'datasets', + 'dataset', 'software' ];