Skip to content

Commit 4b3afe4

Browse files
author
Pranav Gandhi
committed
Forgot to commit this for a while.
1 parent 127d51c commit 4b3afe4

File tree

8 files changed

+54
-28
lines changed

8 files changed

+54
-28
lines changed

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ gulp.task('third-party', function() {
4747

4848
connectOptions = {
4949
host: '127.0.0.1',
50-
livereload: true,
50+
livereload: false,
5151
fallback: 'html/index.html',
5252
proxies: [
5353
{ source: '/api/v1/', target: 'http://127.0.0.1:5000/api/v1/'}

src/coffee/main.coffee

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ CCISCloudUIApp.config(['$routeProvider', '$locationProvider', ($routeProvider, $
1818

1919
CCISCloudUIControllers = angular.module('CCISCloudUIControllers', [])
2020

21-
CCISCloudUIControllers.controller 'BaseCtrl', ['$scope', 'UserCost', ($scope, UserCost) ->
22-
$scope.user_cost = UserCost.get_cost({user: 'hyfi'})
21+
CCISCloudUIControllers.controller 'BaseCtrl', ['$scope', 'UserCost', 'WhoAmI', ($scope, UserCost, WhoAmI) ->
22+
WhoAmI.getWhoIAm (whoiam) ->
23+
$scope.username = whoiam.username
24+
$scope.user_cost = UserCost.get_cost({user: $scope.username})
2325
]
2426

2527
CCISCloudUIControllers.controller 'InstancesCtrl', ['$scope', 'Instance', ($scope, Instance) ->
@@ -29,7 +31,6 @@ CCISCloudUIControllers.controller 'InstancesCtrl', ['$scope', 'Instance', ($scop
2931
CCISCloudUIControllers.controller 'InstanceCtrl', ['$scope', '$routeParams','Instance', ($scope, $routeParams, Instance) ->
3032
$scope.buttonStatus = [false, false, false, false]
3133

32-
3334
$scope.instance = Instance.get { instanceId: $routeParams.instanceId }
3435

3536
$scope.instance_action = (action, buttonId) ->
@@ -44,45 +45,37 @@ CCISCloudUIControllers.controller 'InstanceCtrl', ['$scope', '$routeParams','Ins
4445

4546
$scope.delete_instance = ->
4647
Instance.delete { instanceId: $scope.instance.instance_id }
48+
window.location.href = "/"
4749

4850

4951
]
5052

5153
CCISCloudUIControllers.controller 'CondenseCtrl', ['$scope', '$location', 'Instance', ($scope, $location, Instance) ->
52-
$scope.puppetClass = "ccis::role_base"
53-
$scope.puppetClasses = [
54-
{ puppetClass: 'ccis::role_base', title: 'Nothing' },
55-
{ puppetClass: 'ccis::role_mysql', title: 'MySQL' },
56-
{ puppetClass: 'ccis::role_nginx', title: 'Nginx' },
57-
{ puppetClass: 'ccis::role_app_server', title: 'App Server' },
58-
{ puppetClass: 'ccis::hadoop::role_tasktracker', title: 'Tasktracker' },
59-
{ puppetClass: 'ccis::role_bitcoin_miner', title: 'Bitcoin Miner' }
60-
]
6154

6255
$scope.selectedInstanceType = 't2.micro'
56+
$scope.selectedAnsibleTask = 'base'
6357

6458
$scope.setSelectedInstanceType = (instanceType) ->
6559
$scope.selectedInstanceType = instanceType
6660

6761
$scope.isSelectedInstanceType = (instanceType) ->
6862
instanceType == $scope.selectedInstanceType
6963

70-
$scope.isActive = (pc) ->
71-
$scope.puppetClass == pc
72-
73-
$scope.set_puppet_class = (pc) ->
74-
$scope.puppetClass = pc
64+
$scope.setAnsibleTask = (ansibleTask) ->
65+
$scope.selectedAnsibleTask = ansibleTask
7566

67+
$scope.isAnsibleTask = (ansibleTask) ->
68+
ansibleTask == $scope.selectedAnsibleTask
7669

7770
$scope.condense_instance = ->
78-
Instance.condense {
71+
Instance.condense({
7972
instanceId: 'condense',
8073
hostname: $scope.hostname,
8174
instance_type: $scope.selectedInstanceType,
8275
description: $scope.description,
83-
puppetClass: $scope.puppetClass
84-
}
85-
$location.path("/instance/#{$scope.hostname}")
76+
ansibleTask: $scope.selectedAnsibleTask
77+
}).$promise.then (result) ->
78+
$location.path "/instance/#{result.instance_id}"
8679

8780

8881
]

src/coffee/services.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@ CCISCloudServices.factory 'UserCost', ['$resource', ($resource) ->
1313
$resource '/api/v1/user/:user/cost', { user: '@user' }, {
1414
get_cost: { method: 'GET' }
1515
}
16+
]
17+
18+
CCISCloudServices.factory 'WhoAmI', ['$resource', ($resource) ->
19+
$resource '/api/v1/user/whoami', {}, {
20+
getWhoIAm: { method: 'GET' }
21+
}
1622
]

src/html/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@
2424
<!-- Collect the nav links, forms, and other content for toggling -->
2525
<div class="collapse navbar-collapse">
2626
<ul class="nav navbar-nav">
27-
<li class="active"><a href="/instances">Your Instances <span class="sr-only">(current)</span></a></li>
27+
<li><a href="/instances">Your Instances <span class="sr-only">(current)</span></a></li>
2828
<li><a href="/condense">New Instance</a></li>
2929
</ul>
30+
<ul class="nav navbar-nav navbar-right">
31+
<li><a href="#">{{ username }}</a></li>
32+
</ul>
3033
</div><!-- /.navbar-collapse -->
3134
</div><!-- /.container-fluid -->
3235
</nav>

src/html/templates/condense.html

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h2>Description <small>Something to remember this instance.</small></h2>
1414
</div>
1515
</div>
1616
<div class="row">
17-
<div class="col-md-offset-2 col-md-2">
17+
<div class="col-sm-offset-4 col-sm-2">
1818
<div class="instance-type" ng-class="{'instance-type-active': isSelectedInstanceType('t2.micro')}" ng-click="setSelectedInstanceType('t2.micro')">
1919
<h3 class="text-center">t2.micro</h3>
2020
<ul>
@@ -24,7 +24,7 @@ <h3 class="text-center">t2.micro</h3>
2424
</ul>
2525
</div>
2626
</div>
27-
<div class="col-md-2">
27+
<div class="col-sm-2">
2828
<div class="instance-type" ng-class="{'instance-type-active': isSelectedInstanceType('t2.small')}" ng-click="setSelectedInstanceType('t2.small')">
2929
<h3 class="text-center">t2.small</h3>
3030
<ul>
@@ -36,7 +36,27 @@ <h3 class="text-center">t2.small</h3>
3636
</div>
3737
</div>
3838
<div class="row">
39-
<div class="col-md-2 col-md-offset-5">
39+
<div class="col-sm-offset-4 col-sm-2">
40+
<div class="instance-type" ng-class="{'instance-type-active': isAnsibleTask('base')}" ng-click="setAnsibleTask('base')">
41+
<h3 class="text-center">Base</h3>
42+
<ul>
43+
<li>Amazon Linux 2015.03</li>
44+
<li>LDAP Auth</li>
45+
</ul>
46+
</div>
47+
</div>
48+
<div class="col-sm-2">
49+
<div class="instance-type" ng-class="{'instance-type-active': isAnsibleTask('accountportal')}" ng-click="setAnsibleTask('accountportal')">
50+
<h3 class="text-center">Account Portal</h3>
51+
<ul>
52+
<li>Base</li>
53+
<li>Account Portal</li>
54+
</ul>
55+
</div>
56+
</div>
57+
</div>
58+
<div class="row">
59+
<div class="col-md-2 col-md-offset-5 center-block">
4060
<button class="btn btn-lg btn-primary" ng-click="condense_instance()">Create Instance</button>
4161
</div>
4262
</div>

src/html/templates/instance.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="row">
33
<div class="col-md-12">
44
<div class="page-header">
5-
<h1 class="text-center">{{ instance.tags.hostname }}<br/><small>{{ instance.tags.description || "Enter a memorable description of this instance"}}</small></h1>
5+
<h1 class="text-center">{{ instance.tags.hostname || 'Loading...' }}<br/><small>{{ instance.tags.description || "Enter a memorable description of this instance"}}</small></h1>
66
</div>
77
</div>
88
</div>

src/html/templates/instances.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<div class="row">
33
<div class="col-md-12">
44
<div class="well">
5-
<h4 class="text-center">You've spent ${{ user_cost.total_cost | number : 2}} this month.</h4>
5+
<h4 ng-if="user_cost" class="text-center">You've spent ${{ user_cost.total_cost | number : 2}} this month.</h4>
6+
<h4 ng-if="user_cost == undefined" class="text-center">Loading...</h4>
67
</div>
78
</div>
89
</div>

src/scss/main.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,7 @@ button {
6969
font-weight: 300;
7070
}
7171

72+
.center-block {
73+
float: none !important;
74+
}
7275
}

0 commit comments

Comments
 (0)