]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/menu/language-chooser.component.ts
Add background effect to active menu page
[github/Chocobozzz/PeerTube.git] / client / src / app / menu / language-chooser.component.ts
index 3de6a129d356f28156b541a7095be51a7b46349a..8eb84673ea08242b3d6119f9c514e7378ff1151c 100644 (file)
@@ -1,6 +1,7 @@
-import { Component, ViewChild } from '@angular/core'
-import { ModalDirective } from 'ngx-bootstrap/modal'
+import { Component, ElementRef, ViewChild } from '@angular/core'
 import { I18N_LOCALES } from '../../../../shared'
+import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
+import { sortBy } from '@app/shared/misc/utils'
 
 @Component({
   selector: 'my-language-chooser',
@@ -8,21 +9,19 @@ import { I18N_LOCALES } from '../../../../shared'
   styleUrls: [ './language-chooser.component.scss' ]
 })
 export class LanguageChooserComponent {
-  @ViewChild('modal') modal: ModalDirective
+  @ViewChild('modal') modal: ElementRef
 
-  languages: { [ id: string ]: string }[] = []
+  languages: { id: string, label: string }[] = []
 
-  constructor () {
-    this.languages = Object.keys(I18N_LOCALES)
-      .map(k => ({ id: k, label: I18N_LOCALES[k] }))
-  }
+  constructor (private modalService: NgbModal) {
+    const l = Object.keys(I18N_LOCALES)
+                    .map(k => ({ id: k, label: I18N_LOCALES[k] }))
 
-  show () {
-    this.modal.show()
+    this.languages = sortBy(l, 'label')
   }
 
-  hide () {
-    this.modal.hide()
+  show () {
+    this.modalService.open(this.modal)
   }
 
   buildLanguageLink (lang: { id: string }) {