|
1 | | -# Create open sensors networks without centralization problems |
| 1 | +# sensors.social |
2 | 2 |
|
3 | | -Decentralized Open Sensors Map. Don't forget to your IFPS ID into `src/agents.json` in case you set up your own [Sensors Connectivity module](https://github.com/airalab/sensors-connectivity/tree/master). |
| 3 | +--- |
4 | 4 |
|
5 | | -## Setup your own Map |
| 5 | +## 📌 Overview |
6 | 6 |
|
7 | | -To deploy your own instance of the map using GitHub Pages, start by forking the [repository](https://github.com/airalab/sensors.robonomics.network) and clone it. To enable GitHub Actions, go to the repository page, click on the `Actions` tab, and set up a workflow if you haven't done so already. |
8 | | -To successfully deploy the map, you will need to modify certain files: |
| 7 | +**sensors.social** is a decentralized application that visualizes data from sensors sending their measurements to the blockchain (Polkadot network, Robonomics parachain). The platform supports two modes of operation: |
9 | 8 |
|
10 | | -### Option 1: you don't have Domain |
| 9 | +- **Peer-to-peer connectivity** for direct access to sensor data. |
| 10 | +- **Federative concept** for accumulating sensor data and displaying measurement history. |
11 | 11 |
|
12 | | -1. In `.github/workflows/main.yaml` remove `cname: sensors.robonomics.network`. |
13 | | -2. Add the following code right below `runs-on: ubuntu-latest` in `.github/workflows/main.yaml`: |
| 12 | +For more details on connectivity and how to deploy your own map interface (or even a connectivity server), visit [Robonomics Academy](https://robonomics.academy/en/learn/sensors-connectivity-course/overview/). |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## 🚀 Deployment |
| 17 | + |
| 18 | +This section is intended for contributors working on the existing map and developers setting up their own map interface. For comprehensive instructions on configuring your own user interface, refer to the next sections. |
| 19 | + |
| 20 | +### 1️⃣ Fork & Clone the Repository |
| 21 | + |
| 22 | +If you plan to contribute or customize the project extensively, consider forking it first. Then clone the repository: |
| 23 | + |
| 24 | +```sh |
| 25 | + git clone <map repository> |
14 | 26 | ``` |
15 | | -permissions: |
16 | | - contents: write |
| 27 | + |
| 28 | +If you plan to contribute or customize the project extensively, consider forking it first. |
| 29 | + |
| 30 | +### 2️⃣ Install Dependencies |
| 31 | + |
| 32 | +Ensure **Node.js** and **Yarn** are installed: |
| 33 | + |
| 34 | +```sh |
| 35 | + node -v # Should be >= 16 |
| 36 | + yarn -v # Should be installed |
17 | 37 | ``` |
18 | | -3. In `vite.config.js` add `base: "/<repository name>/",` to the `defineConfig` object just above the `plugins` section , replacing `<repository_name>` with the name of your fork (default will be `sensors.robonomics.network`) |
19 | 38 |
|
20 | | -### Option 2: you have Domanin |
| 39 | +Then install the required dependencies: |
21 | 40 |
|
22 | | -1. In `.github/workflows/main.yaml` change `cname: sensors.robonomics.network` to your `CNAME`. |
23 | | -2. Add the following code right below `runs-on: ubuntu-latest` in `.github/workflows/main.yaml`: |
| 41 | +```sh |
| 42 | + yarn install |
24 | 43 | ``` |
25 | | -permissions: |
26 | | - contents: write |
| 44 | + |
| 45 | +### 3️⃣ Start the Server Locally for Development |
| 46 | + |
| 47 | +```sh |
| 48 | + yarn dev |
27 | 49 | ``` |
28 | 50 |
|
29 | | -### Manage Github Pages |
| 51 | +--- |
30 | 52 |
|
31 | | -After making modifications to the files, you can deploy your instance of the map by following these steps: |
32 | 53 |
|
33 | | -1. Commit and push the changes to your forked repository. |
34 | | -2. Wait until the actions have successfully completed. |
35 | | -3. Go to the `Pages` section of your repository `Settings`. |
36 | | -4. Enable GitHub Pages by selecting `Deploy from a branch` as the source |
37 | | -5. Choose the `gh-pages` branch and the `root` folder. |
38 | | -6. Save the settings, and GitHub Pages will deploy your instance of the map. |
39 | | -7. Access it using the provided GitHub Pages URL. |
| 54 | +## 🔧 Setup Your Own Map (For Experienced Users) |
40 | 55 |
|
41 | | -> If you dont see the GitHub Pages URL try to reload the page. |
| 56 | +### 1️⃣ Deploy Your Own Instance of the Map |
42 | 57 |
|
43 | | -## Project setup |
| 58 | +Refer to the "🚀 Deployment" section. |
44 | 59 |
|
45 | | -``` |
46 | | -yarn install |
47 | | -``` |
| 60 | +### 2️⃣ Enable GitHub Actions |
48 | 61 |
|
49 | | -### Compiles and hot-reloads for development |
| 62 | +To activate GitHub Actions in your repository: |
50 | 63 |
|
51 | | -``` |
52 | | -yarn dev |
| 64 | +- Navigate to the **Actions** tab in your GitHub repository. |
| 65 | +- If prompted, enable workflows by clicking **Enable GitHub Actions**. |
| 66 | +- Ensure that workflows are correctly set up in `.github/workflows/`. |
| 67 | + |
| 68 | +### 3️⃣ Configure Deployment |
| 69 | + |
| 70 | +#### Option 1: Deploy Without a Custom Domain |
| 71 | + |
| 72 | +- Open `.github/workflows/main.yaml` and remove the line: |
| 73 | + ```yaml |
| 74 | + cname: sensors.social |
| 75 | + ``` |
| 76 | +- Add the following permissions block right below `runs-on: ubuntu-latest`: |
| 77 | + ```yaml |
| 78 | + permissions: |
| 79 | + contents: write |
| 80 | + ``` |
| 81 | +- In `vite.config.js`, add the following line to the `defineConfig` object, just above the `plugins` section: |
| 82 | + ```javascript |
| 83 | + base: "/<repository_name>/", |
| 84 | + ``` |
| 85 | + Replace `<repository_name>` with the name of your fork. |
| 86 | + |
| 87 | +#### Option 2: Deploy With a Custom Domain |
| 88 | + |
| 89 | +- Open `.github/workflows/main.yaml` and replace: |
| 90 | + ```yaml |
| 91 | + cname: sensors.social |
| 92 | + ``` |
| 93 | + with your custom domain: |
| 94 | + ```yaml |
| 95 | + cname: your-custom-domain.com |
| 96 | + ``` |
| 97 | +- Add the following permissions block right below `runs-on: ubuntu-latest`: |
| 98 | + ```yaml |
| 99 | + permissions: |
| 100 | + contents: write |
| 101 | + ``` |
| 102 | + |
| 103 | +### 4️⃣ Finalizing Deployment |
| 104 | + |
| 105 | +After modifying the necessary files, deploy your instance of the map by following these steps: |
| 106 | + |
| 107 | +1. Commit and push the changes to your forked repository: |
| 108 | + ```sh |
| 109 | + git add . |
| 110 | + git commit -m "Configured deployment settings" |
| 111 | + git push origin main |
| 112 | + ``` |
| 113 | +2. Wait until the GitHub Actions workflow successfully completes. |
| 114 | +3. Navigate to the **Pages** section in your repository **Settings**. |
| 115 | +4. Enable GitHub Pages by selecting **Deploy from a branch** as the source. |
| 116 | +5. Choose the `gh-pages` branch and the root folder. |
| 117 | +6. Save the settings—GitHub Pages will deploy your instance of the map. |
| 118 | + |
| 119 | +You can now access your deployed map using the provided GitHub Pages URL. |
| 120 | + |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | + |
| 125 | +## 💬 Localization & Translations |
| 126 | + |
| 127 | +You can add a new language to the map by modifying the translation files located in `src/translate/`. |
| 128 | + |
| 129 | +### 📝 Adding a New Language |
| 130 | + |
| 131 | +1️⃣ **Create a new translation file** in `src/translate/`, e.g., `es.js`. |
| 132 | + |
| 133 | +2️⃣ **Update `index.js`** in the same folder: |
| 134 | + - Import your newly created translation file: |
| 135 | + |
| 136 | + ```js |
| 137 | + import es from "./es"; |
| 138 | + |
| 139 | + export default { en, ru, es }; |
| 140 | + ``` |
| 141 | + |
| 142 | + - Add the new language to the language list: |
| 143 | + |
| 144 | + ```js |
| 145 | + export const languages = [ |
| 146 | + { code: "en", title: "English" }, |
| 147 | + { code: "ru", title: "Русский" }, |
| 148 | + { code: "es", title: "Español" }, |
| 149 | + ]; |
| 150 | + ``` |
| 151 | + |
| 152 | + ### 📏 Translating Measurements |
| 153 | + |
| 154 | + Measurement values are located in `src/measurements/`. |
| 155 | + To support multiple languages, update the relevant files in this folder. |
| 156 | + |
| 157 | + #### Files to Update |
| 158 | + |
| 159 | +| Measurement Type | File Name | |
| 160 | +|-------------------------|-----------| |
| 161 | +| Carbon Monoxide | `co.js` | |
| 162 | +| Background Radiation | `gs.js` | |
| 163 | +| Humidity | `humidity.js` | |
| 164 | +| Ammonia (NH₃) | `nh3.js` | |
| 165 | +| Nitrogen Dioxide (NO₂) | `no2.js` | |
| 166 | +| Noise Levels | `noise.js`, `noiseavg.js`, `noisemax.js` | |
| 167 | +| PM10 Particulate Matter | `pm10.js` | |
| 168 | +| PM2.5 Particulate Matter | `pm25.js` | |
| 169 | +| Pressure | `pressure.js` | |
| 170 | +| Temperature | `temperature.js` | |
| 171 | + |
| 172 | +#### Example Translation Update (`humidity.js`) |
| 173 | + |
| 174 | +To add support for **Spanish (es)**, update the `name`, `nameshort`, and `zones` properties: |
| 175 | + |
| 176 | +```js |
| 177 | +
|
| 178 | + name: { |
| 179 | + en: "Humidity", |
| 180 | + ru: "Влажность", |
| 181 | + es: "Humedad" |
| 182 | + }, |
| 183 | + nameshort: { |
| 184 | + en: "Humidity", |
| 185 | + ru: "Влажность", |
| 186 | + es: "Humedad" |
| 187 | + }, |
| 188 | +
|
| 189 | + zones: [ |
| 190 | + { |
| 191 | + value: 30, |
| 192 | + color: "#ff4d00", |
| 193 | + label: { |
| 194 | + en: "Very dry", |
| 195 | + ru: "Очень сухо", |
| 196 | + es: "Muy seco" |
| 197 | + } |
| 198 | + } |
| 199 | + ] |
| 200 | + ``` |
| 201 | + |
| 202 | + --- |
| 203 | + |
| 204 | + |
| 205 | +## How to Fork the Repository with Custom Configuration Files |
| 206 | + |
| 207 | +1️⃣ Copy the `src/config/template` directory to your own: |
| 208 | + |
| 209 | +```sh |
| 210 | +cp -r src/config/template src/config/my-project |
53 | 211 | ``` |
54 | 212 |
|
55 | | -### Compiles and minifies for production |
| 213 | +2️⃣ In the `src/config/my-project/config.json` file, all parameters are optional. You can configure the following settings: |
56 | 214 |
|
| 215 | +```json |
| 216 | +{ |
| 217 | + "LIBP2P": "Configuration for initializing the LIBP2P library", |
| 218 | + "REMOTE_PROVIDER": "Server with Rozman", |
| 219 | + "WIND_PROVIDER": "Server with wind data", |
| 220 | + "MAP": { |
| 221 | + "zoom": "Zoom level", |
| 222 | + "position": { |
| 223 | + "lat": "Latitude", |
| 224 | + "lng": "Longitude" |
| 225 | + } |
| 226 | + }, |
| 227 | + "SHOW_MESSAGES": "Boolean value (true/false) indicating whether to display user messages on the map", |
| 228 | + "DEFAUL_TYPE_PROVIDER": "Default data provider type (remote or realtime)", |
| 229 | + "TITLE": "Project title", |
| 230 | + "SERIES_MAX_VISIBLE": "Maximum number of data points on the chart before grouping is applied" |
| 231 | +} |
57 | 232 | ``` |
58 | | -yarn build |
| 233 | +**Example**: [config.json](https://github.com/airalab/sensors.social/blob/master/src/config/main/config.json) |
| 234 | + |
| 235 | +3️⃣ In the `src/config/my-project/agents.json` file, specify a list of libp2p identifiers from which data can be received via pubsub in realtime mode. |
| 236 | + |
| 237 | +**Example**: [agents.json](https://github.com/airalab/sensors.social/blob/master/src/config/main/agents.json) |
| 238 | + |
| 239 | +4️⃣ In the `src/config/main/sensors.js` file, you can set an icon and a website link for a specific sensor: |
| 240 | + |
| 241 | +```json |
| 242 | +{ |
| 243 | + "HASH ID_SENSOR": { |
| 244 | + "icon": "Path to the icon file", |
| 245 | + "link": "URL of the website" |
| 246 | + } |
| 247 | +} |
59 | 248 | ``` |
60 | 249 |
|
61 | | -### Lints and fixes files |
| 250 | +**Example**: [sensors.json](https://github.com/airalab/sensors.social/blob/master/src/config/main/sensors.js) |
| 251 | + |
| 252 | +5️⃣ To ensure that your configuration is loaded in the final build, set the following environment variable: |
62 | 253 |
|
63 | 254 | ``` |
64 | | -yarn lint |
| 255 | +VITE_CONFIG_ENV=my-project |
65 | 256 | ``` |
66 | 257 |
|
67 | | -### Customize configuration |
| 258 | +You can configure this in your GitHub project settings under the Environments section. |
| 259 | + |
| 260 | +<img src="https://github.com/user-attachments/assets/97368424-ac08-4b62-9beb-3c36a61a1b47" width="500"> |
| 261 | + |
| 262 | +--- |
| 263 | + |
68 | 264 |
|
69 | | -See [Vite Configuration Reference](https://vitejs.dev/config/). |
| 265 | +## ❓ Support |
70 | 266 |
|
71 | | -## Recommended IDE Setup |
| 267 | +For questions or suggestions, create an **issue** in the repository. |
72 | 268 |
|
73 | | -[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin). |
| 269 | +--- |
0 commit comments