diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Controllers/Http/DashboardController.js | 10 | ||||
-rw-r--r-- | app/Controllers/Http/RecipeController.js | 9 | ||||
-rw-r--r-- | app/Controllers/Http/ServiceController.js | 103 | ||||
-rw-r--r-- | app/Controllers/Http/StaticController.js | 36 | ||||
-rw-r--r-- | app/Controllers/Http/UserController.js | 8 | ||||
-rw-r--r-- | app/Controllers/Http/WorkspaceController.js | 2 |
6 files changed, 84 insertions, 84 deletions
diff --git a/app/Controllers/Http/DashboardController.js b/app/Controllers/Http/DashboardController.js index fe179c9..1018f78 100644 --- a/app/Controllers/Http/DashboardController.js +++ b/app/Controllers/Http/DashboardController.js | |||
@@ -166,7 +166,7 @@ class DashboardController { | |||
166 | session, | 166 | session, |
167 | response, | 167 | response, |
168 | }) { | 168 | }) { |
169 | let validation = await validateAll(request.all(), { | 169 | const validation = await validateAll(request.all(), { |
170 | file: 'required', | 170 | file: 'required', |
171 | }); | 171 | }); |
172 | if (validation.fails()) { | 172 | if (validation.fails()) { |
@@ -177,14 +177,14 @@ class DashboardController { | |||
177 | let file; | 177 | let file; |
178 | try { | 178 | try { |
179 | file = JSON.parse(request.input('file')); | 179 | file = JSON.parse(request.input('file')); |
180 | } catch(e) { | 180 | } catch (e) { |
181 | session.flash({ type: 'danger', message: 'Invalid Ferdi account file' }) | 181 | session.flash({ type: 'danger', message: 'Invalid Ferdi account file' }); |
182 | return response.redirect('back'); | 182 | return response.redirect('back'); |
183 | } | 183 | } |
184 | console.log(file); | 184 | console.log(file); |
185 | 185 | ||
186 | if(!file || !file.services || !file.workspaces) { | 186 | if (!file || !file.services || !file.workspaces) { |
187 | session.flash({ type: 'danger', message: 'Invalid Ferdi account file (2)' }) | 187 | session.flash({ type: 'danger', message: 'Invalid Ferdi account file (2)' }); |
188 | return response.redirect('back'); | 188 | return response.redirect('back'); |
189 | } | 189 | } |
190 | 190 | ||
diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js index 6c8aa21..9bfd92e 100644 --- a/app/Controllers/Http/RecipeController.js +++ b/app/Controllers/Http/RecipeController.js | |||
@@ -35,7 +35,7 @@ class RecipeController { | |||
35 | const customRecipes = customRecipesArray.map((recipe) => ({ | 35 | const customRecipes = customRecipesArray.map((recipe) => ({ |
36 | id: recipe.recipeId, | 36 | id: recipe.recipeId, |
37 | name: recipe.name, | 37 | name: recipe.name, |
38 | ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, | 38 | ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, |
39 | })); | 39 | })); |
40 | 40 | ||
41 | const recipes = [ | 41 | const recipes = [ |
@@ -144,7 +144,7 @@ class RecipeController { | |||
144 | results = dbResults.map((recipe) => ({ | 144 | results = dbResults.map((recipe) => ({ |
145 | id: recipe.recipeId, | 145 | id: recipe.recipeId, |
146 | name: recipe.name, | 146 | name: recipe.name, |
147 | ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, | 147 | ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, |
148 | })); | 148 | })); |
149 | } else { | 149 | } else { |
150 | let remoteResults = []; | 150 | let remoteResults = []; |
@@ -155,7 +155,7 @@ class RecipeController { | |||
155 | const localResults = localResultsArray.map((recipe) => ({ | 155 | const localResults = localResultsArray.map((recipe) => ({ |
156 | id: recipe.recipeId, | 156 | id: recipe.recipeId, |
157 | name: recipe.name, | 157 | name: recipe.name, |
158 | ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, | 158 | ...typeof recipe.data === 'string' ? JSON.parse(recipe.data) : recipe.data, |
159 | })); | 159 | })); |
160 | 160 | ||
161 | results = [ | 161 | results = [ |
@@ -194,7 +194,8 @@ class RecipeController { | |||
194 | // Check if recipe exists in recipes folder | 194 | // Check if recipe exists in recipes folder |
195 | if (await Drive.exists(`${service}.tar.gz`)) { | 195 | if (await Drive.exists(`${service}.tar.gz`)) { |
196 | return response.send(await Drive.get(`${service}.tar.gz`)); | 196 | return response.send(await Drive.get(`${service}.tar.gz`)); |
197 | } else if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq | 197 | } |
198 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq | ||
198 | return response.redirect(`https://api.franzinfra.com/v1/recipes/download/${service}`); | 199 | return response.redirect(`https://api.franzinfra.com/v1/recipes/download/${service}`); |
199 | } | 200 | } |
200 | return response.status(400).send({ | 201 | return response.status(400).send({ |
diff --git a/app/Controllers/Http/ServiceController.js b/app/Controllers/Http/ServiceController.js index 90055b6..a1d26cb 100644 --- a/app/Controllers/Http/ServiceController.js +++ b/app/Controllers/Http/ServiceController.js | |||
@@ -86,7 +86,7 @@ class ServiceController { | |||
86 | const services = (await auth.user.services().fetch()).rows; | 86 | const services = (await auth.user.services().fetch()).rows; |
87 | // Convert to array with all data Franz wants | 87 | // Convert to array with all data Franz wants |
88 | const servicesArray = services.map((service) => { | 88 | const servicesArray = services.map((service) => { |
89 | const settings = typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings; | 89 | const settings = typeof service.settings === 'string' ? JSON.parse(service.settings) : service.settings; |
90 | 90 | ||
91 | return { | 91 | return { |
92 | customRecipe: false, | 92 | customRecipe: false, |
@@ -105,7 +105,7 @@ class ServiceController { | |||
105 | name: service.name, | 105 | name: service.name, |
106 | recipeId: service.recipeId, | 106 | recipeId: service.recipeId, |
107 | userId: auth.user.id, | 107 | userId: auth.user.id, |
108 | } | 108 | }; |
109 | }); | 109 | }); |
110 | 110 | ||
111 | return response.send(servicesArray); | 111 | return response.send(servicesArray); |
@@ -127,7 +127,7 @@ class ServiceController { | |||
127 | // Upload custom service icon | 127 | // Upload custom service icon |
128 | const icon = request.file('icon', { | 128 | const icon = request.file('icon', { |
129 | types: ['image'], | 129 | types: ['image'], |
130 | size: '2mb' | 130 | size: '2mb', |
131 | }); | 131 | }); |
132 | const { | 132 | const { |
133 | id, | 133 | id, |
@@ -135,17 +135,17 @@ class ServiceController { | |||
135 | const service = (await Service.query() | 135 | const service = (await Service.query() |
136 | .where('serviceId', id) | 136 | .where('serviceId', id) |
137 | .where('userId', auth.user.id).fetch()).rows[0]; | 137 | .where('userId', auth.user.id).fetch()).rows[0]; |
138 | const settings = typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings; | 138 | const settings = typeof service.settings === 'string' ? JSON.parse(service.settings) : service.settings; |
139 | 139 | ||
140 | let iconId; | 140 | let iconId; |
141 | do { | 141 | do { |
142 | iconId = uuid() + uuid(); | 142 | iconId = uuid() + uuid(); |
143 | } while(await fs.exists(path.join(Helpers.tmpPath('uploads'), iconId))); | 143 | } while (await fs.exists(path.join(Helpers.tmpPath('uploads'), iconId))); |
144 | 144 | ||
145 | await icon.move(Helpers.tmpPath('uploads'), { | 145 | await icon.move(Helpers.tmpPath('uploads'), { |
146 | name: iconId, | 146 | name: iconId, |
147 | overwrite: true | 147 | overwrite: true, |
148 | }) | 148 | }); |
149 | 149 | ||
150 | if (!icon.moved()) { | 150 | if (!icon.moved()) { |
151 | return response.status(500).send(icon.error()); | 151 | return response.status(500).send(icon.error()); |
@@ -175,49 +175,48 @@ class ServiceController { | |||
175 | iconUrl: `${Env.get('APP_URL')}/v1/icon/${newSettings.iconId}`, | 175 | iconUrl: `${Env.get('APP_URL')}/v1/icon/${newSettings.iconId}`, |
176 | userId: auth.user.id, | 176 | userId: auth.user.id, |
177 | }, | 177 | }, |
178 | status: ["updated"] | 178 | status: ['updated'], |
179 | }); | 179 | }); |
180 | } else { | 180 | } |
181 | // Update service info | 181 | // Update service info |
182 | const data = request.all(); | 182 | const data = request.all(); |
183 | const { | 183 | const { |
184 | id, | 184 | id, |
185 | } = params; | 185 | } = params; |
186 | 186 | ||
187 | // Get current settings from db | 187 | // Get current settings from db |
188 | const serviceData = (await Service.query() | 188 | const serviceData = (await Service.query() |
189 | .where('serviceId', id) | 189 | .where('serviceId', id) |
190 | .where('userId', auth.user.id).fetch()).rows[0]; | 190 | .where('userId', auth.user.id).fetch()).rows[0]; |
191 | 191 | ||
192 | const settings = { | 192 | const settings = { |
193 | ...typeof serviceData.settings === "string" ? JSON.parse(serviceData.settings) : serviceData.settings, | 193 | ...typeof serviceData.settings === 'string' ? JSON.parse(serviceData.settings) : serviceData.settings, |
194 | ...data, | 194 | ...data, |
195 | }; | 195 | }; |
196 | 196 | ||
197 | // Update data in database | 197 | // Update data in database |
198 | await (Service.query() | 198 | await (Service.query() |
199 | .where('serviceId', id) | 199 | .where('serviceId', id) |
200 | .where('userId', auth.user.id)).update({ | 200 | .where('userId', auth.user.id)).update({ |
201 | name: data.name, | 201 | name: data.name, |
202 | settings: JSON.stringify(settings), | 202 | settings: JSON.stringify(settings), |
203 | }); | 203 | }); |
204 | 204 | ||
205 | // Get updated row | 205 | // Get updated row |
206 | const service = (await Service.query() | 206 | const service = (await Service.query() |
207 | .where('serviceId', id) | 207 | .where('serviceId', id) |
208 | .where('userId', auth.user.id).fetch()).rows[0]; | 208 | .where('userId', auth.user.id).fetch()).rows[0]; |
209 | 209 | ||
210 | return response.send({ | 210 | return response.send({ |
211 | data: { | 211 | data: { |
212 | id, | 212 | id, |
213 | name: service.name, | 213 | name: service.name, |
214 | ...settings, | 214 | ...settings, |
215 | iconUrl: `${Env.get('APP_URL')}/v1/icon/${settings.iconId}`, | 215 | iconUrl: `${Env.get('APP_URL')}/v1/icon/${settings.iconId}`, |
216 | userId: auth.user.id, | 216 | userId: auth.user.id, |
217 | }, | 217 | }, |
218 | status: ["updated"] | 218 | status: ['updated'], |
219 | }); | 219 | }); |
220 | } | ||
221 | } | 220 | } |
222 | 221 | ||
223 | async icon({ | 222 | async icon({ |
@@ -231,7 +230,7 @@ class ServiceController { | |||
231 | const iconPath = path.join(Helpers.tmpPath('uploads'), id); | 230 | const iconPath = path.join(Helpers.tmpPath('uploads'), id); |
232 | if (!await fs.exists(iconPath)) { | 231 | if (!await fs.exists(iconPath)) { |
233 | return response.status(404).send({ | 232 | return response.status(404).send({ |
234 | status: 'Icon doesn\'t exist' | 233 | status: 'Icon doesn\'t exist', |
235 | }); | 234 | }); |
236 | } | 235 | } |
237 | 236 | ||
@@ -252,7 +251,7 @@ class ServiceController { | |||
252 | .where('userId', auth.user.id).fetch()).rows[0]; | 251 | .where('userId', auth.user.id).fetch()).rows[0]; |
253 | 252 | ||
254 | const settings = { | 253 | const settings = { |
255 | ...typeof serviceData.settings === "string" ? JSON.parse(serviceData.settings) : serviceData.settings, | 254 | ...typeof serviceData.settings === 'string' ? JSON.parse(serviceData.settings) : serviceData.settings, |
256 | order: data[service], | 255 | order: data[service], |
257 | }; | 256 | }; |
258 | 257 | ||
@@ -260,16 +259,16 @@ class ServiceController { | |||
260 | await (Service.query() // eslint-disable-line no-await-in-loop | 259 | await (Service.query() // eslint-disable-line no-await-in-loop |
261 | .where('serviceId', service) | 260 | .where('serviceId', service) |
262 | .where('userId', auth.user.id)) | 261 | .where('userId', auth.user.id)) |
263 | .update({ | 262 | .update({ |
264 | settings: JSON.stringify(settings), | 263 | settings: JSON.stringify(settings), |
265 | }); | 264 | }); |
266 | } | 265 | } |
267 | 266 | ||
268 | // Get new services | 267 | // Get new services |
269 | const services = (await auth.user.services().fetch()).rows; | 268 | const services = (await auth.user.services().fetch()).rows; |
270 | // Convert to array with all data Franz wants | 269 | // Convert to array with all data Franz wants |
271 | const servicesArray = services.map((service) => { | 270 | const servicesArray = services.map((service) => { |
272 | const settings = typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings; | 271 | const settings = typeof service.settings === 'string' ? JSON.parse(service.settings) : service.settings; |
273 | 272 | ||
274 | return { | 273 | return { |
275 | customRecipe: false, | 274 | customRecipe: false, |
@@ -288,7 +287,7 @@ class ServiceController { | |||
288 | name: service.name, | 287 | name: service.name, |
289 | recipeId: service.recipeId, | 288 | recipeId: service.recipeId, |
290 | userId: auth.user.id, | 289 | userId: auth.user.id, |
291 | } | 290 | }; |
292 | }); | 291 | }); |
293 | 292 | ||
294 | return response.send(servicesArray); | 293 | return response.send(servicesArray); |
diff --git a/app/Controllers/Http/StaticController.js b/app/Controllers/Http/StaticController.js index 265578f..cd38b13 100644 --- a/app/Controllers/Http/StaticController.js +++ b/app/Controllers/Http/StaticController.js | |||
@@ -31,44 +31,44 @@ class StaticController { | |||
31 | isTeamManagementIncludedInCurrentPlan: true, | 31 | isTeamManagementIncludedInCurrentPlan: true, |
32 | isTodosEnabled: true, | 32 | isTodosEnabled: true, |
33 | isTodosIncludedInCurrentPlan: true, | 33 | isTodosIncludedInCurrentPlan: true, |
34 | defaultTrialPlan: "franz-pro-yearly", | 34 | defaultTrialPlan: 'franz-pro-yearly', |
35 | subscribeURL: "https://getferdi.com", | 35 | subscribeURL: 'https://getferdi.com', |
36 | planSelectionURL: "https://getferdi.com", | 36 | planSelectionURL: 'https://getferdi.com', |
37 | isMagicBarEnabled: true, | 37 | isMagicBarEnabled: true, |
38 | hasInlineCheckout: true, | 38 | hasInlineCheckout: true, |
39 | isPlanSelectionEnabled: false, | 39 | isPlanSelectionEnabled: false, |
40 | isTrialStatusBarEnabled: false, | 40 | isTrialStatusBarEnabled: false, |
41 | canSkipTrial: true, | 41 | canSkipTrial: true, |
42 | pricingConfig: { | 42 | pricingConfig: { |
43 | currency: "$", | 43 | currency: '$', |
44 | currencyID: "USD", | 44 | currencyID: 'USD', |
45 | plans: { | 45 | plans: { |
46 | personal: { | 46 | personal: { |
47 | monthly: { | 47 | monthly: { |
48 | id: "ferdi-free", | 48 | id: 'ferdi-free', |
49 | price: 0, | 49 | price: 0, |
50 | billed: 0 | 50 | billed: 0, |
51 | }, | 51 | }, |
52 | yearly: { | 52 | yearly: { |
53 | id: "ferdi-completely-free", | 53 | id: 'ferdi-completely-free', |
54 | price: 0, | 54 | price: 0, |
55 | billed: 0 | 55 | billed: 0, |
56 | } | 56 | }, |
57 | }, | 57 | }, |
58 | pro: { | 58 | pro: { |
59 | monthly: { | 59 | monthly: { |
60 | id: "ferdi-still-free", | 60 | id: 'ferdi-still-free', |
61 | price: 0, | 61 | price: 0, |
62 | billed: 0 | 62 | billed: 0, |
63 | }, | 63 | }, |
64 | yearly: { | 64 | yearly: { |
65 | id: "ferdi-forever-free", | 65 | id: 'ferdi-forever-free', |
66 | price: 0, | 66 | price: 0, |
67 | billed: 0 | 67 | billed: 0, |
68 | } | 68 | }, |
69 | } | 69 | }, |
70 | } | 70 | }, |
71 | } | 71 | }, |
72 | }); | 72 | }); |
73 | } | 73 | } |
74 | 74 | ||
diff --git a/app/Controllers/Http/UserController.js b/app/Controllers/Http/UserController.js index edfccf2..979e78a 100644 --- a/app/Controllers/Http/UserController.js +++ b/app/Controllers/Http/UserController.js | |||
@@ -155,17 +155,17 @@ class UserController { | |||
155 | async updateMe({ | 155 | async updateMe({ |
156 | request, | 156 | request, |
157 | response, | 157 | response, |
158 | auth | 158 | auth, |
159 | }) { | 159 | }) { |
160 | let settings = auth.user.settings || {}; | 160 | let settings = auth.user.settings || {}; |
161 | if (typeof settings === 'string') { | 161 | if (typeof settings === 'string') { |
162 | settings = JSON.parse(settings); | 162 | settings = JSON.parse(settings); |
163 | } | 163 | } |
164 | 164 | ||
165 | let newSettings = { | 165 | const newSettings = { |
166 | ...settings, | 166 | ...settings, |
167 | ...request.all(), | 167 | ...request.all(), |
168 | } | 168 | }; |
169 | 169 | ||
170 | auth.user.settings = JSON.stringify(newSettings); | 170 | auth.user.settings = JSON.stringify(newSettings); |
171 | await auth.user.save(); | 171 | await auth.user.save(); |
@@ -188,7 +188,7 @@ class UserController { | |||
188 | }, | 188 | }, |
189 | status: [ | 189 | status: [ |
190 | 'data-updated', | 190 | 'data-updated', |
191 | ] | 191 | ], |
192 | }); | 192 | }); |
193 | } | 193 | } |
194 | 194 | ||
diff --git a/app/Controllers/Http/WorkspaceController.js b/app/Controllers/Http/WorkspaceController.js index a2200a9..cbb6873 100644 --- a/app/Controllers/Http/WorkspaceController.js +++ b/app/Controllers/Http/WorkspaceController.js | |||
@@ -168,7 +168,7 @@ class WorkspaceController { | |||
168 | id: workspace.workspaceId, | 168 | id: workspace.workspaceId, |
169 | name: workspace.name, | 169 | name: workspace.name, |
170 | order: workspace.order, | 170 | order: workspace.order, |
171 | services: typeof workspace.services === "string" ? JSON.parse(workspace.services) : workspace.services, | 171 | services: typeof workspace.services === 'string' ? JSON.parse(workspace.services) : workspace.services, |
172 | userId: auth.user.id, | 172 | userId: auth.user.id, |
173 | })); | 173 | })); |
174 | } | 174 | } |