Explorar el Código

added timeline and thread to mock api

Skylsmoi hace 7 años
padre
commit
c71669c1a6
Se han modificado 2 ficheros con 163 adiciones y 3 borrados
  1. 17 1
      jsonserver/server.js
  2. 146 2
      jsonserver/static_db.json

+ 17 - 1
jsonserver/server.js Ver fichero

@@ -31,7 +31,23 @@ server.get('/user/is_logged_in', (req, res) => res.jsonp(jsonDb.user_logged))
31 31
 
32 32
 server.get('/workspace/:id', (req, res) => res.jsonp(jsonDb.workspace_detail))
33 33
 
34
-server.get('/workspace/:idws/content/:idc', (req, res) => res.jsonp(jsonDb.content_data))
34
+server.get('/workspace/:idws/content/:idc', (req, res) => {
35
+  switch (req.params.idc) {
36
+    case '1': // pageHtml
37
+      return res.jsonp(jsonDb.content_data_pageHtml)
38
+    case '2':
39
+      return res.jsonp(jsonDb.content_data_thread)
40
+  }
41
+})
42
+
43
+server.get('/workspace/:idws/content/:idc/timeline', (req, res) => {
44
+  switch (req.params.idc) {
45
+    case '1': // pageHtml
46
+      return res.jsonp(jsonDb.timeline)
47
+    case '2':
48
+      return res.jsonp([])
49
+  }
50
+})
35 51
 
36 52
 server.use(router)
37 53
 server.listen(GLOBAL_PORT, () => {

+ 146 - 2
jsonserver/static_db.json Ver fichero

@@ -6,7 +6,8 @@
6 6
       "username": "Smoi",
7 7
       "firstname": "Côme",
8 8
       "lastname": "Stoilenom",
9
-      "email": "osef@algoo.fr"
9
+      "email": "osef@algoo.fr",
10
+      "avatar": "https://avatars3.githubusercontent.com/u/11177014?s=460&v=4"
10 11
     }
11 12
   },
12 13
   "app_config": [{
@@ -108,12 +109,155 @@
108 109
       }
109 110
     ]
110 111
   },
