mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
- New nav menu.
- Polishing device list.
This commit is contained in:
parent
8ed3ae1784
commit
593e14a80a
12 changed files with 115 additions and 10 deletions
|
@ -28,6 +28,7 @@
|
|||
},
|
||||
"private": true,
|
||||
"resolutions": {
|
||||
"angular": "~1.3.0-beta.2"
|
||||
"angular": "~1.3.0-beta.2",
|
||||
"localforage": "0.2.0"
|
||||
}
|
||||
}
|
||||
|
|
20
res/app/components/stf/common-ui/safe-apply/index.js
Normal file
20
res/app/components/stf/common-ui/safe-apply/index.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
module.exports = angular.module('stf.safe-apply', [])
|
||||
.config([
|
||||
'$provide', function ($provide) {
|
||||
return $provide.decorator('$rootScope', [
|
||||
'$delegate', function ($delegate) {
|
||||
$delegate.safeApply = function (fn) {
|
||||
var phase = $delegate.$$phase
|
||||
if (phase === "$apply" || phase === "$digest") {
|
||||
if (fn && typeof fn === 'function') {
|
||||
fn()
|
||||
}
|
||||
} else {
|
||||
$delegate.$apply(fn)
|
||||
}
|
||||
}
|
||||
return $delegate
|
||||
}
|
||||
])
|
||||
}
|
||||
])
|
|
@ -6,6 +6,7 @@
|
|||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ng-table th.sortable {
|
||||
|
|
2
res/app/components/stf/nav-menu/index.js
Normal file
2
res/app/components/stf/nav-menu/index.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = angular.module('stf.nav-menu', [])
|
||||
.directive('navMenu', require('./nav-menu-directive'))
|
39
res/app/components/stf/nav-menu/nav-menu-directive.js
Normal file
39
res/app/components/stf/nav-menu/nav-menu-directive.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
module.exports = function ($location) {
|
||||
return function (scope, element, attrs) {
|
||||
var links = element.find('a')
|
||||
var onClass = attrs.navMenu || 'current'
|
||||
var routePattern
|
||||
var link
|
||||
var url
|
||||
var currentLink
|
||||
var urlMap = {}
|
||||
var i
|
||||
|
||||
if (!$location.$$html5) {
|
||||
routePattern = /^#[^/]*/
|
||||
}
|
||||
|
||||
for (i = 0; i < links.length; i++) {
|
||||
link = angular.element(links[i])
|
||||
url = link.attr('href')
|
||||
|
||||
if ($location.$$html5) {
|
||||
urlMap[url] = link
|
||||
} else {
|
||||
urlMap[url.replace(routePattern, '')] = link
|
||||
}
|
||||
}
|
||||
|
||||
scope.$on('$routeChangeStart', function () {
|
||||
var pathLink = urlMap[$location.path()]
|
||||
|
||||
if (pathLink) {
|
||||
if (currentLink) {
|
||||
currentLink.removeClass(onClass);
|
||||
}
|
||||
currentLink = pathLink;
|
||||
currentLink.addClass(onClass);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
23
res/app/components/stf/nav-menu/nav-menu-spec.js
Normal file
23
res/app/components/stf/nav-menu/nav-menu-spec.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
describe('navMenu', function () {
|
||||
|
||||
beforeEach(module('stf.nav-menu'));
|
||||
|
||||
var scope, compile;
|
||||
|
||||
beforeEach(inject(function ($rootScope, $compile) {
|
||||
scope = $rootScope.$new();
|
||||
compile = $compile;
|
||||
}));
|
||||
|
||||
it('should ...', function () {
|
||||
|
||||
/*
|
||||
To test your directive, you need to create some html that would use your directive,
|
||||
send that through compile() then compare the results.
|
||||
|
||||
var element = compile('<div nav-menu name="name">hi</div>')(scope);
|
||||
expect(element.text()).toBe('hello, world');
|
||||
*/
|
||||
|
||||
});
|
||||
});
|
|
@ -6,6 +6,11 @@
|
|||
margin-top: -32px;
|
||||
}
|
||||
|
||||
.stf-device-list .device-not-usable {
|
||||
/*background: rgb(245, 245, 245);*/
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.stf-device-list .devices-not-available {
|
||||
background: #f6f6f6;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ div.stf-device-list
|
|||
div {{"User"|translate}}
|
||||
|
||||
//tbody
|
||||
tr(ng-repeat='device in $data')
|
||||
tr(ng-repeat='device in $data', ng-class='{ "device-not-usable": !device.usable }')
|
||||
td(data-title="'Status'",
|
||||
sortable='"state"',
|
||||
filter="{ 'usable': 'select' }",
|
||||
|
@ -130,7 +130,7 @@ div.stf-device-list
|
|||
a(ng-href='{{deviceUser(device).link}}', target='_blank') {{ deviceUser(device).name }}
|
||||
|
||||
|
||||
ul
|
||||
//ul
|
||||
li(ng-repeat='device in tracker.devices track by device.serial')
|
||||
pre {{device|json}}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require('./menu.css')
|
||||
|
||||
module.exports = angular.module('stf.menu', [
|
||||
require('stf/nav-menu').name
|
||||
])
|
||||
.run(["$templateCache", function ($templateCache) {
|
||||
$templateCache.put('menu.jade', require('./menu.jade'))
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
module.exports = function MenuCtrl($scope) {
|
||||
|
||||
|
||||
$scope.isActive = function (viewLocation) {
|
||||
var pattern = '/' + viewLocation,
|
||||
re = new RegExp(pattern);
|
||||
return re.test($location.path());
|
||||
};
|
||||
|
||||
$scope.isActive = function (path) {
|
||||
console.log($location.path())
|
||||
console.log($location.path().substr(0, path.length))
|
||||
|
||||
return $location.path().substr(0, path.length) == path;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.navbar.stf-menu
|
||||
.container-fluid.stf-top-bar
|
||||
a.stf-logo(href="/") STF 2
|
||||
ul.nav.stf-nav
|
||||
ul.nav.stf-nav(nav-menu)
|
||||
li(ng-cloak)
|
||||
a(href='/#!/control')
|
||||
span.fa.fa-mobile
|
||||
|
|
|
@ -33,15 +33,15 @@ module.exports = {
|
|||
, { test: /\.png$/, loader: "url-loader?limit=5000&mimetype=image/png" }
|
||||
, { test: /\.gif$/, loader: "url-loader?limit=5000&mimetype=image/gif" }
|
||||
, { test: /\.svg$/
|
||||
, loader: "url-loader?limit=5000&mimetype=image/svg+xml" }
|
||||
, loader: "url-loader?limit=1&mimetype=image/svg+xml" }
|
||||
, { test: /\.woff$/
|
||||
, loader: "url-loader?limit=5000&mimetype=application/font-woff" }
|
||||
, loader: "url-loader?limit=1&mimetype=application/font-woff" }
|
||||
, { test: /\.otf$/
|
||||
, loader: "url-loader?limit=5000&mimetype=application/font-woff" }
|
||||
, loader: "url-loader?limit=1&mimetype=application/font-woff" }
|
||||
, { test: /\.ttf$/
|
||||
, loader: "url-loader?limit=5000&mimetype=application/font-woff" }
|
||||
, loader: "url-loader?limit=1&mimetype=application/font-woff" }
|
||||
, { test: /\.eot$/
|
||||
, loader: "url-loader?limit=5000&mimetype=vnd.ms-fontobject" }
|
||||
, loader: "url-loader?limit=1&mimetype=vnd.ms-fontobject" }
|
||||
, { test: /\.jade/
|
||||
, loader: 'template-html-loader' }
|
||||
, { test: /\.html/, loader: 'html-loader' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue