feat(rs): super basic setup

This commit is contained in:
Johannes Millan 2020-05-13 15:40:46 +02:00
parent bf96749580
commit 96f11dd4e8
7 changed files with 81 additions and 2 deletions

View file

@ -155,6 +155,8 @@
"node-sass": "^4.12.0",
"protractor": "^5.4.2",
"query-string": "^6.11.0",
"remotestorage-widget": "^1.5.1",
"remotestoragejs": "1.x",
"rxjs": "^6.5.5",
"rxjs-tslint": "0.1.5",
"sass-loader": "^7.1.0",

View file

@ -38,6 +38,7 @@ import {MaterialCssVarsModule} from 'angular-material-css-vars';
import {WorkContextModule} from './features/work-context/work-context.module';
import {undoTaskDeleteMetaReducer} from './root-store/meta/undo-task-delete.meta-reducer';
import {InitialDialogModule} from './features/initial-dialog/initial-dialog.module';
import {RemoteStorageService} from './core/remote-storage/remote-storage.service';
// NOTE: export required for aot to work
export function createTranslateLoader(http: HttpClient) {
@ -131,6 +132,7 @@ export function createTranslateLoader(http: HttpClient) {
export class AppModule {
constructor(
private _languageService: LanguageService,
private _remoteStorageService: RemoteStorageService,
) {
this._languageService.setDefault(LanguageCode.en);
this._languageService.setFromBrowserLngIfAutoSwitchLng();

View file

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { RemoteStorageService } from './remote-storage.service';
describe('RemoteStorageService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: RemoteStorageService = TestBed.get(RemoteStorageService);
expect(service).toBeTruthy();
});
});

View file

@ -0,0 +1,20 @@
import {Injectable} from '@angular/core';
import * as RemoteStorage from 'remotestoragejs';
import {GOOGLE_SETTINGS} from '../../features/google/google.const';
@Injectable({
providedIn: 'root'
})
export class RemoteStorageService {
rs: RemoteStorage = new RemoteStorage({logging: true});
constructor() {
this.rs.access.claim('superproductivity', 'rw');
this.rs.caching.enable('/superproductivity/');
this.rs.setApiKeys({
googledrive: GOOGLE_SETTINGS.CLIENT_ID
});
}
}

View file

@ -1,5 +1,8 @@
<div class="page-settings page-wrapper">
<div #rsWidget
id="rs-widget">
WWW
</div>
<div *ngIf="globalCfg">
<div class="section-wrapper component-wrapper">

View file

@ -1,4 +1,4 @@
import {ChangeDetectionStrategy, Component, OnDestroy, OnInit} from '@angular/core';
import {ChangeDetectionStrategy, Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {GlobalConfigService} from '../../features/config/global-config.service';
import {
GLOBAL_CONFIG_FORM_CONFIG,
@ -16,6 +16,8 @@ import {IS_ELECTRON} from '../../app.constants';
import {environment} from '../../../environments/environment';
import {T} from '../../t.const';
import {MatSlideToggleChange} from '@angular/material/slide-toggle';
import {RemoteStorageService} from '../../core/remote-storage/remote-storage.service';
import * as Widget from 'remotestorage-widget';
@Component({
selector: 'config-page',
@ -32,10 +34,13 @@ export class ConfigPageComponent implements OnInit, OnDestroy {
appVersion: string = environment.version;
@ViewChild('rsWidget', {static: true}) rsWidget: ElementRef;
private _subs = new Subscription();
constructor(
public readonly configService: GlobalConfigService,
public readonly remoteStorageService: RemoteStorageService,
) {
// somehow they are only unproblematic if assigned here
this.globalConfigFormCfg = GLOBAL_CONFIG_FORM_CONFIG.filter((cfg) => IS_ELECTRON || !cfg.isElectronOnly);
@ -46,6 +51,10 @@ export class ConfigPageComponent implements OnInit, OnDestroy {
this._subs.add(this.configService.cfg$.subscribe((cfg) => {
this.globalCfg = cfg;
}));
const w = new Widget(this.remoteStorageService.rs);
w.attach();
w.attach('rs-widget');
}
ngOnDestroy() {

View file

@ -9459,6 +9459,20 @@ regjsparser@^0.6.4:
dependencies:
jsesc "~0.5.0"
remotestorage-widget@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/remotestorage-widget/-/remotestorage-widget-1.5.1.tgz#e88f7497812fc28a89023d3c2c6b36532d575160"
integrity sha512-CJyqU8E0NkK25i5R9yPFnXGAzTGo6B+ad7HwROLjyjXkfZyiyh1TlD1PhNlADPi3/aBCG3zBjbrlgpGP4HRjjQ==
remotestoragejs@1.x:
version "1.2.3"
resolved "https://registry.yarnpkg.com/remotestoragejs/-/remotestoragejs-1.2.3.tgz#6cf53f3276d7805916febf6b4e7785a5e6a0f1bf"
integrity sha512-uXmWjBC3OoPR7q4v5MHAkYCLzNMvCe7afUeDQSoqdQ53Zw4BjhlF8ARGRVhe+5nbCBuJspaA2O5lTiqp4GVdeA==
dependencies:
tv4 "^1.3.0"
webfinger.js "^2.7.0"
xhr2 "^0.2.0"
remove-trailing-separator@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
@ -11073,6 +11087,11 @@ tunnel@^0.0.6:
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==
tv4@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/tv4/-/tv4-1.3.0.tgz#d020c846fadd50c855abb25ebaecc68fc10f7963"
integrity sha1-0CDIRvrdUMhVq7JeuuzGj8EPeWM=
tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
@ -11487,6 +11506,13 @@ webdriver-manager@^12.0.6:
semver "^5.3.0"
xml2js "^0.4.17"
webfinger.js@^2.7.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/webfinger.js/-/webfinger.js-2.7.0.tgz#403354a14a65aeeba64c1408c18a387487cea106"
integrity sha512-l+UtsuV4zrBKyVAj9VCtwWgscTgadCsdGgL1OvbV102cvydWwJCGXlFIXauzWLzfheIDHfPNRWfgMuwyC6ZfIA==
dependencies:
xhr2 "^0.1.4"
webpack-dev-middleware@3.7.2, webpack-dev-middleware@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-3.7.2.tgz#0019c3db716e3fa5cecbf64f2ab88a74bab331f3"
@ -11718,6 +11744,11 @@ xdg-basedir@^4.0.0:
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13"
integrity sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==
xhr2@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/xhr2/-/xhr2-0.1.4.tgz#7f87658847716db5026323812f818cadab387a5f"
integrity sha1-f4dliEdxbbUCYyOBL4GMras4el8=
xhr2@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/xhr2/-/xhr2-0.2.0.tgz#eddeff782f3b7551061b8d75645085269396e521"