111
-  "content_data": {
112
+  "timeline": [{
113
+    "id": 0,
114
+    "type": "message",
115
+    "author": {
116
+      "id": 5,
117
+      "username": "Stoi",
118
+      "avatar": "https://avatars3.githubusercontent.com/u/11177014?s=460&v=4"
119
+    },
120
+    "createdAt": {
121
+      "day": "27/11/17",
122
+      "hour": "11h45"
123
+    },
124
+    "text": "Proident esse laboris in sed officia exercitation ut anim ea."
125
+  }, {
126
+    "id": 1,
127
+    "type": "message",
128
+    "author": {
129
+      "id": 1,
130
+      "username": "smoi",
131
+      "avatar": "https://www.algoo.fr/static/images/algoo_images/algoo-logo.jpg"
132
+    },
133
+    "createdAt": {
134
+      "day": "27/11/16",
135
+      "hour": "10h30"
136
+    },
137
+    "text": "Proident esse laboris in sed officia exercitation ut anim ea. in sed officia exercitation ut"
138
+  }, {
139
+    "id": 2,
140
+    "type": "message",
141
+    "author": {
142
+      "id": 1,
143
+      "username": "smoi",
144
+      "avatar": "https://www.algoo.fr/static/images/algoo_images/algoo-logo.jpg"
145
+    },
146
+    "createdAt": {
147
+      "day": "27/11/15",
148
+      "hour": "10h30"
149
+    },
150
+    "text": "Proident esse laboris in sed officia exercitation ut anim ea. Proident esse laboris in sed officia exercitation ut anim ea. Proident esse laboris in sed officia exercitation ut anim ea."
151
+  }, {
152
+    "id": 3,
153
+    "type": "version",
154
+    "author": {
155
+      "id": 1,
156
+      "username": "smoi",
157
+      "avatar": "https://www.algoo.fr/static/images/algoo_images/algoo-logo.jpg"
158
+    },
159
+    "createdAt": {
160
+      "day": "27/11/11"
161
+    },
162
+    "number": "5"
163
+  }],
164
+  "content_data_pageHtml": {
112 165
     "id": "1",
113 166
     "type": "pageHtml",
114 167
     "title": "La programmation fonctionnelle",
115 168
     "status": "validated",
116 169
     "version": "3",
117 170
     "text": "<h1>Mon titre nul</h1>Je suis le contenu de cette fameuse <b>page HTML</b><br /> sur la programmation fonctionnelle"
171
+  },
172
+  "content_data_thread": {
173
+    "id": 2,
174
+    "type": "thread",
175
+    "title": "La programmation fonctionnelle est-elle vraiment utile ?",
176
+    "status": "validated",
177
+    "message_list": [{
178
+      "id": 0,
179
+      "author": {
180
+        "id": 2,
181
+        "username": "Peter",
182
+        "avatar": "https://avatars3.githubusercontent.com/u/1104637?s=460&v=4"
183
+      },
184
+      "text": "Tu aurais envie de manger quoi exactement ?",
185
+      "createdAt": {
186
+        "day": "05/03/18",
187
+        "hour": "10h00"
188
+      }
189
+    }, {
190
+      "id": 1,
191
+      "author": {
192
+        "id": 3,
193
+        "username": "Steven",
194
+        "avatar": "https://avatars3.githubusercontent.com/u/705214?s=460&v=4"
195
+      },
196
+      "createdAt": {
197
+        "day": "05/03/18",
198
+        "hour": "09h59"
199
+      },
200
+      "text": "Ben je sais pas, par exemple une quiche lorraine."
201
+    }, {
202
+      "id": 2,
203
+      "author": {
204
+        "id": 2,
205
+        "username": "Peter",
206
+        "avatar": "https://avatars3.githubusercontent.com/u/1104637?s=460&v=4"
207
+      },
208
+      "text": "Une ouiche.",
209
+      "createdAt": {
210
+        "day": "05/03/18",
211
+        "hour": "09h59"
212
+      }
213
+    }, {
214
+      "id": 3,
215
+      "author": {
216
+        "id": 3,
217
+        "username": "Steven",
218
+        "avatar": "https://avatars3.githubusercontent.com/u/705214?s=460&v=4"
219
+      },
220
+      "createdAt": {
221
+        "day": "05/03/18",
222
+        "hour": "09h59"
223
+      },
224
+      "text": "Quoi ?"
225
+    }, {
226
+      "id": 4,
227
+      "author": {
228
+        "id": 2,
229
+        "username": "Peter",
230
+        "avatar": "https://avatars3.githubusercontent.com/u/1104637?s=460&v=4"
231
+      },
232
+      "text": "On dit « une ouiche lorraine ».",
233
+      "createdAt": {
234
+        "day": "05/03/18",
235
+        "hour": "09h59"
236
+      }
237
+    }, {
238
+      "id": 5,
239
+      "author": {
240
+        "id": 3,
241
+        "username": "Steven",
242
+        "avatar": "https://avatars3.githubusercontent.com/u/705214?s=460&v=4"
243
+      },
244
+      "createdAt": {
245
+        "day": "05/03/18",
246
+        "hour": "09h58"
247
+      },
248
+      "text": "Tu es sûr ?"
249
+    }, {
250
+      "id": 6,
251
+      "author": {
252
+        "id": 3,
253
+        "username": "Steven",
254
+        "avatar": "https://avatars3.githubusercontent.com/u/705214?s=460&v=4"
255
+      },
256
+      "text": "Ça fait bizarre, « ouiche lorraine ».",
257
+      "createdAt": {
258
+        "day": "05/03/18",
259
+        "hour": "09h59"
260
+      }
261
+    }]
118 262
   }
119 263
 }