diff --git a/src/app/components/mno-apps/mno-app.coffee b/src/app/components/mno-products/mno-product.coffee
similarity index 88%
rename from src/app/components/mno-apps/mno-app.coffee
rename to src/app/components/mno-products/mno-product.coffee
index b34d5fde..d83d5d02 100644
--- a/src/app/components/mno-apps/mno-app.coffee
+++ b/src/app/components/mno-products/mno-product.coffee
@@ -1,6 +1,6 @@
angular.module 'mnoEnterpriseAngular'
- .controller('mnoApp',($q, $scope, $stateParams, $state, $sce, $window, $uibModal, $anchorScroll,
- $location, isPublic, parentState, toastr, MnoeMarketplace, MnoeOrganizations, MnoeCurrentUser, MnoeAppInstances, MnoConfirm, MnoeConfig, ProvisioningHelper) ->
+ .controller('mnoProduct',($q, $scope, $stateParams, $state, $sce, $window, $uibModal, $anchorScroll,
+ $location, isPublic, parentState, toastr, MnoeMarketplace, MnoeOrganizations, MnoeCurrentUser, MnoConfirm, MnoeConfig, ProvisioningHelper) ->
vm = this
#====================================
@@ -13,7 +13,7 @@ angular.module 'mnoEnterpriseAngular'
vm.app = {}
vm.searchWord = ""
# The already installed app instance of the app, if any
- vm.appInstance = null
+ vm.productInstalled = null
# An already installed app, conflicting with the app because it contains a common subcategory
# that is not multi instantiable, if any
vm.conflictingApp = null
@@ -37,44 +37,61 @@ angular.module 'mnoEnterpriseAngular'
vm.pricedPlan = ProvisioningHelper.pricedPlan
- getPricingPlans = (app) ->
- if vm.isPriceShown
- plans = vm.app.pricing_plans
- currency = MnoeConfig.marketplaceCurrency()
- vm.pricing_plans = plans[currency] || plans.AUD || plans.default
-
# Public initialization - app only, without considering reviews/org
- MnoeMarketplace.getApps().then(
- (response) ->
- apps = response.apps
+ # MnoeMarketplace.getApps().then(
+ # (response) ->
+ # apps = response.apps
+ #
+ # # App to be displayed
+ # appId = $stateParams.appId
+ # vm.app = _.findWhere(apps, { nid: appId })
+ # vm.app ||= _.findWhere(apps, { id: appId })
+ #
+ # $state.go(parentState) unless vm.app?
+ # vm.isLoading = false
+ # )
- # App to be displayed
- appId = $stateParams.appId
- vm.app = _.findWhere(apps, { nid: appId })
- vm.app ||= _.findWhere(apps, { id: appId })
+ #====================================
+ # Pricings
+ #====================================
+ # Return true if the plan has a dollar value
+ vm.pricedPlan = ProvisioningHelper.pricedPlan
- # Init Pricing Plans
- getPricingPlans(vm.app)
+ vm.pricingPlans = () ->
+ _.map(vm.product.pricing_plans, (pricingPlan) ->
+ return pricingPlan unless vm.pricedPlan(pricingPlan)
+ # If its a pricedPlan, only show prices of appropriate currency.
+ pricingPlan.prices = _.filter(pricingPlan.prices, (price) ->
+ price.currency == vm.currency
+ )
- $state.go(parentState) unless vm.app?
- vm.isLoading = false
+ pricingPlan
)
+ vm.showNoPricingFound = (plan) ->
+ _.isEmpty(plan.prices) && vm.pricedPlan(plan)
+
#====================================
# Scope Management
#====================================
- vm.initialize = (app, appInstance, product) ->
+
+ vm.initialize = (product) ->
# Variables initialization
vm.userId = MnoeCurrentUser.user.id
vm.adminRole = MnoeCurrentUser.user.admin_role
# Init current app and app instance
- vm.app = app
- vm.appInstance = appInstance
+ vm.product = product
+ vm.productInstalled = !_.isEmpty(product.productInstances)
# Is the product externally provisioned
vm.isExternallyProvisioned = (vm.isProvisioningEnabled && product?.externally_provisioned)
+ # Init pricing plans
+ vm.currency = MnoeConfig.marketplaceCurrency()
+ vm.pricing_plans = vm.pricingPlans()
+
+ # Get the user role in this organization
MnoeOrganizations.get().then((response) -> vm.user_role = response.current_user.role)
# Init initials reviews if enabled
@@ -443,30 +460,10 @@ angular.module 'mnoEnterpriseAngular'
if val?
vm.isLoading = true
- productPromise = if MnoeConfig.isProvisioningEnabled() then MnoeMarketplace.getProducts() else $q.resolve()
-
- # Retrieve the apps and if any the current app instance
- $q.all(
- marketplace: MnoeMarketplace.getApps(),
- appInstances: MnoeAppInstances.getAppInstances(),
- products: productPromise
- ).then(
+ # Retrieve the product and if any the current product instance
+ MnoeMarketplace.getProduct($stateParams.productId).then(
(response) ->
- apps = response.marketplace.apps
- appInstances = response.appInstances
- products = response.products?.products
-
- # App to be displayed
- appId = $stateParams.appId
- app = _.findWhere(apps, { nid: appId })
- app ||= _.findWhere(apps, { id: appId })
-
- $state.go(parentState) unless app?
-
- # Find if we already have it
- appInstance = _.find(appInstances, { app_nid: app.nid })
- product = _.find(products, { nid: app.nid })
- vm.initialize(app, appInstance, product)
+ vm.initialize(response)
)
return
diff --git a/src/app/components/mno-apps/mno-app.html b/src/app/components/mno-products/mno-product.html
similarity index 87%
rename from src/app/components/mno-apps/mno-app.html
rename to src/app/components/mno-products/mno-product.html
index d2e8c731..e1b0e918 100644
--- a/src/app/components/mno-apps/mno-app.html
+++ b/src/app/components/mno-products/mno-product.html
@@ -8,10 +8,10 @@
-
+
{{'mno_enterprise.templates.dashboard.marketplace.show.answer_q' | translate}}
{{'mno_enterprise.templates.dashboard.marketplace.show.edit_q' | translate}}
diff --git a/src/app/components/mnoe-api/marketplace.svc.coffee b/src/app/components/mnoe-api/marketplace.svc.coffee
index a084e6cf..8816771b 100644
--- a/src/app/components/mnoe-api/marketplace.svc.coffee
+++ b/src/app/components/mnoe-api/marketplace.svc.coffee
@@ -1,7 +1,6 @@
# Service for the listing of Apps on the Markeplace
# MnoeMarketplace.getList()
-# .getApps()
# => GET /mnoe/jpi/v1/marketplace
# Return the list off apps and categories
# {categories: [], apps: []}
@@ -9,33 +8,14 @@ angular.module 'mnoEnterpriseAngular'
.service 'MnoeMarketplace', ($log, MnoeApiSvc, MnoeOrganizations, MnoeFullApiSvc) ->
_self = @
- _transform_products = (products) ->
- _.map(products, (product) ->
- # Transforms the values_attributes ([name: 'Some string', data: 'Its value'])
- # to attributes (vm.product.some_string)
- _.each(product.values_attributes, (v) ->
- try
- product[_.snakeCase(v.name)] = JSON.parse(v.data)
- catch
- product[_.snakeCase(v.name)] = v.data
- )
- product.screenshots = _.map(product.assets_attributes, (a) -> a.url)
-
- product
- )
-
# Using this syntax will not trigger the data extraction in MnoeApiSvc
# as the /marketplace payload isn't encapsulated in "{ marketplace: categories {...}, apps {...} }"
marketplacePromises = []
- @getApps = ->
+ @getMarketplace = ->
params = {organization_id: MnoeOrganizations.selectedId}
paramsKey = JSON.stringify(params)
return marketplacePromises[paramsKey] if marketplacePromises[paramsKey]?
- marketplacePromises[paramsKey] = MnoeApiSvc.oneUrl('/marketplace').get(params).then(
- (response) ->
- response.products = _transform_products(response.products)
- response
- )
+ marketplacePromises[paramsKey] = MnoeApiSvc.oneUrl('/marketplace').get(params)
productsPromise = []
@getProducts = ->
@@ -44,8 +24,7 @@ angular.module 'mnoEnterpriseAngular'
return productsPromise[paramsKey] if productsPromise[paramsKey]?
productsPromise[paramsKey] = MnoeApiSvc.oneUrl('/products').get(params).then(
(response) ->
- response.products = _transform_products(response.products)
- response.plain()
+ response.plain().products
)
# Find a product using its id or nid
@@ -55,23 +34,8 @@ angular.module 'mnoEnterpriseAngular'
_.find(response.products, (a) -> a.id == id || a.nid == nid)
)
- localProductsPromise = []
- @getLocalProducts = (limit, offset, sort, params = {}) ->
- params['organization_id'] = MnoeOrganizations.selectedId
- params['where[local]'] = 'true'
- paramsKey = JSON.stringify([limit, offset, sort, params])
- return localProductsPromise[paramsKey] if localProductsPromise[paramsKey]?
- localProductsPromise[paramsKey] = MnoeApiSvc.all('products').getList(params).then(
- (response) ->
- _transform_products(response.plain())
- )
-
@getProduct = (productId) ->
- MnoeApiSvc.one('/products', productId).get().then(
- (response) ->
- _transform_products([response])
- response
- )
+ MnoeApiSvc.one('/products', productId).get().then((response) -> response.plain())
@getReview = (appId, reviewId) ->
MnoeApiSvc.one('marketplace', appId).one('app_reviews', parseInt(reviewId)).get()
diff --git a/src/app/components/mnoe-config/mnoe-config.svc.coffee b/src/app/components/mnoe-config/mnoe-config.svc.coffee
index 498b6a15..42f76454 100644
--- a/src/app/components/mnoe-config/mnoe-config.svc.coffee
+++ b/src/app/components/mnoe-config/mnoe-config.svc.coffee
@@ -143,9 +143,9 @@ angular.module 'mnoEnterpriseAngular'
else
$log.debug("DASHBOARD_CONFIG.public_pricing.display_pricing missing")
- @publicApplications = () ->
- if DASHBOARD_CONFIG.public_pages?.applications?
- DASHBOARD_CONFIG.public_pages.applications
+ @publicProducts = () ->
+ if DASHBOARD_CONFIG.public_pages?.products?
+ DASHBOARD_CONFIG.public_pages.products
else
$log.debug("DASHBOARD_CONFIG.public_pages.applications missing")
[]
diff --git a/src/app/components/theme-editor/theme-editor.directive.coffee b/src/app/components/theme-editor/theme-editor.directive.coffee
index 12e03240..babe3f78 100644
--- a/src/app/components/theme-editor/theme-editor.directive.coffee
+++ b/src/app/components/theme-editor/theme-editor.directive.coffee
@@ -315,7 +315,7 @@ ThemeEditorCtrl = ($scope, $window, $log, $timeout, toastr, themeEditorSvc) ->
'@dashboard-marketplace-show-sections-bg-color': '@bg-on-bg-inverse-color'
'@dashboard-marketplace-show-sections-text-color': '@text-strong-color'
- '@dashboard-marketplace-app-card': '{ display: block; padding: 10px; height: 120px; margin-bottom: 10px; font-weight: 300; }'
+ '@dashboard-marketplace-product-card': '{ display: block; padding: 10px; height: 120px; margin-bottom: 10px; font-weight: 300; }'
},
'Reviews & Comments Section': {
diff --git a/src/app/index.route.coffee b/src/app/index.route.coffee
index fe9a8cba..88d0e726 100644
--- a/src/app/index.route.coffee
+++ b/src/app/index.route.coffee
@@ -23,9 +23,9 @@ angular.module 'mnoEnterpriseAngular'
.state 'public.product',
data:
pageTitle: "Product Preview"
- url: '/product/:appId'
- templateUrl: 'app/components/mno-apps/mno-app.html'
- controller: 'mnoApp'
+ url: '/product/:productId'
+ templateUrl: 'app/components/mno-product/mno-product.html'
+ controller: 'mnoProduct'
controllerAs: 'vm'
resolve: {
isPublic: -> true
@@ -144,13 +144,13 @@ angular.module 'mnoEnterpriseAngular'
templateUrl: 'app/views/marketplace/marketplace.html'
controller: 'DashboardMarketplaceCtrl'
controllerAs: 'vm'
- .state 'home.marketplace.app',
+ .state 'home.marketplace.product',
data:
pageTitle:'Marketplace'
- url: '^/marketplace/:appId'
+ url: '^/marketplace/:productId'
views: '@home':
- templateUrl: 'app/components/mno-apps/mno-app.html',
- controller: 'mnoApp'
+ templateUrl: 'app/components/mno-products/mno-product.html',
+ controller: 'mnoProduct'
controllerAs: 'vm'
resolve: {
isPublic: -> false
diff --git a/src/app/index.run.coffee b/src/app/index.run.coffee
index ff0c1c4d..068a614f 100644
--- a/src/app/index.run.coffee
+++ b/src/app/index.run.coffee
@@ -81,9 +81,7 @@ angular.module 'mnoEnterpriseAngular'
orgPromise = MnoeOrganizations.getCurrentOrganisation().then(
(response) ->
# Pre-load the marketplace, the products and the local products
- MnoeMarketplace.getApps()
- MnoeMarketplace.getProducts() if MnoeConfig.isProvisioningEnabled()
- MnoeMarketplace.getLocalProducts() if MnoeConfig.areLocalProductsEnabled()
+ MnoeMarketplace.getMarketplace()
# App instances needs to be run after fetching the organization (At least the first call)
MnoeAppInstances.getAppInstances().then(
diff --git a/src/app/stylesheets/variables.less b/src/app/stylesheets/variables.less
index 03ee0e14..65dc0afe 100644
--- a/src/app/stylesheets/variables.less
+++ b/src/app/stylesheets/variables.less
@@ -71,7 +71,7 @@
@landing-marketplace-tile-hover-name-color: @landing-marketplace-tile-name-color;
@landing-marketplace-tile-hover-img-border-color: darken(@landing-marketplace-tile-img-border-color,10%);
@landing-marketplace-tile-hover-arrow-color: @text-strong-color;
-@landing-marketplace-app-card: { display: block; padding: 10px; height: 120px; margin-bottom: 10px; font-weight: 300; };
+@landing-marketplace-product-card: { display: block; padding: 10px; height: 120px; margin-bottom: 10px; font-weight: 300; };
@public-marketplace-show-header-text-color: @text-strong-color;
@public-marketplace-show-sections-bg-color: @bg-on-bg-inverse-color;
@@ -398,7 +398,7 @@
@dashboard-marketplace-show-sections-bg-color: @bg-on-bg-inverse-color;
@dashboard-marketplace-show-sections-text-color: @text-strong-color;
-@dashboard-marketplace-app-card: { display: block; padding: 10px; height: 120px; margin-bottom: 10px; font-weight: 300; };
+@dashboard-marketplace-product-card: { display: block; padding: 10px; height: 120px; margin-bottom: 10px; font-weight: 300; };
@provisioning-breadcrumb-item-color: @text-strong-color;
@provisioning-breadcrumb-item-badge-bg: @decorator-main-color;
diff --git a/src/app/views/marketplace/marketplace.html b/src/app/views/marketplace/marketplace.html
index 26292f3f..fe613507 100644
--- a/src/app/views/marketplace/marketplace.html
+++ b/src/app/views/marketplace/marketplace.html
@@ -4,15 +4,15 @@
{{ 'mno_enterprise.templates.dashboard.marketplace.ind
{{ 'mno_enterprise.templates.dashboard.marketplace.index.applications' | translate }}
-
+
mno_enterprise.templates.dashboard.marketplace.index.reseller_products
-
+
-
+
diff --git a/src/app/views/marketplace/marketplace.less b/src/app/views/marketplace/marketplace.less
index fcd15a6d..37b9f267 100644
--- a/src/app/views/marketplace/marketplace.less
+++ b/src/app/views/marketplace/marketplace.less
@@ -36,12 +36,12 @@
//-------------------------------
// App Card
//-------------------------------
- .marketplace-app-card {
+ .marketplace-product-card {
position: relative;
background-color: @dashboard-marketplace-tile-bg-color;
color: @dashboard-marketplace-tile-text-color;
cursor: pointer;
- @dashboard-marketplace-app-card();
+ @dashboard-marketplace-product-card();
img.media-object {
max-width: 100px;
@@ -64,7 +64,7 @@
}
}
- .marketplace-app-card-checkbox {
+ .marketplace-product-card-checkbox {
position: absolute;
top: 0;
left: 0;
@@ -81,33 +81,33 @@
}
// Application logo
- .marketplace-app-card img.media-object {
+ .marketplace-product-card img.media-object {
max-width: 100px;
border: solid 1px @dashboard-marketplace-tile-img-border-color;
border-radius: 5px;
}
- .marketplace-app-card:hover img.media-object {
+ .marketplace-product-card:hover img.media-object {
border: solid 1px darken(@dashboard-marketplace-tile-hover-img-border-color,5%);
}
// Application Description
- .marketplace-app-card .media-body {
+ .marketplace-product-card .media-body {
padding-right: 10px;
color: @dashboard-marketplace-tile-text-color;
}
- .marketplace-app-card:hover .media-body {
+ .marketplace-product-card:hover .media-body {
color: @dashboard-marketplace-tile-hover-text-color;
}
// App tile arrow right
- .marketplace-app-card .arrow {
+ .marketplace-product-card .arrow {
position: absolute;
right: 20px;
top: 50px;
color: @dashboard-marketplace-tile-hover-arrow-color;
visibility: hidden;
}
- .marketplace-app-card:hover .arrow {
+ .marketplace-product-card:hover .arrow {
visibility: visible;
}
}
diff --git a/src/app/views/public/landing/landing.html b/src/app/views/public/landing/landing.html
index 60b3d096..f7b95842 100644
--- a/src/app/views/public/landing/landing.html
+++ b/src/app/views/public/landing/landing.html
@@ -40,16 +40,16 @@
{{ 'mno_enterprise.templates.dashboard.marketplace.index.applications' | translate }}
-
+
mno_enterprise.templates.dashboard.marketplace.index.reseller_products
-
+
{{ 'mno_enterprise.templates.dashboard.marketplace.show.price' | translate }
{{ 'mno_enterprise.templates.dashboard.marketplace.show.price' | translate }