mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
New Registration process and Phone Home Feature
- Added new registration flow and 7 day trial for developers - Added new registration flow for licensees - Added "Development Trial" and "Development Mode" label - Added Registration tab in dashboard configuration - Store settings centrally in Elasticserch for installation wide registration and reporting. - Closes #213 - Closes #216 - Closes #234
This commit is contained in:
parent
72a23f2ef8
commit
863ea84c41
37 changed files with 1575 additions and 167 deletions
|
@ -20,8 +20,8 @@ module.exports = function (grunt) {
|
|||
dist: 'UA-12395217-5'
|
||||
},
|
||||
statsReportUrl: {
|
||||
dev: '"http://" + window.location.hostname + ":'+ (grunt.option('es_port') || 9200) +'/.marvel_cluster_report/report"',
|
||||
dist: '"https://marvel-stats.elasticsearch.com/"'
|
||||
dev: 'http://'+(grunt.option('host') || 'localhost')+':'+ (grunt.option('es_port') || 9200) +'/.marvel_cluster_report/report',
|
||||
dist: 'https://marvel-stats.elasticsearch.com/'
|
||||
},
|
||||
kibanaPort: grunt.option('port') || 5601,
|
||||
kibanaHost: grunt.option('host') ||'localhost'
|
||||
|
|
235
common/PhoneHome.js
Normal file
235
common/PhoneHome.js
Normal file
|
@ -0,0 +1,235 @@
|
|||
define(function (require) {
|
||||
'use strict';
|
||||
|
||||
var statsReportURL = '@@stats_report_url';
|
||||
var _ = require('lodash');
|
||||
var $ = require("jquery");
|
||||
|
||||
function PhoneHome (options) {
|
||||
this._id = options._id || 'marvelOpts';
|
||||
this._type = options._type || 'appdata';
|
||||
this.client = options.client || $;
|
||||
this.baseUrl = options.baseUrl;
|
||||
this.index = options.index;
|
||||
// set defaults
|
||||
this.attributes = {
|
||||
report: true,
|
||||
purchased: false
|
||||
};
|
||||
this.events = {};
|
||||
this.currentBaseUrl = this.baseUrl;
|
||||
|
||||
this.fieldsToES= [
|
||||
'registrationData',
|
||||
'purchased',
|
||||
'registered',
|
||||
'version',
|
||||
'report'
|
||||
];
|
||||
|
||||
this.fieldsToBrowser = [
|
||||
'trialTimestamp',
|
||||
'lastReport',
|
||||
'registrationSent',
|
||||
'report'
|
||||
];
|
||||
|
||||
var self = this;
|
||||
this.on('change:data', function (data) {
|
||||
self.sendIfDue(data);
|
||||
self.checkAndSendRegistrationData();
|
||||
});
|
||||
}
|
||||
|
||||
PhoneHome.prototype = {
|
||||
|
||||
on: function (id, cb) {
|
||||
if (!_.isArray(this.events[id])) {
|
||||
this.events[id] = [];
|
||||
}
|
||||
this.events[id].push(cb);
|
||||
},
|
||||
|
||||
clear: function (id) {
|
||||
delete this.events[id];
|
||||
},
|
||||
|
||||
trigger: function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var id = args.shift();
|
||||
if (this.events[id]) {
|
||||
_.each(this.events[id], function (cb) {
|
||||
cb.apply(null, args);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
setBaseUrl: function (url) {
|
||||
this.baseUrl = url;
|
||||
},
|
||||
|
||||
set: function (key, value) {
|
||||
var self = this;
|
||||
var previous;
|
||||
if (typeof(key) === 'object') {
|
||||
previous = _.pick(this.attributes, _.keys(key));
|
||||
this.attributes = _.assign(this.attributes, key);
|
||||
_.each(key, function (value, name) {
|
||||
self.trigger('change:'+name, value, previous[name]);
|
||||
});
|
||||
} else {
|
||||
previous = this.attributes[key];
|
||||
this.attributes[key] = value;
|
||||
this.trigger('change:'+key, value, previous);
|
||||
}
|
||||
},
|
||||
|
||||
get: function (key) {
|
||||
if (_.isUndefined(key)) {
|
||||
return this.attributes;
|
||||
} else {
|
||||
return this.attributes[key];
|
||||
}
|
||||
},
|
||||
|
||||
setTrialTimestamp: function (timestamp) {
|
||||
this.set('trialTimestamp', timestamp);
|
||||
this.saveToBrowser();
|
||||
},
|
||||
|
||||
saveToES: function () {
|
||||
var data = _.pick(this.attributes, this.fieldsToES);
|
||||
var url = this.baseUrl+'/'+this.index+'/'+this._type+'/'+this._id;
|
||||
return this.client.put(url, data);
|
||||
},
|
||||
|
||||
saveToBrowser: function () {
|
||||
var data = _.pick(this.attributes, this.fieldsToBrowser);
|
||||
localStorage.setItem(this._id, JSON.stringify(data));
|
||||
},
|
||||
|
||||
saveAll: function () {
|
||||
this.saveToBrowser();
|
||||
return this.saveToES();
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
var url = this.baseUrl+'/'+this.index+'/'+this._type+'/'+this._id;
|
||||
localStorage.removeItem(this._id);
|
||||
return this.client.delete(url);
|
||||
},
|
||||
|
||||
checkReportStatus: function () {
|
||||
var reportInterval = 86400000;
|
||||
var sendReport = false;
|
||||
|
||||
// Check to see if the currentBaseUrl is set along with if it has changed
|
||||
// since the last time we checked.
|
||||
var urlChanged = (!_.isEmpty(this.currentBaseUrl) && (this.currentBaseUrl !== this.baseUrl));
|
||||
this.currentBaseUrl = this.baseUrl;
|
||||
|
||||
if (this.get('version') && this.get('report')) {
|
||||
// if the URL changes we need to send what we can
|
||||
if (urlChanged) {
|
||||
sendReport = true;
|
||||
}
|
||||
// If the last report is empty it means we've never sent an report and
|
||||
// now is the time to send it.
|
||||
if (!this.get('lastReport')) {
|
||||
sendReport = true;
|
||||
}
|
||||
// If it's been a day since we last sent an report, send one.
|
||||
if (new Date().getTime() - parseInt(this.get('lastReport'), 10) > reportInterval) {
|
||||
sendReport = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If we need to send a report then we need to record the last time we
|
||||
// sent it and store it
|
||||
if (sendReport) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If all else fails... don't send
|
||||
return false;
|
||||
},
|
||||
|
||||
checkRegistratonStatus: function () {
|
||||
var regTimeout = (86400000*7); // 7 days
|
||||
// Calculate if the registration is due
|
||||
var regDue = (new Date().getTime() - parseInt(this.get('trialTimestamp'), 10) > regTimeout);
|
||||
// if the user is not registers and they haven't purchased and it's been 7 days
|
||||
// since we displayed the welcome screen then force registration.
|
||||
return (!this.get('registered') && !this.get('purchased') && regDue);
|
||||
},
|
||||
|
||||
sendIfDue: function (data) {
|
||||
var self = this;
|
||||
if (this.checkReportStatus()) {
|
||||
return this.client.post(statsReportURL, data).then(function () {
|
||||
self.set('lastReport', new Date().getTime());
|
||||
self.saveToBrowser();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
register: function (data) {
|
||||
var self = this;
|
||||
this.set('registrationData', data);
|
||||
this.set('registered', true);
|
||||
self.saveToBrowser();
|
||||
return self.saveToES();
|
||||
},
|
||||
|
||||
confirmPurchase: function (data) {
|
||||
var self = this;
|
||||
this.set('registrationData', data);
|
||||
this.set('purchased', true);
|
||||
self.saveToBrowser();
|
||||
return self.saveToES();
|
||||
},
|
||||
|
||||
checkAndSendRegistrationData: function () {
|
||||
var self = this;
|
||||
var regData;
|
||||
var registrationData = this.get('registrationData');
|
||||
var data = this.get('data');
|
||||
|
||||
if (!this.get('registrationSent') && registrationData && data && data.uuid ) {
|
||||
registrationData.uuid = data.uuid;
|
||||
regData = { type: 'registration', data: registrationData };
|
||||
|
||||
if (this.get('purchased')) {
|
||||
regData.type = 'purchase_confirmation';
|
||||
}
|
||||
|
||||
return this.client.post(statsReportURL, regData).then(function () {
|
||||
self.set('registrationSent', true);
|
||||
self.saveToBrowser();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
fetch: function () {
|
||||
var data, self = this;
|
||||
|
||||
try {
|
||||
data = JSON.parse(localStorage.getItem(self._id));
|
||||
this.set(data);
|
||||
} catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
var url = this.baseUrl+'/'+this.index+'/'+this._type+'/'+this._id;
|
||||
return this.client.get(url).then(function (resp) {
|
||||
self.set(resp.data._source);
|
||||
self.saveToBrowser();
|
||||
return self.attributes;
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return PhoneHome;
|
||||
|
||||
});
|
|
@ -68,7 +68,7 @@ define(['settings'],
|
|||
'marvel.shard_allocation'
|
||||
]
|
||||
});
|
||||
s.stats_report_url = @@stats_report_url;
|
||||
s.stats_report_url = '@@stats_report_url';
|
||||
s.ga_tracking_code = '@@ga_tracking_code';
|
||||
return s;
|
||||
});
|
||||
|
|
|
@ -245,6 +245,11 @@
|
|||
}
|
||||
],
|
||||
"nav": [
|
||||
{
|
||||
"type": "marvel.registration",
|
||||
"editable": true,
|
||||
"title": "Registration"
|
||||
},
|
||||
{
|
||||
"type": "timepicker",
|
||||
"collapse": false,
|
||||
|
|
|
@ -43,6 +43,11 @@ dashboard.index = {
|
|||
dashboard.refresh="1m";
|
||||
|
||||
dashboard.nav = [
|
||||
{
|
||||
"type": "marvel.registration",
|
||||
"editable": true,
|
||||
"title": "Registration"
|
||||
},
|
||||
{
|
||||
type:'timepicker'
|
||||
},
|
||||
|
|
|
@ -43,6 +43,11 @@ dashboard.index = {
|
|||
dashboard.refresh = "1m";
|
||||
|
||||
dashboard.nav = [
|
||||
{
|
||||
"type": "marvel.registration",
|
||||
"editable": true,
|
||||
"title": "Registration"
|
||||
},
|
||||
{
|
||||
type:'timepicker'
|
||||
},
|
||||
|
|
|
@ -374,6 +374,11 @@
|
|||
}
|
||||
],
|
||||
"nav": [
|
||||
{
|
||||
"type": "marvel.registration",
|
||||
"editable": true,
|
||||
"title": "Registration"
|
||||
},
|
||||
{
|
||||
"type": "timepicker",
|
||||
"collapse": false,
|
||||
|
|
|
@ -98,6 +98,11 @@
|
|||
}
|
||||
],
|
||||
"nav": [
|
||||
{
|
||||
"type": "marvel.registration",
|
||||
"editable": true,
|
||||
"title": "Registration"
|
||||
},
|
||||
{
|
||||
"type": "timepicker",
|
||||
"collapse": false,
|
||||
|
|
|
@ -1266,6 +1266,11 @@
|
|||
}
|
||||
],
|
||||
"nav": [
|
||||
{
|
||||
"type": "marvel.registration",
|
||||
"editable": true,
|
||||
"title": "Registration"
|
||||
},
|
||||
{
|
||||
"type": "timepicker",
|
||||
"collapse": false,
|
||||
|
|
|
@ -1,30 +1,4 @@
|
|||
|
||||
<div ng-show="!_.isUndefined(panel.optin)" >
|
||||
<div class="editor-row">
|
||||
|
||||
<h4>Cluster statistics</h4>
|
||||
|
||||
Help improve Elasticsearch by reporting <strong>anonymous</strong>
|
||||
cluster statistics, including information about the size and performance of your cluster.
|
||||
Data is sent once daily and is under 1 kilobyte. To
|
||||
see a sample report click <span class="link" ng-click="showSample=true">here</span>. The data will only
|
||||
be used by Elasticsearch and will never be transmitted to a third party.
|
||||
</div>
|
||||
<br>
|
||||
<div class="editor-row">
|
||||
<div class="section">
|
||||
<div class="editor-option">
|
||||
<label class="small">Send statistics<tip>Help make Elasticsearch better by sharing anonymous usage data.</tip></label>
|
||||
<input type="checkbox" ng-model="marvelOpts.report"/>
|
||||
</div>
|
||||
<div ng-show="kbnVersion == '@REV@'" class="editor-option">
|
||||
<label class="small">Clear marvelOpts <tip>Only shown in unbuilt versions, clear stored optin and version data</tip></label>
|
||||
<button class="btn btn-danger" ng-click="clearMarvelStorage()">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-show="showSample">
|
||||
<h4>Sample Statistics</h4>
|
||||
<pre>{{ data | json }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -14,18 +14,17 @@ define([
|
|||
'app',
|
||||
'kbn',
|
||||
'lodash',
|
||||
'../../../../../common/analytics',
|
||||
'factories/store',
|
||||
'services/marvel/index'
|
||||
],
|
||||
function (angular, app, kbn, _, ga) {
|
||||
function (angular, app, kbn, _) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('kibana.panels.marvel.cluster', ['marvel.services']);
|
||||
app.useModule(module);
|
||||
|
||||
module.controller('marvel.cluster', function ($scope, $modal, $q, $http, $clusterState, dashboard, filterSrv,
|
||||
kbnVersion, storeFactory, cacheBust) {
|
||||
kbnVersion, cacheBust, $phoneHome) {
|
||||
$scope.panelMeta = {
|
||||
modals: [],
|
||||
editorTabs: [],
|
||||
|
@ -39,23 +38,9 @@ define([
|
|||
};
|
||||
_.defaults($scope.panel, _d);
|
||||
|
||||
var reportInterval = 86400000;
|
||||
|
||||
// setup the optIn and version values
|
||||
var marvelOpts = storeFactory($scope, 'marvelOpts', {
|
||||
report: true,
|
||||
version: void 0,
|
||||
lastReport: void 0
|
||||
});
|
||||
|
||||
$scope.init = function () {
|
||||
$scope.kbnVersion = kbnVersion;
|
||||
|
||||
// If the user hasn't opted in or out, ask them to.
|
||||
if (marvelOpts.version == null || marvelOpts.version !== kbnVersion) {
|
||||
$scope.optInModal();
|
||||
}
|
||||
|
||||
$scope.$on('refresh', function () {
|
||||
$scope.get_data();
|
||||
});
|
||||
|
@ -111,9 +96,7 @@ define([
|
|||
|
||||
$scope.data = _.isArray(results.hits.hits) ? results.hits.hits[0]._source : undefined;
|
||||
|
||||
if (checkReport()) {
|
||||
sendReport($scope.data);
|
||||
}
|
||||
$phoneHome.set('data', $scope.data);
|
||||
|
||||
// Did we find anything in that index? No? Try the next one.
|
||||
if (_.isUndefined($scope.data) && _segment + 1 < dashboard.indices.length) {
|
||||
|
@ -140,53 +123,6 @@ define([
|
|||
$scope.inspector = angular.toJson(JSON.parse(request.toString()), true);
|
||||
};
|
||||
|
||||
$scope.setOptIn = function (val) {
|
||||
marvelOpts.version = kbnVersion;
|
||||
marvelOpts.report = val;
|
||||
if (val) {
|
||||
ga.pageview();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.clearMarvelStorage = function () {
|
||||
marvelOpts.report = void 0;
|
||||
marvelOpts.version = void 0;
|
||||
marvelOpts.lastReport = void 0;
|
||||
};
|
||||
|
||||
$scope.optInModal = function () {
|
||||
var panelModal = $modal({
|
||||
template: './app/panels/marvel/cluster/optin.html?' + cacheBust,
|
||||
persist: true,
|
||||
backdrop: 'static',
|
||||
show: false,
|
||||
scope: $scope,
|
||||
keyboard: false
|
||||
});
|
||||
|
||||
// and show it
|
||||
$q.when(panelModal).then(function (modalEl) {
|
||||
modalEl.modal('show');
|
||||
});
|
||||
};
|
||||
|
||||
// Checks if we should send a report
|
||||
var checkReport = function () {
|
||||
if (marvelOpts.version && marvelOpts.report) {
|
||||
if (marvelOpts.lastReport == null) {
|
||||
return true;
|
||||
}
|
||||
else if (new Date().getTime() - parseInt(marvelOpts.lastReport, 10) > reportInterval) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.updateHealthStatusData = function () {
|
||||
$scope.healthStatusData = {
|
||||
|
@ -195,22 +131,6 @@ define([
|
|||
};
|
||||
};
|
||||
|
||||
var sendReport = function (data) {
|
||||
if (!$scope.config.stats_report_url) {
|
||||
return;
|
||||
}
|
||||
|
||||
var thisReport = new Date().getTime().toString();
|
||||
|
||||
// TODO: Replace this URL with the actual data sink
|
||||
$http.post(
|
||||
$scope.config.stats_report_url,
|
||||
data
|
||||
).success(function () {
|
||||
marvelOpts.lastReport = thisReport;
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
module.filter('formatBytes', function () {
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<div class="modal-body" style="text-align: center;">
|
||||
<h2>Try Marvel for Free in Development</h2>
|
||||
<p class="lead">Like it? Then <a href="http://www.elasticsearch.com/_redirect/marvel/buynow" target="_BLANK">buy a license</a> for production, only $500 for your first 5 nodes.<br/>
|
||||
…or talk to us about our <a href="http://www.elasticsearch.com/_redirect/support" target="_BLANK">annual support packages</a> that include Marvel for free.</p>
|
||||
<p>
|
||||
<a href="http://www.elasticsearch.com/_redirect/marvel/buynow" target="_BLANK" class="btn btn-success">Buy Marvel Now</a>
|
||||
<a class="btn btn-success" ng-click="setOptIn(marvelOpts.report);dismiss();">Already Have a License</a>
|
||||
<a class="btn btn-success" ng-click="setOptIn(marvelOpts.report);dismiss();">Continue Free Trial</a>
|
||||
</p>
|
||||
<p>Sharing your cluster statistics with us to help us improve. Totally anonymous and never shared with <br/>
|
||||
anyone. Not ever. Curious what we see? <a ng-click="showSample=true">View report here</a>. <span ng-show="marvelOpts.report">Not interested? <a ng-click="setOptIn(false);">Opt out here</a></span><span ng-hide="marvelOpts.report">Opted Out? <a ng-click="setOptIn(true);">Click here to opt back in.</a></span></p>
|
||||
<div ng-show="showSample" style="text-align: left;">
|
||||
<h5>Sample Statistics</h5>
|
||||
<span class="close" ng-click="showSample=false" style="margin: 10px 10px; font-size: 30px;">×</span>
|
||||
<pre>{{ data | json }}</pre>
|
||||
</div>
|
||||
</div>
|
|
@ -18,7 +18,6 @@ define(function (require) {
|
|||
var app = require('app');
|
||||
var $ = require('jquery');
|
||||
var _ = require('lodash');
|
||||
var ga = require('../../../../../common/analytics');
|
||||
|
||||
var loadDashboards = require('./lib/loadDashboards');
|
||||
var extractIds = require('./lib/extractIds');
|
||||
|
@ -33,15 +32,12 @@ define(function (require) {
|
|||
var module = angular.module('kibana.panels.marvel.navigation', []);
|
||||
app.useModule(module);
|
||||
|
||||
module.controller('marvel.navigation', function($scope, $http, storeFactory, $q, dashboard, $location, $routeParams) {
|
||||
module.controller('marvel.navigation', function($scope, $http, $q, dashboard, $location, $routeParams) {
|
||||
$scope.panelMeta = {
|
||||
status : "Stable",
|
||||
description : "A simple dropdown panel with a list of links"
|
||||
};
|
||||
|
||||
// Check to see if the user is opted in to reporting
|
||||
var marvelOpts = storeFactory($scope, 'marvelOpts');
|
||||
|
||||
// Set and populate defaults
|
||||
var _d = {
|
||||
/** @scratch /panels/marvel.navigation/5
|
||||
|
@ -84,10 +80,6 @@ define(function (require) {
|
|||
$scope.links = $scope.panel.links;
|
||||
}
|
||||
|
||||
if (marvelOpts.version && marvelOpts.report) {
|
||||
ga.pageview();
|
||||
}
|
||||
|
||||
if($scope.panel.source === 'url') {
|
||||
|
||||
$http.get($scope.panel.url).then(function (response) {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<style type="text/css">
|
||||
.marvel-confirmation-form .span3 {
|
||||
text-align: left;
|
||||
}
|
||||
.marvel-confirmation-form .span6 {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.marvel-confirmation-form .note {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
<div class="marvel-confirmation-form modal-body" style="text-align: center">
|
||||
<h2>Thank You For Purchasing Marvel!</h2>
|
||||
<p>Please enter the purchase details below.</p>
|
||||
<form name="confirmationForm" ng-submit="confirmPurchase();dismiss();">
|
||||
<div class="row-fluid">
|
||||
<div class="span3 offset3">
|
||||
<label>First Name</label>
|
||||
<input ng-model="registration.first_name" required="true" type="text" class="span12" />
|
||||
</div>
|
||||
<div class="span3">
|
||||
<label>Last Name</label>
|
||||
<input ng-model="registration.last_name" required="true" type="text" class="span12" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span6 offset3">
|
||||
<label>Company Name</label>
|
||||
<input ng-model="registration.company" required="true" type="text" class="span12" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span6 offset3">
|
||||
<label>Order Number or Support Quote Reference<br><span class="note">This can be found either on your signed order form or the order confirmation email.</span></label>
|
||||
<input ng-model="registration.order_number" required="true" type="text" ng-pattern="/^(\d\d\d\d|Q-\S\S\S\S\S\S\S)$/" class="span12" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12 form-actions" style="text-align: center;">
|
||||
<button class="btn btn-success" ng-disabled="confirmationForm.$invalid">Send Confirmation</button> <a class="btn" ng-click="options.showConfirmation = false">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
|
@ -0,0 +1,23 @@
|
|||
define(function (require) {
|
||||
'use strict';
|
||||
var angular = require('angular');
|
||||
var app = require('app');
|
||||
|
||||
var module = angular.module('marvel.directives.registration.purchaseConfirmation', []);
|
||||
app.useModule(module);
|
||||
|
||||
module.directive('purchaseConfirmation', function () {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
registration: '=',
|
||||
options: '=',
|
||||
confirmPurchase: '=',
|
||||
dismiss: '='
|
||||
},
|
||||
templateUrl: './app/panels/marvel/registration/directives/purchase_confirmation.html'
|
||||
};
|
||||
});
|
||||
|
||||
return module;
|
||||
});
|
297
kibana/panels/registration/directives/registration.html
Normal file
297
kibana/panels/registration/directives/registration.html
Normal file
|
@ -0,0 +1,297 @@
|
|||
<style type="text/css">
|
||||
.marvel-registration-form .span3 {
|
||||
text-align: left;
|
||||
}
|
||||
.marvel-registration-form .span4, .marvel-registration-form .span2 {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<div class="marvel-registration-form modal-body" style="text-align: center;">
|
||||
<h2>Please Register</h2>
|
||||
<p class="lead">To continue using the development version of Marvel you will need to register.</p>
|
||||
<form name="registrationForm" ng-submit="register();dismiss();">
|
||||
<div class="row-fluid">
|
||||
<div class="span2 offset2">
|
||||
<label>First Name *</label>
|
||||
<input ng-model="registration.first_name" required="true" type="text" class="span12"/>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<label>Last Name *</label>
|
||||
<input ng-model="registration.last_name" required="true" type="text" class="span12"/>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<label>Email *</label>
|
||||
<input ng-model="registration.email" required="true" type="email" class="span12"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span4 offset2">
|
||||
<label>Company *</label>
|
||||
<input ng-model="registration.company" required="true" type="text" class="span12"/>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<label>Phone</label>
|
||||
<input ng-model="registration.phone" type="text" class="span12"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span4 offset2">
|
||||
<label>Country *</label>
|
||||
<select ng-model="registration.country" required="true">
|
||||
<option value="">--Please Select--</option>
|
||||
<option value="AF">Afghanistan</option>
|
||||
<option value="AL">Albania</option>
|
||||
<option value="DZ">Algeria</option>
|
||||
<option value="AS">American Samoa</option>
|
||||
<option value="AD">Andorra</option>
|
||||
<option value="AO">Angola</option>
|
||||
<option value="AI">Anguilla</option>
|
||||
<option value="AQ">Antarctica</option>
|
||||
<option value="AG">Antigua and Barbuda</option>
|
||||
<option value="AR">Argentina</option>
|
||||
<option value="AM">Armenia</option>
|
||||
<option value="AW">Aruba</option>
|
||||
<option value="AU">Australia</option>
|
||||
<option value="AT">Austria</option>
|
||||
<option value="AZ">Azerbaijan</option>
|
||||
<option value="BS">Bahamas</option>
|
||||
<option value="BH">Bahrain</option>
|
||||
<option value="BD">Bangladesh</option>
|
||||
<option value="BB">Barbados</option>
|
||||
<option value="BY">Belarus</option>
|
||||
<option value="BE">Belgium</option>
|
||||
<option value="BZ">Belize</option>
|
||||
<option value="BJ">Benin</option>
|
||||
<option value="BM">Bermuda</option>
|
||||
<option value="BT">Bhutan</option>
|
||||
<option value="BO">Bolivia</option>
|
||||
<option value="BA">Bosnia and Herzegovina</option>
|
||||
<option value="BW">Botswana</option>
|
||||
<option value="BV">Bouvet Island</option>
|
||||
<option value="BR">Brazil</option>
|
||||
<option value="IO">British Indian Ocean Territory</option>
|
||||
<option value="BN">Brunei Darussalam</option>
|
||||
<option value="BG">Bulgaria</option>
|
||||
<option value="BF">Burkina Faso</option>
|
||||
<option value="BI">Burundi</option>
|
||||
<option value="KH">Cambodia</option>
|
||||
<option value="CM">Cameroon</option>
|
||||
<option value="CA">Canada</option>
|
||||
<option value="CV">Cape Verde</option>
|
||||
<option value="KY">Cayman Islands</option>
|
||||
<option value="CF">Central African Republic</option>
|
||||
<option value="TD">Chad</option>
|
||||
<option value="CL">Chile</option>
|
||||
<option value="CN">China</option>
|
||||
<option value="CX">Christmas Island</option>
|
||||
<option value="CC">Cocos (Keeling) Islands</option>
|
||||
<option value="CO">Colombia</option>
|
||||
<option value="KM">Comoros</option>
|
||||
<option value="CG">Congo</option>
|
||||
<option value="CD">Congo, the Democratic Republic of the</option>
|
||||
<option value="CK">Cook Islands</option>
|
||||
<option value="CR">Costa Rica</option>
|
||||
<option value="CI">Cote D'Ivoire</option>
|
||||
<option value="HR">Croatia</option>
|
||||
<option value="CU">Cuba</option>
|
||||
<option value="CY">Cyprus</option>
|
||||
<option value="CZ">Czech Republic</option>
|
||||
<option value="DK">Denmark</option>
|
||||
<option value="DJ">Djibouti</option>
|
||||
<option value="DM">Dominica</option>
|
||||
<option value="DO">Dominican Republic</option>
|
||||
<option value="EC">Ecuador</option>
|
||||
<option value="EG">Egypt</option>
|
||||
<option value="SV">El Salvador</option>
|
||||
<option value="GQ">Equatorial Guinea</option>
|
||||
<option value="ER">Eritrea</option>
|
||||
<option value="EE">Estonia</option>
|
||||
<option value="ET">Ethiopia</option>
|
||||
<option value="FK">Falkland Islands (Malvinas)</option>
|
||||
<option value="FO">Faroe Islands</option>
|
||||
<option value="FJ">Fiji</option>
|
||||
<option value="FI">Finland</option>
|
||||
<option value="FR">France</option>
|
||||
<option value="GF">French Guiana</option>
|
||||
<option value="PF">French Polynesia</option>
|
||||
<option value="TF">French Southern Territories</option>
|
||||
<option value="GA">Gabon</option>
|
||||
<option value="GM">Gambia</option>
|
||||
<option value="GE">Georgia</option>
|
||||
<option value="DE">Germany</option>
|
||||
<option value="GH">Ghana</option>
|
||||
<option value="GI">Gibraltar</option>
|
||||
<option value="GR">Greece</option>
|
||||
<option value="GL">Greenland</option>
|
||||
<option value="GD">Grenada</option>
|
||||
<option value="GP">Guadeloupe</option>
|
||||
<option value="GU">Guam</option>
|
||||
<option value="GT">Guatemala</option>
|
||||
<option value="GN">Guinea</option>
|
||||
<option value="GW">Guinea-Bissau</option>
|
||||
<option value="GY">Guyana</option>
|
||||
<option value="HT">Haiti</option>
|
||||
<option value="HM">Heard Island and Mcdonald Islands</option>
|
||||
<option value="VA">Holy See (Vatican City State)</option>
|
||||
<option value="HN">Honduras</option>
|
||||
<option value="HK">Hong Kong</option>
|
||||
<option value="HU">Hungary</option>
|
||||
<option value="IS">Iceland</option>
|
||||
<option value="IN">India</option>
|
||||
<option value="ID">Indonesia</option>
|
||||
<option value="IR">Iran, Islamic Republic of</option>
|
||||
<option value="IQ">Iraq</option>
|
||||
<option value="IE">Ireland</option>
|
||||
<option value="IL">Israel</option>
|
||||
<option value="IT">Italy</option>
|
||||
<option value="JM">Jamaica</option>
|
||||
<option value="JP">Japan</option>
|
||||
<option value="JO">Jordan</option>
|
||||
<option value="KZ">Kazakhstan</option>
|
||||
<option value="KE">Kenya</option>
|
||||
<option value="KI">Kiribati</option>
|
||||
<option value="KP">Korea, Democratic People's Republic of</option>
|
||||
<option value="KR">Korea, Republic of</option>
|
||||
<option value="KW">Kuwait</option>
|
||||
<option value="KG">Kyrgyzstan</option>
|
||||
<option value="LA">Lao People's Democratic Republic</option>
|
||||
<option value="LV">Latvia</option>
|
||||
<option value="LB">Lebanon</option>
|
||||
<option value="LS">Lesotho</option>
|
||||
<option value="LR">Liberia</option>
|
||||
<option value="LY">Libyan Arab Jamahiriya</option>
|
||||
<option value="LI">Liechtenstein</option>
|
||||
<option value="LT">Lithuania</option>
|
||||
<option value="LU">Luxembourg</option>
|
||||
<option value="MO">Macao</option>
|
||||
<option value="MK">Macedonia, the Former Yugoslav Republic of</option>
|
||||
<option value="MG">Madagascar</option>
|
||||
<option value="MW">Malawi</option>
|
||||
<option value="MY">Malaysia</option>
|
||||
<option value="MV">Maldives</option>
|
||||
<option value="ML">Mali</option>
|
||||
<option value="MT">Malta</option>
|
||||
<option value="MH">Marshall Islands</option>
|
||||
<option value="MQ">Martinique</option>
|
||||
<option value="MR">Mauritania</option>
|
||||
<option value="MU">Mauritius</option>
|
||||
<option value="YT">Mayotte</option>
|
||||
<option value="MX">Mexico</option>
|
||||
<option value="FM">Micronesia, Federated States of</option>
|
||||
<option value="MD">Moldova, Republic of</option>
|
||||
<option value="MC">Monaco</option>
|
||||
<option value="MN">Mongolia</option>
|
||||
<option value="ME">Montenegro</option>
|
||||
<option value="MS">Montserrat</option>
|
||||
<option value="MA">Morocco</option>
|
||||
<option value="MZ">Mozambique</option>
|
||||
<option value="MM">Myanmar</option>
|
||||
<option value="NA">Namibia</option>
|
||||
<option value="NR">Nauru</option>
|
||||
<option value="NP">Nepal</option>
|
||||
<option value="NL">Netherlands</option>
|
||||
<option value="AN">Netherlands Antilles</option>
|
||||
<option value="NC">New Caledonia</option>
|
||||
<option value="NZ">New Zealand</option>
|
||||
<option value="NI">Nicaragua</option>
|
||||
<option value="NE">Niger</option>
|
||||
<option value="NG">Nigeria</option>
|
||||
<option value="NU">Niue</option>
|
||||
<option value="NF">Norfolk Island</option>
|
||||
<option value="MP">Northern Mariana Islands</option>
|
||||
<option value="NO">Norway</option>
|
||||
<option value="OM">Oman</option>
|
||||
<option value="PK">Pakistan</option>
|
||||
<option value="PW">Palau</option>
|
||||
<option value="PS">Palestinian Territory, Occupied</option>
|
||||
<option value="PA">Panama</option>
|
||||
<option value="PG">Papua New Guinea</option>
|
||||
<option value="PY">Paraguay</option>
|
||||
<option value="PE">Peru</option>
|
||||
<option value="PH">Philippines</option>
|
||||
<option value="PN">Pitcairn</option>
|
||||
<option value="PL">Poland</option>
|
||||
<option value="PT">Portugal</option>
|
||||
<option value="PR">Puerto Rico</option>
|
||||
<option value="QA">Qatar</option>
|
||||
<option value="RE">Reunion</option>
|
||||
<option value="RO">Romania</option>
|
||||
<option value="RU">Russian Federation</option>
|
||||
<option value="RW">Rwanda</option>
|
||||
<option value="SH">Saint Helena</option>
|
||||
<option value="KN">Saint Kitts and Nevis</option>
|
||||
<option value="LC">Saint Lucia</option>
|
||||
<option value="PM">Saint Pierre and Miquelon</option>
|
||||
<option value="VC">Saint Vincent and the Grenadines</option>
|
||||
<option value="WS">Samoa</option>
|
||||
<option value="SM">San Marino</option>
|
||||
<option value="ST">Sao Tome and Principe</option>
|
||||
<option value="SA">Saudi Arabia</option>
|
||||
<option value="SN">Senegal</option>
|
||||
<option value="RS">Serbia</option>
|
||||
<option value="SC">Seychelles</option>
|
||||
<option value="SL">Sierra Leone</option>
|
||||
<option value="SG">Singapore</option>
|
||||
<option value="SK">Slovakia</option>
|
||||
<option value="SI">Slovenia</option>
|
||||
<option value="SB">Solomon Islands</option>
|
||||
<option value="SO">Somalia</option>
|
||||
<option value="ZA">South Africa</option>
|
||||
<option value="GS">South Georgia and the South Sandwich Islands</option>
|
||||
<option value="ES">Spain</option>
|
||||
<option value="LK">Sri Lanka</option>
|
||||
<option value="SD">Sudan</option>
|
||||
<option value="SR">Suriname</option>
|
||||
<option value="SJ">Svalbard and Jan Mayen</option>
|
||||
<option value="SZ">Swaziland</option>
|
||||
<option value="SE">Sweden</option>
|
||||
<option value="CH">Switzerland</option>
|
||||
<option value="SY">Syrian Arab Republic</option>
|
||||
<option value="TW">Taiwan, Province of China</option>
|
||||
<option value="TJ">Tajikistan</option>
|
||||
<option value="TZ">Tanzania, United Republic of</option>
|
||||
<option value="TH">Thailand</option>
|
||||
<option value="TL">Timor-Leste</option>
|
||||
<option value="TG">Togo</option>
|
||||
<option value="TK">Tokelau</option>
|
||||
<option value="TO">Tonga</option>
|
||||
<option value="TT">Trinidad and Tobago</option>
|
||||
<option value="TN">Tunisia</option>
|
||||
<option value="TR">Turkey</option>
|
||||
<option value="TM">Turkmenistan</option>
|
||||
<option value="TC">Turks and Caicos Islands</option>
|
||||
<option value="TV">Tuvalu</option>
|
||||
<option value="UG">Uganda</option>
|
||||
<option value="UA">Ukraine</option>
|
||||
<option value="AE">United Arab Emirates</option>
|
||||
<option value="GB">United Kingdom</option>
|
||||
<option value="US">United States</option>
|
||||
<option value="UM">United States Minor Outlying Islands</option>
|
||||
<option value="UY">Uruguay</option>
|
||||
<option value="UZ">Uzbekistan</option>
|
||||
<option value="VU">Vanuatu</option>
|
||||
<option value="VE">Venezuela</option>
|
||||
<option value="VN">Viet Nam</option>
|
||||
<option value="VG">Virgin Islands, British</option>
|
||||
<option value="VI">Virgin Islands, U.s.</option>
|
||||
<option value="WF">Wallis and Futuna</option>
|
||||
<option value="EH">Western Sahara</option>
|
||||
<option value="YE">Yemen</option>
|
||||
<option value="ZM">Zambia</option>
|
||||
<option value="ZW">Zimbabwe</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<label>State/Province</label>
|
||||
<input ng-model="registration.state" type="text" class="span12"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12 form-actions">
|
||||
<button class="btn btn-success" ng-disabled="registrationForm.$invalid">Send Registration</button> <a class="btn" ng-click="registerLater();dismiss()">Register Later</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
25
kibana/panels/registration/directives/registration.js
Normal file
25
kibana/panels/registration/directives/registration.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
define(function (require) {
|
||||
'use strict';
|
||||
var angular = require('angular');
|
||||
var app = require('app');
|
||||
|
||||
var module = angular.module('marvel.directives.registration.registration', []);
|
||||
app.useModule(module);
|
||||
|
||||
module.directive('registration', function () {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
registration: '=',
|
||||
options: '=',
|
||||
register: '=',
|
||||
registerLater: '=',
|
||||
dismiss: '='
|
||||
},
|
||||
templateUrl: './app/panels/marvel/registration/directives/registration.html'
|
||||
};
|
||||
});
|
||||
|
||||
return module;
|
||||
});
|
||||
|
41
kibana/panels/registration/editor.html
Normal file
41
kibana/panels/registration/editor.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
<style type="text/css" media="screen">
|
||||
em { color: #666; }
|
||||
.optout { font-size: 11px; padding-top: 10px; }
|
||||
</style>
|
||||
<div ng-controller="marvel.registration.editor" ng-init="init()">
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
<h4>License</h4>
|
||||
<div ng-if="purchased && registration">
|
||||
<p>Thank You for Purchasing Marvel!</p>
|
||||
<div>License: <strong>Production</strong></div>
|
||||
<div>Name: <strong>{{ registration.first_name }} {{ registration.last_name }}</strong></div>
|
||||
<div>Company: <strong>{{ registration.company }}</strong></div>
|
||||
</div>
|
||||
<div ng-if="registered && registration">
|
||||
<p>Marvel is Free for Development Use. <br>
|
||||
Like it? Then <a href="http://www.elasticsearch.com/_redirect/marvel/buynow" target="_BLANK">buy a license</a> for production.<p>
|
||||
<div>License <strong>Development</strong></div>
|
||||
<div>Name: <strong>{{ registration.first_name }} {{ registration.last_name }}</strong></div>
|
||||
<div>Email: <strong>{{ registration.email}}</strong></div>
|
||||
<div ng-if="registration.phone">Phone: <strong>{{ registration.phone}}</strong></div>
|
||||
<div ng-if="registration.company">Company: <strong>{{ registration.company }}</strong></div>
|
||||
<div ng-if="registration.state">State: <strong>{{ registration.state}}</strong></div>
|
||||
<div>Country: <strong>{{ registration.country}}</strong></div>
|
||||
</div>
|
||||
<div ng-if="!registration">
|
||||
<p>Marvel is Free for Development Use. <br>
|
||||
Like it? Then <a href="http://www.elasticsearch.com/_redirect/marvel/buynow" target="_BLANK">buy a license</a> for production.<p>
|
||||
<div>License: <strong>Development Trial</strong></div>
|
||||
<em>This product not registered.</em>
|
||||
</div>
|
||||
<div class="optout"><input type="checkbox" ng-model="report" /> Send usage data</div>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<div ng-show="kbnVersion == '@REV@'" class="editor-option">
|
||||
<label class="small">Clear marvelOpts <tip>Only shown in unbuilt versions, clear stored opt-in and version data</tip></label>
|
||||
<button class="btn btn-danger" ng-click="clearMarvelStorage()">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
26
kibana/panels/registration/module.html
Normal file
26
kibana/panels/registration/module.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<style type="text/css">
|
||||
.marvel-registration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.marvel-registration.show {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.marvel-registration > .nav > li {
|
||||
padding: 18px 3px;
|
||||
}
|
||||
.marvel-registration > .nav > li > .label {
|
||||
padding: 4px 10px;
|
||||
font-weight: normal;
|
||||
}
|
||||
</style>
|
||||
<div ng-class="{ show: (purchased != null && !purchased) }" class="marvel-registration" ng-controller='marvel.registration' ng-init="init()">
|
||||
<ul class="nav" style="margin: 0">
|
||||
<li>
|
||||
<div ng-show="!registered" class="label label-warning" ng-click="optInModal()">Development Trial</div>
|
||||
<div ng-show="registered" class="label label-warning" ng-click="optInModal()">Development Mode</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
253
kibana/panels/registration/module.js
Normal file
253
kibana/panels/registration/module.js
Normal file
|
@ -0,0 +1,253 @@
|
|||
define(function (require) {
|
||||
'use strict';
|
||||
var angular = require('angular');
|
||||
var app = require('app');
|
||||
var _ = require('lodash');
|
||||
var config = require('config');
|
||||
var googleAnalytics = require('../../../../../common/analytics');
|
||||
var gracePeriod = (86400000*6);
|
||||
var trialPeriod = (86400000*6);
|
||||
|
||||
require('services/marvel/index');
|
||||
require('./directives/purchase_confirmation');
|
||||
require('./directives/registration');
|
||||
|
||||
var deps = [
|
||||
'marvel.services',
|
||||
'marvel.directives.registration.purchaseConfirmation',
|
||||
'marvel.directives.registration.registration'
|
||||
];
|
||||
|
||||
var module = angular.module('kibana.panels.marvel.registration', deps);
|
||||
app.useModule(module);
|
||||
|
||||
module.controller('marvel.registration', function ($scope, $modal, cacheBust, $q,
|
||||
$phoneHome, kbnVersion) {
|
||||
|
||||
var pageView = function () {
|
||||
if ($phoneHome.get('version') && $phoneHome.get('report')) {
|
||||
googleAnalytics.pageview();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.sysadminModal = function () {
|
||||
|
||||
$scope.options = {
|
||||
showRegistration: false,
|
||||
showConfirmation: false
|
||||
};
|
||||
|
||||
var panelModal = $modal({
|
||||
template: './app/panels/marvel/registration/sysadmin.html?' + cacheBust,
|
||||
persist: true,
|
||||
backdrop: 'static',
|
||||
show: false,
|
||||
scope: $scope,
|
||||
keyboard: false
|
||||
});
|
||||
|
||||
// and show it
|
||||
$q.when(panelModal).then(function (modalEl) {
|
||||
modalEl.modal('show');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.optInModal = function () {
|
||||
|
||||
$scope.options = {
|
||||
showRegistration: false,
|
||||
showConfirmation: false
|
||||
};
|
||||
|
||||
var panelModal = $modal({
|
||||
template: './app/panels/marvel/registration/optin.html?' + cacheBust,
|
||||
persist: true,
|
||||
backdrop: 'static',
|
||||
show: false,
|
||||
scope: $scope,
|
||||
keyboard: false
|
||||
});
|
||||
|
||||
// and show it
|
||||
$q.when(panelModal).then(function (modalEl) {
|
||||
modalEl.modal('show');
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
$scope.registerModal = function () {
|
||||
var panelModal = $modal({
|
||||
template: './app/panels/marvel/registration/register.html?' + cacheBust,
|
||||
persist: true,
|
||||
backdrop: 'static',
|
||||
show: false,
|
||||
scope: $scope,
|
||||
keyboard: false
|
||||
});
|
||||
|
||||
// and show it
|
||||
$q.when(panelModal).then(function (modalEl) {
|
||||
modalEl.modal('show');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.setOptIn = function (report, purchased) {
|
||||
$phoneHome.set({
|
||||
version: kbnVersion,
|
||||
report: report,
|
||||
purchased: purchased
|
||||
});
|
||||
$phoneHome.saveAll();
|
||||
};
|
||||
|
||||
$scope.freeTrial = function () {
|
||||
// Only set the trialTimestamp if it doesn't exist
|
||||
if (!$phoneHome.get('trialTimestamp')) {
|
||||
$phoneHome.setTrialTimestamp(new Date().getTime());
|
||||
$scope.setOptIn($scope.report, false);
|
||||
}
|
||||
// Trigger the page view.
|
||||
pageView();
|
||||
};
|
||||
|
||||
var delayTrial = function () {
|
||||
var trialTimestamp = $phoneHome.get('trialTimestamp');
|
||||
if(new Date().getTime()-trialTimestamp > trialPeriod) {
|
||||
return (new Date().getTime()) - gracePeriod;
|
||||
}
|
||||
return trialTimestamp;
|
||||
};
|
||||
|
||||
|
||||
$scope.register = function () {
|
||||
|
||||
var registration = {
|
||||
first_name: $scope.registration.first_name,
|
||||
last_name: $scope.registration.last_name,
|
||||
email: $scope.registration.email,
|
||||
company: $scope.registration.company,
|
||||
phone: $scope.registration.phone,
|
||||
country: $scope.registration.country,
|
||||
state: $scope.registration.state
|
||||
};
|
||||
|
||||
$phoneHome.register(registration).then(null, function () {
|
||||
$phoneHome.set('registered', false);
|
||||
$phoneHome.setTrialTimestamp(delayTrial());
|
||||
$scope.sysadmin = {
|
||||
data: { registered: true, version: kbnVersion, registrationData: registration, report: $phoneHome.get('report') },
|
||||
registered: true,
|
||||
host_port: config.elasticsearch
|
||||
};
|
||||
$scope.sysadminModal();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.registerLater = function () {
|
||||
// subtract 6 days so it expires tomorrow
|
||||
$phoneHome.setTrialTimestamp((new Date().getTime()) - gracePeriod);
|
||||
};
|
||||
|
||||
$scope.confirmPurchase = function () {
|
||||
// This needs to be set because when the "Already Have License" button is
|
||||
// clicked we don't have the version or report status recorded.
|
||||
$phoneHome.set({
|
||||
version: kbnVersion,
|
||||
report: $scope.report
|
||||
});
|
||||
// Trigger a page view (this is similar to $scope.freeTrial)
|
||||
pageView();
|
||||
|
||||
var registration = {
|
||||
first_name: $scope.registration.first_name,
|
||||
last_name: $scope.registration.last_name,
|
||||
company: $scope.registration.company,
|
||||
order_number: $scope.registration.order_number
|
||||
};
|
||||
|
||||
$phoneHome.confirmPurchase(registration).then(null, function () {
|
||||
$phoneHome.set('purchased', false);
|
||||
$phoneHome.setTrialTimestamp(delayTrial());
|
||||
$scope.sysadmin = {
|
||||
data: { purchased: true, version: kbnVersion, registrationData: registration, report: $phoneHome.get('report') },
|
||||
purchased: true,
|
||||
host_port: config.elasticsearch
|
||||
};
|
||||
$scope.sysadminModal();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.clearMarvelStorage = function () {
|
||||
$phoneHome.destroy();
|
||||
};
|
||||
|
||||
$phoneHome.on('change:data', function (val) {
|
||||
$scope.data = val;
|
||||
});
|
||||
|
||||
$phoneHome.on('change:report', function (val) {
|
||||
$scope.report = val;
|
||||
});
|
||||
|
||||
$phoneHome.on('change:purchased', function (val) {
|
||||
$scope.purchased = val;
|
||||
});
|
||||
|
||||
$phoneHome.on('change:registered', function (val) {
|
||||
$scope.registered = val;
|
||||
});
|
||||
|
||||
$scope.init = function () {
|
||||
$scope.kbnVersion = kbnVersion;
|
||||
$scope.options = {
|
||||
showRegistration: false,
|
||||
showConfirmation: false
|
||||
};
|
||||
|
||||
$phoneHome.fetch().always(function () {
|
||||
$scope.report = $phoneHome.get('report');
|
||||
$scope.purchased = $phoneHome.get('purchased');
|
||||
$scope.registered = $phoneHome.get('registered');
|
||||
$scope.registration = $phoneHome.get('registrationData');
|
||||
|
||||
// Trigger a page view
|
||||
pageView();
|
||||
|
||||
// If the user is registered or has purchased then we can skip the
|
||||
// rest of the checkes.
|
||||
if ($scope.registered || $scope.purchased) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_.isUndefined($phoneHome.get('trialTimestamp'))) {
|
||||
$scope.optInModal();
|
||||
} else {
|
||||
if ($phoneHome.checkRegistratonStatus()) {
|
||||
$scope.registerModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
module.controller('marvel.registration.editor', function ($scope, $phoneHome, kbnVersion) {
|
||||
$scope.$watch('report', function (val) {
|
||||
$phoneHome.set('report', val);
|
||||
$phoneHome.saveAll();
|
||||
});
|
||||
$scope.clearMarvelStorage = function () {
|
||||
$phoneHome.destroy();
|
||||
};
|
||||
$scope.init = function () {
|
||||
$scope.kbnVersion = kbnVersion;
|
||||
$phoneHome.fetch().then(function () {
|
||||
$scope.report = $phoneHome.get('report');
|
||||
$scope.purchased = $phoneHome.get('purchased');
|
||||
$scope.registered = $phoneHome.get('registered');
|
||||
$scope.registration = $phoneHome.get('registrationData');
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
});
|
25
kibana/panels/registration/optin.html
Normal file
25
kibana/panels/registration/optin.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
<div ng-show="!options.showRegistration && !options.showConfirmation" class="modal-body" style="text-align: center;">
|
||||
<h2>Try Marvel for Free in Development</h2>
|
||||
<p class="lead">Like it? Then <a href="http://www.elasticsearch.com/_redirect/marvel/buynow" target="_BLANK">buy a license</a> for production or
|
||||
talk to us about our <a href="http://www.elasticsearch.com/_redirect/support" target="_BLANK">annual support packages</a> that include Marvel. <br/>
|
||||
If you're still trying it out after a 7 day period, we ask that you register to continue using Marvel for free in development mode.</p>
|
||||
<p>
|
||||
<a href="http://www.elasticsearch.com/_redirect/marvel/buynow" target="_BLANK" class="btn btn-success">Buy Marvel Now</a>
|
||||
<a class="btn btn-success" ng-click="options.showConfirmation = true">Already Have a License</a>
|
||||
<a class="btn btn-success" ng-click="freeTrial();dismiss();">Continue Free Trial</a>
|
||||
</p>
|
||||
<p>Sharing your cluster statistics with us to help us improve. Your data is never shared with <br/>
|
||||
anyone. Not ever. Curious what we see? <a ng-click="showSample=true">View report here</a>. <span ng-show="report">Not interested? <a ng-click="setOptIn(false);">Opt out here</a></span><span ng-hide="report">Opted Out? <a ng-click="setOptIn(true);">Click here to opt back in.</a></span></p>
|
||||
<div ng-show="showSample" style="text-align: left;">
|
||||
<h5>Sample Statistics</h5>
|
||||
<span class="close" ng-click="showSample=false" style="margin: 10px 10px; font-size: 30px;">×</span>
|
||||
<pre>{{ data | json }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<purchase-confirmation
|
||||
ng-show="options.showConfirmation"
|
||||
options="options"
|
||||
registration="registration"
|
||||
dismiss="dismiss"
|
||||
confirm-purchase="confirmPurchase"></purchase-confirmation>
|
||||
|
25
kibana/panels/registration/register.html
Normal file
25
kibana/panels/registration/register.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
<div ng-show="!options.showRegistration && !options.showConfirmation" class="modal-body" style="text-align: center;">
|
||||
<h2>Marvel is for Free in Development</h2>
|
||||
<p class="lead">Like it? Then <a href="http://www.elasticsearch.com/_redirect/marvel/buynow" target="_BLANK">buy a license</a> for production or
|
||||
talk to us about our <a href="http://www.elasticsearch.com/_redirect/support" target="_BLANK">annual support packages</a> that include Marvel. <br/>
|
||||
If you're still trying it out after a 7 day period, we ask that you register to continue using Marvel for free in development mode.</p>
|
||||
<p style="padding-bottom: 20px;">
|
||||
<a href="http://www.elasticsearch.com/_redirect/marvel/buynow" target="_BLANK" class="btn btn-success">Buy Marvel Now</a>
|
||||
<a class="btn btn-success" ng-click="options.showConfirmation = true">Already Have a License</a>
|
||||
<a class="btn btn-success" ng-click="options.showRegistration = true">Continue Free Trial</a>
|
||||
</p>
|
||||
</div>
|
||||
<purchase-confirmation
|
||||
ng-show="options.showConfirmation"
|
||||
options="options"
|
||||
registration="registration"
|
||||
dismiss="dismiss"
|
||||
confirm-purchase="confirmPurchase"></purchase-confirmation>
|
||||
<registration
|
||||
ng-show="options.showRegistration"
|
||||
options="options"
|
||||
registration="registration"
|
||||
dismiss="dismiss"
|
||||
register="register"
|
||||
register-later="registerLater"
|
||||
></registration>
|
10
kibana/panels/registration/sysadmin.html
Normal file
10
kibana/panels/registration/sysadmin.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
<div class="modal-body" style="background-color: #600;">
|
||||
<h2>Oops! Unable to Write to Your Marvel Instance.</h2>
|
||||
<p>In order to complete your registration process we need to write some data to your Marvel instance. We have encountered and error while trying to write this data. Please have your administrator run the following command.</p>
|
||||
<div>
|
||||
<pre>curl -XPUT {{ sysadmin.host_port }}/.marvel-kibana/appdata/marvelOpts -d '{{ sysadmin.data | json }}'</pre>
|
||||
</div>
|
||||
<div style="text-align: right;">
|
||||
<a ng-click="dismiss();" class="btn btn-default">Close</a>
|
||||
</div>
|
||||
</div>
|
|
@ -10,6 +10,7 @@ define(function (require) {
|
|||
var refreshState = require('lib/ClusterState/refreshState');
|
||||
var explainStatus = require('lib/ClusterState/explainStatus');
|
||||
var groupIndicesByState = require('lib/ClusterState/groupIndicesByState');
|
||||
var PhoneHome = require('../../../../common/PhoneHome');
|
||||
|
||||
var module = angular.module('marvel.services', []);
|
||||
app.useModule(module);
|
||||
|
@ -44,6 +45,14 @@ define(function (require) {
|
|||
|
||||
});
|
||||
|
||||
module.factory('$phoneHome', function ($http) {
|
||||
return new PhoneHome({
|
||||
client: $http,
|
||||
baseUrl: config.elasticsearch,
|
||||
index: config.kibana_index
|
||||
});
|
||||
});
|
||||
|
||||
return module;
|
||||
|
||||
});
|
||||
|
|
|
@ -297,5 +297,6 @@ define([
|
|||
}
|
||||
|
||||
mappings.onInitComplete();
|
||||
// $(mappings).on('update', phone_home);
|
||||
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@ define([
|
|||
method = "POST";
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
var options = {
|
||||
url: path,
|
||||
data: method == "GET" ? null : data,
|
||||
password: password,
|
||||
|
@ -36,10 +36,20 @@ define([
|
|||
username: uname,
|
||||
crossDomain: true,
|
||||
type: method,
|
||||
dataType: "json",
|
||||
complete: completeCallback,
|
||||
success: successCallback
|
||||
});
|
||||
dataType: "json"
|
||||
};
|
||||
|
||||
// If we provide callback then apply those to the options otherwise
|
||||
// we assume the user will use the promise interface
|
||||
if (typeof(successCallback) === 'function') {
|
||||
options.success = successCallback;
|
||||
}
|
||||
if (typeof(completeCallback) === 'function') {
|
||||
options.complete= completeCallback;
|
||||
}
|
||||
|
||||
// return the promise that other libraries can use them
|
||||
return $.ajax(options);
|
||||
};
|
||||
|
||||
exports.constructESUrl = function (server, path) {
|
||||
|
@ -93,4 +103,4 @@ define([
|
|||
serverChangeListeners.push(cb);
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
|
|
|
@ -9,6 +9,8 @@ define([
|
|||
var per_index_types = {};
|
||||
var per_alias_indexes = [];
|
||||
|
||||
var mappingObj = {};
|
||||
|
||||
function expandAliases(indicesOrAliases) {
|
||||
// takes a list of indices or aliases or a string which may be either and returns a list of indices
|
||||
// returns a list for multiple values or a string for a single.
|
||||
|
@ -206,13 +208,13 @@ define([
|
|||
}
|
||||
|
||||
function retrieveMappingFromServer() {
|
||||
es.send("GET", "_mapping", null, function (data, status, xhr) {
|
||||
loadMappings(data);
|
||||
$.when(es.send("GET", "_mapping"), es.send("GET", "_aliases"))
|
||||
.done(function (mappings, aliases) {
|
||||
loadMappings(mappings[0]);
|
||||
loadAliases(aliases[0]);
|
||||
// Trigger an update event with the mappings and aliases
|
||||
$(mappingObj).trigger('update', [mappings[0], aliases[0]]);
|
||||
});
|
||||
es.send("GET", "_aliases", null, function (data, status, xhr) {
|
||||
loadAliases(data);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function mapping_retriever() {
|
||||
|
@ -228,7 +230,7 @@ define([
|
|||
mapping_retriever();
|
||||
}
|
||||
|
||||
return {
|
||||
return _.assign(mappingObj, {
|
||||
getFields: getFields,
|
||||
getIndices: getIndices,
|
||||
getTypes: getTypes,
|
||||
|
@ -237,6 +239,6 @@ define([
|
|||
expandAliases: expandAliases,
|
||||
clear: clear,
|
||||
onInitComplete: onInitComplete
|
||||
};
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
'ace_mode_json': '../vendor/ace/mode-json',
|
||||
'ace_ext_language_tools': '../vendor/ace/ext-language_tools',
|
||||
'ace_ext_searchbox': '../vendor/ace/ext-searchbox',
|
||||
'analytics': '../../common/analytics'
|
||||
'analytics': '../../common/analytics',
|
||||
'phone_home': '../../common/phone_home'
|
||||
},
|
||||
map: {
|
||||
'*': {
|
||||
|
|
|
@ -21,6 +21,7 @@ module.exports = function (config) {
|
|||
'^/kibana/config.js$': './<%= buildTempDir %>/config.js',
|
||||
'^/kibana(.*)$': '<%= kibanaCheckoutDir %>/src$1',
|
||||
'^/common/analytics.js$': '/<%= buildTempDir %>/common/analytics.js',
|
||||
'^/common/PhoneHome.js$': '/<%= buildTempDir %>/common/PhoneHome.js',
|
||||
'^/sense(.*)$': '/sense$1',
|
||||
'^/common(.*)$': '/common$1',
|
||||
'^/test/panels(.*)$': '/kibana/panels$1',
|
||||
|
@ -32,7 +33,7 @@ module.exports = function (config) {
|
|||
port: '<%= kibanaPort %>',
|
||||
hostname: '<%= kibanaHost %>',
|
||||
base: '.',
|
||||
keepalive: true,
|
||||
keepalive: false,
|
||||
middleware: middleware
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = function (config) {
|
||||
function notAnalytics (src) {
|
||||
return !(/analytics/.test(src));
|
||||
function exclude(src) {
|
||||
return !(/(analytics|PhoneHome)/.test(src));
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -25,7 +25,7 @@ module.exports = function (config) {
|
|||
expand: true,
|
||||
src: ['index.html', './common/**/*'],
|
||||
dest: '<%= buildSiteDir %>',
|
||||
filter: notAnalytics
|
||||
filter: exclude
|
||||
}
|
||||
]},
|
||||
merge_marvel_kibana: {
|
||||
|
|
|
@ -20,7 +20,8 @@ module.exports = function (config) {
|
|||
},
|
||||
files: [
|
||||
{expand: true, flatten: true, src: ['./kibana/config.js'], dest: '<%= buildTempDir %>'},
|
||||
{expand: true, flatten: true, src: ['./common/analytics.js'], dest: '<%= buildTempDir %>/common/'}
|
||||
{expand: true, flatten: true, src: ['./common/analytics.js'], dest: '<%= buildTempDir %>/common/'},
|
||||
{expand: true, flatten: true, src: ['./common/PhoneHome.js'], dest: '<%= buildTempDir %>/common/'}
|
||||
]
|
||||
},
|
||||
dist_marvel_config: {
|
||||
|
@ -42,7 +43,8 @@ module.exports = function (config) {
|
|||
},
|
||||
files: [
|
||||
{expand: true, flatten: true, src: ['./kibana/config.js'], dest: '<%= buildTempDir %>/src/'},
|
||||
{expand: true, flatten: true, src: ['./common/analytics.js'], dest: '<%= buildTempDir %>/common/'}
|
||||
{expand: true, flatten: true, src: ['./common/analytics.js'], dest: '<%= buildTempDir %>/common/'},
|
||||
{expand: true, flatten: true, src: ['./common/PhoneHome.js'], dest: '<%= buildTempDir %>/common/'}
|
||||
]
|
||||
},
|
||||
git_commits: {
|
||||
|
@ -79,5 +81,5 @@ module.exports = function (config) {
|
|||
expand: true, src: ['kibana/index.html'], dest: '<%= buildSiteDir %>/'}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module.exports = function (grunt) {
|
||||
var testFiles = [
|
||||
'common/**/*.js',
|
||||
'kibana/**/*.js',
|
||||
'test/**/*.js',
|
||||
'test/templates/**/*.jade'
|
||||
|
@ -13,9 +14,14 @@ module.exports = function (grunt) {
|
|||
files: ['kibana/panels/**/*.less'],
|
||||
tasks: ['less']
|
||||
},
|
||||
common: {
|
||||
files: ['common/**/*.js'],
|
||||
tasks: ['replace:dev_marvel_config']
|
||||
|
||||
},
|
||||
dev: {
|
||||
files: testFiles,
|
||||
tasks: [ 'jade:test' ],
|
||||
tasks: [ 'jade:test', 'replace:dev_marvel_config'],
|
||||
options: {
|
||||
livereload: true,
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ module.exports = function (grunt) {
|
|||
'replace:dev_marvel_config',
|
||||
'configureRewriteRules',
|
||||
'less',
|
||||
'connect:server'
|
||||
'connect:server',
|
||||
'watch:common'
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
module.exports = function (grunt) {
|
||||
grunt.registerTask('test:dev', [
|
||||
'replace:dev_marvel_config',
|
||||
'configureRewriteRules',
|
||||
'jade:test',
|
||||
'connect:test',
|
||||
'watch:dev'
|
||||
]);
|
||||
grunt.registerTask('test', [
|
||||
'replace:dev_marvel_config',
|
||||
'configureRewriteRules',
|
||||
'jade:test',
|
||||
'connect:test',
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
blanket.options("reporter", "../node_modules/grunt-blanket-mocha/support/grunt-reporter.js");
|
||||
}
|
||||
</script><script type="text/javascript">require.config({
|
||||
baseUrl: '../kibana/app'
|
||||
baseUrl: '../kibana/app',
|
||||
paths: {
|
||||
'common': '../../common'
|
||||
}
|
||||
});
|
||||
require(["/test/unit/lib/ClusterState/explainStatus.js","/test/unit/lib/ClusterState/filterShards.js","/test/unit/lib/ClusterState/getIndices.js","/test/unit/lib/ClusterState/getState.js","/test/unit/lib/ClusterState/groupIndicesByState.js","/test/unit/lib/ClusterState/incrementIndexShardStatusCount.js","/test/unit/lib/ClusterState/popFirstIndexAndReturnEndpoint.js","/test/unit/lib/ClusterState/refreshState.js","/test/unit/shard_allocation/calculateClass.js","/test/unit/shard_allocation/countChildren.js","/test/unit/shard_allocation/extractIp.js","/test/unit/shard_allocation/extractMarkers.js","/test/unit/shard_allocation/extractShards.js","/test/unit/shard_allocation/filterByName.js","/test/unit/shard_allocation/filterHiddenIndices.js","/test/unit/shard_allocation/generateQueryAndLink.js","/test/unit/shard_allocation/getStateSource.js","/test/unit/shard_allocation/hasUnassigned.js","/test/unit/shard_allocation/hasUnassignedPrimaries.js","/test/unit/shard_allocation/updateColors.js","/test/unit/shard_allocation/vents.js","/test/unit/stats_table/lib/detectSplitBrain.js"], function () {
|
||||
require(["/test/unit/common/PhoneHome.js","/test/unit/lib/ClusterState/explainStatus.js","/test/unit/lib/ClusterState/filterShards.js","/test/unit/lib/ClusterState/getIndices.js","/test/unit/lib/ClusterState/getState.js","/test/unit/lib/ClusterState/groupIndicesByState.js","/test/unit/lib/ClusterState/incrementIndexShardStatusCount.js","/test/unit/lib/ClusterState/popFirstIndexAndReturnEndpoint.js","/test/unit/lib/ClusterState/refreshState.js","/test/unit/shard_allocation/calculateClass.js","/test/unit/shard_allocation/countChildren.js","/test/unit/shard_allocation/extractIp.js","/test/unit/shard_allocation/extractMarkers.js","/test/unit/shard_allocation/extractShards.js","/test/unit/shard_allocation/filterByName.js","/test/unit/shard_allocation/filterHiddenIndices.js","/test/unit/shard_allocation/generateQueryAndLink.js","/test/unit/shard_allocation/getStateSource.js","/test/unit/shard_allocation/hasUnassigned.js","/test/unit/shard_allocation/hasUnassignedPrimaries.js","/test/unit/shard_allocation/updateColors.js","/test/unit/shard_allocation/vents.js","/test/unit/stats_table/lib/detectSplitBrain.js"], function () {
|
||||
setTimeout(function () {
|
||||
window.mochaRunner = mocha.run();
|
||||
if (window.mochaRunner) {
|
||||
|
|
|
@ -24,7 +24,10 @@ html
|
|||
|
||||
script(type="text/javascript").
|
||||
require.config({
|
||||
baseUrl: '../kibana/app'
|
||||
baseUrl: '../kibana/app',
|
||||
paths: {
|
||||
'common': '../../common'
|
||||
}
|
||||
});
|
||||
require(!{tests}, function () {
|
||||
setTimeout(function () {
|
||||
|
|
462
test/unit/common/PhoneHome.js
Normal file
462
test/unit/common/PhoneHome.js
Normal file
|
@ -0,0 +1,462 @@
|
|||
define(function (require) {
|
||||
'use strict';
|
||||
var $ = require("jquery");
|
||||
var PhoneHome = require('common/PhoneHome');
|
||||
|
||||
describe('common/PhoneHome.js', function() {
|
||||
describe('Object Model', function() {
|
||||
|
||||
var phoneHome, client;
|
||||
|
||||
beforeEach(function () {
|
||||
client = { delete: sinon.stub(), put: sinon.stub(), post: sinon.stub(), get: sinon.stub() };
|
||||
phoneHome = new PhoneHome({
|
||||
client: client,
|
||||
baseUrl: 'http://localhost:9200',
|
||||
index: '.marvel-kibana'
|
||||
});
|
||||
});
|
||||
|
||||
describe('set()', function() {
|
||||
it('should set a single value', function() {
|
||||
phoneHome.set('test', '123');
|
||||
expect(phoneHome.attributes).to.have.property('test', '123');
|
||||
});
|
||||
|
||||
it('should bulk set using an object', function() {
|
||||
phoneHome.set({ 'key1': 'value1', 'key2': 'value2' });
|
||||
expect(phoneHome.attributes).to.have.property('key1', 'value1');
|
||||
expect(phoneHome.attributes).to.have.property('key2', 'value2');
|
||||
});
|
||||
|
||||
it('should fire a change event on set', function(done) {
|
||||
phoneHome.on('change:key1', function (value) {
|
||||
expect(value).to.equal('value1');
|
||||
done();
|
||||
});
|
||||
phoneHome.set('key1', 'value1');
|
||||
});
|
||||
|
||||
it('should fire a change event on bulk set for each', function(done) {
|
||||
var count = 0;
|
||||
var checkIfDone = function () {
|
||||
count++;
|
||||
if (count === 2) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
phoneHome.on('change:key1', function (value) {
|
||||
expect(value).to.equal('value1');
|
||||
checkIfDone();
|
||||
});
|
||||
phoneHome.on('change:key1', function (value) {
|
||||
expect(value).to.equal('value1');
|
||||
checkIfDone();
|
||||
});
|
||||
phoneHome.set({ 'key1': 'value1', 'key2': 'value2' });
|
||||
});
|
||||
|
||||
it('should set the old value for the change event for single set', function (done) {
|
||||
phoneHome.set('key1', 'value0');
|
||||
phoneHome.on('change:key1', function (newVal, oldVal) {
|
||||
expect(oldVal).to.equal('value0');
|
||||
expect(newVal).to.equal('value1');
|
||||
done();
|
||||
});
|
||||
setTimeout(function () {
|
||||
phoneHome.set('key1', 'value1');
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('should set the old value for the change event for bulk set', function (done) {
|
||||
phoneHome.set('key1', 'value0');
|
||||
phoneHome.on('change:key1', function (newVal, oldVal) {
|
||||
expect(oldVal).to.equal('value0');
|
||||
expect(newVal).to.equal('value1');
|
||||
done();
|
||||
});
|
||||
setTimeout(function () {
|
||||
phoneHome.set({ 'key1': 'value1' });
|
||||
}, 0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('get()', function() {
|
||||
|
||||
it('should return a value when get is called', function() {
|
||||
phoneHome.set('key1', 'value1');
|
||||
expect(phoneHome.get('key1')).to.equal('value1');
|
||||
});
|
||||
|
||||
it('should return a hash when get is called without a key', function() {
|
||||
phoneHome.set('key1', 'value1');
|
||||
phoneHome.set('key2', 'value2');
|
||||
expect(phoneHome.get()).to.have.property('key1', 'value1');
|
||||
expect(phoneHome.get()).to.have.property('key2', 'value2');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('save functions', function() {
|
||||
it('should save only fieldsToBrowser fields to the localStore', function () {
|
||||
var data = {
|
||||
trialTimestamp: 1,
|
||||
report: true,
|
||||
foo: true
|
||||
};
|
||||
phoneHome.set(data);
|
||||
phoneHome.saveToBrowser();
|
||||
expect(localStorage.getItem('marvelOpts')).to.equal(JSON.stringify({ trialTimestamp: 1, report: true }));
|
||||
});
|
||||
|
||||
it('should save only fieldsToES fields to the Elasticsearch', function () {
|
||||
var data = {
|
||||
registrationData: 'test',
|
||||
report: true,
|
||||
trialTimestamp: 1
|
||||
};
|
||||
phoneHome.set(data);
|
||||
phoneHome.saveToES();
|
||||
sinon.assert.calledOnce(client.put);
|
||||
expect(client.put.args[0][0]).to.equal('http://localhost:9200/.marvel-kibana/appdata/marvelOpts');
|
||||
expect(client.put.args[0][1]).to.have.property('purchased', false);
|
||||
expect(client.put.args[0][1]).to.have.property('registrationData', 'test');
|
||||
expect(client.put.args[0][1]).to.have.property('report', true);
|
||||
expect(client.put.args[0][1]).to.not.have.property('trialTimestamp');
|
||||
});
|
||||
});
|
||||
|
||||
describe('misc functions', function() {
|
||||
it('should delete everyting when destory is called', function() {
|
||||
var lsRemoveStub = sinon.stub(localStorage, 'removeItem');
|
||||
phoneHome.destroy();
|
||||
sinon.assert.calledOnce(lsRemoveStub);
|
||||
sinon.assert.calledOnce(client.delete);
|
||||
sinon.assert.calledWith(client.delete, 'http://localhost:9200/.marvel-kibana/appdata/marvelOpts');
|
||||
lsRemoveStub.restore();
|
||||
});
|
||||
|
||||
it('should set the baseUrl', function() {
|
||||
phoneHome.setBaseUrl('http://foo');
|
||||
expect(phoneHome).to.have.property('baseUrl', 'http://foo');
|
||||
});
|
||||
|
||||
it('should set trialTimestamp', function() {
|
||||
var saveToBrowserStub = sinon.stub(phoneHome, 'saveToBrowser');
|
||||
phoneHome.setTrialTimestamp(1);
|
||||
expect(phoneHome.get('trialTimestamp')).to.equal(1);
|
||||
sinon.assert.calledOnce(saveToBrowserStub);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Phone Home Features', function() {
|
||||
var phoneHome, client;
|
||||
|
||||
beforeEach(function () {
|
||||
client = { delete: sinon.stub(), put: sinon.stub(), post: sinon.stub(), get: sinon.stub() };
|
||||
phoneHome = new PhoneHome({
|
||||
client: client,
|
||||
baseUrl: 'http://localhost:9200',
|
||||
index: '.marvel-kibana'
|
||||
});
|
||||
});
|
||||
|
||||
describe('change:data events', function() {
|
||||
it('should call sendIfDue()', function(done) {
|
||||
var sendIfDueStub = sinon.stub(phoneHome, 'sendIfDue');
|
||||
phoneHome.on('change:data', function () {
|
||||
sinon.assert.calledOnce(sendIfDueStub);
|
||||
expect(sendIfDueStub.args[0][0]).to.have.property('key1', 'value1');
|
||||
sendIfDueStub.restore();
|
||||
done();
|
||||
});
|
||||
phoneHome.set('data', { 'key1': 'value1' });
|
||||
});
|
||||
|
||||
it('should call checkAndSendRegistrationData()', function(done) {
|
||||
var checkStub = sinon.stub(phoneHome, 'checkAndSendRegistrationData');
|
||||
phoneHome.on('change:data', function () {
|
||||
sinon.assert.calledOnce(checkStub);
|
||||
checkStub.restore();
|
||||
done();
|
||||
});
|
||||
phoneHome.set('data', {});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkReportStatus()', function() {
|
||||
it('should return true if lastReport is NOT set', function() {
|
||||
phoneHome.set({
|
||||
version: '1.0',
|
||||
report: true
|
||||
});
|
||||
expect(phoneHome.checkReportStatus()).to.equal(true);
|
||||
});
|
||||
|
||||
it('should return true if url changed', function() {
|
||||
phoneHome.setBaseUrl('http://search-01:4080');
|
||||
phoneHome.set({
|
||||
version: '1.0',
|
||||
lastReport: new Date().getTime(),
|
||||
report: true
|
||||
});
|
||||
expect(phoneHome.checkReportStatus()).to.equal(true);
|
||||
});
|
||||
|
||||
it('should return true if lastReport is older then a day', function() {
|
||||
phoneHome.set({
|
||||
version: '1.0',
|
||||
lastReport: new Date().getTime()-86400001,
|
||||
report: true
|
||||
});
|
||||
expect(phoneHome.checkReportStatus()).to.equal(true);
|
||||
});
|
||||
|
||||
it('should return false if lastReport is NOT older then a day', function() {
|
||||
phoneHome.set({
|
||||
version: '1.0',
|
||||
lastReport: new Date().getTime()-3600,
|
||||
report: true
|
||||
});
|
||||
expect(phoneHome.checkReportStatus()).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('checkRegistratonStatus()', function() {
|
||||
it('should return true if registered is false and trialTimestamp is older then 7 days', function() {
|
||||
phoneHome.set({
|
||||
registered: false,
|
||||
trialTimestamp: new Date().getTime()-(86400000*7.25)
|
||||
});
|
||||
expect(phoneHome.checkRegistratonStatus()).to.equal(true);
|
||||
});
|
||||
|
||||
it('should return false if registered is true and trialTimestamp is older then 7 days', function() {
|
||||
phoneHome.set({
|
||||
registered: true,
|
||||
trialTimestamp: new Date().getTime()-(86400000*7.25)
|
||||
});
|
||||
expect(phoneHome.checkRegistratonStatus()).to.equal(false);
|
||||
});
|
||||
|
||||
it('should return false if purchased is true and trialTimestamp is older then 7 days', function() {
|
||||
phoneHome.set({
|
||||
purchased: true,
|
||||
trialTimestamp: new Date().getTime()-(86400000*7.25)
|
||||
});
|
||||
expect(phoneHome.checkRegistratonStatus()).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('sendIfDue()', function() {
|
||||
it('should post to registration url when sendIfDue() is due', function() {
|
||||
var promise = $.Deferred();
|
||||
var checkStub = sinon.stub(phoneHome, 'checkReportStatus');
|
||||
checkStub.onFirstCall().returns(true);
|
||||
client.post.onFirstCall().returns(promise);
|
||||
phoneHome.sendIfDue({ key1: 'value1' });
|
||||
sinon.assert.calledOnce(client.post);
|
||||
expect(client.post.args[0][0]).to.equal('http://localhost:9200/.marvel_cluster_report/report');
|
||||
expect(client.post.args[0][1]).to.have.property('key1', 'value1');
|
||||
});
|
||||
|
||||
it('should set lastReport when sendIfDue() is due', function(done) {
|
||||
var promise = $.Deferred();
|
||||
var checkStub = sinon.stub(phoneHome, 'checkReportStatus');
|
||||
checkStub.onFirstCall().returns(true);
|
||||
client.post.onFirstCall().returns(promise);
|
||||
phoneHome.sendIfDue({ key1: 'value1' }).then(function () {
|
||||
expect(phoneHome.get('lastReport')).to.be.greaterThan(1);
|
||||
done();
|
||||
});
|
||||
promise.resolve({});
|
||||
});
|
||||
|
||||
it('should call saveToBrowser() when sendIfDue() is due', function(done) {
|
||||
var promise = $.Deferred();
|
||||
var checkStub = sinon.stub(phoneHome, 'checkReportStatus');
|
||||
var saveToBrowserStub = sinon.stub(phoneHome, 'saveToBrowser');
|
||||
checkStub.onFirstCall().returns(true);
|
||||
client.post.onFirstCall().returns(promise);
|
||||
phoneHome.sendIfDue({ key1: 'value1' }).then(function () {
|
||||
sinon.assert.calledOnce(saveToBrowserStub);
|
||||
saveToBrowserStub.restore();
|
||||
done();
|
||||
});
|
||||
promise.resolve({});
|
||||
});
|
||||
});
|
||||
|
||||
describe('register()', function() {
|
||||
it('should call saveToBrowser() and saveToES()', function() {
|
||||
var saveToBrowserStub = sinon.stub(phoneHome, 'saveToBrowser');
|
||||
var saveToESStub = sinon.stub(phoneHome, 'saveToES');
|
||||
phoneHome.register({ key1: 'value1' });
|
||||
sinon.assert.calledOnce(saveToBrowserStub);
|
||||
sinon.assert.calledOnce(saveToESStub);
|
||||
});
|
||||
|
||||
it('should set registrationData', function() {
|
||||
phoneHome.register({ key1: 'value1' });
|
||||
expect(phoneHome.get('registrationData')).to.have.property('key1', 'value1');
|
||||
});
|
||||
|
||||
it('should set registered to true', function() {
|
||||
phoneHome.register({ key1: 'value1' });
|
||||
expect(phoneHome.get('registered')).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('confirmPurchase()', function() {
|
||||
it('should call saveToBrowser() and saveToES()', function() {
|
||||
var saveToBrowserStub = sinon.stub(phoneHome, 'saveToBrowser');
|
||||
var saveToESStub = sinon.stub(phoneHome, 'saveToES');
|
||||
phoneHome.confirmPurchase({ key1: 'value1' });
|
||||
sinon.assert.calledOnce(saveToBrowserStub);
|
||||
sinon.assert.calledOnce(saveToESStub);
|
||||
});
|
||||
|
||||
it('should set registrationData', function() {
|
||||
phoneHome.confirmPurchase({ key1: 'value1' });
|
||||
expect(phoneHome.get('registrationData')).to.have.property('key1', 'value1');
|
||||
});
|
||||
|
||||
it('should set purchased to true', function() {
|
||||
phoneHome.confirmPurchase({ key1: 'value1' });
|
||||
expect(phoneHome.get('purchased')).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkAndSendRegistrationData()', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
phoneHome.attributes = {
|
||||
registrationData: { key1: 'value1' },
|
||||
registrationSent: false,
|
||||
data: {
|
||||
uuid: 123456789
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
client.post.reset();
|
||||
});
|
||||
|
||||
it('should not send registration if registrationSent is true', function () {
|
||||
phoneHome.set('registrationSent', true);
|
||||
phoneHome.checkAndSendRegistrationData();
|
||||
sinon.assert.notCalled(client.post);
|
||||
});
|
||||
|
||||
it('should not send registration if data.uuid is not set', function () {
|
||||
delete phoneHome.attributes.data.uuid;
|
||||
phoneHome.checkAndSendRegistrationData();
|
||||
sinon.assert.notCalled(client.post);
|
||||
});
|
||||
|
||||
it('should not send registration if registrationData is not set', function () {
|
||||
delete phoneHome.attributes.registrationData;
|
||||
phoneHome.checkAndSendRegistrationData();
|
||||
sinon.assert.notCalled(client.post);
|
||||
});
|
||||
|
||||
it('should set type to registration', function() {
|
||||
var promise = $.Deferred();
|
||||
client.post.returns(promise);
|
||||
phoneHome.checkAndSendRegistrationData();
|
||||
expect(client.post.args[0][1]).to.have.property('type', 'registration');
|
||||
promise.resolve(true);
|
||||
});
|
||||
|
||||
it('should set type to purchase_confirmation', function() {
|
||||
var promise = $.Deferred();
|
||||
client.post.returns(promise);
|
||||
phoneHome.set('purchased', true);
|
||||
phoneHome.checkAndSendRegistrationData();
|
||||
expect(client.post.args[0][1]).to.have.property('type', 'purchase_confirmation');
|
||||
promise.resolve(true);
|
||||
});
|
||||
|
||||
it('should set the uuid for registrationData', function() {
|
||||
var promise = $.Deferred();
|
||||
client.post.returns(promise);
|
||||
phoneHome.checkAndSendRegistrationData();
|
||||
sinon.assert.calledOnce(client.post);
|
||||
expect(client.post.args[0][1])
|
||||
.to.have.property('data')
|
||||
.to.have.property('uuid', 123456789);
|
||||
});
|
||||
|
||||
it('should set the values for registrationData', function() {
|
||||
var promise = $.Deferred();
|
||||
client.post.returns(promise);
|
||||
phoneHome.checkAndSendRegistrationData();
|
||||
sinon.assert.calledOnce(client.post);
|
||||
expect(client.post.args[0][1])
|
||||
.to.have.property('data')
|
||||
.to.have.property('key1', 'value1');
|
||||
});
|
||||
|
||||
it('should set registrationSent to true', function() {
|
||||
var promise = $.Deferred();
|
||||
client.post.returns(promise);
|
||||
phoneHome.checkAndSendRegistrationData();
|
||||
promise.resolve({});
|
||||
sinon.assert.calledOnce(client.post);
|
||||
expect(phoneHome.get('registrationSent')).to.equal(true);
|
||||
});
|
||||
|
||||
it('should call saveToBrowser() upon successful submission', function() {
|
||||
var promise = $.Deferred();
|
||||
var saveToBrowserStub = sinon.stub(phoneHome, 'saveToBrowser');
|
||||
client.post.returns(promise);
|
||||
phoneHome.checkAndSendRegistrationData();
|
||||
promise.resolve(true);
|
||||
sinon.assert.calledOnce(saveToBrowserStub);
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetch()', function() {
|
||||
|
||||
var promise, lsGetItemStub;
|
||||
|
||||
beforeEach(function() {
|
||||
promise = $.Deferred();
|
||||
lsGetItemStub = sinon.stub(localStorage, 'getItem');
|
||||
client.get.returns(promise);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
lsGetItemStub.restore();
|
||||
client.get.reset();
|
||||
});
|
||||
|
||||
it('should set values stored from the browser', function(done) {
|
||||
lsGetItemStub.returns('{ "key1": "value1" }');
|
||||
phoneHome.fetch().then(function () {
|
||||
expect(phoneHome.get('key1')).to.equal('value1');
|
||||
done();
|
||||
});
|
||||
promise.resolve({ data: { _source: {} } });
|
||||
});
|
||||
|
||||
it('should set values stored in Elasticsearch', function(done) {
|
||||
lsGetItemStub.returns('{}');
|
||||
phoneHome.fetch().then(function () {
|
||||
expect(phoneHome.get('key2')).to.equal('value2');
|
||||
done();
|
||||
});
|
||||
promise.resolve({ data: { _source: { key2: 'value2' } } });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue