Skip to content

Commit 8612d3c

Browse files
author
Tang,Hejun
committed
complete edit env part
1 parent fa8f7eb commit 8612d3c

File tree

10 files changed

+141
-30
lines changed

10 files changed

+141
-30
lines changed

app/css/_base.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ form.default.form-horizontal, form.default.form-inline {
170170
}
171171

172172
}
173+
label {
174+
cursor: pointer;
175+
}
173176
label.require {
174177
&:before {
175178
position: relative;

app/css/main.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,8 @@ input[type="checkbox"] {
378378
}
379379

380380
}
381+
/* class that uses in controller area that pulls them up */
382+
.pull-up {
383+
position: relative;
384+
top: -40px;
385+
}
Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
(function() {
22

3-
angular.module('ilab')
4-
.controller('EnvCtrl', EnvCtrl);
3+
angular.module('ilab')
4+
.controller('EnvCtrl', EnvCtrl);
55

6-
EnvCtrl.$inject = ['_env'];
7-
function EnvCtrl(_env) {
8-
var that = this;
6+
EnvCtrl.$inject = ['_env', '_envs', '$scope', '$state'];
97

10-
that.env = _env;
11-
that.activeTab = 1;
8+
function EnvCtrl(_env, _envs, $scope, $state) {
9+
var self = this;
1210

13-
}
14-
})();
11+
self.env = _env;
12+
self.envs = _envs;
13+
self.activeTab = 1;
14+
15+
activate();
16+
17+
function activate() {
18+
}
19+
$scope.$watch(function() {
20+
return self.env;
21+
}, function(newV, oldV) {
22+
if (newV !== oldV) {
23+
console.log(newV);
24+
$state.go('envs.detail.vm', {
25+
envId: newV.id
26+
});
27+
}
28+
});
29+
}
30+
})();

app/main/environment/env.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<div class="pull-right pull-up">
2+
<ilab-select list="Env.envs" selected-item="Env.env" attr-to-display="name" with-search></ilab-select>
3+
<a ui-sref="envs.basic({envId: Env.env.id})" class="btn btn-default">Overview</a>
4+
<a ui-sref="envs.detail.setting"><span class="intelicon-settings-solid clickable"></span></a>
5+
</div>
6+
17
<ul class="nav nav-tabs nav-tabs-intel">
28
<li ng-class="{'active': Env.activeTab === 1}">
39
<a ui-sref="envs.detail.vm">VM</a>

app/main/environment/envBasic/envBasic.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<a ui-sref="envs.detail.vm({envId: EnvBasic.env.id})" class="pull-right">advanced</a>
2-
<div class="list-env">
3-
<h3>Virtual Machine: {{EnvBasic.env.virtualMachines.length}}</h3>
1+
<a ui-sref="envs.detail.vm({envId: EnvBasic.env.id})" class="btn btn-default pull-right pull-up">advanced</a>
2+
<div class="ilab-section">
3+
<h5>Virtual Machine: {{EnvBasic.env.virtualMachines.length}}</h4>
44
<div class="card-container">
55
<info-card class="list-VMs" type="vm" info="vm" on-connect="EnvBasic.connect(id)" on-power="EnvBasic.powerOperation(id,op)" ng-repeat="vm in EnvBasic.env.virtualMachines"></info-card>
66
</div>

app/main/environment/envs.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
environmentService.post(that.newEnv).then(function(data) {
2525
console.log(data);
2626
$state.go('envs.basic', {envId: data.id});
27-
})
27+
});
2828
}
2929

