diff --git a/api/api.go b/api/api.go index fd4b691793..283f4bb949 100644 --- a/api/api.go +++ b/api/api.go @@ -450,6 +450,8 @@ func (a *ApplicationHandler) BuildControlPlaneRoutes() *chi.Mux { portalLinkRouter.Get("/portal_link", handler.GetPortalLink) + portalLinkRouter.Get("/license/features", handler.GetLicenseFeatures) + portalLinkRouter.Route("/endpoints", func(endpointRouter chi.Router) { endpointRouter.With(middleware.Pagination).Get("/", handler.GetEndpoints) endpointRouter.Get("/{endpointID}", handler.GetEndpoint) @@ -660,6 +662,8 @@ func (a *ApplicationHandler) BuildDataPlaneRoutes() *chi.Mux { portalLinkRouter.Use(middleware.RequireValidPortalLinksLicense(handler.A.Licenser)) portalLinkRouter.Use(middleware.RequireAuth()) + portalLinkRouter.Get("/license/features", handler.GetLicenseFeatures) + portalLinkRouter.Route("/events", func(eventRouter chi.Router) { eventRouter.Post("/", handler.CreateEndpointEvent) eventRouter.With(middleware.Pagination).Get("/", handler.GetEventsPaged) diff --git a/datastore/models.go b/datastore/models.go index 72e6790ca0..de63679338 100644 --- a/datastore/models.go +++ b/datastore/models.go @@ -1049,7 +1049,7 @@ type Subscription struct { UID string `json:"uid" db:"id"` Name string `json:"name" db:"name"` Type SubscriptionType `json:"type" db:"type"` - ProjectID string `json:"-" db:"project_id"` + ProjectID string `json:"project_id" db:"project_id"` SourceID string `json:"-" db:"source_id"` EndpointID string `json:"-" db:"endpoint_id"` DeviceID string `json:"-" db:"device_id"` diff --git a/web/ui/dashboard/src/app/models/subscription.ts b/web/ui/dashboard/src/app/models/subscription.ts index 2015614ce5..16c25bbee2 100644 --- a/web/ui/dashboard/src/app/models/subscription.ts +++ b/web/ui/dashboard/src/app/models/subscription.ts @@ -11,6 +11,7 @@ export interface SUBSCRIPTION { status: string; type: 'outgoing' | 'incoming'; uid: string; + project_id: string; updated_at: string; endpoint_metadata?: ENDPOINT; alert_config?: { count: number; threshold: string }; diff --git a/web/ui/dashboard/src/app/portal/subscriptions/subscriptions.component.ts b/web/ui/dashboard/src/app/portal/subscriptions/subscriptions.component.ts index 89e60aaf51..04f9fd92dc 100644 --- a/web/ui/dashboard/src/app/portal/subscriptions/subscriptions.component.ts +++ b/web/ui/dashboard/src/app/portal/subscriptions/subscriptions.component.ts @@ -17,6 +17,7 @@ import { DropdownComponent, DropdownOptionDirective } from 'src/app/components/d import { PortalService } from '../portal.service'; import { DialogDirective } from 'src/app/components/dialog/dialog.directive'; import { TagComponent } from 'src/app/components/tag/tag.component'; +import { LicensesService } from '../../services/licenses/licenses.service'; @Component({ selector: 'convoy-subscriptions', @@ -43,10 +44,10 @@ export class SubscriptionsComponent implements OnInit { token: string = this.route.snapshot.queryParams.token; - constructor(private privateService: PrivateService, private generalService: GeneralService, private location: Location, private route: ActivatedRoute, private portalService: PortalService) {} + constructor(private privateService: PrivateService, private generalService: GeneralService, private location: Location, private route: ActivatedRoute, private portalService: PortalService, public licenseService: LicensesService) {} ngOnInit() { - Promise.all([this.getPortalDetails(), this.getSubscriptions()]); + Promise.all([this.getPortalDetails(), this.getSubscriptions(), this.licenseService.setLicenses()]); } async getPortalDetails() { @@ -71,10 +72,29 @@ export class SubscriptionsComponent implements OnInit { } openSubsriptionForm(action: 'create' | 'update') { + let project = localStorage.getItem("CONVOY_PROJECT"); + if (!project && this.activeSubscription?.project_id) { + localStorage.setItem( + 'CONVOY_PROJECT', + JSON.stringify({ uid: this.activeSubscription?.project_id }) + ); + } this.action = action; this.showSubscriptionForm = true; - this.location.go(`/portal/subscriptions/${action === 'create' ? 'new' : this.activeSubscription?.uid}?token=${this.token}${this.activeSubscription || this.endpointId ? `&endpointId=${this.activeSubscription?.uid || this.endpointId}` : ''}`); - } + let subscriptionPath = '/portal/subscriptions/'; + if (action === 'create') { + subscriptionPath += 'new'; + } else if (this.activeSubscription?.uid) { + subscriptionPath += this.activeSubscription.uid; + } + + let queryParams = `?token=${this.token}`; + if (this.endpointId) { + queryParams += `&endpointId=${this.endpointId}`; + } + + this.location.go(subscriptionPath + queryParams); + } async deleteSubscripton() { this.isDeletingSubscription = true;