2
0
itizawa 6 жил өмнө
parent
commit
2680548158

+ 6 - 4
src/client/js/services/AdminCustomizeContainer.js

@@ -50,10 +50,12 @@ export default class AdminCustomizeContainer extends Container {
    * @return {Array}} Appearance
    */
   async updateCustomizeLayoutAndTheme() {
-    await this.appContainer.apiv3.put('/customize-setting/layoutTheme');
-    // const { username } = response.data.userData;
-    const Appearance = [];
-    return Appearance;
+    const response = await this.appContainer.apiv3.put('/customize-setting/layoutTheme', {
+      layoutType: this.state.currentLayout,
+      themeType: this.state.currentTheme,
+    });
+    const { customizeParams } = response.data;
+    return customizeParams;
   }
 
 }

+ 16 - 1
src/server/routes/apiv3/customize-setting.js

@@ -23,9 +23,24 @@ module.exports = (crowi) => {
     Config,
   } = crowi.models;
 
+  // TODO validator
   // TODO writte swagger
   router.put('/layoutTheme', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
-    console.log('here is route');
+
+    const customizeParams = {
+      'customize:layout': req.body.layoutType,
+      'customize:theme': req.body.themeType,
+    };
+
+    try {
+      await crowi.configManager.updateConfigsInTheSameNamespace('crowi', customizeParams);
+      return res.apiv3({ customizeParams });
+    }
+    catch (err) {
+      const msg = 'Error occurred in updating presentation';
+      logger.error('Error', err);
+      return res.apiv3Err(new ErrorV3(msg, 'update-presentation-failed'));
+    }
   });
 
   return router;