Files
Eric FELIXINE e30ae8ed09 feat(smart-app): implement complete mobile app MVP
- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
2026-06-01 18:00:35 -04:00

150 lines
3.1 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildResourceGroup = buildResourceGroup;
exports.buildResourceItem = buildResourceItem;
exports.ensureDefaultResourceXML = ensureDefaultResourceXML;
exports.findResourceGroup = findResourceGroup;
exports.getObjectAsResourceGroup = getObjectAsResourceGroup;
exports.getObjectAsResourceItems = getObjectAsResourceItems;
exports.getResourceItemsAsObject = getResourceItemsAsObject;
exports.readResourcesXMLAsync = readResourcesXMLAsync;
function _XML() {
const data = require("../utils/XML");
_XML = function () {
return data;
};
return data;
}
/**
* Name of the resource folder.
*/
const fallbackResourceString = `<?xml version="1.0" encoding="utf-8"?><resources></resources>`;
/**
* Read an XML file while providing a default fallback for resource files.
*
* @param options path to the XML file, returns a fallback XML if the path doesn't exist.
*/
async function readResourcesXMLAsync({
path,
fallback = fallbackResourceString
}) {
const xml = await (0, _XML().readXMLAsync)({
path,
fallback
});
// Ensure the type is expected.
if (!xml.resources) {
xml.resources = {};
}
return xml;
}
/**
* Ensure the provided xml has a `resources` object (the expected shape).
*
* @param xml
*/
function ensureDefaultResourceXML(xml) {
if (!xml) {
xml = {
resources: {}
};
}
if (!xml.resources) {
xml.resources = {};
}
return xml;
}
/**
* Build a `ResourceItemXML` given its `name` and `value`. This makes things a bit more readable.
*
* - JSON: `{ $: { name }, _: value }`
* - XML: `<item name="NAME">VALUE</item>`
*
* @param props name and value strings.
*/
function buildResourceItem({
name,
value,
targetApi,
translatable
}) {
const item = {
$: {
name
},
_: value
};
if (targetApi) {
item.$['tools:targetApi'] = targetApi;
}
if (translatable !== undefined) {
item.$['translatable'] = String(translatable);
}
return item;
}
function buildResourceGroup(parent) {
return {
$: {
name: parent.name,
parent: parent.parent
},
item: parent.items ?? []
};
}
function findResourceGroup(xml, group) {
const app = xml?.filter?.(({
$: head
}) => {
let matches = head.name === group.name;
if (group.parent != null && matches) {
matches = head.parent === group.parent;
}
return matches;
})?.[0];
return app ?? null;
}
/**
* Helper to convert a basic XML object into a simple k/v pair.
*
* @param xml
* @returns
*/
function getResourceItemsAsObject(xml) {
return xml.reduce((prev, curr) => ({
...prev,
[curr.$.name]: curr._
}), {});
}
/**
* Helper to convert a basic k/v object to a ResourceItemXML array.
*
* @param xml
* @returns
*/
function getObjectAsResourceItems(obj) {
return Object.entries(obj).map(([name, value]) => ({
$: {
name
},
_: value
}));
}
function getObjectAsResourceGroup(group) {
return {
$: {
name: group.name,
parent: group.parent
},
item: getObjectAsResourceItems(group.item)
};
}
//# sourceMappingURL=Resources.js.map