2018-10-25 16:51:20 +02:00
|
|
|
/* eslint-disable
|
|
|
|
no-return-assign,
|
|
|
|
no-undef,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2018-10-25 16:50:16 +02:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2018-11-21 11:08:53 +01:00
|
|
|
'use strict';
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2020-02-25 11:40:01 +01:00
|
|
|
Application.Controllers.controller('SettingsController', ['$scope', '$rootScope', '$filter', '$uibModal', 'dialogs', 'Setting', 'growl', 'settingsPromise', 'privacyDraftsPromise', 'cgvFile', 'cguFile', 'logoFile', 'logoBlackFile', 'faviconFile', 'profileImageFile', 'CSRF', '_t', 'Member', 'uiTourService',
|
|
|
|
function ($scope, $rootScope, $filter, $uibModal, dialogs, Setting, growl, settingsPromise, privacyDraftsPromise, cgvFile, cguFile, logoFile, logoBlackFile, faviconFile, profileImageFile, CSRF, _t, Member, uiTourService) {
|
2018-10-25 16:50:16 +02:00
|
|
|
/* PUBLIC SCOPE */
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
// timepickers steps configuration
|
2018-10-25 16:50:16 +02:00
|
|
|
$scope.timepicker = {
|
|
|
|
hstep: 1,
|
2016-03-23 18:39:41 +01:00
|
|
|
mstep: 15
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
// API URL where the upload forms will be posted
|
2018-10-25 16:50:16 +02:00
|
|
|
$scope.actionUrl = {
|
2018-10-25 16:51:20 +02:00
|
|
|
cgu: '/api/custom_assets',
|
|
|
|
cgv: '/api/custom_assets',
|
|
|
|
logo: '/api/custom_assets',
|
|
|
|
logoBlack: '/api/custom_assets',
|
|
|
|
favicon: '/api/custom_assets',
|
|
|
|
profileImage: '/api/custom_assets'
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2018-10-25 16:51:20 +02:00
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
// Form actions on the above URL
|
2018-10-25 16:50:16 +02:00
|
|
|
$scope.methods = {
|
2018-10-25 16:51:20 +02:00
|
|
|
cgu: 'post',
|
|
|
|
cgv: 'post',
|
|
|
|
logo: 'post',
|
|
|
|
logoBlack: 'post',
|
|
|
|
favicon: 'post',
|
|
|
|
profileImage: 'post'
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2018-10-25 16:51:20 +02:00
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
// Are we uploading the files currently (if so, display the loader)
|
2018-10-25 16:50:16 +02:00
|
|
|
$scope.loader = {
|
|
|
|
cgu: false,
|
2016-03-23 18:39:41 +01:00
|
|
|
cgv: false
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2018-10-25 16:51:20 +02:00
|
|
|
|
2020-02-25 11:40:01 +01:00
|
|
|
// default tab: general
|
|
|
|
$scope.tabs = { active: 0 };
|
|
|
|
|
2019-04-18 15:57:56 +02:00
|
|
|
// full history of privacy policy drafts
|
|
|
|
$scope.privacyDraftsHistory = [];
|
|
|
|
|
2020-05-20 15:16:55 +02:00
|
|
|
// all settings as retrieved from database
|
|
|
|
$scope.allSettings = settingsPromise;
|
|
|
|
|
2019-04-18 15:57:56 +02:00
|
|
|
// various configurable settings
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.twitterSetting = { name: 'twitter_name', value: settingsPromise.twitter_name };
|
2020-01-21 16:16:12 +01:00
|
|
|
$scope.linkName = { name: 'link_name', value: settingsPromise.link_name };
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.aboutTitleSetting = { name: 'about_title', value: settingsPromise.about_title };
|
|
|
|
$scope.aboutBodySetting = { name: 'about_body', value: settingsPromise.about_body };
|
2019-04-18 12:30:00 +02:00
|
|
|
$scope.privacyDpoSetting = { name: 'privacy_dpo', value: settingsPromise.privacy_dpo };
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.aboutContactsSetting = { name: 'about_contacts', value: settingsPromise.about_contacts };
|
|
|
|
$scope.homeBlogpostSetting = { name: 'home_blogpost', value: settingsPromise.home_blogpost };
|
2020-01-21 18:03:15 +01:00
|
|
|
$scope.homeContent = { name: 'home_content', value: settingsPromise.home_content };
|
2020-01-27 17:10:29 +01:00
|
|
|
$scope.homeCss = { name: 'home_css', value: settingsPromise.home_css };
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.machineExplicationsAlert = { name: 'machine_explications_alert', value: settingsPromise.machine_explications_alert };
|
|
|
|
$scope.trainingExplicationsAlert = { name: 'training_explications_alert', value: settingsPromise.training_explications_alert };
|
|
|
|
$scope.trainingInformationMessage = { name: 'training_information_message', value: settingsPromise.training_information_message };
|
|
|
|
$scope.subscriptionExplicationsAlert = { name: 'subscription_explications_alert', value: settingsPromise.subscription_explications_alert };
|
|
|
|
$scope.eventExplicationsAlert = { name: 'event_explications_alert', value: settingsPromise.event_explications_alert };
|
|
|
|
$scope.spaceExplicationsAlert = { name: 'space_explications_alert', value: settingsPromise.space_explications_alert };
|
|
|
|
$scope.windowStart = { name: 'booking_window_start', value: settingsPromise.booking_window_start };
|
|
|
|
$scope.windowEnd = { name: 'booking_window_end', value: settingsPromise.booking_window_end };
|
|
|
|
$scope.mainColorSetting = { name: 'main_color', value: settingsPromise.main_color };
|
|
|
|
$scope.secondColorSetting = { name: 'secondary_color', value: settingsPromise.secondary_color };
|
|
|
|
$scope.fablabName = { name: 'fablab_name', value: settingsPromise.fablab_name };
|
|
|
|
$scope.nameGenre = { name: 'name_genre', value: settingsPromise.name_genre };
|
|
|
|
$scope.machinesSortBy = { name: 'machines_sort_by', value: settingsPromise.machines_sort_by };
|
2020-05-19 16:20:59 +02:00
|
|
|
$scope.trackingId = { name: 'tracking_id', value: settingsPromise.tracking_id }
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.cguFile = cguFile.custom_asset;
|
|
|
|
$scope.cgvFile = cgvFile.custom_asset;
|
|
|
|
$scope.customLogo = logoFile.custom_asset;
|
|
|
|
$scope.customLogoBlack = logoBlackFile.custom_asset;
|
|
|
|
$scope.customFavicon = faviconFile.custom_asset;
|
|
|
|
$scope.profileImage = profileImageFile.custom_asset;
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2019-04-18 16:55:50 +02:00
|
|
|
// By default, we display the currently published privacy policy
|
|
|
|
$scope.privacyPolicy = {
|
|
|
|
version: null,
|
|
|
|
bodyTemp: settingsPromise.privacy_body
|
|
|
|
};
|
2019-04-18 15:57:56 +02:00
|
|
|
|
2020-01-21 18:03:15 +01:00
|
|
|
// Extend the options for summernote editor, with special tools for home page
|
2020-01-28 09:24:55 +01:00
|
|
|
$scope.summernoteOptsHomePage = angular.copy($rootScope.summernoteOpts);
|
2020-01-21 18:03:15 +01:00
|
|
|
$scope.summernoteOptsHomePage.toolbar[5][1].push('nugget'); // toolbar -> insert -> nugget
|
|
|
|
$scope.summernoteOptsHomePage.nugget = {
|
2020-01-22 11:53:40 +01:00
|
|
|
label: '\uF12E',
|
|
|
|
tooltip: _t('app.admin.settings.home_items'),
|
2020-01-21 18:03:15 +01:00
|
|
|
list: [
|
2020-01-22 11:53:40 +01:00
|
|
|
`<div id="news">${_t('app.admin.settings.item_news')}</div>`,
|
|
|
|
`<div id="projects">${_t('app.admin.settings.item_projects')}</div>`,
|
|
|
|
`<div id="twitter">${_t('app.admin.settings.item_twitter')}</div>`,
|
|
|
|
`<div id="members">${_t('app.admin.settings.item_members')}</div>`,
|
|
|
|
`<div id="events">${_t('app.admin.settings.item_events')}</div>`
|
2020-01-21 18:03:15 +01:00
|
|
|
]
|
|
|
|
}
|
2020-02-26 16:49:29 +01:00
|
|
|
$scope.summernoteOptsHomePage.height = 400;
|
2020-01-21 18:03:15 +01:00
|
|
|
|
2020-01-27 17:10:29 +01:00
|
|
|
// codemirror editor
|
|
|
|
$scope.codeMirrorEditor = null;
|
|
|
|
|
|
|
|
// Options for codemirror editor, used for custom css
|
|
|
|
$scope.codemirrorOpts = {
|
|
|
|
matchBrackets : true,
|
|
|
|
lineNumbers: true,
|
|
|
|
mode: 'sass'
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show or hide advanced settings
|
|
|
|
$scope.advancedSettings = {
|
|
|
|
open: false
|
|
|
|
}
|
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
/**
|
|
|
|
* For use with 'ng-class', returns the CSS class name for the uploads previews.
|
|
|
|
* The preview may show a placeholder or the content of the file depending on the upload state.
|
|
|
|
* @param v {*} any attribute, will be tested for truthiness (see JS evaluation rules)
|
|
|
|
*/
|
2018-10-25 16:51:20 +02:00
|
|
|
$scope.fileinputClass = function (v) {
|
2018-10-25 16:50:16 +02:00
|
|
|
if (v) {
|
2018-11-21 11:08:53 +01:00
|
|
|
return 'fileinput-exists';
|
2018-10-25 16:50:16 +02:00
|
|
|
} else {
|
2018-11-21 11:08:53 +01:00
|
|
|
return 'fileinput-new';
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
/**
|
|
|
|
* Callback to save the setting value to the database
|
|
|
|
* @param setting {{value:*, name:string}} note that the value will be stringified
|
|
|
|
*/
|
2018-10-25 16:51:20 +02:00
|
|
|
$scope.save = function (setting) {
|
2018-10-25 16:50:16 +02:00
|
|
|
// trim empty html
|
2018-11-21 11:08:53 +01:00
|
|
|
let value;
|
2018-10-25 16:51:20 +02:00
|
|
|
if ((setting.value === '<br>') || (setting.value === '<p><br></p>')) {
|
2018-11-21 11:08:53 +01:00
|
|
|
setting.value = '';
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
// convert dates to ISO format
|
|
|
|
if (setting.value instanceof Date) {
|
2018-11-21 11:08:53 +01:00
|
|
|
setting.value = setting.value.toISOString();
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (setting.value !== null) {
|
2018-11-21 11:08:53 +01:00
|
|
|
value = setting.value.toString();
|
2018-10-25 16:50:16 +02:00
|
|
|
} else {
|
2018-11-21 11:08:53 +01:00
|
|
|
({ value } = setting);
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
|
2019-04-18 16:01:58 +02:00
|
|
|
Setting.update(
|
|
|
|
{ name: setting.name },
|
|
|
|
{ value },
|
2019-12-18 13:04:38 +01:00
|
|
|
function () { growl.success(_t('app.admin.settings.customization_of_SETTING_successfully_saved', { SETTING: _t(`app.admin.settings.${setting.name}`) })); },
|
2020-04-28 16:35:54 +02:00
|
|
|
function (error) {
|
|
|
|
if (error.status === 304) return;
|
|
|
|
|
|
|
|
growl.error(_t('app.admin.settings.an_error_occurred_saving_the_setting'));
|
|
|
|
console.log(error);
|
|
|
|
}
|
2019-04-18 16:01:58 +02:00
|
|
|
);
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2019-04-18 16:55:50 +02:00
|
|
|
/**
|
|
|
|
* The privacy policy has its own special save function because updating the policy must notify all users
|
|
|
|
*/
|
2019-04-18 15:57:56 +02:00
|
|
|
$scope.savePrivacyPolicy = function () {
|
|
|
|
// open modal
|
|
|
|
const modalInstance = $uibModal.open({
|
|
|
|
templateUrl: '<%= asset_path "admin/settings/save_policy.html" %>',
|
2019-04-18 16:55:50 +02:00
|
|
|
controller: 'SavePolicyController',
|
|
|
|
resolve: {
|
|
|
|
saveCb () { return $scope.save; },
|
|
|
|
privacyPolicy () { return $scope.privacyPolicy; }
|
|
|
|
}
|
2019-04-18 15:57:56 +02:00
|
|
|
});
|
|
|
|
|
2019-04-18 16:55:50 +02:00
|
|
|
// once done, update the client data
|
|
|
|
modalInstance.result.then(function (type) {
|
|
|
|
Setting.get({ name: 'privacy_draft', history: true }, function (data) {
|
|
|
|
// reset history
|
|
|
|
$scope.privacyDraftsHistory = [];
|
|
|
|
data.setting.history.forEach(function (draft) {
|
2019-12-17 18:06:56 +01:00
|
|
|
$scope.privacyDraftsHistory.push({ id: draft.id, name: _t('app.admin.settings.privacy.draft_from_USER_DATE', { USER: draft.user.name, DATE: draft.created_at }), content: draft.value });
|
2019-04-18 16:55:50 +02:00
|
|
|
});
|
|
|
|
if (type === 'privacy_draft') {
|
2019-04-23 12:58:01 +02:00
|
|
|
const orderedHistory = $filter('orderBy')(data.setting.history, 'created_at');
|
|
|
|
const last = orderedHistory[orderedHistory.length - 1];
|
|
|
|
if (last) {
|
|
|
|
$scope.privacyPolicy.version = last.id;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$scope.privacyPolicy.version = null;
|
2019-04-18 16:55:50 +02:00
|
|
|
}
|
|
|
|
})
|
2019-04-18 15:57:56 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
/**
|
|
|
|
* For use with ngUpload (https://github.com/twilson63/ngUpload).
|
|
|
|
* Intended to be the callback when the upload is done: Any raised error will be displayed in a growl
|
|
|
|
* message. If everything goes fine, a growl success message is shown.
|
|
|
|
* @param content {Object} JSON - The upload's result
|
|
|
|
*/
|
2018-10-25 16:51:20 +02:00
|
|
|
$scope.submited = function (content) {
|
2018-10-25 16:50:16 +02:00
|
|
|
if ((content.custom_asset == null)) {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.alerts = [];
|
2019-04-18 16:01:58 +02:00
|
|
|
return angular.forEach(content, function (v) {
|
|
|
|
angular.forEach(v, function(err) { growl.error(err); })
|
|
|
|
});
|
2018-10-25 16:50:16 +02:00
|
|
|
} else {
|
2019-12-17 18:06:56 +01:00
|
|
|
growl.success(_t('app.admin.settings.file_successfully_updated'));
|
2018-10-25 16:50:16 +02:00
|
|
|
if (content.custom_asset.name === 'cgu-file') {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.cguFile = content.custom_asset;
|
|
|
|
$scope.methods.cgu = 'put';
|
|
|
|
if (!($scope.actionUrl.cgu.indexOf('/cgu-file') > 0)) { $scope.actionUrl.cgu += '/cgu-file'; }
|
|
|
|
return $scope.loader.cgu = false;
|
2018-10-25 16:50:16 +02:00
|
|
|
} else if (content.custom_asset.name === 'cgv-file') {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.cgvFile = content.custom_asset;
|
|
|
|
$scope.methods.cgv = 'put';
|
|
|
|
if (!($scope.actionUrl.cgv.indexOf('/cgv-file') > 0)) { $scope.actionUrl.cgv += '/cgv-file'; }
|
|
|
|
return $scope.loader.cgv = false;
|
2018-10-25 16:50:16 +02:00
|
|
|
} else if (content.custom_asset.name === 'logo-file') {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.customLogo = content.custom_asset;
|
|
|
|
$scope.methods.logo = 'put';
|
|
|
|
if (!($scope.actionUrl.logo.indexOf('/logo-file') > 0)) { return $scope.actionUrl.logo += '/logo-file'; }
|
2018-10-25 16:50:16 +02:00
|
|
|
} else if (content.custom_asset.name === 'logo-black-file') {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.customLogoBlack = content.custom_asset;
|
|
|
|
$scope.methods.logoBlack = 'put';
|
|
|
|
if (!($scope.actionUrl.logoBlack.indexOf('/logo-black-file') > 0)) { return $scope.actionUrl.logoBlack += '/logo-black-file'; }
|
2018-10-25 16:50:16 +02:00
|
|
|
} else if (content.custom_asset.name === 'favicon-file') {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.customFavicon = content.custom_asset;
|
|
|
|
$scope.methods.favicon = 'put';
|
|
|
|
if (!($scope.actionUrl.favicon.indexOf('/favicon-file') > 0)) { return $scope.actionUrl.favicon += '/favicon-file'; }
|
2018-10-25 16:50:16 +02:00
|
|
|
} else if (content.custom_asset.name === 'profile-image-file') {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.profileImage = content.custom_asset;
|
|
|
|
$scope.methods.profileImage = 'put';
|
|
|
|
if (!($scope.actionUrl.profileImage.indexOf('/profile-image-file') > 0)) { return $scope.actionUrl.profileImage += '/profile-image-file'; }
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
}
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
/**
|
|
|
|
* @param target {String} 'cgu' | 'cgv'
|
|
|
|
*/
|
2019-04-18 16:01:58 +02:00
|
|
|
$scope.addLoader = function (target) {
|
|
|
|
$scope.loader[target] = true;
|
|
|
|
}
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2019-04-18 15:57:56 +02:00
|
|
|
/**
|
|
|
|
* Change the revision of the displayed privacy policy, from drafts history
|
|
|
|
*/
|
|
|
|
$scope.handlePolicyRevisionChange = function () {
|
2019-04-25 11:58:42 +02:00
|
|
|
if ($scope.privacyPolicy.version === null) {
|
|
|
|
$scope.privacyPolicy.bodyTemp = settingsPromise.privacy_body;
|
|
|
|
return;
|
|
|
|
}
|
2019-04-18 16:55:50 +02:00
|
|
|
for (const draft of $scope.privacyDraftsHistory) {
|
|
|
|
if (draft.id == $scope.privacyPolicy.version) {
|
|
|
|
$scope.privacyPolicy.bodyTemp = draft.content;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-18 15:57:56 +02:00
|
|
|
};
|
|
|
|
|
2020-01-15 12:48:55 +01:00
|
|
|
/**
|
|
|
|
* Open a modal showing a sample of the collected data if FabAnalytics is enabled
|
|
|
|
*/
|
|
|
|
$scope.analyticsModal = function() {
|
|
|
|
$uibModal.open({
|
|
|
|
templateUrl: '<%= asset_path "admin/settings/analyticsModal.html" %>',
|
|
|
|
controller: 'AnalyticsModalController',
|
|
|
|
size: 'lg',
|
|
|
|
resolve: {
|
|
|
|
analyticsData: ['FabAnalytics', function (FabAnalytics) { return FabAnalytics.data().$promise; }]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-22 11:53:40 +01:00
|
|
|
/**
|
|
|
|
* Reset the home page to its initial state (factory value)
|
|
|
|
*/
|
|
|
|
$scope.resetHomePage = function () {
|
|
|
|
dialogs.confirm({
|
|
|
|
resolve: {
|
|
|
|
object () {
|
|
|
|
return {
|
|
|
|
title: _t('app.admin.settings.confirmation_required'),
|
|
|
|
msg: _t('app.admin.settings.confirm_reset_home_page')
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
, function () { // confirmed
|
|
|
|
Setting.reset({ name: 'home_content' }, function (data) {
|
|
|
|
$scope.homeContent.value = data.value;
|
|
|
|
growl.success(_t('app.admin.settings.home_content_reset'));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-01-27 17:10:29 +01:00
|
|
|
/**
|
|
|
|
* Callback triggered when the codemirror editor is loaded into the DOM
|
|
|
|
* @param editor codemirror instance
|
|
|
|
*/
|
|
|
|
$scope.codemirrorLoaded = function (editor) {
|
|
|
|
$scope.codeMirrorEditor = editor;
|
|
|
|
}
|
|
|
|
|
2020-02-25 11:40:01 +01:00
|
|
|
/**
|
|
|
|
* Setup the feature-tour for the admin/settings page.
|
|
|
|
* This is intended as a contextual help (when pressing F1)
|
|
|
|
*/
|
|
|
|
$scope.setupSettingsTour = function () {
|
|
|
|
// get the tour defined by the ui-tour directive
|
|
|
|
const uitour = uiTourService.getTourByName('settings');
|
|
|
|
uitour.createStep({
|
|
|
|
selector: 'body',
|
|
|
|
stepId: 'welcome',
|
|
|
|
order: 0,
|
|
|
|
title: _t('app.admin.tour.settings.welcome.title'),
|
|
|
|
content: _t('app.admin.tour.settings.welcome.content'),
|
|
|
|
placement: 'bottom',
|
|
|
|
orphan: true
|
|
|
|
});
|
|
|
|
uitour.createStep({
|
|
|
|
selector: '.admin-settings .home-page-content h4',
|
|
|
|
stepId: 'home',
|
|
|
|
order: 1,
|
|
|
|
title: _t('app.admin.tour.settings.home.title'),
|
|
|
|
content: _t('app.admin.tour.settings.home.content'),
|
|
|
|
placement: 'bottom'
|
|
|
|
});
|
|
|
|
uitour.createStep({
|
|
|
|
selector: '.admin-settings .home-page-content .note-toolbar .note-insert div',
|
|
|
|
stepId: 'components',
|
|
|
|
order: 2,
|
|
|
|
title: _t('app.admin.tour.settings.components.title'),
|
|
|
|
content: _t('app.admin.tour.settings.components.content'),
|
|
|
|
placement: 'bottom'
|
|
|
|
});
|
|
|
|
uitour.createStep({
|
|
|
|
selector: '.admin-settings .home-page-content .note-toolbar .btn-codeview',
|
|
|
|
stepId: 'codeview',
|
|
|
|
order: 3,
|
|
|
|
title: _t('app.admin.tour.settings.codeview.title'),
|
|
|
|
content: _t('app.admin.tour.settings.codeview.content'),
|
|
|
|
placement: 'bottom'
|
|
|
|
});
|
|
|
|
uitour.createStep({
|
|
|
|
selector: '.admin-settings .reset-button',
|
|
|
|
stepId: 'reset',
|
|
|
|
order: 4,
|
|
|
|
title: _t('app.admin.tour.settings.reset.title'),
|
|
|
|
content: _t('app.admin.tour.settings.reset.content'),
|
|
|
|
placement: 'left'
|
|
|
|
});
|
|
|
|
uitour.createStep({
|
|
|
|
selector: '.admin-settings .home-page-style',
|
|
|
|
stepId: 'css',
|
|
|
|
order: 5,
|
|
|
|
title: _t('app.admin.tour.settings.css.title'),
|
|
|
|
content: _t('app.admin.tour.settings.css.content'),
|
|
|
|
placement: 'top'
|
|
|
|
});
|
|
|
|
uitour.createStep({
|
|
|
|
selector: '.admin-settings .about-page-tab',
|
|
|
|
stepId: 'about',
|
|
|
|
order: 6,
|
|
|
|
title: _t('app.admin.tour.settings.about.title'),
|
|
|
|
content: _t('app.admin.tour.settings.about.content'),
|
|
|
|
placement: 'bottom'
|
|
|
|
});
|
|
|
|
uitour.createStep({
|
|
|
|
selector: '.admin-settings .privacy-page-tab',
|
|
|
|
stepId: 'privacy',
|
|
|
|
order: 7,
|
|
|
|
title: _t('app.admin.tour.settings.privacy.title'),
|
|
|
|
content: _t('app.admin.tour.settings.privacy.content'),
|
|
|
|
placement: 'bottom'
|
|
|
|
});
|
|
|
|
uitour.createStep({
|
|
|
|
selector: '.admin-settings .history-select',
|
|
|
|
stepId: 'draft',
|
|
|
|
order: 8,
|
|
|
|
title: _t('app.admin.tour.settings.draft.title'),
|
|
|
|
content: _t('app.admin.tour.settings.draft.content'),
|
|
|
|
placement: 'bottom'
|
|
|
|
});
|
|
|
|
uitour.createStep({
|
|
|
|
selector: 'body',
|
|
|
|
stepId: 'conclusion',
|
|
|
|
order: 9,
|
|
|
|
title: _t('app.admin.tour.conclusion.title'),
|
|
|
|
content: _t('app.admin.tour.conclusion.content'),
|
|
|
|
placement: 'bottom',
|
|
|
|
orphan: true
|
|
|
|
});
|
|
|
|
// on step change, change the active tab if needed
|
|
|
|
uitour.on('stepChanged', function (nextStep) {
|
|
|
|
if (nextStep.stepId === 'home' || nextStep.stepId === 'css') { $scope.tabs.active = 1; }
|
|
|
|
if (nextStep.stepId === 'about') { $scope.tabs.active = 2; }
|
|
|
|
if (nextStep.stepId === 'privacy' || nextStep.stepId === 'draft') { $scope.tabs.active = 3; }
|
|
|
|
});
|
|
|
|
// on tour end, save the status in database
|
|
|
|
uitour.on('ended', function () {
|
|
|
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('settings') < 0) {
|
|
|
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'settings' }, function (res) {
|
|
|
|
$scope.currentUser.profile.tours = res.tours;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
// if the user has never seen the tour, show him now
|
2020-03-02 11:17:28 +01:00
|
|
|
if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('settings') < 0) {
|
2020-02-25 11:40:01 +01:00
|
|
|
uitour.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-25 16:50:16 +02:00
|
|
|
/* PRIVATE SCOPE */
|
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
/**
|
|
|
|
* Kind of constructor: these actions will be realized first when the controller is loaded
|
|
|
|
*/
|
2018-10-25 16:51:20 +02:00
|
|
|
const initialize = function () {
|
2018-10-25 16:50:16 +02:00
|
|
|
// set the authenticity tokens in the forms
|
2018-11-21 11:08:53 +01:00
|
|
|
CSRF.setMetaTags();
|
2018-10-25 16:50:16 +02:00
|
|
|
|
|
|
|
// we prevent the admin from setting the closing time before the opening time
|
2018-10-25 16:51:20 +02:00
|
|
|
$scope.$watch('windowEnd.value', function (newValue, oldValue, scope) {
|
2018-10-25 16:50:16 +02:00
|
|
|
if ($scope.windowStart && moment($scope.windowStart.value).isAfter(newValue)) {
|
2018-11-21 11:08:53 +01:00
|
|
|
return $scope.windowEnd.value = oldValue;
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2018-11-21 11:08:53 +01:00
|
|
|
});
|
2018-10-25 16:50:16 +02:00
|
|
|
|
|
|
|
// change form methods to PUT if items already exists
|
|
|
|
if (cguFile.custom_asset) {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.methods.cgu = 'put';
|
|
|
|
$scope.actionUrl.cgu += '/cgu-file';
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
if (cgvFile.custom_asset) {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.methods.cgv = 'put';
|
|
|
|
$scope.actionUrl.cgv += '/cgv-file';
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
if (logoFile.custom_asset) {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.methods.logo = 'put';
|
|
|
|
$scope.actionUrl.logo += '/logo-file';
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
if (logoBlackFile.custom_asset) {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.methods.logoBlack = 'put';
|
|
|
|
$scope.actionUrl.logoBlack += '/logo-black-file';
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
if (faviconFile.custom_asset) {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.methods.favicon = 'put';
|
|
|
|
$scope.actionUrl.favicon += '/favicon-file';
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
if (profileImageFile.custom_asset) {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.methods.profileImage = 'put';
|
2019-04-25 11:40:26 +02:00
|
|
|
$scope.actionUrl.profileImage += '/profile-image-file';
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2019-04-18 15:57:56 +02:00
|
|
|
|
|
|
|
privacyDraftsPromise.setting.history.forEach(function (draft) {
|
2019-12-17 18:06:56 +01:00
|
|
|
$scope.privacyDraftsHistory.push({ id: draft.id, name: _t('app.admin.settings.privacy.draft_from_USER_DATE', { USER: draft.user.name, DATE: moment(draft.created_at).format('L LT') }), content: draft.value });
|
2019-04-18 15:57:56 +02:00
|
|
|
});
|
2020-01-27 17:10:29 +01:00
|
|
|
|
|
|
|
// refresh codemirror to display the fetched setting
|
|
|
|
$scope.$watch('advancedSettings.open', function (newValue) {
|
|
|
|
if (newValue) $scope.codeMirrorEditor.refresh();
|
|
|
|
})
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2018-10-25 16:50:16 +02:00
|
|
|
|
|
|
|
// init the controller (call at the end !)
|
2018-11-21 11:08:53 +01:00
|
|
|
return initialize();
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
|
2018-11-21 11:08:53 +01:00
|
|
|
]);
|
2019-04-18 15:57:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller used in the invoice refunding modal window
|
|
|
|
*/
|
2019-04-25 12:04:16 +02:00
|
|
|
Application.Controllers.controller('SavePolicyController', ['$scope', '$uibModalInstance', '_t', 'growl', 'saveCb', 'privacyPolicy',
|
|
|
|
function ($scope, $uibModalInstance, _t, growl, saveCb, privacyPolicy) {
|
2019-04-18 15:57:56 +02:00
|
|
|
/* PUBLIC SCOPE */
|
|
|
|
|
2019-04-18 16:55:50 +02:00
|
|
|
/**
|
|
|
|
* Save as draft the current text
|
|
|
|
*/
|
|
|
|
$scope.save = function () {
|
|
|
|
saveCb({ name: 'privacy_draft', value: privacyPolicy.bodyTemp });
|
|
|
|
$uibModalInstance.close('privacy_draft');
|
2019-04-18 15:57:56 +02:00
|
|
|
};
|
|
|
|
|
2019-04-18 16:55:50 +02:00
|
|
|
/**
|
|
|
|
* Publish the current text as the new privacy policy
|
|
|
|
*/
|
|
|
|
$scope.publish = function () {
|
|
|
|
saveCb({ name: 'privacy_body', value: privacyPolicy.bodyTemp });
|
2019-12-17 18:06:56 +01:00
|
|
|
growl.info(_t('app.admin.settings.privacy.users_notified'));
|
2019-04-18 16:55:50 +02:00
|
|
|
$uibModalInstance.close('privacy_body');
|
2019-04-18 15:57:56 +02:00
|
|
|
};
|
2019-04-18 16:55:50 +02:00
|
|
|
/**
|
|
|
|
* Cancel the saving, dismiss the modal window
|
|
|
|
*/
|
2019-04-18 15:57:56 +02:00
|
|
|
$scope.cancel = function () {
|
2019-04-18 16:55:50 +02:00
|
|
|
$uibModalInstance.dismiss('cancel');
|
2019-04-18 15:57:56 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
]);
|
2020-01-15 12:48:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller used in the "what do we collect?" modal, about FabAnalytics
|
|
|
|
*/
|
|
|
|
Application.Controllers.controller('AnalyticsModalController', ['$scope', '$uibModalInstance', 'analyticsData',
|
|
|
|
function ($scope,$uibModalInstance, analyticsData) {
|
|
|
|
// analytics data sample
|
|
|
|
$scope.data = analyticsData;
|
|
|
|
|
|
|
|
// callback to close the modal
|
|
|
|
$scope.close = function () {
|
|
|
|
$uibModalInstance.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])
|