-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
140 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { UsersConfig } from './users-config'; | ||
|
||
describe('UsersConfig', () => { | ||
it('should create an instance', () => { | ||
expect(new UsersConfig()).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { DataFlowNode, Generic } from '../generic'; | ||
import { Observable, Subject, of } from 'rxjs'; | ||
import { AjaxRequest } from 'rxjs/ajax'; | ||
import { map, switchMap, withLatestFrom } from 'rxjs/operators'; | ||
import { IRcloneServer } from '../rclone/noop-auth'; | ||
|
||
export interface IUserConfig extends IRcloneServer { | ||
name: string; | ||
} | ||
|
||
export class UsersConfig extends Generic { | ||
protected cacheSupport: boolean = false; | ||
protected cachePath?: string = ''; | ||
public emitter = new Subject<number>(); | ||
protected prerequest(): Observable<DataFlowNode> { | ||
return this.emitter.pipe(map(() => [{}, []])); | ||
} | ||
protected request(x: DataFlowNode): AjaxRequest { | ||
throw new Error('Method not implemented.'); | ||
} | ||
protected _request(x: DataFlowNode): Observable<object> { | ||
const dataRaw = localStorage.getItem('users'); | ||
if (dataRaw) return of({ users: JSON.parse(dataRaw) }); | ||
const defaultUser = [{ name: 'local', url: 'http://localhost:5572' }]; | ||
localStorage.setItem('users', JSON.stringify(defaultUser)); | ||
return of({ users: defaultUser }); | ||
} | ||
protected generateSuperset(current: DataFlowNode, previous: DataFlowNode): DataFlowNode { | ||
return current; | ||
} | ||
public set(data: IUserConfig[]) { | ||
localStorage.setItem('users', JSON.stringify(data)); | ||
this.emitter.next(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters