From f2826639a77f0fee663c68fd1118d33ca756a405 Mon Sep 17 00:00:00 2001
From: Daviti Gogshelidze <daviti1@mail.com>
Date: Tue, 18 Jun 2019 10:52:16 +0200
Subject: [PATCH] corrections of indo buttons and download references

---
 deploy/datasets/index.js                      | 11 ++-
 src/atlasViewer/atlasViewer.component.ts      | 53 +----------
 src/atlasViewer/atlasViewer.style.css         | 20 +---
 src/atlasViewer/atlasViewer.template.html     | 32 +++----
 src/components/dropdown/dropdown.component.ts |  1 +
 .../dropdown/dropdown.template.html           |  3 +-
 .../radiolist/radiolist.component.ts          | 47 +---------
 src/components/radiolist/radiolist.style.css  | 21 +----
 .../radiolist/radiolist.template.html         | 33 +++----
 src/res/ext/MNI152.json                       |  3 +-
 src/res/ext/colin.json                        |  3 +-
 src/services/zipFileDownload.service.ts       | 18 ++--
 .../referenceToast.component.ts               | 91 +++++++++++++++++++
 .../referenceToast/referenceToast.style.css   | 14 +++
 .../referenceToast.template.html              | 33 +++++++
 .../sharedModules/angularMaterial.module.ts   | 13 ++-
 .../signinBanner/signinBanner.components.ts   | 21 ++++-
 .../signinBanner/signinBanner.template.html   | 32 ++++++-
 src/ui/ui.module.ts                           |  5 +-
 19 files changed, 261 insertions(+), 193 deletions(-)
 create mode 100644 src/ui/referenceToast/referenceToast.component.ts
 create mode 100644 src/ui/referenceToast/referenceToast.style.css
 create mode 100644 src/ui/referenceToast/referenceToast.template.html

