Skip to content

Commit 4f7be32

Browse files
author
Tang,Hejun
committed
add IlabCtrl as main controler
1 parent 1c335bb commit 4f7be32

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

app/index.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
</head>
1919

20-
<body ng-app="ilab">
20+
<body ng-app="ilab" ng-controller="IlabCtrl as Ilab">
2121
<nav class="navbar navbar-default navbar-fixed-top">
2222
<div class="container-fluid">
2323
<div class="navbar-header">
@@ -39,6 +39,11 @@
3939
<div class="loader-backdrop" ng-show="isLoading">
4040
<div class="spin-box"></div>
4141
</div>
42+
<!-- alerts -->
43+
<div class="alert-box col-xs-10 col-sm-8 col-md-6">
44+
<alert ng-repeat="alert in $root.alerts" type="{{alert.type}}" close="Ilab.close(alert.index)" ng-click="Ilab.close(alert.index)">{{alert.message}}</alert>
45+
</div>
46+
4247
<!-- bower:js -->
4348
<script src="bower_components/jquery/dist/jquery.js"></script>
4449
<script src="bower_components/angular/angular.js"></script>

app/main/components/directives/menu.directive.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
angular.module('ilabDirective')
66
.directive('ilabMenu', ilabMenu);
77

8-
ilabMenu.$inject = ['$window'];
8+
ilabMenu.$inject = ['$window', '$state'];
99

10-
function ilabMenu($window) {
10+
function ilabMenu($window, $state) {
1111
return {
1212
restrict: 'E',
1313
templateUrl: 'main/templates/menu.tpl.html',
@@ -24,7 +24,17 @@
2424
var environmentLink = element.find('a[ui-sref^="envs"]');
2525
var labLink = element.find('a[ui-sref^="lab"]');
2626

27-
$($window).ready(checkWindowSize);
27+
scope.$on('$viewContentLoaded', function() {
28+
checkWindowSize();
29+
var currentState = $state.current;
30+
/*first clear id of all link, and add the id to the corresponding link*/
31+
allLink.attr('id', '');
32+
if (environmentPageRegex.test(currentState.name)) {
33+
environmentLink.attr('id', 'selected-link');
34+
} else if (labPageRegex.test(currentState.name)) {
35+
labLink.attr('id', 'selected-link');
36+
}
37+
});
2838
$($window).resize(checkWindowSize);
2939
/* check if it's needed to hide menu. and active corresponding link*/
3040
scope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParms) {

app/main/components/directives/tableColumnFilter.directive.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('table column filter directive:', function () {
1+
ddescribe('table column filter directive:', function () {
22
var element, scope, document;
33

44
// Load the ilab module, which contains the directive

app/main/ilab.controller.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(function() {
2+
3+
angular.module('ilab')
4+
.controller('IlabCtrl', IlabCtrl);
5+
6+
IlabCtrl.$inject = ['$rootScope', 'alert'];
7+
function IlabCtrl($rootScope, alert) {
8+
var self = this;
9+
10+
self.close = closeAlert;
11+
activate();
12+
13+
function activate() {
14+
alert.open({type: 'success', message: 'hello'});
15+
}
16+
function closeAlert(id) {
17+
alert.close(id);
18+
}
19+
}
20+
})();

app/main/welcome/welcome.html

-4
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,3 @@ <h3 class="page-header">alert</h3>
159159
<button class="btn btn-suspend" ng-click="Welcome.show('warning')">warning</button>
160160
<button class="btn btn-danger" ng-click="Welcome.show('danger')">danger</button>
161161

162-
<div class="alert-box col-xs-10 col-sm-8 col-md-6">
163-
<alert ng-repeat="alert in $root.alerts" type="{{alert.type}}" close="Welcome.close(alert.index)" ng-click="Welcome.close(alert.index)">{{alert.message}}</alert>
164-
</div>
165-

grunt/options/watch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
tasks: ['jshint', 'beep:error:3', 'concat']
2121
},
2222
html: {
23-
files: ['<%= meta.srcPath %>/main/**/*.html', '<%= meta.srcPath %>/main/*.html'],
23+
files: ['<%= meta.srcPath %>/main/**/*.html', '<%= meta.srcPath %>/*.html'],
2424
tasks: ['concat']
2525
},
2626
scss: {

0 commit comments

Comments
 (0)