diff --git a/webadmin/src/index.html b/webadmin/src/index.html index 8441822a1..6befcb742 100644 --- a/webadmin/src/index.html +++ b/webadmin/src/index.html @@ -64,6 +64,7 @@

Welcome

This page is the configuration interface to your Cloudron.


+ diff --git a/webadmin/src/js/client.js b/webadmin/src/js/client.js index d2ce98669..54281387b 100644 --- a/webadmin/src/js/client.js +++ b/webadmin/src/js/client.js @@ -777,6 +777,15 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification', return (available - needed) >= 0; }; + Client.prototype.setShowTutorial = function (show, callback) { + var data = { showTutorial: show }; + + $http.put(client.apiOrigin + '/api/v1/profile/tutorial', data).success(function (data, status) { + if (status !== 204) return callback(new ClientError(status, data)); + callback(null); + }).error(defaultErrorHandler(callback)); + } + client = new Client(); return client; }]); diff --git a/webadmin/src/js/main.js b/webadmin/src/js/main.js index 391616568..4092d3344 100644 --- a/webadmin/src/js/main.js +++ b/webadmin/src/js/main.js @@ -16,10 +16,25 @@ angular.module('Application').controller('MainController', ['$scope', '$route', { title: 'finish', page: '#/apps' } ]; + $scope.startTutorial = function () { + $scope.welcomeStep = 0; + if ($scope.welcomeSteps[$scope.welcomeStep]) window.location.href = $scope.welcomeSteps[$scope.welcomeStep].page; + }; + + $scope.endTutorial = function () { + $scope.welcomeStep = -1; + + Client.setShowTutorial(false, function (error) { + if (error) console.error(error); + }); + }; + $scope.nextWelcomeStep = function () { $scope.welcomeStep += 1; if ($scope.welcomeSteps[$scope.welcomeStep]) window.location.href = $scope.welcomeSteps[$scope.welcomeStep].page; + + if ($scope.welcomeStep >= $scope.welcomeSteps.length) $scope.endTutorial(); }; $scope.prevWelcomeStep = function () { @@ -165,7 +180,7 @@ angular.module('Application').controller('MainController', ['$scope', '$route', } // welcome screen - if ($scope.user.showTutorial && $scope.user.admin) $scope.nextWelcomeStep(); + if ($scope.user.showTutorial && $scope.user.admin) $scope.startTutorial(); }); }); }); diff --git a/webadmin/src/views/account.html b/webadmin/src/views/account.html index 8c85c1fca..333275d95 100644 --- a/webadmin/src/views/account.html +++ b/webadmin/src/views/account.html @@ -130,6 +130,7 @@
+ diff --git a/webadmin/src/views/account.js b/webadmin/src/views/account.js index 0256fe5f8..d82e5e7c0 100644 --- a/webadmin/src/views/account.js +++ b/webadmin/src/views/account.js @@ -173,6 +173,13 @@ angular.module('Application').controller('AccountController', ['$scope', '$locat }); }; + $scope.showTutorial = function () { + Client.setShowTutorial(true, function (error) { + if (error) return console.error(error); + $scope.$parent.startTutorial(); + }); + }; + Client.onReady(function () { $scope.tokenInUse = Client._token;