Skip to content

Commit

Permalink
Utilize only the provided project
Browse files Browse the repository at this point in the history
getting rid of the idea of a default project
  • Loading branch information
NeoScript committed Feb 9, 2024
1 parent e6ae138 commit 9d90f17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions webapp/src/app/components/projects/projects.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export class ProjectsComponent implements OnInit {
topicList2$: Observable<Topic[]> = EMPTY
subscriptionList$: Observable<Subscription[]> = EMPTY

currentProject?: string
currentProject: string = ""
currentTopic?: Topic
currentSubscription?: Subscription

constructor(private route: ActivatedRoute, private pubsub: PubsubService) { }

ngOnInit(): void {
this.route.queryParamMap.subscribe(qpm => {
this.currentProject = qpm.get("project") ?? undefined
this.currentProject = qpm.get("project") ?? ""

console.log("loaded project: ", this.currentProject)
this.pubsub.selectProject(this.currentProject!)
Expand Down
13 changes: 6 additions & 7 deletions webapp/src/app/services/pubsub.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { NewSubscriptionRequest } from '../components/subscription-list/new-subs
providedIn: 'root'
})
export class PubsubService {
project_id = "test-project"
public currentHost = "http://localhost:8681"

private _projectList = new BehaviorSubject<string[]>(["test-project"])
private _projectList = new BehaviorSubject<string[]>([])
private _currentProject = new ReplaySubject<string>()
private _currentTopic = new ReplaySubject<Topic>()
private _currentSubscription = new ReplaySubject<Subscription>()
Expand Down Expand Up @@ -39,14 +38,14 @@ export class PubsubService {
this._projectList.next(newList)
}

createTopic(projectId: string = this.project_id, topicId: string){
createTopic(projectId: string, topicId: string){
const url = `${this.currentHost}/v1/projects/${projectId}/topics/${topicId}`

return this.http.put<Topic>(url, {})
}

listTopics(projectId: string = this.project_id) {
return this.http.get<{ topics: Topic[] }>(`${this.currentHost}/v1/projects/${this.project_id}/topics`).pipe(map(incoming => incoming?.topics || []))
listTopics(projectId: string) {
return this.http.get<{ topics: Topic[] }>(`${this.currentHost}/v1/projects/${projectId}/topics`).pipe(map(incoming => incoming?.topics || []))
}

createSubscription(projectId: string, request: NewSubscriptionRequest){
Expand All @@ -60,8 +59,8 @@ export class PubsubService {
return this.http.delete(url)
}

listSubscriptions(): Observable<Subscription[]> {
return this.http.get<{ subscriptions?: string[] }>(`${this.currentHost}/v1/projects/${this.project_id}/subscriptions`)
listSubscriptions(projectId: string): Observable<Subscription[]> {
return this.http.get<{ subscriptions?: string[] }>(`${this.currentHost}/v1/projects/${projectId}/subscriptions`)
.pipe(
map(incoming => incoming.subscriptions), // first we pull out the subscriptions object
map(subNames => subNames??[]),
Expand Down

0 comments on commit 9d90f17

Please sign in to comment.