| .. | .. |
|---|
| 7 | 7 | import { AfterViewInit, Component, ViewChild } from '@angular/core'; |
|---|
| 8 | 8 | import { ActivatedRoute, Router } from '@angular/router'; |
|---|
| 9 | 9 | |
|---|
| 10 | | -import { TdMediaService, TdFileInputComponent } from '@covalent/core'; |
|---|
| 10 | +import { TdMediaService, TdFileInputComponent, TdDialogService } from '@covalent/core'; |
|---|
| 11 | 11 | import { FormBase, IComboOption } from './base'; |
|---|
| 12 | 12 | import { ToastsManager } from "ng2-toastr/ng2-toastr"; |
|---|
| 13 | 13 | |
|---|
| .. | .. |
|---|
| 20 | 20 | export class LicenseFormComponent extends FormBase { |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | @ViewChild('requestFileUploader') requestFileUploader : TdFileInputComponent; |
|---|
| 23 | | - form_title: string = ''; |
|---|
| 24 | | - form_subtitle: string = ''; |
|---|
| 25 | | - data: any = {}; |
|---|
| 26 | 23 | pack: any = null; |
|---|
| 27 | | - isNew : boolean = true; |
|---|
| 28 | 24 | |
|---|
| 29 | 25 | constructor(private http: Http, |
|---|
| 30 | 26 | private licenses: LicensesService, |
|---|
| .. | .. |
|---|
| 32 | 28 | private packs: PacksService, |
|---|
| 33 | 29 | toaster: ToastsManager, |
|---|
| 34 | 30 | route: ActivatedRoute, |
|---|
| 35 | | - $L: LocaleService) { |
|---|
| 36 | | - super($L, route, toaster, licenses, $L.get('license')); |
|---|
| 31 | + $L: LocaleService, |
|---|
| 32 | + dialogs: TdDialogService) { |
|---|
| 33 | + super($L, route, toaster, licenses, $L.get('license'), dialogs); |
|---|
| 37 | 34 | } |
|---|
| 38 | 35 | |
|---|
| 39 | 36 | requestFileSelected(file: File) : void { |
|---|
| .. | .. |
|---|
| 41 | 38 | console.log(this.requestFileUploader); |
|---|
| 42 | 39 | if (!window.FileReader) { // Browser is not |
|---|
| 43 | 40 | // compatible |
|---|
| 44 | | - console.log(this.$L.get("Open your .req file with a text editor and copy&paste the content in the form text field?")); |
|---|
| 41 | + console.log(this.$L.get("Open your .req file with a text editor and copy&paste the content in the form text field")); |
|---|
| 45 | 42 | return; |
|---|
| 46 | 43 | } |
|---|
| 47 | 44 | var reader = new FileReader(); |
|---|
| .. | .. |
|---|
| 54 | 51 | this.requestFileUploader.clear(); |
|---|
| 55 | 52 | } |
|---|
| 56 | 53 | |
|---|
| 54 | + |
|---|
| 57 | 55 | requestFileUploaded(file: File) : void { |
|---|
| 58 | 56 | console.log(file); |
|---|
| 59 | 57 | } |
|---|
| .. | .. |
|---|
| 82 | 80 | |
|---|
| 83 | 81 | this.route.params.subscribe(params => { |
|---|
| 84 | 82 | var packId = +params['packId']; // (+) converts string 'id' to a number |
|---|
| 85 | | - super.prepareData('licenseId', { |
|---|
| 83 | + super.prepareInitialData('licenseId', { |
|---|
| 86 | 84 | pack_id: packId, |
|---|
| 87 | 85 | activation_code: this.createActivationCode() |
|---|
| 88 | 86 | }); |
|---|
| 87 | + this.packs.get(packId).subscribe( |
|---|
| 88 | + packData => { |
|---|
| 89 | + this.pack = packData; |
|---|
| 90 | + }, |
|---|
| 91 | + err => console.error(err) |
|---|
| 92 | + ); |
|---|
| 89 | 93 | }); |
|---|
| 90 | 94 | } |
|---|
| 91 | 95 | } |
|---|