Skip to content

Commit a2c2253

Browse files
authored
Merge pull request #2 from allegroai/v0.16
version 0.16
2 parents c82de80 + df72cc8 commit a2c2253

File tree

655 files changed

+6148
-6665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

655 files changed

+6148
-6665
lines changed

src/app/app.component.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<sm-survey *ngIf="!demo && (showSurvey$ | async) && !showNotification" (dismiss)="dismissSurvey()"></sm-survey>
2-
<sm-update-notifier [availableUpdates]="(updatesAvailable$ | async)"
3-
[dismissedVersion]="serverUpdatesService.lastDismissedVersion"
4-
(versionDismissed)="versionDismissed($event)"
5-
(notifierActive)="notifierActive($event)">
1+
<sm-survey *ngIf="!demo && !guestUser && (showSurvey$ | async) && !update?.active" (dismiss)="dismissSurvey()"></sm-survey>
2+
<sm-update-notifier #update
3+
[availableUpdates]="(updatesAvailable$ | async)"
4+
[currentUser]="currentUser"
5+
[dismissedVersion]="serverUpdatesService.lastDismissedVersion"
6+
(versionDismissed)="versionDismissed($event)"
7+
(notifierActive)="notifierActive($event)">
68
</sm-update-notifier>
7-
<div>
8-
<sm-color-picker-wrapper id="color-picker-outlet"></sm-color-picker-wrapper>
9-
<sm-server-notification-dialog-container></sm-server-notification-dialog-container>
10-
<sm-spinner></sm-spinner>
11-
<sm-side-nav></sm-side-nav>
12-
<div class="app-container" [class.notifier-open]="showNotification || (showSurvey$ | async)">
13-
<sm-header [isDashboard]="isDashboardContext"></sm-header>
14-
<router-outlet class="main-router"></router-outlet>
15-
</div>
9+
<sm-color-picker-wrapper id="color-picker-outlet"></sm-color-picker-wrapper>
10+
<sm-server-notification-dialog-container></sm-server-notification-dialog-container>
11+
<sm-spinner></sm-spinner>
12+
<sm-side-nav></sm-side-nav>
13+
<div class="app-container" [class.notifier-open]="update?.active || ((showSurvey$ | async) && !demo && !guestUser)">
14+
<sm-header [isDashboard]="isDashboardContext" [isLogin]="isLoginContext"></sm-header>
15+
<router-outlet class="main-router"></router-outlet>
1616
</div>
1717
<notifier-container></notifier-container>

src/app/app.component.scss

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,33 @@
44
$notifier-height: 30px;
55