diff --git a/deploy/datasets/index.js b/deploy/datasets/index.js
index f286bf444..3b27cab5f 100644
--- a/deploy/datasets/index.js
+++ b/deploy/datasets/index.js
@@ -125,15 +125,18 @@ datasetsRouter.post("/downloadParcellationThemself", (req,res, next) => {
 
   var zip = new JSZip();
 
-  zip.file("Publications.txt", req.body['publicationsText'])
+  zip.file("credits.txt", req.body['publicationsText'])
   zip.file("Terms of use.txt", termsOfUse)
 
 
 
-  //ToDo: Need to download files dynamicly. Nii folder should remove
-  if (req.body['fileName'].includes("JuBrain Cytoarchitectonic Atlas")) {
+  //ToDo: Need to download files dynamically. Nii folder should be removed
+  if (req.body['niiFiles']) {
     var nii = zip.folder("nifti")
-    nii.file('jubrain-max-pmap-v22c_space-mnicolin27.nii', fs.readFileSync(path.join(__dirname, 'nii') + '/' + 'jubrain-max-pmap-v22c_space-mnicolin27.nii'))
+    const filepath = process.env.STORAGE_PATH || path.join(__dirname, 'nii')
+    req.body['niiFiles'].forEach(file => {
+      nii.file(file['file'], fs.readFileSync(path.join(filepath, file['file'])))
+    })
   }
 
   zip.generateAsync({type:"base64"})
diff --git a/src/atlasViewer/atlasViewer.component.ts b/src/atlasViewer/atlasViewer.component.ts
index 076bae1eb..aa551f293 100644
--- a/src/atlasViewer/atlasViewer.component.ts
+++ b/src/atlasViewer/atlasViewer.component.ts
@@ -20,7 +20,6 @@ import { DatabrowserService } from "src/ui/databrowserModule/databrowser.service
 import { AGREE_COOKIE, AGREE_KG_TOS, SHOW_KG_TOS } from "src/services/state/uiState.store";
 import { TabsetComponent } from "ngx-bootstrap/tabs";
 import { ToastService } from "src/services/toastService.service";
-import { ZipFileDownloadService } from "src/services/zipFileDownload.service";
 
 /**
  * TODO
@@ -96,8 +95,6 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit {
   public sidePanelOpen$: Observable<boolean>
 
   handleToast
-  tPublication
-  pPublication
 
   get toggleMessage(){
     return this.constantsService.toggleMessage
@@ -114,7 +111,6 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit {
     private databrowserService: DatabrowserService,
     private dispatcher$: ActionsSubject,
     private toastService: ToastService,
-    private zipFileDownloadService: ZipFileDownloadService,
   ) {
     this.ngLayerNames$ = this.store.pipe(
       select('viewerState'),
@@ -233,24 +229,10 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit {
       this.selectedParcellation$.subscribe(parcellation => {
         this.selectedParcellation = parcellation
 
-        if (this.selectedTemplate && this.selectedParcellation) {
-          if (this.selectedTemplate['properties'] && this.selectedTemplate['properties']['publications']) {
-            this.tPublication = this.selectedTemplate['properties']['publications']
-          } else {
-            this.tPublication = null
-          }
-          if (this.selectedParcellation['properties'] && this.selectedParcellation['properties']['publications']) {
-            this.pPublication = this.selectedParcellation['properties']['publications']
-          } else {
-            this.pPublication = null
-          }
-        } else {
-          this.tPublication = null
-          this.pPublication = null
-        }
-        
-        if (this.tPublication || this.pPublication) {
-
+        if ((this.selectedParcellation['properties'] &&
+            (this.selectedParcellation['properties']['publications'] || this.selectedParcellation['properties']['description']))
+            || (this.selectedTemplate['properties'] &&
+                (this.selectedTemplate['properties']['publications'] || this.selectedTemplate['properties']['description']))) {
           if (this.handleToast) {
             this.handleToast()
             this.handleToast = null
@@ -258,38 +240,11 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit {
           this.handleToast = this.toastService.showToast(this.publications, {
               timeout: 7000
           })
-          
         }
       })
     )
-
-
   }
 
-  downloadPublications() {
-    const fileName = this.selectedTemplate.name + ' - ' + this.selectedParcellation.name
-    let publicationsText = ''
-
-    if (this.tPublication) {
-      publicationsText += this.selectedTemplate.name + ' Publications:\r\n'
-      this.tPublication.forEach((tp, i) => {
-        publicationsText += '\t' + (i+1) + '. ' + tp['citation'] + ' - ' + tp['doi'] + '\r\n'
-      });
-    }
-
-    if (this.pPublication) {
-      if (this.tPublication) publicationsText += '\r\n\r\n'
-      publicationsText += this.selectedParcellation.name + ' Publications:\r\n'
-      this.pPublication.forEach((pp, i) => {
-        publicationsText += '\t' + (i+1) + '. ' + pp['citation'] + ' - ' + pp['doi'] + '\r\n'
-      });
-    }
-    
-    this.zipFileDownloadService.downloadZip(publicationsText, fileName)
-    publicationsText = ''
-  }
-
-
   private selectedParcellation$: Observable<any>
   private selectedParcellation: any
 
diff --git a/src/atlasViewer/atlasViewer.style.css b/src/atlasViewer/atlasViewer.style.css
index 283df246c..756043887 100644
--- a/src/atlasViewer/atlasViewer.style.css
+++ b/src/atlasViewer/atlasViewer.style.css
@@ -1,5 +1,3 @@
-/* @import '~@angular/material/prebuilt-themes/indigo-pink.css'; */
-
 :host, :host > .atlas-container
 {
   display:block;
@@ -175,22 +173,6 @@ mat-sidenav {
   box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
 }
 
-.mpobileMenuTabs {
+.mobileMenuTabs {
   margin: 40px 0 0 5px;
-}
-
-.timerToast {
-  max-width: 700px;
-  display: flex;
-  flex-direction: column;
-  justify-content: center;
-}
-
-.downloadPublications {
-  align-self: flex-end;
-  outline: none;
-}
-
-.textPartInPublications {
-  text-align: left;
 }
\ No newline at end of file
diff --git a/src/atlasViewer/atlasViewer.template.html b/src/atlasViewer/atlasViewer.template.html
index 198592529..40ac79d2c 100644
--- a/src/atlasViewer/atlasViewer.template.html
+++ b/src/atlasViewer/atlasViewer.template.html
@@ -23,7 +23,7 @@
         <button mat-button style="height: 0; position: absolute;"></button>
         <logo-container class="logoContainerMobile"></logo-container>
   
-        <tabset #mobileMenuTabs [justified]="true" class="mpobileMenuTabs" >
+        <tabset #mobileMenuTabs [justified]="true" class="mobileMenuTabs" >
           <tab heading="Template">
             <signin-banner [darktheme] = "darktheme" signinWrapper></signin-banner>
             <layout-floating-container *ngIf="this.nehubaContainer && this.nehubaContainer.nehubaViewer">
@@ -128,9 +128,9 @@
     </ui-nehuba-container>
   
     <div *ngIf="!isMobile" bannerWrapper>
-      <menu-icons iconWrapper>
+      <menu-icons iconWrapper *ngIf="selectedTemplate">
       </menu-icons>
-      <signin-banner signinWrapper>
+      <signin-banner signinWrapper *ngIf="selectedTemplate">
       </signin-banner>
     </div>
   
@@ -260,21 +260,13 @@
 </ng-template>
 
 <ng-template #publications >
-  <div *ngIf="tPublication || pPublication" class="timerToast">
-    <button mat-mini-fab color="primary" class="downloadPublications" (click)="downloadPublications()">↓</button>
-
-    <div *ngIf="tPublication">
-      <p>{{selectedTemplate['name']}} Publication(s)</p>
-      <div *ngFor="let tp of tPublication" class="textPartInPublications">
-        <a [href]="tp['doi']" target="_blank">{{tp['citation']}}</a>
-      </div>
-      <hr *ngIf="pPublication">
-    </div>
-    <div *ngIf="pPublication">
-      <p>{{selectedParcellation['name']}} Publication(s)</p>
-      <div *ngFor="let pp of pPublication" class="textPartInPublications">
-        <a [href]="pp['doi']" target="_blank">{{pp['citation']}}</a>
-      </div>  
-    </div>
-  </div>
+  <reference-toast-component
+          [templateName] = "selectedTemplate['name']? selectedTemplate['name'] : null"
+          [parcellationName] = "selectedParcellation['name']? selectedParcellation['name'] : null"
+          [templateDescription] = "selectedTemplate['properties'] && selectedTemplate['properties']['description']? selectedTemplate['properties']['description'] : null"
+          [parcellationDescription] = "selectedParcellation['properties'] && selectedParcellation['properties']['description']? selectedParcellation['properties']['description'] : null"
+          [templatePublications] = "selectedTemplate['properties'] && selectedTemplate['properties']['publications']? selectedTemplate['properties']['publications']: null"
+          [parcellationPublications] = "selectedParcellation['properties'] && selectedParcellation['properties']['publications']? selectedParcellation['properties']['publications']: null"
+          [parcellationNifti] = "selectedParcellation['properties'] && selectedParcellation['properties']['nifti']? selectedParcellation['properties']['nifti'] : null">
+  </reference-toast-component>
 </ng-template>
\ No newline at end of file
diff --git a/src/components/dropdown/dropdown.component.ts b/src/components/dropdown/dropdown.component.ts
index 139e1add8..9141a4219 100644
--- a/src/components/dropdown/dropdown.component.ts
+++ b/src/components/dropdown/dropdown.component.ts
@@ -26,6 +26,7 @@ export class DropdownComponent{
   @Input() darktheme: boolean
 
   @Output() itemSelected : EventEmitter<any> = new EventEmitter()
+  @Output() listItemButtonClicked: EventEmitter<any> = new EventEmitter()
 
   @ViewChild('dropdownToggle',{read:ElementRef}) dropdownToggle : ElementRef
 
diff --git a/src/components/dropdown/dropdown.template.html b/src/components/dropdown/dropdown.template.html
index b31ed3fc1..b4d7ff326 100644
--- a/src/components/dropdown/dropdown.template.html
+++ b/src/components/dropdown/dropdown.template.html
@@ -25,6 +25,7 @@
   [inputArray]="inputArray"
   [@showState]="openState ? 'show' : 'hide'"
   [isMobile]="isMobile"
-  [darktheme]="darktheme">
+  [darktheme]="darktheme"
+  (listItemButtonClicked) = listItemButtonClicked.emit($event)>
 
 </radio-list>
diff --git a/src/components/radiolist/radiolist.component.ts b/src/components/radiolist/radiolist.component.ts
index bd5fd328c..9db15d19c 100644
--- a/src/components/radiolist/radiolist.component.ts
+++ b/src/components/radiolist/radiolist.component.ts
@@ -1,6 +1,4 @@
 import { Component, ChangeDetectionStrategy, Input, Output, EventEmitter, OnInit, ViewChild, TemplateRef } from "@angular/core";
-import { ToastService } from "src/services/toastService.service";
-import { ZipFileDownloadService } from "src/services/zipFileDownload.service";
 
 @Component({
   selector: 'radio-list',
@@ -8,22 +6,6 @@ import { ZipFileDownloadService } from "src/services/zipFileDownload.service";
   styleUrls: [
     './radiolist.style.css'
   ],
-  styles: [
-    `
-    ul > li.selected > .textSpan:before
-    {
-      content: '\u2022';
-      width : 1em;
-      display:inline-block;
-    }
-    ul > li:not(.selected) > .textSpan:before
-    {
-      content: ' ';
-      width : 1em;
-      display:inline-block;
-    }  
-    `
-  ],
   changeDetection: ChangeDetectionStrategy.OnPush
 })
 
@@ -48,32 +30,13 @@ export class RadioList{
   @Input() isMobile: boolean
   @Input() darktheme: boolean
 
-  @ViewChild('publicationTemplate') publicationTemplate: TemplateRef<any>
-
-  handleToast
-
-  constructor(private toastService: ToastService,
-              private zipFileDownloadService: ZipFileDownloadService) {}
-
-  showToast(item) {
-    if (this.handleToast) {
-      this.handleToast()
-      this.handleToast = null
-    }
-    this.handleToast = this.toastService.showToast(this.publicationTemplate, {
-        timeout: 7000
-    })
+  @Output() listItemButtonClicked = new EventEmitter<string>();
 
+  clickListButton(i) {
+    this.listItemButtonClicked.emit(i)
   }
 
-
-  downloadPublications(item) {
-    const filename = item['name']
-    let publicationsText = item['name'] + ' Publications:\r\n'
-      item['properties']['publications'].forEach((p, i) => {
-        publicationsText += '\t' + (i+1) + '. ' + p['citation'] + ' - ' + p['doi'] + '\r\n'
-      });
-    this.zipFileDownloadService.downloadZip(publicationsText, filename)
-    publicationsText = ''
+  overflowText(event) {
+    return (event.offsetWidth < event.scrollWidth)
   }
 }
\ No newline at end of file
diff --git a/src/components/radiolist/radiolist.style.css b/src/components/radiolist/radiolist.style.css
index c3fcf157b..152360dc3 100644
--- a/src/components/radiolist/radiolist.style.css
+++ b/src/components/radiolist/radiolist.style.css
@@ -54,31 +54,18 @@ ul,span.dropdown-item-1
   border-radius:0px;
   white-space: nowrap;
   border:none;
+  overflow: hidden;
+  text-overflow: ellipsis
 }
 
 .infoIcon {
-  margin-right: 5px;
+  margin-left: 5px;
   display: inline-block;
   border: 1px solid gray;
   border-radius: 15px;
   width: 24px;
   height: 24px;
+  min-width: 24px;
   cursor: pointer;
   text-align: center;
-}
-
-.timerToast {
-  max-width: 700px;
-  display: flex;
-  flex-direction: column;
-  justify-content: center;
-}
-
-.downloadPublications {
-  align-self: flex-end;
-  outline: none;
-}
-
-.textPartInPublications {
-  text-align: left;
 }
\ No newline at end of file
diff --git a/src/components/radiolist/radiolist.template.html b/src/components/radiolist/radiolist.template.html
index ffa5c4fc1..7d25135f4 100644
--- a/src/components/radiolist/radiolist.template.html
+++ b/src/components/radiolist/radiolist.template.html
@@ -2,34 +2,23 @@
   [ngClass]="ulClass"
   [ngStyle]="{'opacity': isMobile? '1' : '0.8', 'border-color': darktheme? 'white' : 'black'}"
   role="menu">
-  <li 
-    *ngFor="let input of inputArray" 
+  <li
+    *ngFor="let input of inputArray; let i = index"
+    class="d-flex justify-content-between"
     [ngClass]="checkSelected(selectedItem, input) ? 'selected' : 'notselected'"
     role="menuitem"
     (click)="itemSelected.emit({previous: selectedItem, current: input})">
     
-    <span *ngIf="input['properties'] && input['properties']['publications']" class="infoIcon" (click)="showToast(input);$event.stopPropagation()">
-      i
+    <span class="dropdown-item-1 textSpan"
+          #DropDownText
+          [innerHTML] = "listDisplay(input)"
+          [style.fontWeight] = "checkSelected(selectedItem, input)? 'bold' : ''"
+          [matTooltip]="overflowText(DropDownText)? DropDownText.innerText: ''">
     </span>
 
-    <span class="dropdown-item-1 textSpan" 
-      [innerHTML] = "listDisplay(input)">
+    <span *ngIf="input['properties'] && (input['properties']['publications'] || input['properties']['description'])"
+          class="infoIcon align-self-end" (click)="clickListButton(i);$event.stopPropagation()">
+      i
     </span>
-
-
-
-    
-<ng-template #publicationTemplate>
-    <div *ngIf="input['properties'] && input['properties']['publications']" class="timerToast">
-        <button mat-mini-fab color="primary" class="downloadPublications" (click)="downloadPublications(input)">↓</button>
-          <p>{{input['name']}} Publication(s)</p>
-          <div *ngFor="let p of input['properties']['publications']" class="textPartInPublications">
-            <a [href]="p['doi']" target="_blank">{{p['citation']}}</a>
-          </div>
-      </div>
-</ng-template>
-
-
-
   </li>
 </ul>
\ No newline at end of file
diff --git a/src/res/ext/MNI152.json b/src/res/ext/MNI152.json
index ce4f53cd9..6f90ede30 100644
--- a/src/res/ext/MNI152.json
+++ b/src/res/ext/MNI152.json
@@ -12,7 +12,8 @@
       "properties": {
         "version": "1.0",
         "description": "not yet",
-        "publications": []
+        "publications": [],
+        "nifti": [{"file":  "jubrain-max-pmap-v22c_space-mnicolin27.nii", "size": "4400000"}]
       },
       "regions": [
         {
diff --git a/src/res/ext/colin.json b/src/res/ext/colin.json
index 76799e077..f0a34ad3f 100644
--- a/src/res/ext/colin.json
+++ b/src/res/ext/colin.json
@@ -12,7 +12,8 @@
       "properties": {
         "version": "1.0",
         "description": "not yet",
-        "publications": []
+        "publications": [],
+        "nifti": [{"file":  "jubrain-max-pmap-v22c_space-mnicolin27.nii", "size": "4400000"}]
       },
       "regions": [
         {
diff --git a/src/services/zipFileDownload.service.ts b/src/services/zipFileDownload.service.ts
index 434a11338..68131c4bf 100644
--- a/src/services/zipFileDownload.service.ts
+++ b/src/services/zipFileDownload.service.ts
@@ -1,29 +1,31 @@
 import { Injectable } from "@angular/core";
 import {HttpClient} from "@angular/common/http";
 import {AtlasViewerConstantsServices} from "src/atlasViewer/atlasViewer.constantService.service";
+import {map} from "rxjs/operators";
 
 @Injectable({ providedIn: 'root' })
 export class ZipFileDownloadService {
 
     constructor(private httpClient: HttpClient, private constantService: AtlasViewerConstantsServices) {}
 
-    downloadZip(publicationsText, fileName) {
+    downloadZip(publicationsText, fileName, niiFiles) {
         const correctedName = fileName.replace(/[|&;$%@"<>()+,/]/g, "")
-        this.httpClient.post(this.constantService.backendUrl + 'datasets/downloadParcellationThemself', {
+        return this.httpClient.post(this.constantService.backendUrl + 'datasets/downloadParcellationThemself', {
                 fileName: correctedName,
                 publicationsText: publicationsText,
+                niiFiles: niiFiles === 0 ? null : niiFiles
             },{responseType: "text"}
-        ).subscribe(data => {
-            this.downloadFile(data, correctedName)
-        })
+        ).pipe(
+            map (data => {
+                this.downloadFile(data, correctedName)
+            })
+        )
     }
 
     downloadFile(data, fileName) {
-
         const contentType = 'application/zip';
         const b64Data = data
 
-
         const b64toBlob = (b64Data, contentType='', sliceSize=512) => {
             const byteCharacters = atob(b64Data);
             const byteArrays = [];
@@ -44,9 +46,7 @@ export class ZipFileDownloadService {
             return blob;
         }
 
-
         const blob = b64toBlob(b64Data, contentType);
-        // const blob = new Blob([data], { type: 'text/csv' });
         const url= window.URL.createObjectURL(blob);
         const anchor = document.createElement("a");
         anchor.download = fileName + '.zip';
diff --git a/src/ui/referenceToast/referenceToast.component.ts b/src/ui/referenceToast/referenceToast.component.ts
new file mode 100644
index 000000000..9b68e7dcd
--- /dev/null
+++ b/src/ui/referenceToast/referenceToast.component.ts
@@ -0,0 +1,91 @@
+import { Component, Input, OnInit } from "@angular/core";
+import { ZipFileDownloadService } from "src/services/zipFileDownload.service";
+
+@Component({
+    selector : 'reference-toast-component',
+    templateUrl : './referenceToast.template.html',
+    styleUrls : [
+        `./referenceToast.style.css`
+    ],
+})
+export class ReferenceToastComponent implements OnInit{
+    @Input() templateName? : string
+    @Input() parcellationName? : string
+    @Input() templateDescription? : string
+    @Input() parcellationDescription? : string
+    @Input() templatePublications? : any
+    @Input() parcellationPublications? : any
+    @Input() parcellationNifti? : any
+
+    downloadingProcess = false
+    niiFileSize = 0
+
+    constructor(private zipFileDownloadService: ZipFileDownloadService) {}
+
+    ngOnInit(): void {
+        if (this.parcellationNifti) {
+            this.parcellationNifti.forEach(nii => {
+                this.niiFileSize += nii['size']
+            })
+        }
+    }
+
+    downloadPublications() {
+        this.downloadingProcess = true
+
+        let fileName = ''
+        let publicationsText = ''
+
+        if (this.templatePublications || this.templateDescription) {
+            fileName += this.templateName? this.templateName : 'Template'
+
+            if (this.templateDescription) {
+                publicationsText += this.templateName + '\r\n'
+                this.templateDescription.split(" ").forEach((word, index) => {
+                    publicationsText += word + ' '
+                    if (index && index%15 === 0) publicationsText += '\r\n'
+                })
+                publicationsText += '\r\n'
+            }
+
+            if (this.templatePublications) {
+                if (!this.templateDescription) publicationsText += this.templateName
+                publicationsText += ' Publications:\r\n'
+                this.templatePublications.forEach((tp, i) => {
+                    publicationsText += '\t' + (i+1) + '. ' + tp['citation'] + ' - ' + tp['doi'] + '\r\n'
+                })
+            }
+        }
+
+        if (this.parcellationPublications || this.parcellationDescription) {
+            if (this.templateName) fileName += ' - '
+            fileName += this.parcellationName? this.parcellationName : 'Parcellation'
+            if (this.templateDescription || this.templatePublications) publicationsText += '\r\n\r\n'
+
+            if (this.parcellationDescription) {
+                publicationsText += this.parcellationName + '\r\n'
+                this.parcellationDescription.split(" ").forEach((word, index) => {
+                    publicationsText += word + ' '
+                    if (index && index%15 === 0) publicationsText += '\r\n'
+                })
+                publicationsText += '\r\n'
+            }
+
+            if (this.parcellationPublications) {
+                if (!this.parcellationDescription) publicationsText += this.parcellationName
+                publicationsText += ' Publications:\r\n'
+                this.parcellationPublications.forEach((pp, i) => {
+                    publicationsText += '\t' + (i+1) + '. ' + pp['citation'] + ' - ' + pp['doi'] + '\r\n'
+                })
+            }
+        }
+
+        this.zipFileDownloadService.downloadZip(
+            publicationsText,
+            fileName,
+            this.parcellationNifti? this.parcellationNifti : 0).subscribe(data => {
+            this.downloadingProcess = false
+        })
+        publicationsText = ''
+    }
+}
diff --git a/src/ui/referenceToast/referenceToast.style.css b/src/ui/referenceToast/referenceToast.style.css
new file mode 100644
index 000000000..cf52094f5
--- /dev/null
+++ b/src/ui/referenceToast/referenceToast.style.css
@@ -0,0 +1,14 @@
+.timerToast {
+    max-width: 700px;
+    max-height: 500px;
+    padding-right: 10px;
+    overflow-y: auto;
+}
+
+.download-buttons-panel {
+    align-self: flex-end;
+}
+.downloadPublications {
+    margin: 5px;
+    outline: none;
+}
\ No newline at end of file
diff --git a/src/ui/referenceToast/referenceToast.template.html b/src/ui/referenceToast/referenceToast.template.html
new file mode 100644
index 000000000..7db995f2b
--- /dev/null
+++ b/src/ui/referenceToast/referenceToast.template.html
@@ -0,0 +1,33 @@
+<div class="timerToast d-flex flex-column">
+    <div *ngIf="templateDescription">
+        <p *ngIf="templateName">{{templateName}}</p>
+        <p class="text-justify">{{templateDescription}}</p>
+    </div>
+    <div *ngIf="templatePublications">
+        <p>Publication(s)</p>
+        <div *ngFor="let tp of templatePublications" class="text-justify">
+            <a [href]="tp['doi']" target="_blank">{{tp['citation']}}</a>
+        </div>
+        <hr *ngIf="parcellationPublications">
+    </div>
+    <div *ngIf="parcellationDescription">
+        <p *ngIf="parcellationName">{{parcellationName}}</p>
+        <p class="text-justify">{{parcellationDescription}}</p>
+    </div>
+
+    <div *ngIf="parcellationPublications">
+        <p>Publication(s)</p>
+        <div *ngFor="let pp of parcellationPublications" class="text-justify">
+            <a [href]="pp['doi']" target="_blank">{{pp['citation']}}</a>
+        </div>
+    </div>
+
+    <div class="align-self-end">
+        <button mat-raised-button color="primary" class="downloadPublications" (click)="downloadPublications()">Explore &nbsp;<i class="fas fa-external-link-alt"></i></button>
+        <button mat-raised-button color="primary" class="downloadPublications" (click)="downloadPublications()" [disabled] = "downloadingProcess" >
+            Download &nbsp;
+            <span *ngIf="niiFileSize > 0">(.nii {{niiFileSize/1000000 | number:'.1-2'}} Mb) &nbsp;</span>
+            <i class="fas" [ngClass]="!downloadingProcess? 'fa-download' :'fa-spinner fa-pulse'"></i>
+        </button>
+    </div>
+</div>
\ No newline at end of file
diff --git a/src/ui/sharedModules/angularMaterial.module.ts b/src/ui/sharedModules/angularMaterial.module.ts
index f5b493857..b63e2dfaa 100644
--- a/src/ui/sharedModules/angularMaterial.module.ts
+++ b/src/ui/sharedModules/angularMaterial.module.ts
@@ -1,8 +1,15 @@
-import {MatButtonModule, MatCheckboxModule, MatSidenavModule, MatCardModule, MatTabsModule} from '@angular/material';
+import {
+  MatButtonModule,
+  MatCheckboxModule,
+  MatSidenavModule,
+  MatCardModule,
+  MatTabsModule,
+  MatTooltipModule
+} from '@angular/material';
 import { NgModule } from '@angular/core';
 
 @NgModule({
-  imports: [MatButtonModule, MatCheckboxModule, MatSidenavModule, MatCardModule, MatTabsModule],
-  exports: [MatButtonModule, MatCheckboxModule, MatSidenavModule, MatCardModule, MatTabsModule],
+  imports: [MatButtonModule, MatCheckboxModule, MatSidenavModule, MatCardModule, MatTabsModule, MatTooltipModule],
+  exports: [MatButtonModule, MatCheckboxModule, MatSidenavModule, MatCardModule, MatTabsModule, MatTooltipModule],
 })
 export class AngularMaterialModule { }
\ No newline at end of file
diff --git a/src/ui/signinBanner/signinBanner.components.ts b/src/ui/signinBanner/signinBanner.components.ts
index 713f00828..83f06a09c 100644
--- a/src/ui/signinBanner/signinBanner.components.ts
+++ b/src/ui/signinBanner/signinBanner.components.ts
@@ -1,4 +1,4 @@
-import { Component, ChangeDetectionStrategy, OnDestroy, OnInit, Input } from "@angular/core";
+import {Component, ChangeDetectionStrategy, OnDestroy, OnInit, Input, ViewChild, TemplateRef} from "@angular/core";
 import { AtlasViewerConstantsServices } from "src/atlasViewer/atlasViewer.constantService.service";
 import { AuthService, User } from "src/services/auth.service";
 import { Store, select } from "@ngrx/store";
@@ -33,6 +33,12 @@ export class SigninBanner implements OnInit, OnDestroy{
   private selectedRegions: any[] = []
   @Input() darktheme: boolean
 
+  @ViewChild('publicationTemplate', {read:TemplateRef}) publicationTemplate: TemplateRef<any>
+
+  dismissToastHandler: any
+  chosenTemplateIndex: number
+  chosenParcellationIndex: number
+
   constructor(
     private constantService: AtlasViewerConstantsServices,
     private authService: AuthService,
@@ -170,6 +176,19 @@ export class SigninBanner implements OnInit, OnDestroy{
     })
   }
 
+  showInfoToast($event, toastType) {
+    this.chosenTemplateIndex = toastType === 'template'? $event : null
+    this.chosenParcellationIndex = toastType === 'parcellation'? $event : null
+
+    if (this.dismissToastHandler) {
+      this.dismissToastHandler()
+      this.dismissToastHandler = null
+    }
+    this.dismissToastHandler = this.toastService.showToast(this.publicationTemplate, {
+      timeout: 7000
+    })
+  }
+
   get isMobile(){
     return this.constantService.mobile
   }
diff --git a/src/ui/signinBanner/signinBanner.template.html b/src/ui/signinBanner/signinBanner.template.html
index 51ae875d9..da2fd5e6c 100644
--- a/src/ui/signinBanner/signinBanner.template.html
+++ b/src/ui/signinBanner/signinBanner.template.html
@@ -9,7 +9,8 @@
     [inputArray]="loadedTemplates$ | async | filterNull"
     [isMobile] = "isMobile"
     [ngClass]="isMobile ? flexItemIsMobileClass : flexItemIsDesktopClass"
-    [darktheme] ="darktheme">
+    [darktheme] ="darktheme"
+    (listItemButtonClicked)="showInfoToast($event, 'template')">
   </dropdown-component>
 
   <ng-container *ngIf="selectedTemplate$ | async as selectedTemplate">
@@ -22,7 +23,8 @@
       [inputArray]="selectedTemplate.parcellations"
       [isMobile] = "isMobile"
       [ngClass]="isMobile ? flexItemIsMobileClass : flexItemIsDesktopClass"
-      [darktheme] ="darktheme">
+      [darktheme] ="darktheme"
+      (listItemButtonClicked)="showInfoToast($event, 'parcellation')">>
 
     </dropdown-component>
     <region-hierarchy
@@ -75,4 +77,28 @@
     </div>
 
   </div>
-</div>
\ No newline at end of file
+</div>
+
+<ng-template #publicationTemplate>
+  <div *ngIf="loadedTemplates$ | async as loadedTemplates">
+    <div *ngIf="chosenTemplateIndex !== null; else parcellationToast">
+      <reference-toast-component *ngIf="loadedTemplates[chosenTemplateIndex]['properties'] && (loadedTemplates[chosenTemplateIndex]['properties']['description'] || loadedTemplates[chosenTemplateIndex]['properties']['publications'])"
+                               [templateName] = "loadedTemplates[chosenTemplateIndex]['name'] ? loadedTemplates[chosenTemplateIndex]['name'] : null"
+                               [templateDescription] = "loadedTemplates[chosenTemplateIndex]['properties']['description']? loadedTemplates[chosenTemplateIndex]['properties']['description'] : null"
+                               [templatePublications] = "loadedTemplates[chosenTemplateIndex]['properties']['publications']? loadedTemplates[chosenTemplateIndex]['properties']['publications']: null">
+      </reference-toast-component>
+    </div>
+    <ng-template #parcellationToast>
+      <div *ngIf="(selectedTemplate$ | async) as selectedTemplate">
+        <div *ngIf="selectedTemplate.parcellations[chosenParcellationIndex]['properties'] && (selectedTemplate.parcellations[chosenParcellationIndex]['properties']['description'] || selectedTemplate.parcellations[chosenParcellationIndex]['properties']['publications'])">
+        <reference-toast-component
+              [parcellationName] = "selectedTemplate.parcellations[chosenParcellationIndex]['name']? selectedTemplate.parcellations[chosenParcellationIndex]['name'] : null"
+              [parcellationDescription] = "selectedTemplate.parcellations[chosenParcellationIndex]['properties']['description']? selectedTemplate.parcellations[chosenParcellationIndex]['properties']['description'] : null"
+              [parcellationPublications] = "selectedTemplate.parcellations[chosenParcellationIndex]['properties']['publications']? selectedTemplate.parcellations[chosenParcellationIndex]['properties']['publications']: null"
+              [parcellationNifti] = "selectedTemplate.parcellations[chosenParcellationIndex]['properties']['nifti']? selectedTemplate.parcellations[chosenParcellationIndex]['properties']['nifti'] : null">
+        </reference-toast-component>
+        </div>
+      </div>
+    </ng-template>
+  </div>
+</ng-template>
diff --git a/src/ui/ui.module.ts b/src/ui/ui.module.ts
index 33649a517..868912b55 100644
--- a/src/ui/ui.module.ts
+++ b/src/ui/ui.module.ts
@@ -46,6 +46,7 @@ import { StatusCardComponent } from "./nehubaContainer/statusCard/statusCard.com
 import { CookieAgreement } from "./cookieAgreement/cookieAgreement.component";
 import { KGToS } from "./kgtos/kgtos.component";
 import { AngularMaterialModule } from "./sharedModules/angularMaterial.module";
+import {ReferenceToastComponent} from "src/ui/referenceToast/referenceToast.component";
 
 
 @NgModule({
@@ -82,6 +83,7 @@ import { AngularMaterialModule } from "./sharedModules/angularMaterial.module";
     StatusCardComponent,
     CookieAgreement,
     KGToS,
+    ReferenceToastComponent,
 
     /* pipes */
     GroupDatasetByRegion,
@@ -126,7 +128,8 @@ import { AngularMaterialModule } from "./sharedModules/angularMaterial.module";
     CookieAgreement,
     KGToS,
     AngularMaterialModule,
-    StatusCardComponent
+    StatusCardComponent,
+    ReferenceToastComponent
   ]
 })
 
-- 
GitLab