1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-03 17:59:28 +02:00

Ensure that all API calls and static resources are in their own unique paths. This makes it easier to add a load balancer on top of everything.

This commit is contained in:
Simo Kinnunen 2014-07-14 17:09:50 +09:00
parent 7da3c91289
commit 1d77d8c97d
34 changed files with 37 additions and 36 deletions

View file

@ -39,13 +39,13 @@ module.exports = function(options) {
if (options.disableWatch) {
app.use(compression())
app.use('/static/build/entry',
app.use('/static/app/build/entry',
serveStatic(pathutil.resource('build/entry')))
app.use('/static/build', serveStatic(pathutil.resource('build'), {
maxAge: '10d'
}))
} else {
app.use('/static/build', webpack({
app.use('/static/app/build', webpack({
debug: true
, devtool: 'eval'
, stats: {
@ -64,11 +64,11 @@ module.exports = function(options) {
serveStatic(pathutil.resource('bower_components/stf-site/manual/advanced')))
app.use('/v2-features',
serveStatic(pathutil.resource('bower_components/stf-site/v2-features')))
app.use('/static/data', serveStatic(pathutil.resource('data')))
app.use('/static/status', serveStatic(pathutil.resource('common/status')))
app.use('/static/browsers', browserIconMiddleware())
app.use('/static/devices', deviceIconMiddleware())
app.use('/static', serveStatic(pathutil.resource('app')))
app.use('/static/app/data', serveStatic(pathutil.resource('data')))
app.use('/static/app/status', serveStatic(pathutil.resource('common/status')))
app.use('/static/app/browsers', browserIconMiddleware())
app.use('/static/app/devices', deviceIconMiddleware())
app.use('/static/app', serveStatic(pathutil.resource('app')))
app.use(serveFavicon(pathutil.resource(
'bower_components/stf-graphics/logo/exports/STF-128.png')))
@ -119,14 +119,14 @@ module.exports = function(options) {
})
})
app.get('/api/v1/user', function(req, res) {
app.get('/api/v1/app/user', function(req, res) {
res.json({
success: true
, user: req.user
})
})
app.get('/api/v1/group', function(req, res) {
app.get('/api/v1/app/group', function(req, res) {
dbapi.loadGroup(req.user.email)
.then(function(cursor) {
return Promise.promisify(cursor.toArray, cursor)()
@ -148,7 +148,7 @@ module.exports = function(options) {
})
})
app.get('/api/v1/devices', function(req, res) {
app.get('/api/v1/app/devices', function(req, res) {
dbapi.loadDevices()
.then(function(cursor) {
return Promise.promisify(cursor.toArray, cursor)()
@ -171,7 +171,7 @@ module.exports = function(options) {
})
})
app.get('/api/v1/devices/:serial', function(req, res) {
app.get('/api/v1/app/devices/:serial', function(req, res) {
dbapi.loadDevice(req.params.serial)
.then(function(device) {
if (device) {

View file

@ -30,7 +30,7 @@ module.exports = function(options) {
})
app.set('view engine', 'jade')
app.set('views', pathutil.resource('auth-ldap/views'))
app.set('views', pathutil.resource('auth/ldap/views'))
app.set('strict routing', true)
app.set('case sensitive routing', true)
@ -43,7 +43,7 @@ module.exports = function(options) {
app.use(validator())
app.use('/static/bower_components',
serveStatic(pathutil.resource('bower_components')))
app.use('/static', serveStatic(pathutil.resource('auth-ldap')))
app.use('/static/auth/ldap', serveStatic(pathutil.resource('auth/ldap')))
app.use(function(req, res, next) {
res.cookie('XSRF-TOKEN', req.csrfToken());

View file

@ -29,7 +29,7 @@ module.exports = function(options) {
})
app.set('view engine', 'jade')
app.set('views', pathutil.resource('auth-mock/views'))
app.set('views', pathutil.resource('auth/mock/views'))
app.set('strict routing', true)
app.set('case sensitive routing', true)
@ -42,7 +42,7 @@ module.exports = function(options) {
app.use(validator())
app.use('/static/bower_components',
serveStatic(pathutil.resource('bower_components')))
app.use('/static', serveStatic(pathutil.resource('auth-mock')))
app.use('/static/auth/mock', serveStatic(pathutil.resource('auth/mock')))
app.use(function(req, res, next) {
res.cookie('XSRF-TOKEN', req.csrfToken());

View file

@ -164,7 +164,7 @@ module.exports = function DeviceServiceFactory($http, socket, EnhanceDeviceServi
, digest: false
})
oboe('/api/v1/devices')
oboe('/api/v1/app/devices')
.node('devices[*]', function (device) {
tracker.add(device)
})
@ -180,7 +180,7 @@ module.exports = function DeviceServiceFactory($http, socket, EnhanceDeviceServi
, digest: true
})
oboe('/api/v1/group')
oboe('/api/v1/app/group')
.node('devices[*]', function (device) {
tracker.add(device)
})
@ -189,7 +189,7 @@ module.exports = function DeviceServiceFactory($http, socket, EnhanceDeviceServi
}
deviceService.load = function(serial) {
return $http.get('/api/v1/devices/' + serial)
return $http.get('/api/app/v1/devices/' + serial)
.then(function (response) {
return response.data.device
})

View file

@ -31,4 +31,4 @@
.btn-group
label.btn.btn-default-outline(ng-repeat='b in device.browser.apps', ng-model='$root.browser', btn-radio='b',
tooltip='{{b.name}} ({{b.developer}})')
img(ng-src='/static/browsers/icon/24x24/{{b.type}}.png', ng-show='b.type').browser-icon.pointer
img(ng-src='/static/app/browsers/icon/24x24/{{b.type}}.png', ng-show='b.type').browser-icon.pointer

View file

@ -20,7 +20,7 @@
a.stf-vnc-device-name.pointer.unselectable.dropdown-toggle
p
.device-small-image
img(ng-src='/static/devices/icon/x24/{{ device.image || "E30HT.jpg" }}')
img(ng-src='/static/app/devices/icon/x24/{{ device.image || "E30HT.jpg" }}')
span.device-name-text {{ device.name }}
span.caret(ng-show='groupDevices.length > 0')
//span(ng-show='device && !device.present', translate) (Absent)
@ -29,7 +29,7 @@
li(ng-repeat='groupDevice in groupDevices')
a(ng-click='controlDevice(groupDevice); $event.stopPropagation()')
.device-small-image
img(ng-src='/static/devices/icon/x24/{{ groupDevice.image || "E30HT.jpg" }}')
img(ng-src='/static/app/devices/icon/x24/{{ groupDevice.image || "E30HT.jpg" }}')
span(ng-class='{"current-device": groupDevice.serial === device.serial }') {{ groupDevice.name }}
span.pull-right(ng-click='kickDevice(groupDevice); $event.stopPropagation()').kick-device

View file

@ -1,7 +1,7 @@
module.exports = function InfoCtrl($scope, LightboxImageService) {
$scope.openDevicePhoto = function (device) {
var title = device.name
var enhancedPhoto800 = '/static/devices/photo/x800/' + device.image
var enhancedPhoto800 = '/static/app/devices/photo/x800/' + device.image
LightboxImageService.open(title, enhancedPhoto800)
}
}

View file

@ -396,7 +396,8 @@ function DeviceModelCell(options) {
, image = span.firstChild
, a = span.nextSibling
, t = a.firstChild
, src = '/static/devices/icon/x24/' + (device.image || '_default.jpg')
, src = '/static/app/devices/icon/x24/' +
(device.image || '_default.jpg')
// Only change if necessary so that we don't trigger a download
if (image.getAttribute('src') !== src) {
image.setAttribute('src', src)

View file

@ -23,6 +23,6 @@ html
div(ng-view).fill-height
script(src='data:application/javascript;base64,#{new Buffer("var APPSTATE=" + JSON.stringify(APPSTATE)).toString("base64")}')
script(src='/static/build/entry/commons.entry.js')
script(src='/static/build/entry/app.entry.js')
script(src='/static/app/build/entry/commons.entry.js')
script(src='/static/app/build/entry/app.entry.js')
script(src='/static/bower_components/stf-analytics/analytics.js')

View file

@ -1,7 +1,7 @@
require.config({
paths: {
'angular': '../bower_components/angular/angular'
, 'angular-route': '../bower_components/angular-route/angular-route'
'angular': '../../../bower_components/angular/angular'
, 'angular-route': '../../../bower_components/angular-route/angular-route'
}
, shim: {
'angular': {

View file

@ -7,5 +7,5 @@ html
include partials/styles
body(ng-cloak)
div(ng-view)
script(src='/static/bower_components/requirejs/require.js', data-main='static/scripts/main.js')
script(src='/static/bower_components/requirejs/require.js', data-main='static/auth/ldap/scripts/main.js')
script(src='/static/bower_components/stf-analytics/analytics.js')

View file

@ -3,4 +3,4 @@ link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/st
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/se7en-font.css')
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/style.css')
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/font-awesome.min.css')
link(rel='stylesheet', href='/static/styles/login.css')
link(rel='stylesheet', href='/static/auth/ldap/styles/login.css')

View file

@ -1,7 +1,7 @@
require.config({
paths: {
'angular': '../bower_components/angular/angular'
, 'angular-route': '../bower_components/angular-route/angular-route'
'angular': '../../../bower_components/angular/angular'
, 'angular-route': '../../../bower_components/angular-route/angular-route'
}
, shim: {
'angular': {

View file

@ -7,5 +7,5 @@ html
include partials/styles
body(ng-cloak)
div(ng-view)
script(src='/static/bower_components/requirejs/require.js', data-main='static/scripts/main.js')
script(src='/static/bower_components/requirejs/require.js', data-main='static/auth/mock/scripts/main.js')
script(src='/static/bower_components/stf-analytics/analytics.js')

View file

@ -3,4 +3,4 @@ link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/st
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/se7en-font.css')
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/style.css')
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/font-awesome.min.css')
link(rel='stylesheet', href='/static/styles/login.css')
link(rel='stylesheet', href='/static/auth/mock/styles/login.css')

View file

@ -6,12 +6,12 @@ module.exports = {
cache: true
, entry: {
app: pathutil.resource('app/app.js')
, authldap: pathutil.resource('auth-ldap/scripts/entry.js')
, authmock: pathutil.resource('auth-mock/scripts/entry.js')
, authldap: pathutil.resource('auth/ldap/scripts/entry.js')
, authmock: pathutil.resource('auth/mock/scripts/entry.js')
}
, output: {
path: pathutil.resource('build')
, publicPath: '/static/build/'
, publicPath: '/static/app/build/'
, filename: 'entry/[name].entry.js'
, chunkFilename: '[id].[hash].chunk.js'
}