Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNOE-206] Add pricing details to dock settings #82

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"less": "~2.5.3",
"lodash": "~3.10.1",
"ng-page-title": "^1.1.1",
"restangular": "~1.5.1"
"restangular": "~1.5.1",
"angular-translate-interpolation-messageformat": "^2.13.1"
},
"devDependencies": {
"angular-mocks": "~1.6.0"
Expand All @@ -46,6 +47,17 @@
"less/font-awesome.less",
"./fonts/*"
]
},
"moment": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to do this? We already import angular-moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @alexnoox
In angular moment docs:

Usage
Include both moment.js and angular-moment.js in your application.

My input
This solution is out of the box and works by loading the different locales files we need in the project from the bower.json. The best part is that we can load all of them, or also only the ones we need. I specified id and ch to avoid having unnecessary extra files, but it can be extended anytime!
"moment": {
"main": [
"moment.js",
"locale/*.js"

Once it is loaded, by passing the locale we are using to moment in the run, or in the select language box for changing it.

moment.locale(TheLocaleWeAreUsing)

The language will be set globally and therefore propagated to every bit in the code where we are binding the result of moment.
The default language is English, it does not need to be loaded.
I tried with Chinese, french and Indonesian and seems to work perfectly fine, so it is very easy to extend.

"main": [
"moment.js",
"locale/id.js",
"locale/zh-cn.js"
]
}
},
"resolutions": {
"angular": ">=1.2.0 <1.7.0",
"angular-translate": "~2.15.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ angular.module 'mnoEnterpriseAngular'
->
# Success
$translate.use($scope.selectedLangKey)
moment.locale($scope.selectedLangKey)
$window.location.href = "/#{$scope.selectedLangKey}#{URI.dashboard}"
->
# Error
Expand Down
2 changes: 1 addition & 1 deletion src/app/index.config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ angular.module 'mnoEnterpriseAngular'
prefix: 'locales/',
suffix: '.locale.json'
})

$translateProvider.addInterpolation('$translateMessageFormatInterpolation')
$translateProvider.fallbackLanguage(LOCALES.fallbackLanguage)
$translateProvider.useSanitizeValueStrategy('sanitizeParameters')

Expand Down
1 change: 1 addition & 0 deletions src/app/index.run.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ angular.module 'mnoEnterpriseAngular'
locale = LOCALES.preferredLocale

$translate.use(locale)
moment.locale(locale)
)

# Override the default toastr template to use angular-translate
Expand Down
19 changes: 11 additions & 8 deletions src/app/views/apps/modals/app-settings-modal.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ angular.module 'mnoEnterpriseAngular'

$scope.modal ||= {}
$scope.app = app
$scope.app.free_trial_end_at_humanized = moment(app.free_trial_end_at).format('dddd, MMMM Do YYYY')
$scope.sentence = "Please proceed to the deletion of my app and all data it contains"
$scope.organization_uid = ImpacMainSvc.config.currentOrganization.uid

# ----------------------------------------------------------
# Permissions helper
# ----------------------------------------------------------

$scope.helper = {}
$scope.helper.canDeleteApp = ->
MnoeOrganizations.can.destroy.appInstance()

$scope.modal.close = ->
$uibModalInstance.close()

Expand All @@ -31,6 +24,16 @@ angular.module 'mnoEnterpriseAngular'
$scope.modal.errors = Utilities.processRailsError(error)
).finally(-> $scope.modal.loading = false)

# ----------------------------------------------------------
# Permissions helper
# ----------------------------------------------------------
$scope.helper = {}
$scope.helper.canDeleteApp = ->
MnoeOrganizations.can.destroy.appInstance()

$scope.helper.canDisplayBilling = ->
MnoeOrganizations.can.read.billing()

$scope.helper.isDataSyncShown = (app) ->
app.stack == 'connector' && app.oauth_keys_valid

Expand Down
21 changes: 13 additions & 8 deletions src/app/views/apps/modals/app-settings-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ <h3><b>{{ 'mno_enterprise.templates.impac.dock.settings.settings' | translate }}
</div>
</div>
</div>

<!-- Add on settings -->
<div ng-show="helper.isAddOnSettingShown(app)">
<hr>
<button ng-click="helper.addOnSettingLauch(app)" class="btn btn-warning">{{ 'mno_enterprise.templates.impac.dock.settings.access_add-on_settings' | translate }}</button>
</div>

