2020-03-10 16:38:29 +01:00
|
|
|
'use strict';
|
|
|
|
|
2020-04-29 12:57:17 +02:00
|
|
|
Application.Services.factory('Help', ['$rootScope', '$uibModal', '$state', 'AuthService',
|
|
|
|
function ($rootScope, $uibModal, $state, AuthService) {
|
2020-03-10 16:38:29 +01:00
|
|
|
const TOURS = {
|
|
|
|
'app.public.home': 'welcome',
|
|
|
|
'app.public.machines_list': 'machines',
|
|
|
|
'app.public.spaces_list': 'spaces',
|
|
|
|
'app.admin.trainings': 'trainings',
|
|
|
|
'app.admin.calendar': 'calendar',
|
|
|
|
'app.admin.members': 'members',
|
|
|
|
'app.admin.invoices': 'invoices',
|
|
|
|
'app.admin.pricing': 'pricing',
|
|
|
|
'app.admin.events': 'events',
|
2020-06-01 17:52:39 +02:00
|
|
|
'app.admin.projects': 'projects',
|
2020-03-10 16:38:29 +01:00
|
|
|
'app.admin.statistics': 'statistics',
|
|
|
|
'app.admin.settings': 'settings',
|
2020-03-11 10:26:53 +01:00
|
|
|
'app.admin.open_api_clients': 'open-api'
|
2020-03-10 16:38:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return function (e) {
|
2020-04-29 12:57:17 +02:00
|
|
|
if (!AuthService.isAuthorized(['admin', 'manager'])) return;
|
2020-03-11 10:26:53 +01:00
|
|
|
|
2020-03-10 16:38:29 +01:00
|
|
|
if (e.key === 'F1') {
|
|
|
|
e.preventDefault();
|
|
|
|
// retrieve the tour name, based on the current location
|
2020-03-11 10:26:53 +01:00
|
|
|
const tourName = TOURS[$state.current.name];
|
2020-03-10 16:38:29 +01:00
|
|
|
|
|
|
|
// if no tour, just open the guide
|
2020-03-11 10:26:53 +01:00
|
|
|
if (tourName === undefined) {
|
2020-09-23 10:54:45 +02:00
|
|
|
return window.open('https://github.com/sleede/fab-manager/raw/master/doc/fr/guide_utilisation_fab_manager_v4.5.pdf', '_blank');
|
2020-03-10 16:38:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$uibModal.open({
|
|
|
|
animation: true,
|
|
|
|
templateUrl: '<%= asset_path "shared/help_modal.html" %>',
|
2020-03-11 10:26:53 +01:00
|
|
|
resolve: {
|
|
|
|
tourName: function () { return tourName; }
|
|
|
|
},
|
|
|
|
controller: ['$scope', '$uibModalInstance', 'uiTourService', 'tourName', function ($scope, $uibModalInstance, uiTourService, tourName) {
|
2020-03-10 16:38:29 +01:00
|
|
|
// start the tour and hide the modal
|
|
|
|
$scope.onTour = function () {
|
2020-03-11 10:26:53 +01:00
|
|
|
const tour = uiTourService.getTourByName(tourName);
|
2020-03-10 16:38:29 +01:00
|
|
|
if (tour) { tour.start(); }
|
|
|
|
|
|
|
|
$uibModalInstance.close('tour');
|
|
|
|
};
|
|
|
|
|
|
|
|
// open the user's guide and hide the modal
|
|
|
|
$scope.onGuide = function () {
|
|
|
|
$uibModalInstance.close('guide');
|
|
|
|
};
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}]);
|