You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/06/30 22:41:32 UTC
[02/52] [partial] incubator-trafficcontrol git commit: promotes TO
experimental UI to the new Traffic Portal
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/build/build_rpm.sh
----------------------------------------------------------------------
diff --git a/traffic_portal/build/build_rpm.sh b/traffic_portal/build/build_rpm.sh
index 2ce3c97..9542f14 100755
--- a/traffic_portal/build/build_rpm.sh
+++ b/traffic_portal/build/build_rpm.sh
@@ -16,9 +16,12 @@
function importFunctions() {
local script=$(readlink -f "$0")
+ local suff=${script##*control/}
+ local tcdirlen=$[${#script} - ${#suff}]
+ export TC_DIR=${script:0:$tcdirlen}
local scriptdir=$(dirname "$script")
export TS_DIR=$(dirname "$scriptdir")
- export TC_DIR=$(dirname "$TS_DIR")
+
functions_sh="$TC_DIR/build/functions.sh"
if [[ ! -r $functions_sh ]]; then
echo "error: can't find $functions_sh"
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/build/etc/init.d/traffic_portal
----------------------------------------------------------------------
diff --git a/traffic_portal/build/etc/init.d/traffic_portal b/traffic_portal/build/etc/init.d/traffic_portal
index be4697d..9b9c384 100755
--- a/traffic_portal/build/etc/init.d/traffic_portal
+++ b/traffic_portal/build/etc/init.d/traffic_portal
@@ -25,6 +25,7 @@
# description: My Application
### END CHKCONFIG INFO
#
+#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/build/traffic_portal.spec
----------------------------------------------------------------------
diff --git a/traffic_portal/build/traffic_portal.spec b/traffic_portal/build/traffic_portal.spec
index b3fb47a..6881030 100644
--- a/traffic_portal/build/traffic_portal.spec
+++ b/traffic_portal/build/traffic_portal.spec
@@ -82,7 +82,6 @@ tar -xzvf $RPM_SOURCE_DIR/traffic_portal-%{version}.tgz
%attr(755,root,root) %{traffic_portal_home}/node_modules/forever/bin/*
%config(noreplace)/etc/traffic_portal/conf/config.js
%dir /var/log/traffic_portal
-/etc/traffic_portal/conf/config-template.js
%{traffic_portal_home}/*
/etc/logrotate.d/traffic_portal
/etc/logrotate.d/traffic_portal-access
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/conf/config-template.js
----------------------------------------------------------------------
diff --git a/traffic_portal/conf/config-template.js b/traffic_portal/conf/config-template.js
deleted file mode 100644
index 6618ff5..0000000
--- a/traffic_portal/conf/config-template.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-
-// this is the config for /opt/traffic_portal/server/server.js and is consumed when 'sudo service traffic_portal start'
-module.exports = {
- timeout: '120s',
- useSSL: false, // set to true if you plan to use https (self-signed or trusted certs).
- port: 8080,
- sslPort: 8443,
- proxyPort: 8009,
- // if useSSL is true, generate ssl certs and provide the proper locations.
- ssl: {
- key: '/path/to/ssl.key',
- cert: '/path/to/ssl.crt',
- ca: [
- '/path/to/ssl-bundle.crt'
- ]
- },
- // set api 'base_url' to the traffic ops api (all api calls made from the traffic portal will be proxied to the api base_url)
- api: {
- base_url: 'http(s)://where-traffic-ops-api-is.com/api/'
- },
- // default files location (this is where the traffic portal html, css and javascript was installed)
- files: {
- static: '/opt/traffic_portal/public'
- },
- // default log location (this is where traffic_portal logs are written)
- log: {
- stream: '/var/log/traffic_portal/access.log'
- },
- reject_unauthorized: 0 // 0 if using self-signed certs, 1 if trusted certs
-};
-
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/conf/config.js
----------------------------------------------------------------------
diff --git a/traffic_portal/conf/config.js b/traffic_portal/conf/config.js
index f32449a..b4611a0 100644
--- a/traffic_portal/conf/config.js
+++ b/traffic_portal/conf/config.js
@@ -1,42 +1,46 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-// see config-template.js for comments
+// this is the config that is consumed by server/server.js
module.exports = {
timeout: '120s',
- useSSL: false,
+ useSSL: false, // set to true if you plan to use https (self-signed or trusted certs).
port: 8080,
sslPort: 8443,
- proxyPort: 8009,
+ // if useSSL is true, generate ssl certs and provide the proper locations.
ssl: {
- key: '/path/to/ssl.key',
- cert: '/path/to/ssl.crt',
- ca: [
- '/path/to/ssl-bundle.crt'
- ]
+ key: '/etc/pki/tls/private/localhost.key',
+ cert: '/etc/pki/tls/certs/localhost.crt',
+ ca: [ '/etc/pki/tls/certs/ca-bundle.crt' ]
},
+ // set api 'base_url' to the traffic ops api (all api calls made from the traffic portal will be proxied to the api base_url)
api: {
base_url: 'http://localhost:3000/api/'
},
+ // default static files location (this is where the traffic portal html, css and javascript was installed) - /opt/traffic_portal/public
files: {
static: './app/dist/public/'
},
+ // default log location (this is where traffic_portal logs are written) - /var/log/traffic_portal/access.log
log: {
stream: './server/log/access.log'
},
reject_unauthorized: 0 // 0 if using self-signed certs, 1 if trusted certs
};
+
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/traffic_portal/docker/Dockerfile b/traffic_portal/docker/Dockerfile
new file mode 100644
index 0000000..6e699e9
--- /dev/null
+++ b/traffic_portal/docker/Dockerfile
@@ -0,0 +1,25 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+FROM node:4-onbuild
+#FROM buildpack-deps:jessie
+
+RUN apt-get update -y && apt-get install libffi-dev ruby-dev rubygems vim -y
+
+# replace this with your application's default port
+RUN gem update --system && gem install --no-rdoc --no-ri compass && gem install --no-rdoc --no-ri sass -v 3.4.22
+RUN npm install -g bower grunt-cli
+RUN echo '{ "allow_root": true }' > /root/.bowerrc
+
+ADD infrastructure/docker/build/clean_build.sh /
+CMD /clean_build.sh traffic_portal
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/docker/docker-compose.yml
----------------------------------------------------------------------
diff --git a/traffic_portal/docker/docker-compose.yml b/traffic_portal/docker/docker-compose.yml
new file mode 100644
index 0000000..dd81b61
--- /dev/null
+++ b/traffic_portal/docker/docker-compose.yml
@@ -0,0 +1,32 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+version: '2'
+
+services:
+ portal:
+ build:
+ context: ..
+ dockerfile: /opt/traffic_portal/docker/Dockerfile
+ ports:
+ - 80:80
+ - 443:443
+ volumes:
+ - /etc/traffic_portal/conf:/etc/traffic_portal/conf
+ - /etc/pki:/etc/pki
+ networks:
+ - default
+
+networks:
+ default:
+ driver: bridge
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/docker/reset.sh
----------------------------------------------------------------------
diff --git a/traffic_portal/docker/reset.sh b/traffic_portal/docker/reset.sh
new file mode 100755
index 0000000..91be282
--- /dev/null
+++ b/traffic_portal/docker/reset.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+sudo systemctl stop traffic_portal
+
+docker rm traffic_portal_1 #remove container
+docker rmi traffic_portal #remove image
+docker ps -a
+
+sudo systemctl start traffic_portal
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/etc/systemd/system/traffic_portal.service
----------------------------------------------------------------------
diff --git a/traffic_portal/etc/systemd/system/traffic_portal.service b/traffic_portal/etc/systemd/system/traffic_portal.service
new file mode 100644
index 0000000..dc24d3a
--- /dev/null
+++ b/traffic_portal/etc/systemd/system/traffic_portal.service
@@ -0,0 +1,30 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-----------------------------------------
+# Ansible managed
+#-----------------------------------------
+#
+[Unit]
+Description=Traffic Portal Docker Container
+Requires=docker.service
+After=docker.service
+
+[Service]
+Restart=always
+ExecStart=/usr/bin/docker-compose -p traffic -f /opt/traffic_portal/docker/docker-compose.yml up
+ExecStop=/usr/bin/docker-compose -p traffic -f /opt/traffic_portal/docker/docker-compose.yml down -v
+WorkingDirectory=/opt/traffic_portal/docker
+
+[Install]
+WantedBy=default.target
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/browserify2.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/browserify2.js b/traffic_portal/grunt/browserify2.js
old mode 100755
new mode 100644
index 122651d..2528df4
--- a/traffic_portal/grunt/browserify2.js
+++ b/traffic_portal/grunt/browserify2.js
@@ -1,18 +1,20 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
module.exports = {
@@ -30,6 +32,7 @@ module.exports = {
'angular-animate/angular-animate.min.js',
'angular-bootstrap/ui-bootstrap.min.js',
'angular-bootstrap/ui-bootstrap-tpls.min.js',
+ 'angular-jwt/dist/angular-jwt.min.js',
'angular-loading-bar/build/loading-bar.min.js',
'angular-resource/angular-resource.min.js',
'angular-route/angular-route.min.js',
@@ -38,7 +41,8 @@ module.exports = {
'bootstrap-sass-official/assets/javascripts/bootstrap.min.js',
'es5-shim/es5-shim.min.js',
'jquery/jquery.min.js',
- 'json3/lib/json3.min.js'
+ 'json3/lib/json3.min.js',
+ 'restangular/dist/restangular.min.js'
]
},
{
@@ -48,6 +52,11 @@ module.exports = {
},
{
cwd: '<%= globalConfig.app %>/bower_components/',
+ src: [ 'flot/jquery.flot.pie.js' ],
+ rename: function () { return 'jquery-flot-pie.js'; }
+ },
+ {
+ cwd: '<%= globalConfig.app %>/bower_components/',
src: [ 'flot/jquery.flot.stack.js' ],
rename: function () { return 'jquery-flot-stack.js'; }
},
@@ -84,6 +93,7 @@ module.exports = {
'angular-animate/angular-animate.js',
'angular-bootstrap/ui-bootstrap.js',
'angular-bootstrap/ui-bootstrap-tpls.js',
+ 'angular-jwt/dist/angular-jwt.js',
'angular-loading-bar/build/loading-bar.js',
'angular-resource/angular-resource.js',
'angular-route/angular-route.js',
@@ -92,7 +102,8 @@ module.exports = {
'bootstrap-sass-official/assets/javascripts/bootstrap.js',
'es5-shim/es5-shim.js',
'jquery/jquery.js',
- 'json3/lib/json3.js'
+ 'json3/lib/json3.js',
+ 'restangular/dist/restangular.js'
]
},
{
@@ -102,6 +113,11 @@ module.exports = {
},
{
cwd: '<%= globalConfig.app %>/bower_components/',
+ src: [ 'flot/jquery.flot.pie.js' ],
+ rename: function () { return 'jquery-flot-pie.js'; }
+ },
+ {
+ cwd: '<%= globalConfig.app %>/bower_components/',
src: [ 'flot/jquery.flot.stack.js' ],
rename: function () { return 'jquery-flot-stack.js'; }
},
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/clean.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/clean.js b/traffic_portal/grunt/clean.js
old mode 100755
new mode 100644
index fead1ce..cb999b8
--- a/traffic_portal/grunt/clean.js
+++ b/traffic_portal/grunt/clean.js
@@ -1,23 +1,29 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
+
module.exports = {
all: [
'<%= globalConfig.distdir %>/*',
'<%= globalConfig.tmpdir %>/*'
- ]
-};
\ No newline at end of file
+ ],
+ options: {
+ force: true
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/compass.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/compass.js b/traffic_portal/grunt/compass.js
old mode 100755
new mode 100644
index 5ec79fd..2aed889
--- a/traffic_portal/grunt/compass.js
+++ b/traffic_portal/grunt/compass.js
@@ -1,20 +1,23 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
+
module.exports = {
options: {
sassDir: '<%= globalConfig.srcdir %>',
@@ -41,4 +44,4 @@ module.exports = {
environment: 'development'
}
}
-};
\ No newline at end of file
+};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/copy.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/copy.js b/traffic_portal/grunt/copy.js
old mode 100755
new mode 100644
index 4bee643..f774d39
--- a/traffic_portal/grunt/copy.js
+++ b/traffic_portal/grunt/copy.js
@@ -1,18 +1,20 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
module.exports = {
@@ -25,9 +27,9 @@ module.exports = {
dest: '<%= globalConfig.resourcesdir %>',
src: [
'assets/css/**/*',
+ 'assets/fonts/**/*',
'assets/images/**/*',
- 'assets/js/**/*',
- 'assets/other/**/*'
+ 'assets/js/**/*'
]
},
{
@@ -52,9 +54,9 @@ module.exports = {
dest: '<%= globalConfig.resourcesdir %>',
src: [
'assets/css/**/*',
+ 'assets/fonts/**/*',
'assets/images/**/*',
- 'assets/js/**/*',
- 'assets/other/**/*'
+ 'assets/js/**/*'
]
},
{
@@ -73,6 +75,7 @@ module.exports = {
dest: '<%= globalConfig.distdir %>/public',
src: [
'*.html',
+ 'traffic_portal_release.json',
'traffic_portal_properties.json'
]
}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/express.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/express.js b/traffic_portal/grunt/express.js
index aa76337..97c3bda 100644
--- a/traffic_portal/grunt/express.js
+++ b/traffic_portal/grunt/express.js
@@ -1,24 +1,26 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
module.exports = {
dev: {
options: {
- script: './server/server.js',
+ script: './server.js',
node_env: 'dev'
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/globalConfig.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/globalConfig.js b/traffic_portal/grunt/globalConfig.js
old mode 100755
new mode 100644
index 9d76412..71ab1b4
--- a/traffic_portal/grunt/globalConfig.js
+++ b/traffic_portal/grunt/globalConfig.js
@@ -1,18 +1,20 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
module.exports = function() {
@@ -20,7 +22,6 @@ module.exports = function() {
app: 'app',
resourcesdir: 'app/dist/public/resources',
distdir: 'app/dist',
- srcconfdir: './conf',
srcserverdir: './server',
srcdir: 'app/src',
tmpdir: '.tmp',
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/html2js.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/html2js.js b/traffic_portal/grunt/html2js.js
old mode 100755
new mode 100644
index 65760e5..8cd52af
--- a/traffic_portal/grunt/html2js.js
+++ b/traffic_portal/grunt/html2js.js
@@ -1,20 +1,23 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
+
module.exports = {
options: {
base: './app/src'
@@ -24,4 +27,4 @@ module.exports = {
dest: '<%= globalConfig.tmpdir %>/app-templates.js',
module: 'app.templates'
}
-};
\ No newline at end of file
+};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/install-dependencies.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/install-dependencies.js b/traffic_portal/grunt/install-dependencies.js
index 8af5b3c..5729bf8 100644
--- a/traffic_portal/grunt/install-dependencies.js
+++ b/traffic_portal/grunt/install-dependencies.js
@@ -16,8 +16,8 @@
*/
module.exports = {
- options: {
- cwd: '<%= globalConfig.distdir %>',
- isDevelopment: false
- }
+ options: {
+ cwd: '<%= globalConfig.distdir %>',
+ isDevelopment: false
+ }
};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/jshint.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/jshint.js b/traffic_portal/grunt/jshint.js
old mode 100755
new mode 100644
index aa7be4a..f95dfa1
--- a/traffic_portal/grunt/jshint.js
+++ b/traffic_portal/grunt/jshint.js
@@ -1,23 +1,26 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
+
module.exports = {
files: ['Gruntfile.js', '<%= globalConfig.srcfiles.js %>'],
options: {
jshintrc:true
}
-};
\ No newline at end of file
+};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/ngconstant.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/ngconstant.js b/traffic_portal/grunt/ngconstant.js
deleted file mode 100644
index 356d43e..0000000
--- a/traffic_portal/grunt/ngconstant.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-
-module.exports = {
- options: {
- space: ' ',
- wrap: '"use strict";\n\n {%= __ngModule %}',
- name: 'config',
- dest: '<%= globalConfig.srcdir %>/scripts/config.js'
- },
- dev: {
- constants: {
- ENV: {
- apiEndpoint: {
- '1.1': '/api/1.1/',
- '1.2': '/api/1.2/'
- }
- }
- }
- },
- prod: {
- constants: {
- ENV: {
- apiEndpoint: {
- '1.1': '/api/1.1/',
- '1.2': '/api/1.2/'
- }
- }
- }
- }
-};
-
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/uglify.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/uglify.js b/traffic_portal/grunt/uglify.js
old mode 100755
new mode 100644
index 1150381..5f124ce
--- a/traffic_portal/grunt/uglify.js
+++ b/traffic_portal/grunt/uglify.js
@@ -1,18 +1,20 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
module.exports = {
@@ -23,4 +25,4 @@ module.exports = {
]
}
}
-};
\ No newline at end of file
+};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/grunt/watch.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/watch.js b/traffic_portal/grunt/watch.js
old mode 100755
new mode 100644
index 971b472..bc72b39
--- a/traffic_portal/grunt/watch.js
+++ b/traffic_portal/grunt/watch.js
@@ -1,20 +1,23 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
+
module.exports = {
options: {
livereload: true
@@ -31,4 +34,4 @@ module.exports = {
files: ['app/**/*.tpl.html', 'app/**/index.html'],
tasks: ['copy:dist', 'build-dev']
}
-};
\ No newline at end of file
+};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/package.json
----------------------------------------------------------------------
diff --git a/traffic_portal/package.json b/traffic_portal/package.json
index a0df0d7..069c22f 100755
--- a/traffic_portal/package.json
+++ b/traffic_portal/package.json
@@ -1,16 +1,15 @@
{
- "name": "trafficPortal",
- "description": "Traffic Portal",
+ "name": "traffic_portal",
"devDependencies": {
"morgan": "1.7.0",
- "errorhandler": "1.4.3",
- "connect-modrewrite": "0.8.5",
- "connect-timeout": "1.7.0",
- "ssl-root-cas": "1.1.10",
- "express": "4.13.4",
+ "connect-modrewrite": "0.10.1",
+ "connect-timeout": "1.8.0",
+ "ssl-root-cas": "1.2.3",
+ "express": "4.15.2",
+ "requirejs": "2.3.3",
+ "connect-livereload": "0.5.4",
"grunt": "0.4.5",
"grunt-adam-compass": "0.7.1",
- "grunt-wiredep": "2.0.0",
"grunt-browserify2": "0.1.8",
"grunt-concurrent": "2.2.1",
"grunt-contrib-clean": "1.0.0",
@@ -25,12 +24,14 @@
"grunt-html2js": "0.3.5",
"grunt-install-dependencies": "0.2.0",
"grunt-newer": "1.1.2",
- "grunt-ng-constant": "2.0.1",
+ "grunt-rev": "0.1.0",
+ "grunt-usemin": "3.0.0",
+ "grunt-wiredep": "2.0.0",
"load-grunt-config": "0.19.1",
"load-grunt-tasks": "3.4.1",
"time-grunt": "1.3.0"
},
"engines": {
- "node": ">=0.12.0"
+ "node": "0.11.14"
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/server/server.js
----------------------------------------------------------------------
diff --git a/traffic_portal/server/server.js b/traffic_portal/server/server.js
index 77b87e4..d87851e 100644
--- a/traffic_portal/server/server.js
+++ b/traffic_portal/server/server.js
@@ -1,66 +1,81 @@
/*
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
var constants = require('constants'),
express = require('express'),
http = require('http'),
https = require('https'),
+ path = require('path'),
fs = require('fs'),
morgan = require('morgan'),
- errorhandler = require('errorhandler'),
modRewrite = require('connect-modrewrite'),
timeout = require('connect-timeout');
var config;
try {
- // this should exist in prod environment. no need to create this file in dev as it will use the fallback (see catch)
config = require('/etc/traffic_portal/conf/config');
}
catch(e) {
- // this is used for dev environment
- config = require('../conf/config');
+ config = require('./conf/config');
}
-var logStream = fs.createWriteStream(config.log.stream, { flags: 'a' });
-var useSSL = config.useSSL;
+var logStream = fs.createWriteStream(config.log.stream, { flags: 'a' }),
+ useSSL = config.useSSL;
// Disable for self-signed certs in dev/test
process.env.NODE_TLS_REJECT_UNAUTHORIZED = config.reject_unauthorized;
var app = express();
+
+app.use(function(req, res, next) {
+ var err = null;
+ try {
+ decodeURIComponent(req.path)
+ }
+ catch(e) {
+ err = e;
+ }
+ if (err){
+ console.log(err, req.url);
+ }
+ next();
+});
+
// Add a handler to inspect the req.secure flag (see
// http://expressjs.com/api#req.secure). This allows us
// to know whether the request was via http or https.
app.all ("/*", function (req, res, next) {
if (useSSL && !req.secure) {
- var headersHost = req.headers.host.split(':');
- var httpsUrl = 'https://' + headersHost[0] + ':' + config.sslPort + req.url;
// request was via http, so redirect to https
- res.redirect(httpsUrl);
+ return res.redirect(['https://', req.get('Host'), ':', config.sslPort, req.url].join(''));
} else {
+ // request was via https or useSSL=false, so do no special handling
next();
}
});
app.use(modRewrite([
- '^/api/(.*?)\\?(.*)$ ' + config.api.base_url + '$1?$2 [P]',
- '^/api/(.*)$ ' + config.api.base_url + '$1 [P]'
+ '^/api/(.*?)\\?(.*)$ ' + config.api.base_url + '$1?$2 [P]',
+ '^/api/(.*)$ ' + config.api.base_url + '$1 [P]'
]));
+
app.use(express.static(config.files.static));
app.use(morgan('combined', {
stream: logStream,
@@ -69,11 +84,47 @@ app.use(morgan('combined', {
app.use(timeout(config.timeout));
if (app.get('env') === 'dev') {
- app.use(errorhandler());
+ app.use(require('connect-livereload')({
+ port: 35728,
+ excludeList: ['.woff', '.flv']
+ }));
} else {
- app.set('env', "production");
+ app.set('env', 'production');
}
+// special handling required for dbdump. haven't got this to work yet
+// app.get('/dbdump', function (req, res) {
+// var port = (useSSL) ? config.sslPort : config.port,
+// options = {
+// method: 'GET',
+// host: 'localhost',
+// port: port,
+// path: '/api/1.2/dbdump',
+// headers: {
+// cookie: req.headers['cookie']
+// }
+// };
+//
+// var request = http.request(options, function(response) {
+// var data = [];
+// console.log(response.statusCode);
+// response.on('data', function(chunk) {
+// data.push(chunk);
+// });
+// response.on('end', function() {
+// data = Buffer.concat(data);
+// res.writeHead(200, {
+// 'Content-Type': 'application/download',
+// 'Content-Disposition': 'attachment; filename=foo.dump.gz',
+// 'Content-Length': data.length
+// });
+// res.end(data);
+// });
+// });
+//
+// request.end();
+// });
+
// Enable reverse proxy support in Express. This causes the
// the "X-Forwarded-Proto" header field to be trusted so its
// value can be used to determine the protocol. See
@@ -106,5 +157,4 @@ if (useSSL) {
}
console.log("Traffic Portal Port : %s", config.port);
-console.log("Traffic Portal Proxy Port : %s", config.proxyPort);
console.log("Traffic Portal SSL Port : %s", config.sslPort);
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/.bowerrc
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/.bowerrc b/traffic_portal/v1/.bowerrc
new file mode 100644
index 0000000..ba0accc
--- /dev/null
+++ b/traffic_portal/v1/.bowerrc
@@ -0,0 +1,3 @@
+{
+ "directory": "app/bower_components"
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/.gitignore
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/.gitignore b/traffic_portal/v1/.gitignore
new file mode 100644
index 0000000..a6d8ee5
--- /dev/null
+++ b/traffic_portal/v1/.gitignore
@@ -0,0 +1,9 @@
+.tmp
+.sass-cache
+app/bower_components
+app/dist
+app/src/scripts/config.js
+node_modules
+rpm/rpmbuild
+rpm/*.rpm
+server/log/access.log
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/.jshintrc
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/.jshintrc b/traffic_portal/v1/.jshintrc
new file mode 100644
index 0000000..6b2ddc7
--- /dev/null
+++ b/traffic_portal/v1/.jshintrc
@@ -0,0 +1,23 @@
+{
+ "browser": true,
+ "esnext": true,
+ "bitwise": true,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "indent": 2,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "quotmark": "single",
+ "regexp": true,
+ "undef": true,
+ "unused": true,
+ "strict": true,
+ "trailing": true,
+ "smarttabs": true,
+ "globals": {
+ "angular": false
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/Gruntfile.js
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/Gruntfile.js b/traffic_portal/v1/Gruntfile.js
new file mode 100755
index 0000000..f86d919
--- /dev/null
+++ b/traffic_portal/v1/Gruntfile.js
@@ -0,0 +1,96 @@
+/*
+
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+'use strict';
+
+module.exports = function (grunt) {
+ var os = require("os");
+ var globalConfig = require('./grunt/globalConfig');
+
+ // load time grunt - helps with optimizing build times
+ require('time-grunt')(grunt);
+
+ // load grunt task configurations
+ require('load-grunt-config')(grunt);
+
+ // default task - runs in dev mode
+ grunt.registerTask('default', ['dev']);
+
+ // dev task - when you type 'grunt dev' <-- builds unminified app and starts dev node.js server and watches for source file changes
+ grunt.registerTask('dev', [
+ 'build-dev',
+ 'express:dev',
+ 'watch'
+ ]);
+
+ // dist task - when you type 'grunt dist' <-- builds minified app for distribution and generates node dependencies all wrapped up nicely in a /dist folder
+ grunt.registerTask('dist', [
+ 'build',
+ 'install-dependencies'
+ ]);
+
+ // build tasks
+ grunt.registerTask('build', [
+ 'ngconstant:prod',
+ 'clean',
+ 'copy:dist',
+ 'build-css',
+ 'build-js',
+ 'build-shared-libs'
+ ]);
+
+ grunt.registerTask('build-dev', [
+ 'ngconstant:dev',
+ 'clean',
+ 'copy:dev',
+ 'build-css-dev',
+ 'build-js-dev',
+ 'build-shared-libs-dev'
+ ]);
+
+ // css
+ grunt.registerTask('build-css', [
+ 'compass:prod'
+ ]);
+
+ grunt.registerTask('build-css-dev', [
+ 'compass:dev'
+ ]);
+
+ // js (custom)
+ grunt.registerTask('build-js', [
+ 'html2js',
+ 'browserify2:app-prod',
+ 'browserify2:app-config'
+ ]);
+
+ grunt.registerTask('build-js-dev', [
+ 'html2js',
+ 'browserify2:app-dev',
+ 'browserify2:app-config'
+ ]);
+
+ // js (libraries)
+ grunt.registerTask('build-shared-libs', [
+ 'browserify2:shared-libs-prod'
+ ]);
+
+ grunt.registerTask('build-shared-libs-dev', [
+ 'browserify2:shared-libs-dev'
+ ]);
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/README.md
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/README.md b/traffic_portal/v1/README.md
new file mode 100644
index 0000000..92a0fa9
--- /dev/null
+++ b/traffic_portal/v1/README.md
@@ -0,0 +1,5 @@
+# Traffic Portal
+
+An AngularJS client served from a lightweight Node.js web server designed to consume the Traffic Ops 1.x API.
+
+Installation instructions found in traffic_portal/build directory.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/AppController.js
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/AppController.js b/traffic_portal/v1/app/src/AppController.js
new file mode 100644
index 0000000..b9e87d7
--- /dev/null
+++ b/traffic_portal/v1/app/src/AppController.js
@@ -0,0 +1,21 @@
+/*
+
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+var AppController = function() {};
+
+AppController.$inject = [];
+module.exports = AppController;
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/app.js
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/app.js b/traffic_portal/v1/app/src/app.js
new file mode 100755
index 0000000..9d7ac4a
--- /dev/null
+++ b/traffic_portal/v1/app/src/app.js
@@ -0,0 +1,181 @@
+/*
+
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+'use strict';
+require('app-templates');
+
+var App = function($urlRouterProvider) {
+ $urlRouterProvider.otherwise('/');
+};
+
+App.$inject = ['$urlRouterProvider'];
+
+var trafficPortal = angular.module('trafficPortal', [
+ 'config',
+ 'ngAnimate',
+ 'ngResource',
+ 'ngSanitize',
+ 'ngRoute',
+ 'ui.router',
+ 'ui.bootstrap',
+ 'ui.bootstrap.datetimepicker',
+ 'app.templates',
+ 'angular-loading-bar',
+
+ // public modules
+ require('./modules/public').name,
+ require('./modules/public/home').name,
+ require('./modules/public/home/landing').name,
+ require('./modules/public/about').name,
+
+ // private modules
+ require('./modules/private').name,
+
+ // collateral
+ require('./modules/private/collateral').name,
+
+ // dashboard
+ require('./modules/private/dashboard').name,
+ require('./modules/private/dashboard/overview').name,
+
+ // delivery service
+ require('./modules/private/deliveryService').name,
+ require('./modules/private/deliveryService/new').name,
+ require('./modules/private/deliveryService/view').name,
+ require('./modules/private/deliveryService/view/overview').name,
+ require('./modules/private/deliveryService/view/overview/detail').name,
+
+ // delivery service charts
+ require('./modules/private/deliveryService/view/charts').name,
+ require('./modules/private/deliveryService/view/charts/bandwidthPerSecond').name,
+ require('./modules/private/deliveryService/view/charts/httpStatus').name,
+ require('./modules/private/deliveryService/view/charts/transactionsPerSecond').name,
+
+ // user
+ require('./modules/private/user').name,
+ require('./modules/private/user/edit').name,
+ require('./modules/private/user/register').name,
+ require('./modules/private/user/reset').name,
+
+ // common modules
+ require('./common/modules/cacheGroups').name,
+ require('./common/modules/chart/bandwidthPerSecond').name,
+ require('./common/modules/chart/capacity').name,
+ require('./common/modules/chart/dates').name,
+ require('./common/modules/chart/httpStatus').name,
+ require('./common/modules/chart/routing').name,
+ require('./common/modules/chart/transactionsPerSecond').name,
+ require('./common/modules/dates').name,
+ require('./common/modules/deliveryService/config/edit').name,
+ require('./common/modules/dialog/confirm').name,
+ require('./common/modules/dialog/reset').name,
+ require('./common/modules/footer').name,
+ require('./common/modules/header').name,
+ require('./common/modules/message').name,
+ require('./common/modules/release/version').name,
+ require('./common/modules/tools/purge').name,
+
+ require('./common/models').name,
+ require('./common/api').name,
+
+ //directives
+ require('./common/directives/enter').name,
+ require('./common/directives/formattedDate').name,
+ require('./common/directives/match').name,
+ require('./common/directives/rcSubmit').name,
+ require('./common/directives/rcVerifySet').name,
+ require('./common/directives/selectOnClick').name,
+
+ // services
+ require('./common/service/application').name,
+ require('./common/service/utils').name,
+ require('./common/service/utils/date').name,
+
+ //filters
+ require('./common/filters').name
+
+ ], App)
+
+ .controller('AppController', require('./AppController'))
+
+ .config(function($stateProvider, $logProvider, $controllerProvider) {
+ $controllerProvider.allowGlobals();
+ $logProvider.debugEnabled(true);
+ $stateProvider
+ .state('trafficPortal', {
+ url: '/',
+ abstract: true,
+ templateUrl: 'common/templates/master.tpl.html',
+ controller: 'AppController',
+ resolve: {
+ properties: function(portalService, propertiesModel) {
+ return portalService.getProperties()
+ .then(function(result) {
+ propertiesModel.setProperties(result);
+ });
+ }
+ }
+ });
+ })
+
+ .run(function(applicationService) {
+ applicationService.startup();
+ })
+ ;
+
+trafficPortal.factory('authInterceptor', function ($q, $location, $timeout, dateUtils, messageModel, userModel) {
+ return {
+ responseError: function (rejection) {
+ var url = $location.url(),
+ alerts = [];
+
+ try { alerts = rejection.data.alerts; }
+ catch(e) {}
+
+ // 401, 403, 404 and 5xx errors handled globally; all others handled in fault handler
+ if (rejection.status === 401) {
+ userModel.resetUser();
+ if (url == '/' || $location.search().redirect) {
+ messageModel.setMessages(alerts, false);
+ } else {
+ $timeout(function () {
+ messageModel.setMessages(alerts, true);
+ // forward the to the home page with ?redirect=page/they/were/trying/to/reach
+ $location.url('/').search({ redirect: encodeURIComponent(url) });
+ }, 200);
+ }
+ } else if (rejection.status === 403 || rejection.status === 404) {
+ $timeout(function () {
+ messageModel.setMessages(alerts, false);
+ }, 200);
+ } else if (rejection.status.toString().match(/^5\d[01356789]$/)) {
+ // matches 5xx EXCEPT for 502's and 504's which indicate a timeout and will be handled by each service call accordingly
+ $timeout(function () {
+ messageModel.setMessages([ { level: 'error', text: rejection.status.toString() + ': ' + rejection.statusText + ' (' + dateUtils.dateFormat(new Date(), "UTC:dd/mmm/yyyy:HH:MM:ss o") + ')' } ], false);
+ }, 200);
+ }
+
+ return $q.reject(rejection);
+ }
+ };
+});
+
+trafficPortal.config(function ($httpProvider) {
+ $httpProvider.interceptors.push('authInterceptor');
+});
+
+
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/assets/css/custom.css
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/assets/css/custom.css b/traffic_portal/v1/app/src/assets/css/custom.css
new file mode 100644
index 0000000..c0c95c3
--- /dev/null
+++ b/traffic_portal/v1/app/src/assets/css/custom.css
@@ -0,0 +1,23 @@
+/*
+
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+
+/*
+ This file is a placeholder for custom styles for Traffic Portal. To customize styles, create your own custom.css and copy it
+ to /resources/assets/css/ on your web server replacing the old, blank one. This file should remain blank in source control.
+ If the default bootstrap styles are sufficient, do nothing.
+*/
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/assets/images/favicon.png
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/assets/images/favicon.png b/traffic_portal/v1/app/src/assets/images/favicon.png
new file mode 100755
index 0000000..da095e9
Binary files /dev/null and b/traffic_portal/v1/app/src/assets/images/favicon.png differ
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/assets/js/.keep
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/assets/js/.keep b/traffic_portal/v1/app/src/assets/js/.keep
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/assets/other/collateral.txt
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/assets/other/collateral.txt b/traffic_portal/v1/app/src/assets/other/collateral.txt
new file mode 100644
index 0000000..f402ca7
--- /dev/null
+++ b/traffic_portal/v1/app/src/assets/other/collateral.txt
@@ -0,0 +1 @@
+This is a document you want to share with your traffic portal users.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/common/api/AuthService.js
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/common/api/AuthService.js b/traffic_portal/v1/app/src/common/api/AuthService.js
new file mode 100644
index 0000000..c3fea82
--- /dev/null
+++ b/traffic_portal/v1/app/src/common/api/AuthService.js
@@ -0,0 +1,82 @@
+/*
+
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+var AuthService = function($http, $state, $location, $q, userModel, deliveryServicesModel, messageModel, ENV) {
+
+ this.login = function(username, password) {
+ userModel.resetUser();
+ deliveryServicesModel.resetDeliveryServices();
+ var promise = $http.post(
+ ENV.apiEndpoint['1.2'] + "user/login", { u: username, p: password })
+ .success(function(result) {
+ var redirect = decodeURIComponent($location.search().redirect);
+ if (redirect !== 'undefined') {
+ $location.search('redirect', null); // remove the redirect query param
+ $location.url(redirect);
+ } else {
+ $location.url('/dashboard');
+ }
+ return result;
+ })
+ .error(function(fault) {
+ return fault;
+ });
+
+ return promise;
+ };
+
+ this.tokenLogin = function(token) {
+ userModel.resetUser();
+ deliveryServicesModel.resetDeliveryServices();
+ var deferred = $q.defer();
+ $http.post(
+ ENV.apiEndpoint['1.2'] + "user/login/token", { t: token })
+ .success(function(result) {
+ deferred.resolve(result);
+ })
+ .error(function(fault) {
+ deferred.reject(fault);
+ });
+
+ return deferred.promise;
+ };
+
+ this.logout = function() {
+ userModel.resetUser();
+ deliveryServicesModel.resetDeliveryServices();
+ var promise = $http.post(
+ ENV.apiEndpoint['1.2'] + "user/logout")
+ .success(function(result) {
+ if ($state.current.name == 'trafficPortal.public.home.landing') {
+ messageModel.setMessages(result.alerts, false);
+ } else {
+ messageModel.setMessages(result.alerts, true);
+ $state.go('trafficPortal.public.home.landing');
+ }
+ return result;
+ })
+ .error(function(fault) {
+ return fault;
+ });
+
+ return promise;
+ };
+
+};
+
+AuthService.$inject = ['$http', '$state', '$location', '$q', 'userModel', 'deliveryServicesModel', 'messageModel', 'ENV'];
+module.exports = AuthService;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/common/api/DeliveryServiceService.js
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/common/api/DeliveryServiceService.js b/traffic_portal/v1/app/src/common/api/DeliveryServiceService.js
new file mode 100644
index 0000000..e2f2976
--- /dev/null
+++ b/traffic_portal/v1/app/src/common/api/DeliveryServiceService.js
@@ -0,0 +1,177 @@
+/*
+
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+var DeliveryServiceService = function($http, $q, deliveryServicesModel, messageModel, propertiesModel, ENV) {
+
+ var capacityRequest,
+ routingMethodsRequest,
+ cacheGroupHealthRequest;
+
+ var displayTimoutError = function(options) {
+ var msg = (angular.isDefined(options.message)) ? options.message : 'Request timeout';
+ if (options.status.toString().match(/^5\d[24]$/)) {
+ // 502 or 504
+ messageModel.setMessages([ { level: 'error', text: msg } ], false);
+ }
+ };
+
+ this.getDeliveryServices = function() {
+ var promise = $http.get(ENV.apiEndpoint['1.2'] + "deliveryservices.json")
+ .success(function(result) {
+ deliveryServicesModel.setDeliveryServices(result.response);
+ return result.response;
+ })
+ .error(function(fault) {
+ });
+
+ return promise;
+ };
+
+ this.getDeliveryService = function(deliveryServiceId) {
+ var deferred = $q.defer();
+ $http.get(ENV.apiEndpoint['1.2'] + "deliveryservices/" + deliveryServiceId + ".json")
+ .success(function(result) {
+ deferred.resolve(result.response[0]);
+ })
+ .error(function(fault) {
+ deferred.resolve(null);
+ });
+
+ return deferred.promise;
+ };
+
+ this.getState = function(deliveryServiceId, ignoreLoadingBar) {
+ var deferred = $q.defer();
+ $http.get(ENV.apiEndpoint['1.2'] + "deliveryservices/" + deliveryServiceId + "/state.json", { ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ deferred.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ displayTimoutError({ status: status });
+ deferred.reject();
+ });
+
+ return deferred.promise;
+ };
+
+ this.getCapacity = function(deliveryServiceId, ignoreLoadingBar, showTimeoutError) {
+ if (capacityRequest) {
+ capacityRequest.reject();
+ }
+ capacityRequest = $q.defer();
+
+ $http.get(ENV.apiEndpoint['1.2'] + "deliveryservices/" + deliveryServiceId + "/capacity.json",
+ { timeout: capacityRequest.promise, ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ capacityRequest.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showTimeoutError) displayTimoutError({ status: status });
+ capacityRequest.reject();
+ });
+
+ return capacityRequest.promise;
+ };
+
+
+ this.getRoutingMethods = function(deliveryServiceId, ignoreLoadingBar, showTimeoutError) {
+ if (routingMethodsRequest) {
+ routingMethodsRequest.reject();
+ }
+ routingMethodsRequest = $q.defer();
+
+ $http.get(ENV.apiEndpoint['1.2'] + "deliveryservices/" + deliveryServiceId + "/routing.json",
+ { timeout: routingMethodsRequest.promise, ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ routingMethodsRequest.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showTimeoutError) displayTimoutError({ status: status });
+ routingMethodsRequest.reject();
+ });
+
+ return routingMethodsRequest.promise;
+ };
+
+ this.getCacheGroupHealth = function(deliveryServiceId, ignoreLoadingBar, showTimeoutError) {
+ if (cacheGroupHealthRequest) {
+ cacheGroupHealthRequest.reject();
+ }
+ cacheGroupHealthRequest = $q.defer();
+
+ $http.get(ENV.apiEndpoint['1.2'] + "deliveryservices/" + deliveryServiceId + "/health.json",
+ { timeout: cacheGroupHealthRequest.promise, ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ cacheGroupHealthRequest.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showTimeoutError) displayTimoutError({ status: status });
+ cacheGroupHealthRequest.reject();
+ });
+
+ return cacheGroupHealthRequest.promise;
+ };
+
+ this.getPurgeJobs = function(deliveryServiceId, ignoreLoadingBar) {
+ var deferred = $q.defer();
+ $http.get(ENV.apiEndpoint['1.2'] + "user/current/jobs.json?dsId=" + deliveryServiceId + "&keyword=PURGE", { ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ deferred.resolve(result.response);
+ })
+ .error(function(fault) {
+ deferred.reject();
+ });
+
+ return deferred.promise;
+ };
+
+ this.getServers = function(deliveryServiceId, ignoreLoadingBar) {
+ var deferred = $q.defer();
+ $http.get(ENV.apiEndpoint['1.2'] + "servers.json?orderby=type&dsId=" + deliveryServiceId, { ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ deferred.resolve(result.response);
+ })
+ .error(function(fault) {
+ deferred.reject();
+ });
+
+ return deferred.promise;
+ };
+
+ this.createDSRequest = function(dsData) {
+ var deferred = $q.defer();
+ $http.post(ENV.apiEndpoint['1.2'] + "deliveryservices/request", { emailTo: propertiesModel.properties.deliveryService.request.email, details: dsData } )
+ .success(function(result) {
+ if (angular.isDefined(result.alerts)) {
+ messageModel.setMessages(result.alerts, false);
+ }
+ deferred.resolve(result);
+ })
+ .error(function(fault) {
+ if (angular.isDefined(fault.alerts)) {
+ messageModel.setMessages(fault.alerts, false);
+ }
+ deferred.reject();
+ });
+
+ return deferred.promise;
+ };
+
+};
+
+DeliveryServiceService.$inject = ['$http', '$q', 'deliveryServicesModel', 'messageModel', 'propertiesModel', 'ENV'];
+module.exports = DeliveryServiceService;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/common/api/HealthService.js
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/common/api/HealthService.js b/traffic_portal/v1/app/src/common/api/HealthService.js
new file mode 100644
index 0000000..a7948cd
--- /dev/null
+++ b/traffic_portal/v1/app/src/common/api/HealthService.js
@@ -0,0 +1,45 @@
+/*
+
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+var HealthService = function($http, $q, ENV) {
+
+ var displayTimoutError = function(options) {
+ var msg = (angular.isDefined(options.message)) ? options.message : 'Request timeout. Failed to load cache groups.';
+ if (options.status.toString().match(/^5\d[24]$/)) {
+ // 502 or 504
+ messageModel.setMessages([ { level: 'error', text: msg } ], false);
+ }
+ };
+
+ this.getCacheGroupHealth = function(entityId, ignoreLoadingBar, showTimeoutError) {
+ var deferred = $q.defer();
+ $http.get(ENV.apiEndpoint['1.2'] + "cdns/health.json", { ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ deferred.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showTimeoutError) displayTimoutError({ status: status });
+ deferred.reject();
+ });
+
+ return deferred.promise;
+ };
+
+};
+
+HealthService.$inject = ['$http', '$q', 'ENV'];
+module.exports = HealthService;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/common/api/PortalService.js
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/common/api/PortalService.js b/traffic_portal/v1/app/src/common/api/PortalService.js
new file mode 100644
index 0000000..baadf8e
--- /dev/null
+++ b/traffic_portal/v1/app/src/common/api/PortalService.js
@@ -0,0 +1,43 @@
+/*
+
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+var PortalService = function($http, $q) {
+
+ this.getReleaseVersionInfo = function() {
+ var deferred = $q.defer();
+ $http.get('traffic_portal_release.json')
+ .success(function(result) {
+ deferred.resolve(result);
+ });
+
+ return deferred.promise;
+ };
+
+ this.getProperties = function() {
+ var deferred = $q.defer();
+ $http.get('traffic_portal_properties.json')
+ .success(function(result) {
+ deferred.resolve(result.properties);
+ });
+
+ return deferred.promise;
+ };
+
+};
+
+PortalService.$inject = ['$http', '$q'];
+module.exports = PortalService;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3195e0cc/traffic_portal/v1/app/src/common/api/StatsService.js
----------------------------------------------------------------------
diff --git a/traffic_portal/v1/app/src/common/api/StatsService.js b/traffic_portal/v1/app/src/common/api/StatsService.js
new file mode 100644
index 0000000..98ab370
--- /dev/null
+++ b/traffic_portal/v1/app/src/common/api/StatsService.js
@@ -0,0 +1,159 @@
+/*
+
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+var StatsService = function($http, $q, messageModel, ENV) {
+
+ var edgeBandwidthRequest,
+ edgeBandwidthSummaryRequest;
+
+ var edgeTransactionsRequest,
+ edgeTransactionsSummaryRequest;
+
+ var retentionPeriodInDays; // used as an influxdb override, leave null if no override
+
+ var displayTimoutError = function(options) {
+ var msg = (angular.isDefined(options.message)) ? options.message : 'Request timeout. Please narrow your chart window.';
+ if (options.status.toString().match(/^5\d[24]$/)) {
+ // 502 or 504
+ messageModel.setMessages([ { level: 'error', text: msg } ], false);
+ }
+ };
+
+ this.getEdgeBandwidthBatch = function(deliveryService, start, end, interval, exclude, ignoreLoadingBar, showError) {
+ var deferred = $q.defer();
+
+ var url = ENV.apiEndpoint['1.2'] + "deliveryservice_stats.json",
+ params = { deliveryServiceName: deliveryService.xmlId, metricType: 'kbps', serverType: 'edge', startDate: start.seconds(00).format(), endDate: end.seconds(00).format(), interval: interval, exclude: exclude, retentionPeriodInDays: retentionPeriodInDays };
+
+ $http.get(url, { params: params, ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ deferred.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showError) displayTimoutError({ status: status });
+ deferred.reject();
+ });
+
+ return deferred.promise;
+ };
+
+ this.getEdgeBandwidth = function(deliveryService, start, end, interval, exclude, ignoreLoadingBar, showError) {
+ if (edgeBandwidthRequest) {
+ edgeBandwidthRequest.reject();
+ }
+ edgeBandwidthRequest = $q.defer();
+
+ var url = ENV.apiEndpoint['1.2'] + "deliveryservice_stats.json",
+ params = { deliveryServiceName: deliveryService.xmlId, metricType: 'kbps', serverType: 'edge', startDate: start.seconds(00).format(), endDate: end.seconds(00).format(), interval: interval, exclude: exclude, retentionPeriodInDays: retentionPeriodInDays};
+
+ $http.get(url, { params: params, timeout: edgeBandwidthRequest.promise, ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ edgeBandwidthRequest.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showError) displayTimoutError({ status: status });
+ edgeBandwidthRequest.reject();
+ });
+
+ return edgeBandwidthRequest.promise;
+ };
+
+ this.getEdgeBandwidthSummary = function(deliveryService, start, end, interval, exclude, ignoreLoadingBar, showError) {
+ if (edgeBandwidthSummaryRequest) {
+ edgeBandwidthSummaryRequest.reject();
+ }
+ edgeBandwidthSummaryRequest = $q.defer();
+
+ var url = ENV.apiEndpoint['1.2'] + "deliveryservice_stats.json",
+ params = { deliveryServiceName: deliveryService.xmlId, metricType: 'kbps', serverType: 'edge', startDate: start.seconds(00).format(), endDate: end.seconds(00).format(), interval: interval, exclude: exclude, retentionPeriodInDays: retentionPeriodInDays };
+
+ $http.get(url, { params: params, timeout: edgeBandwidthSummaryRequest.promise, ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ edgeBandwidthSummaryRequest.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showError) displayTimoutError({ status: status });
+ edgeBandwidthSummaryRequest.reject();
+ });
+
+ return edgeBandwidthSummaryRequest.promise;
+ };
+
+ this.getEdgeTransactions = function(deliveryService, start, end, interval, exclude, ignoreLoadingBar, showError) {
+ if (edgeTransactionsRequest) {
+ edgeTransactionsRequest.reject();
+ }
+ edgeTransactionsRequest = $q.defer();
+
+ var url = ENV.apiEndpoint['1.2'] + "deliveryservice_stats.json",
+ params = { deliveryServiceName: deliveryService.xmlId, metricType: 'tps_total', serverType: 'edge', startDate: start.seconds(00).format(), endDate: end.seconds(00).format(), interval: interval, exclude: exclude, retentionPeriodInDays: retentionPeriodInDays };
+
+ $http.get(url, { params: params, timeout: edgeTransactionsRequest.promise, ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ edgeTransactionsRequest.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showError) displayTimoutError({ status: status });
+ edgeTransactionsRequest.reject();
+ });
+
+ return edgeTransactionsRequest.promise;
+ };
+
+ this.getEdgeTransactionsSummary = function(deliveryService, start, end, interval, ignoreLoadingBar, showError) {
+ if (edgeTransactionsSummaryRequest) {
+ edgeTransactionsSummaryRequest.reject();
+ }
+ edgeTransactionsSummaryRequest = $q.defer();
+
+ var url = ENV.apiEndpoint['1.2'] + "deliveryservice_stats.json",
+ params = { deliveryServiceName: deliveryService.xmlId, metricType: 'tps_total', serverType: 'edge', startDate: start.seconds(00).format(), endDate: end.seconds(00).format(), interval: interval, exclude: 'series', retentionPeriodInDays: retentionPeriodInDays };
+
+ $http.get(url, { params: params, timeout: edgeTransactionsSummaryRequest.promise, ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ edgeTransactionsSummaryRequest.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showError) displayTimoutError({ status: status });
+ edgeTransactionsSummaryRequest.reject();
+ });
+
+ return edgeTransactionsSummaryRequest.promise;
+ };
+
+ this.getEdgeTransactionsByStatusGroup = function(deliveryService, httpStatus, start, end, interval, exclude, ignoreLoadingBar, showError) {
+ var request = $q.defer();
+
+ var url = ENV.apiEndpoint['1.2'] + "deliveryservice_stats.json",
+ params = { deliveryServiceName: deliveryService.xmlId, metricType: 'tps_' + httpStatus, serverType: 'edge', startDate: start.seconds(00).format(), endDate: end.seconds(00).format(), interval: interval, exclude: exclude, retentionPeriodInDays: retentionPeriodInDays };
+
+ $http.get(url, { params: params, ignoreLoadingBar: ignoreLoadingBar })
+ .success(function(result) {
+ request.resolve(result.response);
+ })
+ .error(function(fault, status) {
+ if (showError) displayTimoutError({ status: status });
+ request.reject();
+ });
+
+ return request.promise;
+ };
+
+};
+
+StatsService.$inject = ['$http', '$q', 'messageModel', 'ENV'];
+module.exports = StatsService;
\ No newline at end of file