|
|
@@ -21,45 +21,46 @@ const ErrorV3 = require('../../models/vo/error-apiv3');
|
|
|
*
|
|
|
* components:
|
|
|
* schemas:
|
|
|
- * CustomizeLayoutTheme:
|
|
|
+ * CustomizeParams:
|
|
|
* type: object
|
|
|
- * properties:
|
|
|
- * layoutType:
|
|
|
- * type: string
|
|
|
- * themeType:
|
|
|
- * type: string
|
|
|
- * CustomizeBehavior:
|
|
|
- * type: object
|
|
|
- * behaviorType
|
|
|
- * type: string
|
|
|
- * CustomizeFunction:
|
|
|
- * type: object
|
|
|
- * isEnabledTimeline:
|
|
|
- * type: boolean
|
|
|
- * isSavedStatesOfTabChanges:
|
|
|
- * type: boolean
|
|
|
- * isEnabledAttachTitleHeader:
|
|
|
- * type: boolean
|
|
|
- * recentCreatedLimit:
|
|
|
- * type: number
|
|
|
- * CustomizeHighlight:
|
|
|
- * type: object
|
|
|
- * styleName:
|
|
|
- * type: string
|
|
|
- * styleBorder:
|
|
|
- * type: boolean
|
|
|
- * CustomizeHeader:
|
|
|
- * type: object
|
|
|
- * customizeHeader:
|
|
|
- * type: string
|
|
|
- * CustomizeCss:
|
|
|
- * type: object
|
|
|
- * customizeCss:
|
|
|
- * type: string
|
|
|
- * CustomizeScript:
|
|
|
- * type: object
|
|
|
- * customizeScript:
|
|
|
- * type: string
|
|
|
+ * CustomizeLayoutTheme:
|
|
|
+ * type: object
|
|
|
+ * layoutType:
|
|
|
+ * type: string
|
|
|
+ * themeType:
|
|
|
+ * type: string
|
|
|
+ * CustomizeBehavior:
|
|
|
+ * type: object
|
|
|
+ * behaviorType
|
|
|
+ * type: string
|
|
|
+ * CustomizeFunction:
|
|
|
+ * type: object
|
|
|
+ * isEnabledTimeline:
|
|
|
+ * type: boolean
|
|
|
+ * isSavedStatesOfTabChanges:
|
|
|
+ * type: boolean
|
|
|
+ * isEnabledAttachTitleHeader:
|
|
|
+ * type: boolean
|
|
|
+ * recentCreatedLimit:
|
|
|
+ * type: number
|
|
|
+ * CustomizeHighlight:
|
|
|
+ * type: object
|
|
|
+ * styleName:
|
|
|
+ * type: string
|
|
|
+ * styleBorder:
|
|
|
+ * type: boolean
|
|
|
+ * CustomizeHeader:
|
|
|
+ * type: object
|
|
|
+ * customizeHeader:
|
|
|
+ * type: string
|
|
|
+ * CustomizeCss:
|
|
|
+ * type: object
|
|
|
+ * customizeCss:
|
|
|
+ * type: string
|
|
|
+ * CustomizeScript:
|
|
|
+ * type: object
|
|
|
+ * customizeScript:
|
|
|
+ * type: string
|
|
|
*/
|
|
|
module.exports = (crowi) => {
|
|
|
const loginRequiredStrictly = require('../../middleware/login-required')(crowi);
|
|
|
@@ -68,26 +69,29 @@ module.exports = (crowi) => {
|
|
|
|
|
|
const { ApiV3FormValidator } = crowi.middlewares;
|
|
|
|
|
|
- // TODO GW-533 implement accurate validation
|
|
|
const validator = {
|
|
|
layoutTheme: [
|
|
|
- body('layoutType').isString(),
|
|
|
- body('themeType').isString(),
|
|
|
+ body('layoutType').isString().isIn(['growi', 'kibela', 'crowi']),
|
|
|
+ body('themeType').isString().isIn([
|
|
|
+ 'default', 'nature', 'mono-blue', 'wood', 'island', 'christmas', 'antarctic', 'default-dark', 'future', 'blue-night', 'halloween',
|
|
|
+ ]),
|
|
|
],
|
|
|
behavior: [
|
|
|
- body('behaviorType').isString(),
|
|
|
+ body('behaviorType').isString().isIn(['growi', 'crowi-plus']),
|
|
|
],
|
|
|
function: [
|
|
|
body('isEnabledTimeline').isBoolean(),
|
|
|
body('isSavedStatesOfTabChanges').isBoolean(),
|
|
|
body('isEnabledAttachTitleHeader').isBoolean(),
|
|
|
- body('recentCreatedLimit').isInt(),
|
|
|
+ body('recentCreatedLimit').isInt().isInt({ min: 1, max: 1000 }),
|
|
|
],
|
|
|
customizeHeader: [
|
|
|
body('customizeHeader').isString(),
|
|
|
],
|
|
|
highlight: [
|
|
|
- body('highlightJsStyle').isString(),
|
|
|
+ body('highlightJsStyle').isString().isIn([
|
|
|
+ 'github', 'github-gist', 'atom-one-light', 'xcode', 'vs', 'atom-one-dark', 'hybrid', 'monokai', 'tororrow-night', 'vs2015',
|
|
|
+ ]),
|
|
|
body('highlightJsStyleBorder').isBoolean(),
|
|
|
],
|
|
|
customizeCss: [
|
|
|
@@ -98,11 +102,42 @@ module.exports = (crowi) => {
|
|
|
],
|
|
|
};
|
|
|
|
|
|
- // TODO GW-575 writte swagger
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /customize-setting/:
|
|
|
+ * get:
|
|
|
+ * tags: [CustomizeSetting]
|
|
|
+ * description: Get customize paramators
|
|
|
+ * responses:
|
|
|
+ * 200:
|
|
|
+ * description: params of customize
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * customizedParams:
|
|
|
+ * $ref: '#/components/schemas/CustomizeParams'
|
|
|
+ */
|
|
|
router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
|
|
|
|
|
|
- // TODO GW-575 return others customize settings
|
|
|
- return res.apiv3();
|
|
|
+ const customizeParams = {
|
|
|
+ layoutType: await crowi.configManager.getConfig('crowi', 'customize:layout'),
|
|
|
+ themeType: await crowi.configManager.getConfig('crowi', 'customize:theme'),
|
|
|
+ behaviorType: await crowi.configManager.getConfig('crowi', 'customize:behavior'),
|
|
|
+ isEnabledTimeline: await crowi.configManager.getConfig('crowi', 'customize:isEnabledTimeline'),
|
|
|
+ isSavedStatesOfTabChanges: await crowi.configManager.getConfig('crowi', 'customize:isSavedStatesOfTabChanges'),
|
|
|
+ isEnabledAttachTitleHeader: await crowi.configManager.getConfig('crowi', 'customize:isEnabledAttachTitleHeader'),
|
|
|
+ recentCreatedLimit: await crowi.configManager.getConfig('crowi', 'customize:showRecentCreatedNumber'),
|
|
|
+ styleName: await crowi.configManager.getConfig('crowi', 'customize:highlightJsStyle'),
|
|
|
+ styleBorder: await crowi.configManager.getConfig('crowi', 'customize:highlightJsStyleBorder'),
|
|
|
+ customizeTitle: await crowi.configManager.getConfig('crowi', 'customize:title'),
|
|
|
+ customizeHeader: await crowi.configManager.getConfig('crowi', 'customize:header'),
|
|
|
+ customizeCss: await crowi.configManager.getConfig('crowi', 'customize:header'),
|
|
|
+ customizeScript: await crowi.configManager.getConfig('crowi', 'customize:script'),
|
|
|
+ };
|
|
|
+
|
|
|
+ return res.apiv3({ customizeParams });
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
@@ -133,7 +168,7 @@ module.exports = (crowi) => {
|
|
|
* schema:
|
|
|
* properties:
|
|
|
* customizedParams:
|
|
|
- * $ref: '#/components/schemas/CustomizeLayoutTheme'
|
|
|
+ * $ref: '#/components/schemas/CustomizeParams/CustomizeLayoutTheme'
|
|
|
*/
|
|
|
router.put('/layoutTheme', loginRequiredStrictly, adminRequired, csrf, validator.layoutTheme, ApiV3FormValidator, async(req, res) => {
|
|
|
const requestParams = {
|
|
|
@@ -181,7 +216,7 @@ module.exports = (crowi) => {
|
|
|
* schema:
|
|
|
* properties:
|
|
|
* customizedParams:
|
|
|
- * $ref: '#/components/schemas/CustomizeBehavior'
|
|
|
+ * $ref: '#/components/schemas/CustomizeParams/CustomizeBehavior'
|
|
|
*/
|
|
|
router.put('/behavior', loginRequiredStrictly, adminRequired, csrf, validator.behavior, ApiV3FormValidator, async(req, res) => {
|
|
|
const requestParams = {
|
|
|
@@ -236,7 +271,7 @@ module.exports = (crowi) => {
|
|
|
* schema:
|
|
|
* properties:
|
|
|
* customizedParams:
|
|
|
- * $ref: '#/components/schemas/CustomizeFunction'
|
|
|
+ * $ref: '#/components/schemas/CustomizeParams/CustomizeFunction'
|
|
|
*/
|
|
|
router.put('/function', loginRequiredStrictly, adminRequired, csrf, validator.function, ApiV3FormValidator, async(req, res) => {
|
|
|
const requestParams = {
|
|
|
@@ -291,7 +326,7 @@ module.exports = (crowi) => {
|
|
|
* schema:
|
|
|
* properties:
|
|
|
* customizedParams:
|
|
|
- * $ref: '#/components/schemas/CustomizeHighlight'
|
|
|
+ * $ref: '#/components/schemas/CustomizeParams/CustomizeHighlight'
|
|
|
*/
|
|
|
router.put('/highlight', loginRequiredStrictly, adminRequired, csrf, validator.highlight, ApiV3FormValidator, async(req, res) => {
|
|
|
const requestParams = {
|
|
|
@@ -379,7 +414,7 @@ module.exports = (crowi) => {
|
|
|
* schema:
|
|
|
* properties:
|
|
|
* customizedParams:
|
|
|
- * $ref: '#/components/schemas/CustomizeHeader'
|
|
|
+ * $ref: '#/components/schemas/CustomizeParams/CustomizeHeader'
|
|
|
*/
|
|
|
router.put('/customize-header', loginRequiredStrictly, adminRequired, csrf, validator.customizeHeader, ApiV3FormValidator, async(req, res) => {
|
|
|
const requestParams = {
|
|
|
@@ -388,7 +423,7 @@ module.exports = (crowi) => {
|
|
|
try {
|
|
|
await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestParams);
|
|
|
const customizedParams = {
|
|
|
- customizeCss: await crowi.configManager.getConfig('crowi', 'customize:header'),
|
|
|
+ customizeHeader: await crowi.configManager.getConfig('crowi', 'customize:header'),
|
|
|
};
|
|
|
return res.apiv3({ customizedParams });
|
|
|
}
|
|
|
@@ -424,7 +459,7 @@ module.exports = (crowi) => {
|
|
|
* schema:
|
|
|
* properties:
|
|
|
* customizedParams:
|
|
|
- * $ref: '#/components/schemas/CustomizeCss'
|
|
|
+ * $ref: '#/components/schemas/CustomizeParams/CustomizeCss'
|
|
|
*/
|
|
|
router.put('/customize-css', loginRequiredStrictly, adminRequired, csrf, validator.customizeCss, ApiV3FormValidator, async(req, res) => {
|
|
|
const requestParams = {
|
|
|
@@ -469,7 +504,7 @@ module.exports = (crowi) => {
|
|
|
* schema:
|
|
|
* properties:
|
|
|
* customizedParams:
|
|
|
- * $ref: '#/components/schemas/CustomizeScript'
|
|
|
+ * $ref: '#/components/schemas/CustomizeParams/CustomizeScript'
|
|
|
*/
|
|
|
router.put('/customize-script', loginRequiredStrictly, adminRequired, csrf, validator.customizeScript, ApiV3FormValidator, async(req, res) => {
|
|
|
const requestParams = {
|