This repository has been archived by the owner on Dec 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from APItools/merge-on-premise
Merge on premise
- Loading branch information
Showing
22 changed files
with
238 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
angular.module('slug.root', ['ui.router']) | ||
angular.module('slug.root', ['ui.router', 'slug.setup']) | ||
.config ($urlRouterProvider) -> | ||
$urlRouterProvider.when('/', '/dashboard') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
angular.module('slug.setup', ['ui.router', 'slug.user_settings']) | ||
|
||
.config ($stateProvider) -> | ||
Config = | ||
config: (UserSettings) -> | ||
UserSettings.$promise | ||
|
||
$stateProvider | ||
.state 'setup', | ||
url: '/setup' | ||
templateUrl: '/setup/show.html' | ||
controller: 'SetupCtrl' | ||
resolve: Config | ||
|
||
.state 'pair', | ||
url: '/pair' | ||
templateUrl: '/setup/pair.html' | ||
controller: 'PairCtrl' | ||
resolve: Config | ||
|
||
.controller 'SetupCtrl', ($scope, $state, config, flash, OnPremise) -> | ||
setup = $scope.setup = report_usage: true | ||
|
||
if config.get('set_up') | ||
$state.go('dashboard') | ||
|
||
$scope.saveSetup = -> | ||
failure = -> | ||
flash.error = 'There was an error when setting up this Traffic Monitor. Dou you have internet connection?' | ||
|
||
update_config = -> | ||
config.extend(report_usage: setup.report_usage, set_up: true) | ||
config.$promise.then -> | ||
flash.success = 'Successfully set up your Traffic Monitor' | ||
$state.go('dashboard') | ||
|
||
if setup.report_usage | ||
uuid = config.get('uuid') | ||
OnPremise.register(uuid).then(update_config, failure) | ||
else | ||
update_config() | ||
|
||
|
||
|
||
|
||
.controller 'PairCtrl', ($scope, $state, Brain, OnPremise) -> | ||
Brain.$promise.then -> | ||
$scope.get_key = "#{Brain.host}/on_premise/link" | ||
|
||
$scope.setup = {} | ||
|
||
$scope.pair = () -> | ||
key = $scope.setup.pairing_key | ||
linking = OnPremise.link(key) | ||
|
||
linking.success -> | ||
$state.go('dashboard') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
angular.module('slug.services.brain', []) | ||
|
||
.factory 'Brain', ($http) -> | ||
brain = { $promise: $http(method: 'GET', url: '/api/brain') } | ||
|
||
brain.$promise.success (data) -> | ||
brain.host = data.host | ||
|
||
brain | ||
|
||
.factory 'OnPremise', ($http) -> | ||
register: (uuid) -> | ||
$http.post('/api/brain/register', uuid: uuid) | ||
|
||
link: (key) -> | ||
$http.post('/api/brain/link', key: key) | ||
|
||
unlink: -> | ||
$http.post('/api/brain/unlink', {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<h1>Pair your Traffic Monitor with the Global Dashboard</h1> | ||
|
||
<form class="form-horizontal" name='pair_form' ng-submit="pair()"> | ||
|
||
<fieldset> | ||
<div class="control-group" ng-class="{error: pair_form.pairing_key.$invalid}"> | ||
<label class="control-label" for="pairing_key">Your Pairing Key:</label> | ||
<div class="controls"> | ||
<input id="pairing_key" class="input-xlarge" type="text" | ||
name="pairing_key" ng-model="setup.pairing_key" required> | ||
</div> | ||
</div> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<div class="control-group"> | ||
<div class="controls"> | ||
<button type="submit" class="btn btn-primary">Pair!</button> | ||
<span class="help-inline"> | ||
Or <a ng-href="{{get_key}}">Get new key</a> | ||
</span> | ||
</div> | ||
|
||
</div> | ||
</fieldset> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<div id="setup-modal"> | ||
<div id="setup-dialog" class="container"> | ||
<div class="hero-unit"> | ||
|
||
<h1>Congratulations! Your API traffic monitor is up and running.</h1> | ||
|
||
|
||
<h2>What's next?</h2> | ||
|
||
<ul> | ||
<li>Pair your traffic monitor with your APItools account. <a | ||
href="https://docs.apitools.com/docs/on-premise/">Learn more</a> | ||
</li> | ||
<li>Learn more about different ways of installation, DNS configuration <a | ||
href="https://docs.apitools.com/docs/on-premise/">Learn more</a> | ||
</li> | ||
<li>Get familiar with APItools taking our tour. <a | ||
href="https://docs.apitools.com/docs/tour/">Learn more</a> | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
<form id="setup-form" name='setup_form' ng-submit="saveSetup()"> | ||
<fieldset ng-class="{error: form.name.$invalid}"> | ||
<legend>Anonymously report usage</legend> | ||
<label class="checkbox" for="report_usage"> | ||
|
||
<input id="report_usage" type="checkbox" name="report_usage" | ||
ng-model="setup.report_usage"> | ||
Send report</label> | ||
|
||
<p class="help-block"> | ||
You can run your APItools monitor completely standalone if you don't choose to pair it with the cloud service. | ||
However, if you're willing the you can help us out by reporting anonymized traffic stats. | ||
This will allow us to do performance analysis of various APIs, predict performance issues | ||
or just tell you if it is broken just for you or everyone else.</p> | ||
<p class="help-block"> | ||
Read our <a href="https://docs.apitools.com/legal/terms-and-conditions/" target="_blank">Terms and Conditions</a> | ||
and <a href="https://docs.apitools.com/legal/privacy-policy/" target="_blank">Privacy Policy</a> | ||
to learn more about how we handle these data.<br/> | ||
By running APItools Traffic Monitor you accept these Terms and Conditions and Privacy Policy. | ||
</p> | ||
|
||
<button type="submit" class="btn btn-primary btn-large">Save</button> | ||
</fieldset> | ||
</form> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'spec_helper' | ||
|
||
describe "Brain" do | ||
|
||
let(:host) { "http://localhost:7071" } | ||
|
||
describe "POST /api/brain/register" do | ||
it "registers into the brain with the uuid" do | ||
expect(post_json("#{host}/api/brain/register")).to be | ||
end | ||
end | ||
|
||
describe "POST /api/brain/link" do | ||
it "registers into the brain with the uuid" do | ||
expect(post_json("#{host}/api/brain/link", body: {key: 'a key'}.to_json)).to be | ||
expect(post_json("#{host}/api/config", body: "{}")).to include('link_key' => 'a key') | ||
end | ||
end | ||
|
||
describe "POST /api/brain/unlink" do | ||
it "registers into the brain with the uuid" do | ||
expect(post_json("#{host}/api/brain/register")).to be | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"oauth_access_token": "123", "name": "simba", "uuid": "uuid", "link_key": "link_key", "_id": 1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"oauth_access_token": "123", "name": "simba", "_id": 1} | ||
{"oauth_access_token": "123", "name": "simba", "uuid": "uuid", "_id": 1} |
Oops, something went wrong.