Skip to content

Commit

Permalink
DP-177 Add Service Analytics
Browse files Browse the repository at this point in the history
- Add a controller to sending a request to updates server
- Add send a request method in load paywall elements time
- Implement paywall as separate component
- Implement sending request each time when user hit paywall
- Change old paywalls to new paywall component
- Move paywall ng-if to wrapper
- Remove additional text variable from paywall component
- Add df help text to reports page
- Change reports header text
  • Loading branch information
oleksandrono committed Apr 1, 2020
1 parent b5851b5 commit cf01e6e
Show file tree
Hide file tree
Showing 25 changed files with 83 additions and 30 deletions.
1 change: 1 addition & 0 deletions app/admin_components/adf-admins/dreamfactory-admins.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ angular.module('dfAdmins', ['ngRoute', 'dfUtility', 'dfApplication', 'dfHelp'])
templateUrl: MOD_ADMIN_ASSET_PATH + 'views/df-access-by-tabs.html',
link: function (scope, elem, attrs) {
var currentUser = UserDataService.getCurrentUser();
scope.accessByTabsLoaded = false;
scope.subscription_required = !dfApplicationData.isGoldLicense();
scope.isRootAdmin = currentUser.is_root_admin;
scope.widgetDescription = "Restricted admin. An auto-generated role will be created for this admin.";
Expand Down
8 changes: 3 additions & 5 deletions app/admin_components/adf-admins/views/df-access-by-tabs.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="panel">
<div>
<a data-toggle="collapse" style="text-decoration: none; cursor: pointer" data-target="#select-access-tabs-body">
<a ng-click="accessByTabsLoaded = true" data-toggle="collapse" style="text-decoration: none; cursor: pointer" data-target="#select-access-tabs-body">
<h4>Access by tabs</h4>
</a>
</div>
Expand Down Expand Up @@ -31,10 +31,8 @@ <h4>Access by tabs</h4>
</div>
</div>

<div data-ng-if="subscription_required">
<br/><h5>This feature requires a DreamFactory GOLD product subscription.</h5> Email <a
href="mailto:[email protected]">[email protected]</a> or call +1-415-993-5877 for pricing
information.
<div data-ng-if="subscription_required && loaded" ng-controller="PaywallCtrl">
<df-paywall license-type="'GOLD'" service-name="'Access by tabs'"></df-paywall>
</div>
</div>
<hr/>
Expand Down
4 changes: 2 additions & 2 deletions app/admin_components/adf-limit/views/df-manage-limits.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@
<div data-ng-show="limitEnabled && currentEditLimit.record.id">
<df-limit-details data-limit-data="currentEditLimit" data-new-limit="false" data-api-data="apiData"></df-limit-details>
</div>
<div data-ng-if="subscription_required">
<br/><h4>This feature requires a DreamFactory GOLD product subscription.</h4> Email <a href="mailto:[email protected]" >[email protected]</a> or call +1-415-993-5877 for pricing information.
<div data-ng-if="subscription_required" ng-controller="PaywallCtrl">
<df-paywall license-type="'GOLD'" service-name="'Limits'"></df-paywall>
</div>


Expand Down
8 changes: 8 additions & 0 deletions app/admin_components/adf-reports/dreamfactory-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ angular.module('dfReports', ['ngRoute', 'dfUtility', 'dfApplication', 'dfHelp'])
text: ''
};

//HELP
$scope.dfLargeHelp = {
manageReports: {
title: 'Manage Service Reports',
text: 'Service reports tell you when each service was created, modified, and deleted.'
}
};

// load data

$scope.apiData = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div data-ng-hide="!reportsEnabled">

<!-- Section Header -->
<df-section-header data-title="'Manage Service Reports'"></df-section-header>
<df-large-help data-options="dfLargeHelp.manageReports"></df-large-help>

<!-- ToolBar -->
<df-section-toolbar>
Expand Down Expand Up @@ -105,7 +105,7 @@
</div>
</div>

<div data-ng-if="subscription_required">
<br/><h4>This feature will be available for root admin and requires a DreamFactory GOLD product subscription.</h4> Email <a href="mailto:[email protected]" >[email protected]</a> or call +1-415-993-5877 for pricing information.
<div data-ng-if="!reportsEnabled" ng-controller="PaywallCtrl">
<df-paywall license-type="'GOLD'" service-name="'Reports'"></df-paywall>
</div>
</div>
4 changes: 2 additions & 2 deletions app/admin_components/adf-scheduler/views/df-manage-tasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
data-api-data="apiData"></df-task-details>
</div>

<div data-ng-if="subscription_required">
<br/><h4>This feature requires a DreamFactory GOLD product subscription.</h4> Email <a href="mailto:[email protected]" >[email protected]</a> or call +1-415-993-5877 for pricing information.
<div ng-controller="PaywallCtrl" data-ng-if="subscription_required">
<df-paywall license-type="'GOLD'" service-name="'Scheduler'"></df-paywall>
</div>

</div>
4 changes: 2 additions & 2 deletions app/admin_components/adf-scripts/views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
</div>
</div>
</div>
<div data-ng-if="subscription_required">
<br/><h4>This feature requires a DreamFactory SILVER product subscription.</h4> Email <a href="mailto:[email protected]" >[email protected]</a> or call +1-415-993-5877 for pricing information.
<div data-ng-if="subscription_required" ng-controller="PaywallCtrl">
<df-paywall license-type="'SILVER'" service-name="'Scripts'"></df-paywall>
</div>
</pane>
<pane title="Script Samples">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@
</div>
</div>

<div data-ng-if="selectedSchema && !selectedSchema.available">
<br/><h4>This feature requires a DreamFactory {{selectedSchema.subscription_required}} product subscription.</h4> Email <a href="mailto:[email protected]" >[email protected]</a> or call +1-415-993-5877 for pricing information.
<div data-ng-if="selectedSchema && !selectedSchema.available" ng-controller="PaywallCtrl">
<df-paywall license-type="selectedSchema.subscription_required"></df-paywall>
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
</div>
</div>

<div data-ng-if="selectedSchema && !selectedSchema.available">
<br/><h4>This feature requires a DreamFactory {{selectedSchema.subscription_required}} product subscription.</h4> Email <a href="mailto:[email protected]" >[email protected]</a> or call +1-415-993-5877 for pricing information.
<div data-ng-if="selectedSchema && !selectedSchema.available" ng-controller="PaywallCtrl">
<df-paywall license-type="selectedSchema.subscription_required"></df-paywall>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions app/admin_components/adf-services/views/df-service-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</div>
</div>

<div data-ng-if="selectedSchema && !selectedSchema.available">
<br/><h4>This feature requires a DreamFactory {{selectedSchema.subscription_required}} product subscription.</h4> Email <a href="mailto:[email protected]" >[email protected]</a> or call +1-415-993-5877 for pricing information.
<div data-ng-if="selectedSchema && !selectedSchema.available" ng-controller="PaywallCtrl">
<df-paywall license-type="selectedSchema.subscription_required" service-name="selectedSchema.label"></df-paywall>
</div>
</div>
20 changes: 20 additions & 0 deletions app/admin_components/adf-utility/dreamfactory-utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -2712,6 +2712,26 @@ angular.module('dfUtility', ['dfApplication'])
}
}])

.directive('dfPaywall', ['MOD_UTILITY_ASSET_PATH', function (MOD_UTILITY_ASSET_PATH) {
return {
restrict: 'E',
scope: {
serviceName: '=?',
licenseType: '=?'
},
templateUrl: MOD_UTILITY_ASSET_PATH + 'views/df-paywall.html',

link: function (scope, elem, attrs) {
scope.$watch('serviceName', function (newValue, oldValue) {
if (scope.serviceName) {
scope.$emit('hitPaywall', newValue);

}
});
}
}
}])

// Helps merge objects. Supports deep merge. Many modules
// need this
.service('dfObjectService', [
Expand Down
2 changes: 2 additions & 0 deletions app/admin_components/adf-utility/views/df-paywall.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<br/><h4>This feature requires a DreamFactory {{ licenseType }} product subscription.</h4> Email <a href="mailto:[email protected]" >[email protected]</a> or call +1-415-993-5877 for pricing information.

23 changes: 23 additions & 0 deletions app/scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,4 +824,27 @@ angular.module('dreamfactoryApp')
e.stopPropagation();
$scope.confirmLoginErrorMsg = errMsg.data.error.message;
});
}])

