aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/app/core/config/config.service.ts
blob: acdc12cc66b5e60065c458161c29702c26178f08 (plain) (tree)
1
2
3
4
5
6
7
8
9

                                          
 
                                                 
                                                    


                            
                                                              
 
                                  
             
                    
     
   
 
               
                       
                                        

      
                 


                                                    

                                 

   

                      

   
import { Injectable } from '@angular/core'
import { Http } from '@angular/http'

import { RestExtractor } from '../../shared/rest'
import { ServerConfig } from '../../../../../shared'

@Injectable()
export class ConfigService {
  private static BASE_CONFIG_URL = API_URL + '/api/v1/config/'

  private config: ServerConfig = {
    signup: {
      allowed: false
    }
  }

  constructor (
    private http: Http,
    private restExtractor: RestExtractor
  ) {}

  loadConfig () {
    this.http.get(ConfigService.BASE_CONFIG_URL)
             .map(this.restExtractor.extractDataGet)
             .subscribe(data => {
               this.config = data
             })
  }

  getConfig () {
    return this.config
  }
}