<!-- Billing Details -->
<div ng-show="helper.canDisplayBilling()">
<hr>
<div ng-show="!!app.free_trial_end_at">
{{ 'mno_enterprise.templates.impac.dock.settings.free_trial' | translate }}: {{ app.free_trial_end_at_humanized }}
</div>
<div ng-show="!app.free_trial_end_at && app.per_user_licence">
<p translate="mno_enterprise.templates.impac.dock.settings.nb_of_users" translate-values="{ num_users: app.licences_count }" translate-interpolation="messageformat"></p>
</div>
<div ng-show="!app.app.free_trial_end_at && !app.per_user_licence">{{ 'mno_enterprise.templates.impac.dock.settings.pricing_details' | translate }}</div>
</div>
<!-- Data Sharing -->
<div ng-show="helper.isDataSyncShown(app) || helper.isDataDisconnectShown(app)">
<hr>
Expand All @@ -41,7 +50,6 @@ <h3><b>{{ 'mno_enterprise.templates.impac.dock.settings.settings' | translate }}
<span class="title">{{ 'mno_enterprise.templates.impac.dock.settings.manual_data_sharing' | translate }}</span>
</div>
<div class="col-md-8">

<!-- Connected company name -->
<div ng-show="helper.companyName(app)">
{{ 'mno_enterprise.templates.impac.dock.settings.linked_to' | translate }}: {{ helper.companyName(app) | truncate:45 }}
Expand All @@ -55,7 +63,6 @@ <h3><b>{{ 'mno_enterprise.templates.impac.dock.settings.settings' | translate }}
<a class="btn btn-info" ng-href="{{helper.dataSyncPath(app)}}" uib-tooltip="{{ 'mno_enterprise.templates.dashboard.apps_list.manual_data_sync_tooltip' | translate:{ appname: app.app_name } }}">{{ 'mno_enterprise.templates.impac.dock.settings.manual_data_sync' | translate }}</a>
</div>
</div>

<!-- Data Disconnect Button -->
<div ng-show="helper.isDataDisconnectShown(app)">
<a class="btn btn-danger" ng-click="helper.dataDisconnectClick(app)" href="" uib-tooltip="{{ 'mno_enterprise.templates.dashboard.apps_list.disconnect_link_tooltip' | translate:{ appname: app.app_name } }}">
Expand All @@ -64,7 +71,6 @@ <h3><b>{{ 'mno_enterprise.templates.impac.dock.settings.settings' | translate }}
</div>
</div>
</div>

<!-- Deletion -->
<hr>
<div ng-show="helper.canDeleteApp()" class="app-deletion">
Expand All @@ -86,13 +92,12 @@ <h4>{{ 'mno_enterprise.templates.impac.dock.settings.confirm_app_deletion' | tra
</div>
<div class="buttons">
<button class="btn btn-default" ng-click="app.showDelete=false" >{{ 'mno_enterprise.templates.impac.dock.settings.cancel' | translate}}</button>
<button class="btn btn-danger" ng-click="deleteApp()" ng-disabled="sentence != sentenceCheck || modal.loading">
<span ng-show="modal.loading"><i class="fa fa-spinner fa-pulse"></i>&nbsp;</span>
<button class="btn btn-danger" ng-click="deleteApp()" ng-disabled="sentence != sentenceCheck">
<span ng-show="modal.loading"><i class="fa fa-spinner fa-spin"></i>&nbsp;</span>
{{ 'mno_enterprise.templates.impac.dock.settings.delete' | translate }} </button>
</div>
</div>
</div>

<!-- Developer details -->
<div ng-show="helper.canDeleteApp()">
<hr>
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en.locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,10 @@
"mno_enterprise.templates.impac.dock.settings.manual_data_sync": "Manual Data Sync",
"mno_enterprise.templates.impac.dock.settings.disconnect_link": "Disconnect Link",
"mno_enterprise.templates.impac.dock.settings.delete": "Delete",
"mno_enterprise.templates.impac.dock.settings.pricing_details": "Pricing details inside your app",
"mno_enterprise.templates.impac.dock.settings.free_trial": "Free Trial",
"mno_enterprise.templates.impac.dock.settings.number_of_people_tooltip": "This is the total number of people in your organization using",
"mno_enterprise.templates.impac.dock.settings.nb_of_users": "{num_users, plural, =0{No users} =1{1 user} other{# users}}",
"mno_enterprise.templates.impac.dock.settings.confirm_app_deletion": "Confirm app deletion",
"mno_enterprise.templates.impac.dock.settings.please_note_this_app": "Please note this app is on a monthly plan. Your billing for this app will be calculated pro rata.",
"mno_enterprise.templates.impac.dock.settings.delete_instructions": "In order to delete your app, please enter the following statement in the box below.",
Expand Down