Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions frontend/src/app/common/service/user/auth-guard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import { Injectable } from "@angular/core";
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from "@angular/router";
import { GuiConfigService } from "../gui-config.service";
import { UserService } from "./user.service";
import { LOGIN } from "../../../app-routing.constant";

Expand All @@ -31,8 +30,7 @@ import { LOGIN } from "../../../app-routing.constant";
export class AuthGuardService implements CanActivate {
constructor(
private userService: UserService,
private router: Router,
private config: GuiConfigService
private router: Router
) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
if (this.userService.isLogin()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { Component, Inject, Input, TemplateRef, ViewChild } from "@angular/core";
import { Component, Inject, TemplateRef, ViewChild } from "@angular/core";
import { NZ_MODAL_DATA } from "ng-zorro-antd/modal";
import { NzSpaceCompactItemDirective } from "ng-zorro-antd/space";
import { NzInputDirective } from "ng-zorro-antd/input";
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/app/common/service/user/stub-user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,4 @@ export class StubUserService implements PublicInterfaceOf<UserService> {
getAvatar(avatarUrl: string): Observable<string | undefined> {
return of(undefined);
}

checkAffiliation(): Observable<Boolean> {
return of(true);
}

updateAffiliation(_affiliation: string): Observable<void> {
return of(void 0);
}
}
5 changes: 1 addition & 4 deletions frontend/src/app/common/service/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/

import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { AppSettings } from "../../app-setting";
import { Observable, of, ReplaySubject } from "rxjs";
import { Role, User } from "../../type/user";
import { AuthService } from "./auth.service";
Expand All @@ -42,8 +40,7 @@ export class UserService {

constructor(
private authService: AuthService,
private config: GuiConfigService,
private http: HttpClient
private config: GuiConfigService
) {
const user = this.authService.loginWithExistingToken();
this.changeUser(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

import { Injectable } from "@angular/core";
import { NzModalService } from "ng-zorro-antd/modal";
import { EMPTY, catchError, shareReplay } from "rxjs";
import { Observable, firstValueFrom } from "rxjs";
import { Observable, EMPTY, catchError, firstValueFrom, shareReplay } from "rxjs";
import { NotificationService } from "../notification/notification.service";
import { DashboardWarehouse } from "../../type/warehouse";
import { extractErrorMessage } from "../../util/error";
Expand Down
29 changes: 0 additions & 29 deletions frontend/src/app/common/type/datasetVersionFileTree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import {
DatasetFileNode,
getFullPathFromDatasetFileNode,
getPathsUnderOrEqualDatasetFileNode,
getRelativePathFromDatasetFileNode,
} from "./datasetVersionFileTree";

Expand Down Expand Up @@ -72,31 +71,3 @@ describe("getRelativePathFromDatasetFileNode", () => {
expect(getRelativePathFromDatasetFileNode(node)).toBe("sub/f.csv");
});
});

describe("getPathsUnderOrEqualDatasetFileNode", () => {
it("returns the single path for a file node", () => {
const file: DatasetFileNode = { name: "a.txt", type: "file", parentDir: "/dir" };
expect(getPathsUnderOrEqualDatasetFileNode(file)).toEqual(["/dir/a.txt"]);
});

it("collects every file path under a directory", () => {
const file1: DatasetFileNode = { name: "file1.txt", type: "file", parentDir: "/dir" };
const file2: DatasetFileNode = { name: "file2.txt", type: "file", parentDir: "/dir" };
const dir: DatasetFileNode = { name: "dir", type: "directory", parentDir: "", children: [file1, file2] };
expect(getPathsUnderOrEqualDatasetFileNode(dir)).toEqual(["/dir/file1.txt", "/dir/file2.txt"]);
});

it("recurses into nested directories", () => {
const deepFile: DatasetFileNode = { name: "deep.txt", type: "file", parentDir: "/a/b" };
const subDir: DatasetFileNode = { name: "b", type: "directory", parentDir: "/a", children: [deepFile] };
const topDir: DatasetFileNode = { name: "a", type: "directory", parentDir: "", children: [subDir] };
expect(getPathsUnderOrEqualDatasetFileNode(topDir)).toEqual(["/a/b/deep.txt"]);
});

it("returns an empty array for an empty directory", () => {
const emptyChildren: DatasetFileNode = { name: "dir", type: "directory", parentDir: "", children: [] };
const noChildrenProp: DatasetFileNode = { name: "dir", type: "directory", parentDir: "" };
expect(getPathsUnderOrEqualDatasetFileNode(emptyChildren)).toEqual([]);
expect(getPathsUnderOrEqualDatasetFileNode(noChildrenProp)).toEqual([]);
});
});
15 changes: 0 additions & 15 deletions frontend/src/app/common/type/datasetVersionFileTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,3 @@ export function getRelativePathFromDatasetFileNode(node: DatasetFileNode): strin

return pathSegments.slice(4).join("/"); // Join remaining segments as the relative path
}

export function getPathsUnderOrEqualDatasetFileNode(node: DatasetFileNode): string[] {
// Helper function to recursively gather paths
const gatherPaths = (node: DatasetFileNode): string[] => {
// Base case: if the node is a file, return its path
if (node.type === "file") {
return [getFullPathFromDatasetFileNode(node)];
}

// Recursive case: if the node is a directory, explore its children
return node.children ? node.children.flatMap(child => gatherPaths(child)) : [];
};

return gatherPaths(node);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { ComponentFixture, TestBed } from "@angular/core/testing";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { ReactiveFormsModule } from "@angular/forms";
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
import { HttpClientTestingModule } from "@angular/common/http/testing";
import { Subject } from "rxjs";
Expand Down Expand Up @@ -50,7 +50,7 @@ describe("AdminGmailComponent", () => {
const gmailServiceStub = { getSenderEmail: getSenderEmailSpy, sendEmail: sendEmailSpy };

await TestBed.configureTestingModule({
imports: [AdminGmailComponent, FormsModule, ReactiveFormsModule, NoopAnimationsModule, HttpClientTestingModule],
imports: [AdminGmailComponent, ReactiveFormsModule, NoopAnimationsModule, HttpClientTestingModule],
providers: [{ provide: GmailService, useValue: gmailServiceStub }, ...commonTestProviders],
}).compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { Component, OnInit } from "@angular/core";
import { GmailService } from "../../../../common/service/gmail/gmail.service";
import { FormBuilder, FormGroup, Validators, FormsModule, ReactiveFormsModule } from "@angular/forms";
import { FormBuilder, FormGroup, Validators, ReactiveFormsModule } from "@angular/forms";
import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
import { NzCardComponent } from "ng-zorro-antd/card";
import { NzFormDirective, NzFormItemComponent, NzFormLabelComponent, NzFormControlComponent } from "ng-zorro-antd/form";
Expand All @@ -36,7 +36,6 @@ import { ɵNzTransitionPatchDirective } from "ng-zorro-antd/core/transition-patc
templateUrl: "./admin-gmail.component.html",
imports: [
NzCardComponent,
FormsModule,
NzFormDirective,
ReactiveFormsModule,
NzRowDirective,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
[(ngModel)]="searchParam"
(ngModelChange)="onSearchInputChange($event)"
(keydown.enter)="performSearch(searchParam)"
[nzAutocomplete]="auto"
#searchInput />
[nzAutocomplete]="auto" />
</nz-input-group>
<nz-autocomplete
class="autocomplete"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,9 @@
* under the License.
*/

.nz-input-group {
display: flex;
align-items: center;
margin: 0;
}

input[nz-input] {
border: none;
outline: none;
font-size: 17px;
padding: 0 5px;
}

.nz-prefix-icon {
color: #888;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("SearchResultsComponent", () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SearchResultsComponent, NoopAnimationsModule],
providers: [{ provide: UserService, useClass: StubUserService }, ...commonTestProviders],
providers: [...commonTestProviders],
}).compileComponents();

// ListItemComponent is heavy (needs a full service graph); swap it for a
Expand All @@ -106,25 +106,6 @@ describe("SearchResultsComponent", () => {
expect(component).toBeTruthy();
});

describe("getUid", () => {
it("returns the current user's uid when a user is logged in", () => {
// StubUserService default user has uid = 1 (MOCK_USER_ID).
expect(component.getUid()).toBe(1);
});

it("returns a spied uid", () => {
const userService = TestBed.inject(UserService);
vi.spyOn(userService, "getCurrentUser").mockReturnValue({ uid: 42 } as any);
expect(component.getUid()).toBe(42);
});

it("returns undefined when no user is logged in", () => {
const userService = TestBed.inject(UserService);
vi.spyOn(userService, "getCurrentUser").mockReturnValue(undefined);
expect(component.getUid()).toBeUndefined();
});
});

describe("reset", () => {
it("clears entries and stores the provided loadMoreFunction", async () => {
component.entries = [makeEntry("workflow", 1), makeEntry("dataset", 2)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import { Component, EventEmitter, Input, Output, TemplateRef } from "@angular/core";
import { DashboardEntry } from "../../../type/dashboard-entry";
import { UserService } from "../../../../common/service/user/user.service";
import { NzCardComponent } from "ng-zorro-antd/card";
import { ɵɵCdkVirtualScrollViewport, ɵɵCdkFixedSizeVirtualScroll } from "@angular/cdk/overlay";
import { NzListComponent } from "ng-zorro-antd/list";
Expand Down Expand Up @@ -72,12 +71,6 @@ export class SearchResultsComponent {
@Output() notifyWorkflow = new EventEmitter<void>();
@Output() refresh = new EventEmitter<void>();

constructor(private userService: UserService) {}

getUid(): number | undefined {
return this.userService.getCurrentUser()?.uid;
}

reset(loadMoreFunction: LoadMoreFunction): void {
this.entries = [];
this.loadMoreFunction = loadMoreFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import { NzIconModule } from "ng-zorro-antd/icon";
import { NzModalService } from "ng-zorro-antd/modal";
import { FileAddOutline } from "@ant-design/icons-angular/icons";
import { HttpClientTestingModule } from "@angular/common/http/testing";
import { UserService } from "../../../../common/service/user/user.service";
import { StubUserService } from "../../../../common/service/user/stub-user.service";
import { commonTestProviders } from "../../../../common/testing/test-utils";
import { WorkflowComputingUnitManagingService } from "../../../../common/service/computing-unit/workflow-computing-unit/workflow-computing-unit-managing.service";
import { ComputingUnitStatusService } from "../../../../common/service/computing-unit/computing-unit-status/computing-unit-status.service";
Expand Down Expand Up @@ -59,7 +57,6 @@ describe("UserComputingUnitComponent", () => {
await TestBed.configureTestingModule({
providers: [
NzModalService,
{ provide: UserService, useClass: StubUserService },
{ provide: WorkflowComputingUnitManagingService, useValue: mockComputingUnitService },
{ provide: ComputingUnitStatusService, useClass: MockComputingUnitStatusService },
...commonTestProviders,
Expand Down Expand Up @@ -99,7 +96,7 @@ describe("UserComputingUnitComponent", () => {
expect(component.addComputeUnitModalVisible).toBe(false);
});

describe("session, polling and termination", () => {
describe("fetching, polling and termination", () => {
function makeUnit(cuid: number): DashboardWorkflowComputingUnit {
return {
computingUnit: {
Expand Down Expand Up @@ -134,17 +131,6 @@ describe("UserComputingUnitComponent", () => {
fixture.destroy();
});

it("follows the signed-in user when the session changes", () => {
fixture.detectChanges();
const stubUserService = TestBed.inject(UserService) as unknown as StubUserService;

stubUserService.user = undefined;
stubUserService.userChangeSubject.next(undefined);

expect(component.isLogin).toBe(false);
expect(component.currentUid).toBeUndefined();
});

it("maps the fetched computing units into dashboard entries", () => {
Comment thread
aglinxinyuan marked this conversation as resolved.
Resolved
const statusService = TestBed.inject(ComputingUnitStatusService);
vi.spyOn(statusService, "getAllComputingUnits").mockReturnValue(of([makeUnit(7)]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { DashboardEntry } from "../../../type/dashboard-entry";
import { DashboardWorkflowComputingUnit } from "../../../../common/type/workflow-computing-unit";
import { NotificationService } from "../../../../common/service/notification/notification.service";
import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
import { UserService } from "../../../../common/service/user/user.service";
import { ComputingUnitActionsService } from "../../../../common/service/computing-unit/computing-unit-actions/computing-unit-actions.service";
import { interval } from "rxjs";
import { NzCardComponent } from "ng-zorro-antd/card";
Expand Down Expand Up @@ -59,28 +58,16 @@ import { ComputingUnitCreateModalComponent } from "../../../../common/component/
})
export class UserComputingUnitComponent implements OnInit {
public entries: DashboardEntry[] = [];
public isLogin = this.userService.isLogin();
public currentUid = this.userService.getCurrentUser()?.uid;

allComputingUnits: DashboardWorkflowComputingUnit[] = [];

// visibility of the shared create-computing-unit modal
addComputeUnitModalVisible = false;

constructor(
private notificationService: NotificationService,
private userService: UserService,
private computingUnitStatusService: ComputingUnitStatusService,
private computingUnitActionsService: ComputingUnitActionsService
) {
this.userService
.userChanged()
.pipe(untilDestroyed(this))
.subscribe(() => {
this.isLogin = this.userService.isLogin();
this.currentUid = this.userService.getCurrentUser()?.uid;
});
}
) {}

ngOnInit() {
this.computingUnitStatusService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { EntityType } from "../../../../../../hub/service/hub.service";
import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
import { Subscription } from "rxjs";
import * as Papa from "papaparse";
import { ParseResult } from "papaparse";
import { DomSanitizer, SafeUrl } from "@angular/platform-browser";
import readXlsxFile from "read-excel-file";
import { NotificationService } from "../../../../../../common/service/notification/notification.service";
Expand Down Expand Up @@ -270,7 +269,7 @@ export class UserDatasetFileRendererComponent implements OnInit, OnChanges, OnDe
this.displayCSV = true;
// Handle CSV display
Papa.parse(this.currentFile, {
complete: (results: ParseResult<any>) => {
complete: (results: Papa.ParseResult<any>) => {
if (!isCurrent()) return;
if (results.data.length > 0) {
this.loadTabularFile(results.data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ <h2 class="page-title">Datasets</h2>
<div class="section-search-bar">
<texera-filters-instructions></texera-filters-instructions>
<nz-select
#searchInput
class="search-input-box"
name="search-input-box"
nzMode="tags"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ <h2 class="page-title">Models</h2>
<div class="section-search-bar">
<texera-filters-instructions></texera-filters-instructions>
<nz-select
#searchInput
class="search-input-box"
name="search-input-box"
nzMode="tags"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { ActivatedRoute } from "@angular/router";
import { NgIf } from "@angular/common";
import { NzButtonComponent } from "ng-zorro-antd/button";
import { NzIconDirective } from "ng-zorro-antd/icon";
import { NzTooltipModule } from "ng-zorro-antd/tooltip";
import {
SearchResultsComponent,
SearchResultsViewMode,
Expand Down Expand Up @@ -50,7 +49,6 @@ const HUB_VIEW_MODE_STORAGE_KEY = "texera.hub.dataset.viewMode";
NgIf,
NzButtonComponent,
NzIconDirective,
NzTooltipModule,
SortButtonComponent,
FiltersComponent,
SearchResultsComponent,
Expand Down
Loading
Loading