mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
remove open hours from domain settings
This commit is contained in:
parent
be4fbb63cf
commit
4bbd823a5a
5 changed files with 2 additions and 330 deletions
|
@ -141,218 +141,6 @@
|
|||
"can_set": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "Operating Hours",
|
||||
"help": "\"Open\" domains can be searched using their operating hours. Hours are entered in the local timezone, selected below.",
|
||||
|
||||
"name": "weekday_hours",
|
||||
"caption": "Weekday Hours (Monday-Friday)",
|
||||
"type": "table",
|
||||
"can_add_new_rows": false,
|
||||
"columns": [
|
||||
{
|
||||
"name": "open",
|
||||
"label": "Opening Time",
|
||||
"type": "time",
|
||||
"default": "00:00",
|
||||
"editable": true
|
||||
},
|
||||
{
|
||||
"name": "close",
|
||||
"label": "Closing Time",
|
||||
"type": "time",
|
||||
"default": "23:59",
|
||||
"editable": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "weekend_hours",
|
||||
"label": "Weekend Hours (Saturday/Sunday)",
|
||||
"type": "table",
|
||||
"can_add_new_rows": false,
|
||||
"columns": [
|
||||
{
|
||||
"name": "open",
|
||||
"label": "Opening Time",
|
||||
"type": "time",
|
||||
"default": "00:00",
|
||||
"editable": true
|
||||
},
|
||||
{
|
||||
"name": "close",
|
||||
"label": "Closing Time",
|
||||
"type": "time",
|
||||
"default": "23:59",
|
||||
"editable": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "Time Zone",
|
||||
"name": "utc_offset",
|
||||
"caption": "Time Zone",
|
||||
"help": "This server's time zone. Used to define your server's operating hours.",
|
||||
"type": "select",
|
||||
"options": [
|
||||
{
|
||||
"value": "-12",
|
||||
"label": "UTC-12:00"
|
||||
},
|
||||
{
|
||||
"value": "-11",
|
||||
"label": "UTC-11:00"
|
||||
},
|
||||
{
|
||||
"value": "-10",
|
||||
"label": "UTC-10:00"
|
||||
},
|
||||
{
|
||||
"value": "-9.5",
|
||||
"label": "UTC-09:30"
|
||||
},
|
||||
{
|
||||
"value": "-9",
|
||||
"label": "UTC-09:00"
|
||||
},
|
||||
{
|
||||
"value": "-8",
|
||||
"label": "UTC-08:00"
|
||||
},
|
||||
{
|
||||
"value": "-7",
|
||||
"label": "UTC-07:00"
|
||||
},
|
||||
{
|
||||
"value": "-6",
|
||||
"label": "UTC-06:00"
|
||||
},
|
||||
{
|
||||
"value": "-5",
|
||||
"label": "UTC-05:00"
|
||||
},
|
||||
{
|
||||
"value": "-4",
|
||||
"label": "UTC-04:00"
|
||||
},
|
||||
{
|
||||
"value": "-3.5",
|
||||
"label": "UTC-03:30"
|
||||
},
|
||||
{
|
||||
"value": "-3",
|
||||
"label": "UTC-03:00"
|
||||
},
|
||||
{
|
||||
"value": "-2",
|
||||
"label": "UTC-02:00"
|
||||
},
|
||||
{
|
||||
"value": "-1",
|
||||
"label": "UTC-01:00"
|
||||
},
|
||||
{
|
||||
"value": "",
|
||||
"label": "UTC±00:00"
|
||||
},
|
||||
{
|
||||
"value": "1",
|
||||
"label": "UTC+01:00"
|
||||
},
|
||||
{
|
||||
"value": "2",
|
||||
"label": "UTC+02:00"
|
||||
},
|
||||
{
|
||||
"value": "3",
|
||||
"label": "UTC+03:00"
|
||||
},
|
||||
{
|
||||
"value": "3.5",
|
||||
"label": "UTC+03:30"
|
||||
},
|
||||
{
|
||||
"value": "4",
|
||||
"label": "UTC+04:00"
|
||||
},
|
||||
{
|
||||
"value": "4.5",
|
||||
"label": "UTC+04:30"
|
||||
},
|
||||
{
|
||||
"value": "5",
|
||||
"label": "UTC+05:00"
|
||||
},
|
||||
{
|
||||
"value": "5.5",
|
||||
"label": "UTC+05:30"
|
||||
},
|
||||
{
|
||||
"value": "5.75",
|
||||
"label": "UTC+05:45"
|
||||
},
|
||||
{
|
||||
"value": "6",
|
||||
"label": "UTC+06:00"
|
||||
},
|
||||
{
|
||||
"value": "6.5",
|
||||
"label": "UTC+06:30"
|
||||
},
|
||||
{
|
||||
"value": "7",
|
||||
"label": "UTC+07:00"
|
||||
},
|
||||
{
|
||||
"value": "8",
|
||||
"label": "UTC+08:00"
|
||||
},
|
||||
{
|
||||
"value": "8.5",
|
||||
"label": "UTC+08:30"
|
||||
},
|
||||
{
|
||||
"value": "8.75",
|
||||
"label": "UTC+08:45"
|
||||
},
|
||||
{
|
||||
"value": "9",
|
||||
"label": "UTC+09:00"
|
||||
},
|
||||
{
|
||||
"value": "9.5",
|
||||
"label": "UTC+09:30"
|
||||
},
|
||||
{
|
||||
"value": "10",
|
||||
"label": "UTC+10:00"
|
||||
},
|
||||
{
|
||||
"value": "10.5",
|
||||
"label": "UTC+10:30"
|
||||
},
|
||||
{
|
||||
"value": "11",
|
||||
"label": "UTC+11:00"
|
||||
},
|
||||
{
|
||||
"value": "12",
|
||||
"label": "UTC+12:00"
|
||||
},
|
||||
{
|
||||
"value": "12.75",
|
||||
"label": "UTC+12:45"
|
||||
},
|
||||
{
|
||||
"value": "13",
|
||||
"label": "UTC+13:00"
|
||||
},
|
||||
{
|
||||
"value": "14",
|
||||
"label": "UTC+14:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -35,12 +35,6 @@ const QString DomainMetadata::Descriptors::RESTRICTION = "restriction"; // parse
|
|||
const QString DomainMetadata::Descriptors::MATURITY = "maturity";
|
||||
const QString DomainMetadata::Descriptors::HOSTS = "hosts";
|
||||
const QString DomainMetadata::Descriptors::TAGS = "tags";
|
||||
const QString DomainMetadata::Descriptors::HOURS = "hours";
|
||||
const QString DomainMetadata::Descriptors::Hours::WEEKDAY = "weekday";
|
||||
const QString DomainMetadata::Descriptors::Hours::WEEKEND = "weekend";
|
||||
const QString DomainMetadata::Descriptors::Hours::UTC_OFFSET = "utc_offset";
|
||||
const QString DomainMetadata::Descriptors::Hours::OPEN = "open";
|
||||
const QString DomainMetadata::Descriptors::Hours::CLOSE = "close";
|
||||
// descriptors metadata will appear as (JSON):
|
||||
// { "description": String, // capped description
|
||||
// "capacity": Number,
|
||||
|
@ -48,11 +42,6 @@ const QString DomainMetadata::Descriptors::Hours::CLOSE = "close";
|
|||
// "maturity": String, // enum corresponding to ESRB ratings
|
||||
// "hosts": [ String ], // capped list of usernames
|
||||
// "tags": [ String ], // capped list of tags
|
||||
// "hours": {
|
||||
// "utc_offset": Number,
|
||||
// "weekday": [ [ Time, Time ] ],
|
||||
// "weekend": [ [ Time, Time ] ],
|
||||
// }
|
||||
// }
|
||||
|
||||
// metadata will appear as (JSON):
|
||||
|
@ -60,52 +49,10 @@ const QString DomainMetadata::Descriptors::Hours::CLOSE = "close";
|
|||
//
|
||||
// it is meant to be sent to and consumed by an external API
|
||||
|
||||
// merge delta into target
|
||||
// target should be of the form [ OpenTime, CloseTime ],
|
||||
// delta should be of the form [ { open: Time, close: Time } ]
|
||||
void parseHours(QVariant delta, QVariant& target) {
|
||||
using Hours = DomainMetadata::Descriptors::Hours;
|
||||
static const QVariantList DEFAULT_HOURS{
|
||||
{ QVariantList{ "00:00", "23:59" } }
|
||||
};
|
||||
target.setValue(DEFAULT_HOURS);
|
||||
|
||||
if (!delta.canConvert<QVariantList>()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& deltaList = *static_cast<QVariantList*>(delta.data());
|
||||
if (deltaList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& deltaHours = *static_cast<QVariantMap*>(deltaList.first().data());
|
||||
auto open = deltaHours.find(Hours::OPEN);
|
||||
auto close = deltaHours.find(Hours::CLOSE);
|
||||
if (open == deltaHours.end() || close == deltaHours.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// merge delta into new hours
|
||||
static const int OPEN_INDEX = 0;
|
||||
static const int CLOSE_INDEX = 1;
|
||||
auto& hours = *static_cast<QVariantList*>(static_cast<QVariantList*>(target.data())->first().data());
|
||||
hours[OPEN_INDEX] = open.value();
|
||||
hours[CLOSE_INDEX] = close.value();
|
||||
|
||||
assert(hours[OPEN_INDEX].canConvert<QString>());
|
||||
assert(hours[CLOSE_INDEX].canConvert<QString>());
|
||||
}
|
||||
|
||||
DomainMetadata::DomainMetadata(QObject* domainServer) : QObject(domainServer) {
|
||||
// set up the structure necessary for casting during parsing (see parseHours, esp.)
|
||||
// set up the structure necessary for casting during parsing
|
||||
_metadata[USERS] = QVariantMap {};
|
||||
_metadata[DESCRIPTORS] = QVariantMap { {
|
||||
Descriptors::HOURS, QVariantMap {
|
||||
{ Descriptors::Hours::WEEKDAY, QVariant{} },
|
||||
{ Descriptors::Hours::WEEKEND, QVariant{} }
|
||||
}
|
||||
} };
|
||||
_metadata[DESCRIPTORS] = QVariantMap {};
|
||||
|
||||
assert(dynamic_cast<DomainServer*>(domainServer));
|
||||
DomainServer* server = static_cast<DomainServer*>(domainServer);
|
||||
|
@ -154,16 +101,6 @@ void DomainMetadata::descriptorsChanged() {
|
|||
unsigned int capacity = capacityVariant ? capacityVariant->toUInt() : 0;
|
||||
state[Descriptors::CAPACITY] = capacity;
|
||||
|
||||
// parse operating hours
|
||||
static const QString WEEKDAY_HOURS = "weekday_hours";
|
||||
static const QString WEEKEND_HOURS = "weekend_hours";
|
||||
static const QString UTC_OFFSET = "utc_offset";
|
||||
assert(state[Descriptors::HOURS].canConvert<QVariantMap>());
|
||||
auto& hours = *static_cast<QVariantMap*>(state[Descriptors::HOURS].data());
|
||||
hours[Descriptors::Hours::UTC_OFFSET] = descriptors.take(UTC_OFFSET);
|
||||
parseHours(descriptors[WEEKDAY_HOURS], hours[Descriptors::Hours::WEEKDAY]);
|
||||
parseHours(descriptors[WEEKEND_HOURS], hours[Descriptors::Hours::WEEKEND]);
|
||||
|
||||
#if DEV_BUILD || PR_BUILD
|
||||
qDebug() << "Domain metadata descriptors set:" << QJsonObject::fromVariantMap(_metadata[DESCRIPTORS].toMap());
|
||||
#endif
|
||||
|
|
|
@ -39,15 +39,6 @@ public:
|
|||
static const QString MATURITY;
|
||||
static const QString HOSTS;
|
||||
static const QString TAGS;
|
||||
static const QString HOURS;
|
||||
class Hours {
|
||||
public:
|
||||
static const QString WEEKDAY;
|
||||
static const QString WEEKEND;
|
||||
static const QString UTC_OFFSET;
|
||||
static const QString OPEN;
|
||||
static const QString CLOSE;
|
||||
};
|
||||
};
|
||||
|
||||
DomainMetadata(QObject* domainServer);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <QtCore/QStandardPaths>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QUrlQuery>
|
||||
#include <QTimeZone>
|
||||
|
||||
#include <AccountManager.h>
|
||||
#include <Assignment.h>
|
||||
|
@ -270,11 +269,6 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
|
|||
_agentPermissions.clear();
|
||||
}
|
||||
|
||||
if (oldVersion < 1.5) {
|
||||
// This was prior to operating hours, so add default hours
|
||||
validateDescriptorsMap();
|
||||
}
|
||||
|
||||
if (oldVersion < 1.6) {
|
||||
unpackPermissions();
|
||||
|
||||
|
@ -305,46 +299,10 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
|
|||
}
|
||||
|
||||
QVariantMap& DomainServerSettingsManager::getDescriptorsMap() {
|
||||
validateDescriptorsMap();
|
||||
|
||||
static const QString DESCRIPTORS{ "descriptors" };
|
||||
return *static_cast<QVariantMap*>(getSettingsMap()[DESCRIPTORS].data());
|
||||
}
|
||||
|
||||
void DomainServerSettingsManager::validateDescriptorsMap() {
|
||||
static const QString WEEKDAY_HOURS{ "descriptors.weekday_hours" };
|
||||
static const QString WEEKEND_HOURS{ "descriptors.weekend_hours" };
|
||||
static const QString UTC_OFFSET{ "descriptors.utc_offset" };
|
||||
|
||||
QVariant* weekdayHours = _configMap.valueForKeyPath(WEEKDAY_HOURS, true);
|
||||
QVariant* weekendHours = _configMap.valueForKeyPath(WEEKEND_HOURS, true);
|
||||
QVariant* utcOffset = _configMap.valueForKeyPath(UTC_OFFSET, true);
|
||||
|
||||
static const QString OPEN{ "open" };
|
||||
static const QString CLOSE{ "close" };
|
||||
static const QString DEFAULT_OPEN{ "00:00" };
|
||||
static const QString DEFAULT_CLOSE{ "23:59" };
|
||||
bool wasMalformed = false;
|
||||
if (weekdayHours->isNull()) {
|
||||
*weekdayHours = QVariantList{ QVariantMap{ { OPEN, QVariant(DEFAULT_OPEN) }, { CLOSE, QVariant(DEFAULT_CLOSE) } } };
|
||||
wasMalformed = true;
|
||||
}
|
||||
if (weekendHours->isNull()) {
|
||||
*weekendHours = QVariantList{ QVariantMap{ { OPEN, QVariant(DEFAULT_OPEN) }, { CLOSE, QVariant(DEFAULT_CLOSE) } } };
|
||||
wasMalformed = true;
|
||||
}
|
||||
if (utcOffset->isNull()) {
|
||||
*utcOffset = QVariant(QTimeZone::systemTimeZone().offsetFromUtc(QDateTime::currentDateTime()) / (float)SECS_PER_HOUR);
|
||||
wasMalformed = true;
|
||||
}
|
||||
|
||||
if (wasMalformed) {
|
||||
// write the new settings to file
|
||||
persistToFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DomainServerSettingsManager::initializeGroupPermissions(NodePermissionsMap& permissionsRows,
|
||||
QString groupName, NodePermissionsPointer perms) {
|
||||
// this is called when someone has used the domain-settings webpage to add a group. They type the group's name
|
||||
|
|
|
@ -138,8 +138,6 @@ private:
|
|||
|
||||
friend class DomainServer;
|
||||
|
||||
void validateDescriptorsMap();
|
||||
|
||||
// these cause calls to metaverse's group api
|
||||
void apiGetGroupID(const QString& groupName);
|
||||
void apiGetGroupRanks(const QUuid& groupID);
|
||||
|
|
Loading…
Reference in a new issue