Skip to content

Commit be980fc

Browse files
committed
show bookmarks details when click from left menu - right click to go directly to link
1 parent 59bfba4 commit be980fc

14 files changed

+244
-170
lines changed

backend/src/routes/public/public-bookmarks.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let getBookmarksForTag = async (tag, orderBy, page, limit) => {
5252

5353
/* GET bookmark by id. */
5454
let getBookmarkById = async function (bookmarkId) {
55-
const bookmark = await Bookmark.find({
55+
const bookmark = await Bookmark.findOne({
5656
public: true,
5757
_id: bookmarkId
5858
});

frontend/src/app/app.component.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@
6161
class="badge badge-secondary mb-1 ml-2"
6262
[class.my-bookmarks-last-search]="bookmark.public === false"
6363
[class.public-bookmarks-last-search]="bookmark.public === true"
64-
href="{{bookmark.location}}"
65-
title="Go to {{bookmark.name}}"
66-
(click)="addToHistoryService.promoteInHistoryIfLoggedIn(userIsLoggedIn, bookmark)"
67-
(auxclick)="addToHistoryService.promoteInHistoryIfLoggedIn(userIsLoggedIn, bookmark)"
64+
title="See bookmark details. Right click to go directly to main link - {{bookmark.location}}"
65+
(click)="navigateToBookmarkDetails(bookmark)"
66+
(auxclick)="goToMainLink(bookmark)"
6867
target="_blank">
6968
<i class="fa fa-xs fa-bookmark mr-1"></i>
7069
<span

frontend/src/app/app.component.ts

Lines changed: 168 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -17,184 +17,198 @@ import { Search, UserData } from './core/model/user-data';
1717
import { Observable } from 'rxjs';
1818
import { map } from 'rxjs/operators';
1919
import { Bookmark } from './core/model/bookmark';
20-
import { AddToHistoryService } from './core/user/add-to-history.service';
20+
import { Router } from '@angular/router';
2121

2222
@Component({
23-
selector: 'app-root',
24-
templateUrl: './app.component.html',
25-
styleUrls: ['./app.component.scss'],
23+
selector: 'app-root',
24+
templateUrl: './app.component.html',
25+
styleUrls: ['./app.component.scss'],
2626
})
2727
export class AppComponent implements OnInit {
2828

29-
url = 'https://www.codever.land';
30-
innerWidth: any;
31-
32-
userIsLoggedIn = false;
33-
userId: string;
34-
35-
userData$: Observable<UserData>;
36-
showAcknowledgeMigrationHeader = false;
37-
latestSearches$: Observable<Search[]>;
38-
latestVisitedBookmarks$: Observable<Bookmark[]>;
39-
40-
private hoveringLastSearches: boolean[] = [];
41-
private hoveringLastVisited: boolean[] = [false, false, false, false, false, false, false, false, false, false];
42-
43-
constructor(private keycloakService: KeycloakService,
44-
private userInfoStore: UserInfoStore,
45-
private userDataStore: UserDataStore,
46-
private userDataHistoryStore: UserDataHistoryStore,
47-
private userDataPinnedStore: UserDataPinnedStore,
48-
private historyDialog: MatDialog,
49-
private loginDialog: MatDialog,
50-
private cookieService: CookieService,
51-
private feedbackService: FeedbackService,
52-
private addToHistoryService: AddToHistoryService) {
53-
this.innerWidth = 100;
29+
url = 'https://www.codever.land';
30+
innerWidth: any;
31+
32+
userIsLoggedIn = false;
33+
userId: string;
34+
35+
userData$: Observable<UserData>;
36+
showAcknowledgeMigrationHeader = false;
37+
latestSearches$: Observable<Search[]>;
38+
latestVisitedBookmarks$: Observable<Bookmark[]>;
39+
40+
private hoveringLastSearches: boolean[] = [];
41+
private hoveringLastVisited: boolean[] = [false, false, false, false, false, false, false, false, false, false];
42+
43+
constructor(private keycloakService: KeycloakService,
44+
private userInfoStore: UserInfoStore,
45+
private userDataStore: UserDataStore,
46+
private userDataHistoryStore: UserDataHistoryStore,
47+
private userDataPinnedStore: UserDataPinnedStore,
48+
private historyDialog: MatDialog,
49+
private loginDialog: MatDialog,
50+
private cookieService: CookieService,
51+
private feedbackService: FeedbackService,
52+
protected router: Router) {
53+
this.innerWidth = 100;
54+
}
55+
56+
ngOnInit(): void {
57+
const acknowledgedCodeverMigration = this.cookieService.readCookie('acknowledge-codever-migration');
58+
if (acknowledgedCodeverMigration !== 'true') {
59+
this.showAcknowledgeMigrationHeader = true;
5460
}
5561

56-
ngOnInit(): void {
57-
const acknowledgedCodeverMigration = this.cookieService.readCookie('acknowledge-codever-migration');
58-
if (acknowledgedCodeverMigration !== 'true') {
59-
this.showAcknowledgeMigrationHeader = true;
60-
}
61-
62-
this.keycloakService.isLoggedIn().then(isLoggedIn => {
63-
if (isLoggedIn) {
64-
this.userIsLoggedIn = true;
65-
this.userInfoStore.getUserInfo$().subscribe(userInfo => {
66-
this.userId = userInfo.sub;
67-
this.latestVisitedBookmarks$ = this.userDataHistoryStore.getHistory$(this.userId, 1);
68-
});
69-
this.userData$ = this.userDataStore.getUserData$();
70-
this.latestSearches$ = this.userData$.pipe(
71-
map(userData => {
72-
for (let i = 0; i < 10; i++) {
73-
this.hoveringLastSearches.push(false);
74-
}
75-
return userData.searches.slice(0, 10);
76-
})
77-
)
78-
}
62+
this.keycloakService.isLoggedIn().then(isLoggedIn => {
63+
if (isLoggedIn) {
64+
this.userIsLoggedIn = true;
65+
this.userInfoStore.getUserInfo$().subscribe(userInfo => {
66+
this.userId = userInfo.sub;
67+
this.latestVisitedBookmarks$ = this.userDataHistoryStore.getHistory$(this.userId, 1);
7968
});
80-
}
81-
82-
@HostListener('window:keydown.control.p', ['$event'])
83-
showPinned(event: KeyboardEvent) {
84-
if (!this.userIsLoggedIn) {
85-
const dialogConfig = new MatDialogConfig();
86-
87-
dialogConfig.disableClose = true;
88-
dialogConfig.autoFocus = true;
89-
dialogConfig.data = {
90-
message: 'You need to be logged in to see the Pinned Bookmarks popup'
91-
};
92-
93-
this.loginDialog.open(LoginRequiredDialogComponent, dialogConfig);
94-
} else {
95-
event.preventDefault();
96-
const dialogConfig = new MatDialogConfig();
97-
98-
dialogConfig.disableClose = false;
99-
dialogConfig.autoFocus = true;
100-
dialogConfig.width = this.getRelativeWidth();
101-
dialogConfig.height = this.getRelativeHeight();
102-
dialogConfig.data = {
103-
bookmarks$: this.userDataPinnedStore.getPinnedBookmarks$(this.userId, 1),
104-
title: '<i class="fas fa-thumbtack"></i> Pinned'
105-
};
106-
107-
const dialogRef = this.historyDialog.open(HotKeysDialogComponent, dialogConfig);
108-
dialogRef.afterClosed().subscribe(
109-
data => {
110-
console.log('Dialog output:', data);
111-
}
112-
);
69+
this.userData$ = this.userDataStore.getUserData$();
70+
this.latestSearches$ = this.userData$.pipe(
71+
map(userData => {
72+
for (let i = 0; i < 10; i++) {
73+
this.hoveringLastSearches.push(false);
74+
}
75+
return userData.searches.slice(0, 10);
76+
})
77+
)
78+
}
79+
});
80+
}
81+
82+
@HostListener('window:keydown.control.p', ['$event'])
83+
showPinned(event: KeyboardEvent) {
84+
if (!this.userIsLoggedIn) {
85+
const dialogConfig = new MatDialogConfig();
86+
87+
dialogConfig.disableClose = true;
88+
dialogConfig.autoFocus = true;
89+
dialogConfig.data = {
90+
message: 'You need to be logged in to see the Pinned Bookmarks popup'
91+
};
92+
93+
this.loginDialog.open(LoginRequiredDialogComponent, dialogConfig);
94+
} else {
95+
event.preventDefault();
96+
const dialogConfig = new MatDialogConfig();
97+
98+
dialogConfig.disableClose = false;
99+
dialogConfig.autoFocus = true;
100+
dialogConfig.width = this.getRelativeWidth();
101+
dialogConfig.height = this.getRelativeHeight();
102+
dialogConfig.data = {
103+
bookmarks$: this.userDataPinnedStore.getPinnedBookmarks$(this.userId, 1),
104+
title: '<i class="fas fa-thumbtack"></i> Pinned'
105+
};
106+
107+
const dialogRef = this.historyDialog.open(HotKeysDialogComponent, dialogConfig);
108+
dialogRef.afterClosed().subscribe(
109+
data => {
110+
console.log('Dialog output:', data);
113111
}
112+
);
114113
}
114+
}
115115

116-
private getRelativeWidth() {
117-
let relativeWidth = (window.innerWidth * 80) / 100;
118-
if (window.innerWidth > 1500) {
119-
relativeWidth = (1500 * 80) / 100;
120-
}
121-
122-
return relativeWidth + 'px';
116+
private getRelativeWidth() {
117+
let relativeWidth = (window.innerWidth * 80) / 100;
118+
if (window.innerWidth > 1500) {
119+
relativeWidth = (1500 * 80) / 100;
123120
}
124121

125-
private getRelativeHeight() {
126-
let relativeHeight = (window.innerHeight * 80) / 100;
127-
if (window.innerHeight > 1200) {
128-
relativeHeight = (1200 * 80) / 100;
129-
}
122+
return relativeWidth + 'px';
123+
}
130124

131-
return relativeHeight + 'px';
125+
private getRelativeHeight() {
126+
let relativeHeight = (window.innerHeight * 80) / 100;
127+
if (window.innerHeight > 1200) {
128+
relativeHeight = (1200 * 80) / 100;
132129
}
133130

134-
@HostListener('window:keydown.control.h', ['$event'])
135-
showHistory(event: KeyboardEvent) {
136-
if (!this.userIsLoggedIn) {
137-
const dialogConfig = new MatDialogConfig();
138-
139-
dialogConfig.disableClose = true;
140-
dialogConfig.autoFocus = true;
141-
dialogConfig.data = {
142-
message: 'You need to be logged in to see the History Bookmarks popup'
143-
};
144-
145-
this.loginDialog.open(LoginRequiredDialogComponent, dialogConfig);
146-
} else {
147-
event.preventDefault();
148-
const dialogConfig = new MatDialogConfig();
149-
150-
dialogConfig.disableClose = false;
151-
dialogConfig.autoFocus = true;
152-
dialogConfig.width = this.getRelativeWidth();
153-
dialogConfig.height = this.getRelativeHeight();
154-
dialogConfig.data = {
155-
bookmarks$: this.userDataHistoryStore.getAllHistory$(this.userId),
156-
title: '<i class="fas fa-history"></i> History'
157-
};
158-
159-
const dialogRef = this.historyDialog.open(HotKeysDialogComponent, dialogConfig);
160-
dialogRef.afterClosed().subscribe(
161-
data => {
162-
console.log('Dialog output:', data);
163-
}
164-
);
131+
return relativeHeight + 'px';
132+
}
133+
134+
@HostListener('window:keydown.control.h', ['$event'])
135+
showHistory(event: KeyboardEvent) {
136+
if (!this.userIsLoggedIn) {
137+
const dialogConfig = new MatDialogConfig();
138+
139+
dialogConfig.disableClose = true;
140+
dialogConfig.autoFocus = true;
141+
dialogConfig.data = {
142+
message: 'You need to be logged in to see the History Bookmarks popup'
143+
};
144+
145+
this.loginDialog.open(LoginRequiredDialogComponent, dialogConfig);
146+
} else {
147+
event.preventDefault();
148+
const dialogConfig = new MatDialogConfig();
149+
150+
dialogConfig.disableClose = false;
151+
dialogConfig.autoFocus = true;
152+
dialogConfig.width = this.getRelativeWidth();
153+
dialogConfig.height = this.getRelativeHeight();
154+
dialogConfig.data = {
155+
bookmarks$: this.userDataHistoryStore.getAllHistory$(this.userId),
156+
title: '<i class="fas fa-history"></i> History'
157+
};
158+
159+
const dialogRef = this.historyDialog.open(HotKeysDialogComponent, dialogConfig);
160+
dialogRef.afterClosed().subscribe(
161+
data => {
162+
console.log('Dialog output:', data);
165163
}
164+
);
166165
}
166+
}
167167

168-
public acknowledgeCodeverRebranding(response: string) {
169-
this.cookieService.createCookie('acknowledge-codever-migration', 'true', 365);
170-
this.showAcknowledgeMigrationHeader = false;
168+
public acknowledgeCodeverRebranding(response: string) {
169+
this.cookieService.createCookie('acknowledge-codever-migration', 'true', 365);
170+
this.showAcknowledgeMigrationHeader = false;
171171

172-
const iziToastSettings: IziToastSettings = {
173-
title: 'Thank you for your feedback',
174-
timeout: 3000,
175-
position: 'topRight'
176-
}
177-
iziToast.success(iziToastSettings);
178-
179-
const feedback: Feedback = {
180-
question: 'Bookmarks.dev rebranding to Codever',
181-
userResponse: response,
182-
userId: this.userId ? this.userId : null,
183-
userAgent: navigator.userAgent
184-
}
185-
186-
this.feedbackService.createFeedback(feedback).subscribe();
172+
const iziToastSettings: IziToastSettings = {
173+
title: 'Thank you for your feedback',
174+
timeout: 3000,
175+
position: 'topRight'
187176
}
177+
iziToast.success(iziToastSettings);
188178

189-
acknowledgeWelcomeMessage() {
190-
this.userDataStore.updateWelcomeAcknowledge$();
179+
const feedback: Feedback = {
180+
question: 'Bookmarks.dev rebranding to Codever',
181+
userResponse: response,
182+
userId: this.userId ? this.userId : null,
183+
userAgent: navigator.userAgent
191184
}
192185

193-
resetHoveringLastSearches() {
194-
this.hoveringLastSearches.forEach(item => item = false);
195-
}
186+
this.feedbackService.createFeedback(feedback).subscribe();
187+
}
188+
189+
acknowledgeWelcomeMessage() {
190+
this.userDataStore.updateWelcomeAcknowledge$();
191+
}
192+
193+
resetHoveringLastSearches() {
194+
this.hoveringLastSearches.forEach(item => item = false);
195+
}
196+
197+
resetHoveringLastVisited() {
198+
this.hoveringLastVisited.forEach(item => item = false);
199+
}
196200

197-
resetHoveringLastVisited() {
198-
this.hoveringLastVisited.forEach(item => item = false);
201+
navigateToBookmarkDetails(bookmark: Bookmark): void {
202+
let link = [`./my-bookmarks/${bookmark._id}/details`];
203+
if (bookmark.public) {
204+
link = [`./bookmarks/${bookmark._id}/details`];
199205
}
206+
this.router.navigate(link, {
207+
state: {bookmark: bookmark}
208+
});
209+
}
210+
211+
goToMainLink(bookmark: Bookmark) {
212+
window.open(bookmark.location, '_blank');
213+
}
200214
}

frontend/src/app/my-bookmarks/bookmark-details/bookmark-details.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<div>
1+
<div *ngIf="(bookmark$ | async) as bookmark">
22
<app-bookmark-list-element
33
[bookmark]="bookmark"
44
[userData$]="userData$"
5-
[isDetailsPage]="true">
5+
[isDetailsPage]="true"
6+
[showMoreText]="popup ? false : true">
67
</app-bookmark-list-element>
78

89
<div class="container">

0 commit comments

Comments
 (0)