|
|
@@ -108,11 +108,8 @@ module.exports = (crowi) => {
|
|
|
layout: [
|
|
|
body('isContainerFluid').isBoolean(),
|
|
|
],
|
|
|
- themeAssetPath: [
|
|
|
- query('themeName').isString(),
|
|
|
- ],
|
|
|
theme: [
|
|
|
- body('themeType').isString(),
|
|
|
+ body('theme').isString(),
|
|
|
],
|
|
|
sidebar: [
|
|
|
body('isSidebarDrawerMode').isBoolean(),
|
|
|
@@ -175,7 +172,6 @@ module.exports = (crowi) => {
|
|
|
*/
|
|
|
router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
|
|
|
const customizeParams = {
|
|
|
- themeType: await crowi.configManager.getConfig('crowi', 'customize:theme'),
|
|
|
isEnabledTimeline: await crowi.configManager.getConfig('crowi', 'customize:isEnabledTimeline'),
|
|
|
isEnabledAttachTitleHeader: await crowi.configManager.getConfig('crowi', 'customize:isEnabledAttachTitleHeader'),
|
|
|
pageLimitationS: await crowi.configManager.getConfig('crowi', 'customize:showPageLimitationS'),
|
|
|
@@ -272,41 +268,17 @@ module.exports = (crowi) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- /**
|
|
|
- * @swagger
|
|
|
- *
|
|
|
- * /customize-setting/theme/asset-path:
|
|
|
- * put:
|
|
|
- * tags: [CustomizeSetting]
|
|
|
- * operationId: getThemeAssetPath
|
|
|
- * summary: /customize-setting/theme/asset-path
|
|
|
- * description: Get theme asset path
|
|
|
- * parameters:
|
|
|
- * - name: themeName
|
|
|
- * in: query
|
|
|
- * required: true
|
|
|
- * schema:
|
|
|
- * type: string
|
|
|
- * responses:
|
|
|
- * 200:
|
|
|
- * description: Succeeded to get theme asset path
|
|
|
- * content:
|
|
|
- * application/json:
|
|
|
- * schema:
|
|
|
- * properties:
|
|
|
- * assetPath:
|
|
|
- * type: string
|
|
|
- */
|
|
|
- router.get('/theme/asset-path', loginRequiredStrictly, adminRequired, validator.themeAssetPath, apiV3FormValidator, async(req, res) => {
|
|
|
- const { themeName } = req.query;
|
|
|
-
|
|
|
- const webpackAssetKey = `styles/theme-${themeName}.css`;
|
|
|
- const assetPath = res.locals.webpack_asset(webpackAssetKey);
|
|
|
+ router.get('/theme', loginRequiredStrictly, adminRequired, async(req, res) => {
|
|
|
|
|
|
- if (assetPath == null) {
|
|
|
- return res.apiv3Err(new ErrorV3(`The asset for '${webpackAssetKey}' is undefined.`, 'invalid-asset'));
|
|
|
+ try {
|
|
|
+ const theme = await crowi.configManager.getConfig('crowi', 'customize:theme');
|
|
|
+ return res.apiv3({ theme });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ const msg = 'Error occurred in getting theme';
|
|
|
+ logger.error('Error', err);
|
|
|
+ return res.apiv3Err(new ErrorV3(msg, 'get-theme-failed'));
|
|
|
}
|
|
|
- return res.apiv3({ assetPath });
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
@@ -334,13 +306,13 @@ module.exports = (crowi) => {
|
|
|
*/
|
|
|
router.put('/theme', loginRequiredStrictly, adminRequired, addActivity, validator.theme, apiV3FormValidator, async(req, res) => {
|
|
|
const requestParams = {
|
|
|
- 'customize:theme': req.body.themeType,
|
|
|
+ 'customize:theme': req.body.theme,
|
|
|
};
|
|
|
|
|
|
try {
|
|
|
await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestParams);
|
|
|
const customizedParams = {
|
|
|
- themeType: await crowi.configManager.getConfig('crowi', 'customize:theme'),
|
|
|
+ theme: await crowi.configManager.getConfig('crowi', 'customize:theme'),
|
|
|
};
|
|
|
const parameters = { action: SupportedAction.ACTION_ADMIN_THEME_UPDATE };
|
|
|
activityEvent.emit('update', res.locals.activity._id, parameters);
|