Commit 22c7280f authored by Jan Wagemakers's avatar Jan Wagemakers

DEMO changes

parent 3103d797
......@@ -5,6 +5,7 @@
*/
package be.janwagemakers.controlthermostatbluetooth.controller;
import be.janwagemakers.controlthermostatbluetooth.Config;
import be.janwagemakers.controlthermostatbluetooth.DataList;
import be.janwagemakers.controlthermostatbluetooth.Entity.Configuration;
import be.janwagemakers.controlthermostatbluetooth.Entity.Rule;
......@@ -38,6 +39,7 @@ public class HTMLController {
@Autowired private Outside outside;
@Autowired private DataList data;
private final static boolean DEMO = Config.DEMO;
private Configuration config;
private User user = new User("New User");
......@@ -46,6 +48,7 @@ public class HTMLController {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd - HH:mm:ss");
Date date = new Date();
String clock = dateFormat.format(date);
if (DEMO) clock = clock + " DEMO";
model.addAttribute("clock", clock);
model.addAttribute("sp", data.getSp());
model.addAttribute("pv", data.getPv());
......@@ -107,10 +110,10 @@ public class HTMLController {
switch (action) {
case "Add" :
case "Save" :
newUser = userRepository.save(newUser);
if (!DEMO) newUser = userRepository.save(newUser);
break;
case "Del" :
userRepository.deleteById(Integer.parseInt(id));
if (!DEMO) userRepository.deleteById(Integer.parseInt(id));
break;
case "Rules" :
user = userRepository.findById(Integer.parseInt(id)).get();
......@@ -121,7 +124,7 @@ public class HTMLController {
@PostMapping("/config")
public String config(@ModelAttribute Configuration newConfig, Model model ) {
newConfig = configurationRepository.save(newConfig);
if (!DEMO) newConfig = configurationRepository.save(newConfig);
return config(model);
}
......@@ -130,10 +133,10 @@ public class HTMLController {
switch (action) {
case "Add" :
case "Save" :
newRule = ruleRepository.save(newRule);
if (!DEMO) newRule = ruleRepository.save(newRule);
break;
case "Del" :
ruleRepository.deleteById(Integer.parseInt(line));
if (!DEMO) ruleRepository.deleteById(Integer.parseInt(line));
break;
}
return rules(model);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment