Skip to content

Commit

Permalink
Better onboarding when a connection to kong admin is pregenerated
Browse files Browse the repository at this point in the history
  • Loading branch information
pantsel committed Mar 14, 2019
1 parent bcec107 commit 7ef9fac
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
3 changes: 0 additions & 3 deletions api/hooks/load-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ module.exports = function hook(sails) {

})
}



async.series([
sails.models.user.seed,
seedPassports,
Expand Down
18 changes: 15 additions & 3 deletions assets/js/app/dashboard/02_dashboard-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

angular.module('frontend.dashboard')
.controller('DashboardController', [
'$scope', '$rootScope','$log', '$state','$q','InfoService','$localStorage','HttpTimeout',
'$scope', '$rootScope','$log', '$state','$q','InfoService','$localStorage','HttpTimeout', '$location',
'SettingsService', 'NodeModel','$timeout', 'MessageService','UserModel','UserService','Semver','$http',
function controller($scope,$rootScope, $log, $state,$q,InfoService,$localStorage,HttpTimeout,
function controller($scope,$rootScope, $log, $state,$q,InfoService,$localStorage,HttpTimeout, $location,
SettingsService, NodeModel, $timeout, MessageService, UserModel, UserService, Semver, $http) {


Expand All @@ -19,6 +19,9 @@
hasInitiallyLoaded = false,
loadPromise;

$scope.loading = true;
$scope.hasConnections = false;

$scope.HttpTimeout = HttpTimeout;

$scope.showCluster = $rootScope.Gateway ? Semver.cmp($rootScope.Gateway.version,"0.11.0") < 0 : false;
Expand Down Expand Up @@ -272,7 +275,16 @@
* Init UI
*/

if($rootScope.Gateway || UserService.user().node) fetchData();
if($rootScope.Gateway || UserService.user().node) {
fetchData();
}else{
NodeModel.count().then(data => {
if(data.count) $scope.hasConnections = true;
$scope.loading = false;
}).catch(err => {
$scope.loading = false;
})
}



Expand Down
39 changes: 27 additions & 12 deletions assets/js/app/dashboard/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@

<div class="container" style="width: 600px;max-width: 100%" ng-if="!loading">
<div class="row" ng-if="!user.node && !Gateway">
<div class="col-md-12 text-center">
<img src="images/conn_sync-100.png" class="margin-bottom">
<h3>
Welcome!
</h3>
<p class="lead">
First of all, lets setup a connection to Kong Admin.<br>
<small class="text-muted">Select a connection type.</small>
</p>
<div data-ng-if="hasConnections">
<div class="col-md-12 text-center">
<img src="images/conn_sync-100.png" class="margin-bottom">
<h3>
Welcome!
</h3>
<p class="lead">
No active connection to Kong Admin was found.<br>
<small class="text-muted">Activate one from the <a ui-sref="connections">Connections</a> page.</small>
</p>

</div>
</div>
<div class="col-md-12">
<div ng-include="'js/app/connections/partials/create-connection-form-flat.html?r=' + Date.now()"
class=""></div>
<div data-ng-if="!hasConnections">
<div class="col-md-12 text-center">
<img src="images/conn_sync-100.png" class="margin-bottom">
<h3>
Welcome!
</h3>
<p class="lead">
First of all, lets setup a connection to Kong Admin.<br>
<small class="text-muted">Select a connection type.</small>
</p>

</div>
<div class="col-md-12">
<div ng-include="'js/app/connections/partials/create-connection-form-flat.html?r=' + Date.now()"
class=""></div>
</div>
</div>
</div>
<div class="row" ng-if="user.node && !Gateway && error">
Expand Down
3 changes: 2 additions & 1 deletion config/default-seed-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ function getseedData(env_var_name, model_name) {
if (typeof (readEnvVar) == 'undefined') {
return [];
};

return seedUserData
}

module.exports = {
userSeedData: getseedData('KONGA_SEED_USER_DATA_SOURCE_FILE', 'user'),
kongNodeSeedData: getseedData('KONGA_SEED_KONG_NODE_DATA_SOURCE_FILE', 'Kong node')
kongNodeSeedData: getseedData('KONGA_SEED_KONG_NODE_DATA_SOURCE_FILE', 'kong_node')
}

0 comments on commit 7ef9fac

Please sign in to comment.