66
.app-container {
7+
height: 100%;
78
margin-left: $side-bar-close-width;
9+
10+
&.notifier-open {
11+
height: calc(100% - #{$notifier-height});
12+
.main-router + * {
13+
height: calc(100% - #{$top-bar-height});
14+
}
15+
}
816
}
917

1018
.main-router + * {
1119
display: block;
12-
height: calc(100vh - #{$top-bar-height});
20+
height: calc(100% - #{$top-bar-height});
1321
}
1422

15-
.notifier-open {
16-
.main-router + * {
17-
height: calc(100vh - #{$top-bar-height + $notifier-height});
18-
}
19-
}
2023

2124
sm-side-nav {
25+
display: block;
26+
position: fixed;
27+
top: 0;
2228
z-index: 999;
29+
height: 100%;
2330
}
2431

2532
#color-picker-outlet {
2633
position: absolute;
2734
visibility: hidden;
2835
}
2936

30-
31-
32-

src/app/app.component.ts

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ApiUsersService} from './business-logic/api-services/users.service';
22
import {selectCurrentUser} from './webapp-common/core/reducers/users-reducer';
3-
import {Component, OnDestroy, OnInit, ViewEncapsulation, HostListener} from '@angular/core';
3+
import {Component, OnDestroy, OnInit, ViewEncapsulation, HostListener, Renderer2} from '@angular/core';
44
import {ActivatedRoute, NavigationEnd, Router, Params} from '@angular/router';
55
import {Title} from '@angular/platform-browser';
66
import {selectLoggedOut} from './webapp-common/core/reducers/view-reducer';
@@ -11,12 +11,17 @@ import {ApiProjectsService} from './business-logic/api-services/projects.service
1111
import {Project} from './business-logic/model/projects/project';
1212
import {GetAllProjects, SetSelectedProjectId, UpdateProject} from './webapp-common/core/actions/projects.actions';
1313
import {selectSelectedProject} from './webapp-common/core/reducers/projects.reducer';
14-
import {selectS3BucketCredentialsBucketCredentials, selectS3PopUpDetails, selectShowLocalFilesPopUp, selectShowS3PopUp} from './webapp-common/core/reducers/common-auth-reducer';
14+
import {
15+
selectS3BucketCredentialsBucketCredentials,
16+
selectS3PopUpDetails,
17+
selectShowLocalFilesPopUp,
18+
selectShowS3PopUp
19+
} from './webapp-common/core/reducers/common-auth-reducer';
1520
import {MatDialog, MatDialogRef} from '@angular/material/dialog';
1621
import {S3AccessResolverComponent} from './webapp-common/layout/s3-access-resolver/s3-access-resolver.component';
1722
import {cancelS3Credentials, getTutorialBucketCredentials} from './webapp-common/core/actions/common-auth.actions';
1823
import {FetchCurrentUser} from './webapp-common/core/actions/users.actions';
19-
import {filter, map, take, withLatestFrom} from 'rxjs/operators';
24+
import {distinct, distinctUntilChanged, filter, map, take, withLatestFrom} from 'rxjs/operators';
2025
import * as routerActions from './webapp-common/core/actions/router.actions';
2126
import {combineLatest, Observable, Subscription} from 'rxjs';
2227
import {selectBreadcrumbsStrings} from './webapp-common/layout/layout.reducer';
@@ -25,17 +30,19 @@ import {formatStaticCrumb} from './webapp-common/layout/breadcrumbs/breadcrumbs-
2530
import {ServerUpdatesService} from './webapp-common/shared/services/server-updates.service';
2631
import {selectAvailableUpdates, selectShowSurvey} from './core/reducers/view-reducer';
2732
import {UPDATE_SERVER_PATH} from './app.constants';
28-
import {VisibilityChanged} from './webapp-common/core/actions/layout.actions';
33+
import {setScaleFactor, VisibilityChanged} from './webapp-common/core/actions/layout.actions';
2934
import {UiUpdatesService} from './webapp-common/shared/services/ui-updates.service';
3035
import {UsageStatsService} from './core/Services/usage-stats.service';
3136
import {UiUpdateDialogComponent} from './webapp-common/layout/ui-update-dialog/ui-update-dialog.component';
3237
import {dismissSurvey} from './core/Actions/layout.actions';
3338
import {environment} from '../environments/environment';
39+
import {getScaleFactor} from './webapp-common/shared/utils/shared-utils';
40+
import {User} from './business-logic/model/users/user';
3441

3542
@Component({
36-
selector : 'sm-root',
37-
templateUrl : 'app.component.html',
38-
styleUrls : ['app.component.scss'],
43+
selector: 'sm-root',
44+
templateUrl: 'app.component.html',
45+
styleUrls: ['app.component.scss'],
3946
encapsulation: ViewEncapsulation.None
4047
})
4148
export class AppComponent implements OnInit, OnDestroy {
@@ -57,12 +64,14 @@ export class AppComponent implements OnInit, OnDestroy {
5764
public showNotification: boolean = true;
5865
public showSurvey$: Observable<boolean>;
5966
public demo = environment.demo;
67+
public isLoginContext: boolean;
68+
public currentUser: User;
6069

6170
@HostListener('document:visibilitychange') onVisibilityChange() {
6271
this.store.dispatch(new VisibilityChanged(!document.hidden));
6372
}
6473

65-
constructor (
74+
constructor(
6675
private router: Router,
6776
private route: ActivatedRoute,
6877
private titleService: Title,
@@ -72,15 +81,16 @@ export class AppComponent implements OnInit, OnDestroy {
7281
public serverUpdatesService: ServerUpdatesService,
7382
private uiUpdatesService: UiUpdatesService,
7483
private matDialog: MatDialog,
75-
private userStats: UsageStatsService
84+
private userStats: UsageStatsService,
85+
private renderer: Renderer2
7686
) {
77-
this.showS3Popup$ = this.store.select(selectShowS3PopUp);
78-
this.showLocalFilePopup$ = this.store.pipe(select(selectShowLocalFilesPopUp));
79-
this.loggedOut$ = store.select(selectLoggedOut);
80-
this.selectedProject$ = this.store.select(selectSelectedProject);
81-
this.updatesAvailable$ = this.store.select(selectAvailableUpdates);
82-
this.showSurvey$ = this.store.select(selectShowSurvey);
83-
this.selectedCurrentUser$ = this.store.select(selectCurrentUser);
87+
this.showS3Popup$ = this.store.select(selectShowS3PopUp);
88+
this.showLocalFilePopup$ = this.store.pipe(select(selectShowLocalFilesPopUp));
89+
this.loggedOut$ = store.select(selectLoggedOut);
90+
this.selectedProject$ = this.store.select(selectSelectedProject);
91+
this.updatesAvailable$ = this.store.select(selectAvailableUpdates);
92+
this.showSurvey$ = this.store.select(selectShowSurvey);
93+
this.selectedCurrentUser$ = this.store.select(selectCurrentUser);
8494
this.selectedProjectFromUrl$ = this.store.select(selectRouterParams)
8595
.pipe(
8696
filter((params: Params) => !!params),
@@ -100,8 +110,11 @@ export class AppComponent implements OnInit, OnDestroy {
100110
this.store.dispatch(new FetchCurrentUser());
101111
this.selectedCurrentUser$.pipe(
102112
filter( user => !!user),
103-
take(1))
104-
.subscribe(() => this.serverUpdatesService.checkForUpdates(UPDATE_SERVER_PATH));
113+
distinctUntilChanged())
114+
.subscribe((user) => {
115+
this.currentUser = user;
116+
this.serverUpdatesService.checkForUpdates(UPDATE_SERVER_PATH);
117+
} );
105118

106119
this.selectedProjectFromUrl$.subscribe((projectId: string) => {
107120
this.store.dispatch(new SetSelectedProjectId(projectId));
@@ -116,7 +129,7 @@ export class AppComponent implements OnInit, OnDestroy {
116129
)
117130
.subscribe(([data, bucketCredentials, popupDetails]) => {
118131
if (!(data && data.success)) {
119-
const emptyCredentials = bucketCredentials.find((cred => cred.Bucket === popupDetails.credentials.Bucket)) === undefined;
132+
const emptyCredentials = bucketCredentials.find((cred => cred.Bucket === popupDetails.credentials.Bucket)) === undefined;
120133
const dontAskAgainForBucketName = emptyCredentials ? '' : popupDetails.credentials.Bucket + popupDetails.credentials.Endpoint;
121134
this.store.dispatch(cancelS3Credentials({dontAskAgainForBucketName}));
122135
}
@@ -126,9 +139,10 @@ export class AppComponent implements OnInit, OnDestroy {
126139

127140
this.urlSubscription = combineLatest([this.store.select(selectRouterUrl), this.store.select(selectRouterParams)])
128141
.subscribe(([url, params]) => {
129-
this.projectId = get('projectId', params);
142+
this.projectId = get('projectId', params);
130143
this.isDashboardContext = url && url.includes('dashboard');
131-
this.isWorkersContext = url && url.includes('workers-and-queues');
144+
this.isLoginContext = url && url.includes('login');
145+
this.isWorkersContext = url && url.includes('workers-and-queues');
132146
if (this.projectId) {
133147
try { // TODO: refactor to a better solution after all navbar are declared...
134148
this.activeFeature = url.split(this.projectId)[1].split('/')[1];
@@ -147,13 +161,26 @@ export class AppComponent implements OnInit, OnDestroy {
147161
this.updateTitle();
148162
}
149163
);
164+
if (window.localStorage.getItem('disableHidpi') !== 'true') {
165+
this.setScale();
166+
}
150167

151168
// TODO: move to somewhere else...
152169
this.store.dispatch(new GetAllProjects());
153170
this.store.dispatch(getTutorialBucketCredentials());
154171
this.uiUpdatesService.checkForUiUpdate();
155172
}
156173

174+
private setScale() {
175+
const dimensionRatio = getScaleFactor();
176+
this.store.dispatch(setScaleFactor({scale: dimensionRatio}));
177+
const scale = 100 / dimensionRatio;
178+
this.renderer.setStyle(document.body, 'transform', `scale(${scale})`);
179+
this.renderer.setStyle(document.body, 'transform-origin', '0 0');
180+
this.renderer.setStyle(document.body, 'height', `${dimensionRatio}vh`);
181+
this.renderer.setStyle(document.body, 'width', `${dimensionRatio}vw`);
182+
}
183+
157184
nameChanged(name) {
158185
this.store.dispatch(new UpdateProject({id: this.projectId, changes: {name: name}}));
159186
}
@@ -172,13 +199,13 @@ export class AppComponent implements OnInit, OnDestroy {
172199
}
173200

174201
updateTitle() {
175-
let route = this.route.snapshot.firstChild;
202+
let route = this.route.snapshot.firstChild;
176203
let routeConfig = [];
177204

178205
while (route) {
179-
const path = route.routeConfig.path.split('/').filter((item) => !!item);
206+
const path = route.routeConfig.path.split('/').filter((item) => !!item);
180207
routeConfig = routeConfig.concat(path);
181-
route = route.firstChild;
208+
route = route.firstChild;
182209
}
183210
const crumbs = routeConfig
184211
.reduce((acc, config) => {
@@ -201,5 +228,9 @@ export class AppComponent implements OnInit, OnDestroy {
201228
this.store.dispatch(dismissSurvey());
202229

203230
}
231+
232+
get guestUser(): boolean {
233+
return !this.currentUser || this.currentUser?.role === 'guest';
234+
}
204235
}
205236

src/app/app.constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export const NAVIGATION_ACTIONS = {
256256

257257

258258

259-
export const ENVIRONMENT = {API_VERSION: '/v2.8'};
259+
export const ENVIRONMENT = {API_VERSION: '/v2.9'};
260260
const url = window.location.origin;
261261
let apiBaseUrl: string;
262262
if (environment.apiBaseUrl) {

src/app/app.module.ts

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,42 @@ import {ApiUsersService} from './business-logic/api-services/users.service';
1616
import {loadUserAndPreferences} from './webapp-common/user-preferences';
1717
import {AdminModule} from './webapp-common/admin/admin.module';
1818
import {AngularSplitModule} from 'angular-split';
19-
import {NotifierModule} from 'angular-notifier';
19+
import {NotifierModule} from './webapp-common/angular-notifier';
2020
import {LayoutModule} from './layout/layout.module';
2121
import {ColorHashService} from './webapp-common/shared/services/color-hash/color-hash.service';
22-
import {LoginModule} from './webapp-common/login/login.module';
2322
import {LoginService} from './webapp-common/shared/services/login.service';
2423
import {Store} from '@ngrx/store';
25-
import {TitleCasePipe} from '@angular/common';
24+
import {SharedModule} from './shared/shared.module';
2625

2726
@NgModule({
2827
declarations : [AppComponent],
29-
imports : [
28+
imports: [
3029
FormsModule,
3130
BrowserAnimationsModule,
3231
BrowserModule,
3332
SMCoreModule,
3433
BusinessLogicModule,
3534
SMSharedModule,
36-
LoginModule,
3735
AngularSplitModule.forRoot(),
38-
RouterModule.forRoot(routes, {preloadingStrategy: PreloadAllModules, scrollPositionRestoration: 'top', onSameUrlNavigation: 'reload'}),
36+
RouterModule.forRoot(routes, {
37+
preloadingStrategy: PreloadAllModules,
38+
scrollPositionRestoration: 'top',
39+
onSameUrlNavigation: 'reload'
40+
}),
3941
AdminModule,
4042
NotifierModule.withConfig({
41-
theme : 'material',
43+
theme: 'material',
4244
behaviour: {
4345
autoHide: {default: 5000, error: false}
4446
},
45-
position : {
46-
vertical : {position: 'top', distance: 12, gap: 10},
47+
position: {
48+
vertical: {position: 'top', distance: 12, gap: 10},
4749
horizontal: {position: 'right', distance: 12}
4850
}
4951
}),
5052
CommonLayoutModule,
5153
LayoutModule,
54+
SharedModule,
5255
],
5356
providers : [
5457
{
@@ -65,19 +68,4 @@ import {TitleCasePipe} from '@angular/common';
6568
exports : []
6669
})
6770

68-
export class AppModule {
69-
70-
constructor() {
71-
72-
// store.select(selectRouter)
73-
// // .filter(state => !state.skipNextNavigation)
74-
// .subscribe(state => {
75-
// this.store.dispatch(new ResetDontShowAgainForBucketEndpoint());
76-
// (!state.params || !state.url) ?
77-
// this.router.navigateByUrl(state.url, { queryParams: { unGuard: state.unGuard } }) :
78-
// this.router.navigate([state.url, state.params], { queryParams: { unGuard: state.unGuard } });
79-
// });
80-
81-
}
82-
83-
}
71+
export class AppModule {}

src/app/business-logic/api-services/auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* auth
33
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
44
*
5-
* OpenAPI spec version: 2.7
5+
* OpenAPI spec version: 2.9
66
*
77
*
88
* NOTE: This class is auto generated by the swagger code generator program.

src/app/business-logic/api-services/events.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* events
33
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
44
*
5-
* OpenAPI spec version: 2.7
5+
* OpenAPI spec version: 2.9
66
*
77
*
88
* NOTE: This class is auto generated by the swagger code generator program.
@@ -540,7 +540,7 @@ export class ApiEventsService {
540540

541541
/**
542542
*
543-
* Get all \&#39;log\&#39; events for this task
543+
* Get \&#39;log\&#39; events for this task
544544
* @param request request body
545545
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
546546
* @param reportProgress flag to report request and response progress.

0 commit comments

Comments
 (0)