3030
function resetEnv() {

app/main/environment/envs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h5>Add Environment</h5>
2323
<div class="form-group">
2424
<div class="col-sm-offset-2 col-sm-10">
2525
<button type="submit" class="btn btn-primary">Add</button>
26-
<button type="reset" class="btn btn-default" ng-click="Envs.reset()">Cancel</button>
26+
<button type="button" class="btn btn-default" ng-click="Envs.reset()">Cancel</button>
2727
</div>
2828
</div>
2929
</form>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(function() {
2+
3+
angular.module('ilab')
4+
.controller('EnvSettingCtrl', EnvSettingCtrl);
5+
6+
EnvSettingCtrl.$inject = ['_env', 'environmentService', 'alert'];
7+
8+
function EnvSettingCtrl(_env, environmentService, alert) {
9+
var self = this;
10+
11+
self.tmpEnv = {};
12+
self.updateEnv = updateEnv;
13+
self.resetEnv = resetEnv;
14+
activate();
15+
16+
function activate() {
17+
angular.copy(_env, self.tmpEnv);
18+
console.log(self.tmpEnv);
19+
}
20+
21+
function updateEnv() {
22+
angular.extend(_env, self.tmpEnv);
23+
console.log(_env.expiryDate.toISOString());
24+
_env.expiryDate = _env.expiryDate.toISOString();
25+
_env.put().then(function(data) {
26+
console.log(data);
27+
alert.open({type: 'success', message: 'update success'});
28+
});
29+
}
30+
31+
function resetEnv() {
32+
angular.copy(_env, self.tmpEnv);
33+
console.log(self.tmpEnv);
34+
}
35+
}
36+
})();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div class="ilab-section">
2+
<h5>Basic Settings</h5>
3+
<form class="form-horizontal default" ng-submit="EnvSetting.updateEnv()">
4+
<div class="form-group">
5+
<label for="env_name" class="col-sm-2 control-label require">Name:</label>
6+
<div class="col-sm-10">
7+
<input type="text" class="form-control" id="env_name" ng-model="EnvSetting.tmpEnv.name" placeholder="Environment name" required>
8+
</div>
9+
</div>
10+
<div class="form-group">
11+
<label for="env_desc" class="col-sm-2 control-label">Description:</label>
12+
<div class="col-sm-10">
13+
<input type="text" class="form-control" id="env_desc" ng-model="EnvSetting.tmpEnv.description" placeholder="Description">
14+
</div>
15+
</div>
16+
<div class="form-group">
17+
<label for="env_expire" class="col-sm-2 control-label">Expiration:</label>
18+
<div class="col-sm-10">
19+
<input type="date" class="form-control" id="env_expire" ng-model="EnvSetting.tmpEnv.expiryDate">
20+
<input type="checkbox" id="env_never_expire" ng-model="EnvSetting.tmpEnv.neverExpire">
21+
<label for="env_never_expire">Never</label>
22+
</div>
23+
</div>
24+
<div class="form-group">
25+
<div class="col-sm-offset-2 col-sm-10">
26+
<button type="submit" class="btn btn-primary">update</button>
27+
<button type="button" class="btn btn-default" ng-click="EnvSetting.resetEnv()">Cancel</button>
28+
</div>
29+
</div>
30+
</form>
31+
</div>

app/main/ilab.config.js

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@
5050
}
5151
}
5252
},
53-
controller: function() {
54-
console.log('data');
53+
resolve: {
54+
_envs: function(environmentService) {
55+
return environmentService.getList({expand: 'virtualMachines,physicalMachines,networks,users'});
56+
}
5557
},
5658
breadcrumb: {
5759
proxy: 'envs.list'
@@ -66,17 +68,12 @@
6668
controllerAs: 'Envs'
6769
}
6870
},
69-
resolve: {
70-
_envs: function(environmentService) {
71-
return environmentService.getList({expand: 'virtualMachines,physicalMachines,networks,users'});
72-
}
73-
},
7471
breadcrumb: {
7572
name: 'All environments'
7673
}
7774
})
78-
.state('envs.detail', {
79-
abstract: true,
75+
.state('envs.detail', {
76+
// abstract: true,
8077
url: "/environment/:envId",
8178
views: {
8279
'content@envs': {
@@ -91,7 +88,7 @@
9188
}
9289
},
9390
breadcrumb: {
94-
name: false
91+
name: '{{_env.name}}'
9592
}
9693
})
9794
.state('envs.detail.vm', {
@@ -105,12 +102,11 @@
105102
},
106103
resolve: {
107104
_vms: function(_env) {
108-
console.log(_env.virtualMachines);
109105
return _env.virtualMachines;
110106
}
111107
},
112108
breadcrumb: {
113-
name: '{{_env.name}}'
109+
name: 'Virtual Machines'
114110
}
115111
})
116112
.state('envs.detail.pm', {
@@ -129,7 +125,7 @@
129125
}
130126
},
131127
breadcrumb: {
132-
name: '{{_env.name}}'
128+
name: 'Physical Machines'
133129
}
134130
})
135131
.state('envs.detail.pm.add', {
@@ -167,6 +163,19 @@
167163
name: 'Basic View'
168164
}
169165
})
166+
.state('envs.detail.setting', {
167+
url: "/setting",
168+
views: {
169+
'content@envs': {
170+
templateUrl: "main/environment/setting/setting.html",
171+
controller: 'EnvSettingCtrl',
172+
controllerAs: 'EnvSetting'
173+
}
174+
},
175+
breadcrumb: {
176+
name: 'Environment Settings'
177+
}
178+
})
170179
.state('lab', {
171180
abstract: true,
172181
url: "/lab",
@@ -229,7 +238,7 @@
229238

230239
function restangular(RestangularProvider) {
231240
RestangularProvider.setBaseUrl('/services/api/');
232-
RestangularProvider.setDefaultHttpFields({cache: true});
241+
// RestangularProvider.setDefaultHttpFields({cache: true});
233242
// RestangularProvider.setDefaultHttpFields({'withCredentials': true});
234243
}
235244

@@ -239,11 +248,16 @@
239248
paginationTemplateProvider.setPath('main/templates/pagination.tpl.html');
240249
}
241250

242-
init.$inject = ['$rootScope'];
251+
init.$inject = ['$rootScope', '$state'];
243252

244-
function init($rootScope) {
253+
function init($rootScope, $state) {
245254
$rootScope.page = {
246255
title: 'default page title'
247256
};
257+
$rootScope.$on('$stateChangeSuccess', function(e, toState, toParams) {
258+
if(toState.name === 'envs.detail') {
259+
$state.go('envs.detail.vm', toParams);
260+
}
261+
});
248262
}
249263
})();

0 commit comments

Comments
 (0)