'use strict'; import { RhamtModelService } from 'raas-core'; import { Request, Response, NextFunction } from "express"; export class ConfigController { constructor(private modelService: RhamtModelService) { } public get(req: Request, res: Response, next: NextFunction): void { const config = this.modelService.getConfiguration(req.params.id); if (config) { res.render('index', {configId: JSON.stringify(config.id)}); } else { console.log('unable to find config associated with request: ' + req.originalUrl); } next(); } public post(req: Request, res: Response, next: NextFunction): void { let config = this.modelService.getConfiguration(req.params.id); let option = req.body; console.log('server received option: ' + JSON.stringify(option)); if (config) { console.log('rendering index to: ' + req.originalUrl); res.render('index', {configId: JSON.stringify(config.id)}); } else { console.log('unable to get config from path: ' + req.originalUrl); } next(); } public update(req: Request, res: Response, next: NextFunction): void { var id = req.params.id; var name = req.body.name; var cli = req.body.cli; var javaHome = req.body.javaHome; var options = req.body.options; this.modelService.update(id, name, cli, javaHome, options); next(); } }