.controller('PaywallCtrl', ['$scope', '$http', 'UserDataService', 'SystemConfigDataService', function($scope, $http, UserDataService, SystemConfigDataService) {

$scope.$on('hitPaywall', function (e, data) {
$scope.sendRequest(data);
});

$scope.sendRequest = function(serviceName) {
var data = {
email: UserDataService.getCurrentUser().email,
ip_address: SystemConfigDataService.getSystemConfig().client.ip_address,
service_name: serviceName
};

var req = {
method: 'POST',
url: 'https://updates.dreamfactory.com/api/paywall',
data: JSON.stringify(data)
};

$http(req).then();
};
}]);
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div class="panel"> <div> <a data-toggle="collapse" style="text-decoration: none; cursor: pointer" data-target="#select-access-tabs-body"> <h4>Access by tabs</h4> </a> </div> <div id="select-access-tabs-body" class="panel-collapse collapse" ng-class="{'in': !subscription_required}" style="overflow: hidden; margin-left: -20px; margin-right: -20px; padding-right: 20px; padding-left: 20px"> <div data-ng-if="!subscription_required"> <div class="alert alert-info" style="margin-top: 10px"> <div class="fa fa-info-circle"></div> {{ widgetDescription }} </div> <div> <div class="form-group"> <div class="checkbox" style="margin-bottom: 20px"> <label> <input id="select-all-tabs" type="checkbox" ng-model="areAllTabsSelected" ng-change="selectAllTabs(areAllTabsSelected)"> Select all </label> </div> <div class="checkbox col-sm-6 no-gutter" ng-repeat="tab in accessByTabs track by $index"> <label> <input type="checkbox" ng-model="tab.checked" ng-change="selectTab(tab)"> {{tab.title}} </label> </div> </div> </div> </div> <div data-ng-if="subscription_required"> <br><h5>This feature requires a DreamFactory GOLD product subscription.</h5> Email <a href="mailto:[email protected]">[email protected]</a> or call +1-415-993-5877 for pricing information. </div> </div> <hr> </div>
<div class="panel"> <div> <a ng-click="accessByTabsLoaded = true" data-toggle="collapse" style="text-decoration: none; cursor: pointer" data-target="#select-access-tabs-body"> <h4>Access by tabs</h4> </a> </div> <div id="select-access-tabs-body" class="panel-collapse collapse" ng-class="{'in': !subscription_required}" style="overflow: hidden; margin-left: -20px; margin-right: -20px; padding-right: 20px; padding-left: 20px"> <div data-ng-if="!subscription_required"> <div class="alert alert-info" style="margin-top: 10px"> <div class="fa fa-info-circle"></div> {{ widgetDescription }} </div> <div> <div class="form-group"> <div class="checkbox" style="margin-bottom: 20px"> <label> <input id="select-all-tabs" type="checkbox" ng-model="areAllTabsSelected" ng-change="selectAllTabs(areAllTabsSelected)"> Select all </label> </div> <div class="checkbox col-sm-6 no-gutter" ng-repeat="tab in accessByTabs track by $index"> <label> <input type="checkbox" ng-model="tab.checked" ng-change="selectTab(tab)"> {{tab.title}} </label> </div> </div> </div> </div> <div data-ng-if="subscription_required && loaded" ng-controller="PaywallCtrl"> <df-paywall license-type="'GOLD'" service-name="'Access by tabs'"></df-paywall> </div> </div> <hr> </div>
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
</div>--> <df-toolbar-paginate data-api="'limit'"></df-toolbar-paginate> <div class="btn-group btn-group-sm hidden-xs df-btn-group" ng-show="limits.length"> <button class="btn btn-default" data-ng-click="deleteSelectedLimits()" data-ng-disabled="selectedLimits.length === 0" title="Delete selected limits"><i class="fa fa-fw fa-trash"></i></button> </div> <div class="btn-group btn-group-sm hidden-xs df-btn-group" ng-show="limits.length"> <button class="btn btn-default" data-ng-click="resetSelectedLimits()" data-ng-disabled="selectedLimits.length === 0" title="Reset selected limits"><i class="fa fa-fw fa-bolt"></i></button> </div> <div style="clear: both"></div> </df-section-toolbar> <div data-ng-show="limits.length === 0 && emptySectionOptions.active"> <df-empty-section></df-empty-section> </div> <div data-ng-show="limits.length > 0"> <div> <div class="row"> <div class="col-xs-12"> <div class="panel panel-default" style="overflow-x: scroll"> <table class="table table-responsive table-bordered table-striped table-hover table-condensed"> <thead> <th> <input type="checkbox" data-ng-init="checkStatus=false" data-ng-model="checkStatus" data-ng-change="selectAll(checkStatus)"> </th> <th data-ng-class="order.orderBy === field.name ? 'df-th-selected' : ''" data-ng-click="orderOnSelect(field)" data-ng-repeat="field in fields"> <span class="df-th-text" style="white-space: nowrap">{{field.label}} <i style="margin-left: 5px;" data-ng-if="order.orderBy === field.name" class="fa" data-ng-class="order.orderBy === field.name && order.orderByReverse ? 'fa-caret-down' : 'fa-caret-up'"></i> </span> </th> </thead> <tbody> <tr data-ng-repeat="obj in limits | orderObjectBy:order.orderBy:order.orderByReverse" class="repeated-item" class="repeated-item" data-ng-class="obj.__dfUI.selected ? 'danger' : ''"> <td style="width: 80px"> <div class="cell-content"> <div class="checkbox" style="margin: 0"> <label> <input type="checkbox" data-ng-checked="obj.__dfUI.selected" data-ng-click="setSelected(obj)"> <div class="btn-group btn-group-xs"> <button type="button" class="btn btn-default" data-ng-click="deleteLimit(obj)" title="Delete limit"> <i class="fa fa-trash"></i> </button> </div> <div class="btn-group btn-group-xs"> <button type="button" class="btn btn-default" data-ng-click="resetCounter(obj)" title="Reset limit Counter"> <i class="fa fa-bolt"></i> </button> </div> </label> </div> </div> </td> <!-- Auto build table based on fieldorderobj in directive --> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.id}} </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.name}} </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.type}} </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.rate + ' / ' + obj.record.period}} </div> </div> </td> <td data-ng-click="editLimit(obj)" ng-if="obj.record.limit_cache_by_limit_id.length === 1" width="215px"> <div class="cell-content"> <div> <div style="width: 215px;" class="progress" data-ng-init="obj.record.limit_cache_by_limit_id[0].percent = (obj.record.limit_cache_by_limit_id[0].attempts / obj.record.limit_cache_by_limit_id[0].max) * 100"> <div class="progress-bar" ng-class="{ 'progress-bar-success' : obj.record.limit_cache_by_limit_id[0].percent < 75,
'progress-bar-warning' : obj.record.limit_cache_by_limit_id[0].percent >= 75 && obj.record.limit_cache_by_limit_id[0].percent < 90,
'progress-bar-danger' : obj.record.limit_cache_by_limit_id[0].percent >= 90 }" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width: {{ obj.record.limit_cache_by_limit_id[0].percent }}%"> </div> </div> <div style="text-align: center;">{{ obj.record.limit_cache_by_limit_id[0].attempts + ' / ' + obj.record.limit_cache_by_limit_id[0].max }}</div> </div> </div> </td> <td data-ng-click="editLimit(obj)" ng-if="obj.record.limit_cache_by_limit_id.length !== 1"> <div class="cell-content"> <div> </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.user_by_user_id.name}} </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.service_by_service_id.name}} </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.role_by_role_id.name }} </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> <span data-ng-if="obj.record.is_active === true" class="label label-success">Active</span> <span data-ng-if="obj.record.is_active != true" class="label label-warning">Inactive</span> </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> </div> </div> </div> <!-- Edit Limit --> <div data-ng-show="limitEnabled && currentEditLimit.record.id"> <df-limit-details data-limit-data="currentEditLimit" data-new-limit="false" data-api-data="apiData"></df-limit-details> </div> <div data-ng-if="subscription_required"> <br><h4>This feature requires a DreamFactory GOLD product subscription.</h4> Email <a href="mailto:[email protected]">[email protected]</a> or call +1-415-993-5877 for pricing information. </div> </div>
'progress-bar-danger' : obj.record.limit_cache_by_limit_id[0].percent >= 90 }" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width: {{ obj.record.limit_cache_by_limit_id[0].percent }}%"> </div> </div> <div style="text-align: center;">{{ obj.record.limit_cache_by_limit_id[0].attempts + ' / ' + obj.record.limit_cache_by_limit_id[0].max }}</div> </div> </div> </td> <td data-ng-click="editLimit(obj)" ng-if="obj.record.limit_cache_by_limit_id.length !== 1"> <div class="cell-content"> <div> </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.user_by_user_id.name}} </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.service_by_service_id.name}} </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> {{obj.record.role_by_role_id.name }} </div> </div> </td> <td data-ng-click="editLimit(obj)"> <div class="cell-content"> <div> <span data-ng-if="obj.record.is_active === true" class="label label-success">Active</span> <span data-ng-if="obj.record.is_active != true" class="label label-warning">Inactive</span> </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> </div> </div> </div> <!-- Edit Limit --> <div data-ng-show="limitEnabled && currentEditLimit.record.id"> <df-limit-details data-limit-data="currentEditLimit" data-new-limit="false" data-api-data="apiData"></df-limit-details> </div> <div data-ng-if="subscription_required" ng-controller="PaywallCtrl"> <df-paywall license-type="'GOLD'" service-name="'Limits'"></df-paywall> </div> </div>
Loading

0 comments on commit cf01e6e

Please sign in to comment.