Instance names can now be renamed on the WebUI (incl. inst 0)

Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
Paulchen-Panther
2019-08-04 20:19:33 +02:00
parent a080c7151d
commit 3dee474356
9 changed files with 121 additions and 44 deletions

View File

@@ -25,7 +25,7 @@ public:
setTable("instances");
createTable(QStringList()<<"instance INTEGER"<<"friendly_name TEXT"<<"enabled INTEGER DEFAULT 0"<<"last_use TEXT");
// create the first Hyperion instance index 0
// start/create the first Hyperion instance index 0
createInstance();
};
@@ -93,14 +93,21 @@ public:
///
inline bool saveName(const quint8& inst, const QString& name)
{
if(instanceExist(inst))
{
VectorPair cond;
cond.append(CPair("instance",inst));
QVariantMap data;
data["friendly_name"] = name;
VectorPair fcond;
fcond.append(CPair("friendly_name",name));
return updateRecord(cond, data);
// check duplicate
if(!recordExists(fcond))
{
if(instanceExist(inst))
{
VectorPair cond;
cond.append(CPair("instance",inst));
QVariantMap data;
data["friendly_name"] = name;
return updateRecord(cond, data);
}
}
return false;
}
@@ -207,13 +214,18 @@ private:
///
inline void createInstance()
{
QVariantMap data;
data["friendly_name"] = "First LED Hardware instance";
VectorPair cond;
cond.append(CPair("instance", 0));
if(createRecord(cond, data))
if(instanceExist(0))
setEnable(0, true);
else
throw std::runtime_error("Failed to create Hyperion root instance in db! This should never be the case...");
{
QVariantMap data;
data["friendly_name"] = "First LED Hardware instance";
VectorPair cond;
cond.append(CPair("instance", 0));
if(createRecord(cond, data))
setEnable(0, true);
else
throw std::runtime_error("Failed to create Hyperion root instance in db! This should never be the case...");
}
}
};