|
@@ -88,198 +88,6 @@ module.exports = function(crowi, app) {
|
|
|
return pager;
|
|
return pager;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- actions.index = function(req, res) {
|
|
|
|
|
- return res.render('admin/index');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // app.get('/admin/app' , admin.app.index);
|
|
|
|
|
- actions.app = {};
|
|
|
|
|
- actions.app.index = function(req, res) {
|
|
|
|
|
- return res.render('admin/app');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- actions.app.settingUpdate = function(req, res) {
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // app.get('/admin/security' , admin.security.index);
|
|
|
|
|
- actions.security = {};
|
|
|
|
|
- actions.security.index = function(req, res) {
|
|
|
|
|
-
|
|
|
|
|
- return res.render('admin/security');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // app.get('/admin/markdown' , admin.markdown.index);
|
|
|
|
|
- actions.markdown = {};
|
|
|
|
|
- actions.markdown.index = function(req, res) {
|
|
|
|
|
- const markdownSetting = configManager.getConfigByPrefix('markdown', 'markdown:');
|
|
|
|
|
-
|
|
|
|
|
- return res.render('admin/markdown', {
|
|
|
|
|
- markdownSetting,
|
|
|
|
|
- recommendedWhitelist,
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // app.get('/admin/customize' , admin.customize.index);
|
|
|
|
|
- actions.customize = {};
|
|
|
|
|
- actions.customize.index = function(req, res) {
|
|
|
|
|
- const settingForm = configManager.getConfigByPrefix('crowi', 'customize:');
|
|
|
|
|
-
|
|
|
|
|
- return res.render('admin/customize', {
|
|
|
|
|
- settingForm,
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // app.get('/admin/notification' , admin.notification.index);
|
|
|
|
|
- actions.notification = {};
|
|
|
|
|
- actions.notification.index = async(req, res) => {
|
|
|
|
|
-
|
|
|
|
|
- return res.render('admin/notification');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // app.get('/admin/notification/slackAuth' , admin.notification.slackauth);
|
|
|
|
|
- actions.notification.slackAuth = function(req, res) {
|
|
|
|
|
- const code = req.query.code;
|
|
|
|
|
- const { t } = req;
|
|
|
|
|
-
|
|
|
|
|
- if (!code || !slackIntegrationService.isSlackConfigured()) {
|
|
|
|
|
- return res.redirect('/admin/notification');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const slack = crowi.slack;
|
|
|
|
|
- slack.getOauthAccessToken(code)
|
|
|
|
|
- .then(async(data) => {
|
|
|
|
|
- debug('oauth response', data);
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- await configManager.updateConfigsInTheSameNamespace('notification', { 'slack:token': data.access_token });
|
|
|
|
|
- req.flash('successMessage', [t('message.successfully_connected')]);
|
|
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
- req.flash('errorMessage', [t('message.fail_to_save_access_token')]);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return res.redirect('/admin/notification');
|
|
|
|
|
- })
|
|
|
|
|
- .catch((err) => {
|
|
|
|
|
- debug('oauth response ERROR', err);
|
|
|
|
|
- req.flash('errorMessage', [t('message.fail_to_fetch_access_token')]);
|
|
|
|
|
- return res.redirect('/admin/notification');
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // app.post('/admin/notification/slackSetting/disconnect' , admin.notification.disconnectFromSlack);
|
|
|
|
|
- actions.notification.disconnectFromSlack = async function(req, res) {
|
|
|
|
|
- await configManager.updateConfigsInTheSameNamespace('notification', { 'slack:token': '' });
|
|
|
|
|
- req.flash('successMessage', [req.t('successfully_disconnected')]);
|
|
|
|
|
-
|
|
|
|
|
- return res.redirect('/admin/notification');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- actions.globalNotification = {};
|
|
|
|
|
- actions.globalNotification.detail = async(req, res) => {
|
|
|
|
|
- const notificationSettingId = req.params.id;
|
|
|
|
|
- let globalNotification;
|
|
|
|
|
-
|
|
|
|
|
- if (notificationSettingId) {
|
|
|
|
|
- try {
|
|
|
|
|
- globalNotification = await GlobalNotificationSetting.findOne({ _id: notificationSettingId });
|
|
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
- logger.error(`Error in finding a global notification setting with {_id: ${notificationSettingId}}`);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return res.render('admin/global-notification-detail', { globalNotification });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- actions.search = {};
|
|
|
|
|
- actions.search.index = function(req, res) {
|
|
|
|
|
- return res.render('admin/search', {});
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- actions.user = {};
|
|
|
|
|
- actions.user.index = async function(req, res) {
|
|
|
|
|
- return res.render('admin/users');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- actions.externalAccount = {};
|
|
|
|
|
- actions.externalAccount.index = function(req, res) {
|
|
|
|
|
- return res.render('admin/external-accounts');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- actions.slackIntegrationLegacy = {};
|
|
|
|
|
- actions.slackIntegrationLegacy = function(req, res) {
|
|
|
|
|
- return res.render('admin/slack-integration-legacy');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- actions.slackIntegration = {};
|
|
|
|
|
- actions.slackIntegration = function(req, res) {
|
|
|
|
|
- return res.render('admin/slack-integration');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- actions.userGroup = {};
|
|
|
|
|
- actions.userGroup.index = function(req, res) {
|
|
|
|
|
- const page = parseInt(req.query.page) || 1;
|
|
|
|
|
- const renderVar = {
|
|
|
|
|
- userGroups: [],
|
|
|
|
|
- userGroupRelations: new Map(),
|
|
|
|
|
- pager: null,
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- UserGroup.findUserGroupsWithPagination({ page })
|
|
|
|
|
- .then((result) => {
|
|
|
|
|
- const pager = createPager(result.total, result.limit, result.page, result.pages, MAX_PAGE_LIST);
|
|
|
|
|
- const userGroups = result.docs;
|
|
|
|
|
- renderVar.userGroups = userGroups;
|
|
|
|
|
- renderVar.pager = pager;
|
|
|
|
|
- return userGroups.map((userGroup) => {
|
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
|
- UserGroupRelation.findAllRelationForUserGroup(userGroup)
|
|
|
|
|
- .then((relations) => {
|
|
|
|
|
- return resolve({
|
|
|
|
|
- id: userGroup._id,
|
|
|
|
|
- relatedUsers: relations.map((relation) => {
|
|
|
|
|
- return relation.relatedUser;
|
|
|
|
|
- }),
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- })
|
|
|
|
|
- .then((allRelationsPromise) => {
|
|
|
|
|
- return Promise.all(allRelationsPromise);
|
|
|
|
|
- })
|
|
|
|
|
- .then((relations) => {
|
|
|
|
|
- for (const relation of relations) {
|
|
|
|
|
- renderVar.userGroupRelations[relation.id] = relation.relatedUsers;
|
|
|
|
|
- }
|
|
|
|
|
- debug('in findUserGroupsWithPagination findAllRelationForUserGroupResult', renderVar.userGroupRelations);
|
|
|
|
|
- return res.render('admin/user-groups', renderVar);
|
|
|
|
|
- })
|
|
|
|
|
- .catch((err) => {
|
|
|
|
|
- debug('Error on find all relations', err);
|
|
|
|
|
- return res.json(ApiResponse.error('Error'));
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // グループ詳細
|
|
|
|
|
- actions.userGroup.detail = async function(req, res) {
|
|
|
|
|
- const userGroupId = req.params.id;
|
|
|
|
|
- const userGroup = await UserGroup.findOne({ _id: userGroupId }).populate('parent');
|
|
|
|
|
-
|
|
|
|
|
- if (userGroup == null) {
|
|
|
|
|
- logger.error('no userGroup is exists. ', userGroupId);
|
|
|
|
|
- return res.redirect('/admin/user-groups');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return res.render('admin/user-group-detail', { userGroup });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // AuditLog
|
|
|
|
|
- actions.auditLog = {};
|
|
|
|
|
- actions.auditLog.index = (req, res) => {
|
|
|
|
|
- return res.render('admin/audit-log');
|
|
|
|
|
- };
|
|
|
|
|
|
|
|
|
|
// Importer management
|
|
// Importer management
|
|
|
actions.importer = {};
|
|
actions.importer = {};
|
|
@@ -287,13 +95,6 @@ module.exports = function(crowi, app) {
|
|
|
api.validators = {};
|
|
api.validators = {};
|
|
|
api.validators.importer = {};
|
|
api.validators.importer = {};
|
|
|
|
|
|
|
|
- actions.importer.index = function(req, res) {
|
|
|
|
|
- const settingForm = configManager.getConfigByPrefix('crowi', 'importer:');
|
|
|
|
|
- return res.render('admin/importer', {
|
|
|
|
|
- settingForm,
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
api.validators.importer.esa = function() {
|
|
api.validators.importer.esa = function() {
|
|
|
const validator = [
|
|
const validator = [
|
|
|
check('importer:esa:team_name').not().isEmpty().withMessage('Error. Empty esa:team_name'),
|
|
check('importer:esa:team_name').not().isEmpty().withMessage('Error. Empty esa:team_name'),
|
|
@@ -316,10 +117,6 @@ module.exports = function(crowi, app) {
|
|
|
actions.export.api = api;
|
|
actions.export.api = api;
|
|
|
api.validators.export = {};
|
|
api.validators.export = {};
|
|
|
|
|
|
|
|
- actions.export.index = (req, res) => {
|
|
|
|
|
- return res.render('admin/export');
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
api.validators.export.download = function() {
|
|
api.validators.export.download = function() {
|
|
|
const validator = [
|
|
const validator = [
|
|
|
// https://regex101.com/r/mD4eZs/6
|
|
// https://regex101.com/r/mD4eZs/6
|
|
@@ -507,13 +304,5 @@ module.exports = function(crowi, app) {
|
|
|
return res.json(ApiResponse.success());
|
|
return res.json(ApiResponse.success());
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- * Use AdminNotFoundPage component instead
|
|
|
|
|
- */
|
|
|
|
|
- // actions.notFound = {};
|
|
|
|
|
- // actions.notFound.index = function(req, res) {
|
|
|
|
|
- // return res.render('admin/not_found');
|
|
|
|
|
- // };
|
|
|
|
|
-
|
|
|
|
|
return actions;
|
|
return actions;
|
|
|
};
|
|
};
|