...
 
Commits (9)
......@@ -253,7 +253,7 @@ review:start:
image: minds/helm-eks:latest
script:
- aws eks update-kubeconfig --name=sandbox
- git clone --branch=epic/SSR https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git
- git clone --branch=master https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git
- "helm upgrade \
--install \
--reuse-values \
......
......@@ -48,3 +48,30 @@ export function verticallyScrollToEnsureElementIsInView(
}
}
}
export function horizontallyScrollToEnsureElementIsInView(
container: HTMLElement,
element: HTMLElement,
smooth?: boolean // true if you want the scroll to be animated
) {
// Determine container left and right
const cLeft = container.scrollLeft;
const cRight = cLeft + container.clientWidth;
// Determine element left and right
const eLeft = element.offsetLeft;
const eRight = eLeft + element.clientWidth;
// Check if out of view and scroll horizontally if it is
if (smooth) {
if (eLeft < cLeft || eRight > cRight) {
element.scrollIntoView({ behavior: 'smooth' });
}
} else {
if (eLeft < cLeft) {
container.scrollLeft -= cLeft - eLeft;
} else if (eRight > cRight) {
container.scrollLeft += eRight - cRight;
}
}
}
......@@ -10,6 +10,7 @@ import { Session } from '../../../../../services/session';
import { AttachmentService } from '../../../../../services/attachment';
import { ActivityService } from '../../../../../common/services/activity.service';
import { ConfigsService } from '../../../../../common/services/configs.service';
@Component({
moduleId: module.id,
......@@ -23,6 +24,10 @@ import { ActivityService } from '../../../../../common/services/activity.service
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ActivityPreview {
readonly cdnUrl: string;
readonly cdnAssetsUrl: string;
readonly siteUrl: string;
activity: any;
hideTabs: boolean;
......@@ -40,9 +45,12 @@ export class ActivityPreview {
public session: Session,
public client: Client,
public attachment: AttachmentService,
private _changeDetectorRef: ChangeDetectorRef
configs: ConfigsService
) {
this.hideTabs = true;
this.cdnUrl = configs.get('cdn_url');
this.cdnAssetsUrl = configs.get('cdn_assets_url');
this.siteUrl = configs.get('site_url');
}
set object(value: any) {
......
......@@ -5,7 +5,10 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Input,
Inject,
PLATFORM_ID,
} from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { Client } from '../../../../services/api/client';
import { Subscription } from 'rxjs';
import { Session } from '../../../../services/session';
......@@ -42,7 +45,8 @@ export class WalletBalanceTokensV2Component implements OnInit, OnDestroy {
protected cd: ChangeDetectorRef,
protected session: Session,
protected walletService: WalletDashboardService,
protected formToastService: FormToastService
protected formToastService: FormToastService,
@Inject(PLATFORM_ID) protected platformId: Object
) {}
ngOnInit() {
......@@ -52,11 +56,19 @@ export class WalletBalanceTokensV2Component implements OnInit, OnDestroy {
this.getPayout();
this.inProgress = false;
this.updateTimer$ = setInterval(this.updateNextPayoutDate.bind(this), 1000);
if (isPlatformBrowser(this.platformId)) {
this.updateTimer$ = setInterval(
this.updateNextPayoutDate.bind(this),
1000
);
}
this.detectChanges();
}
ngOnDestroy() {
clearInterval(this.updateTimer$);
if (this.updateTimer$) {
clearInterval(this.updateTimer$);
}
if (this.payoutSubscription) {
this.payoutSubscription.unsubscribe();
}
......
......@@ -40,7 +40,7 @@
<div
class="m-walletDashboardViews__tabsContainer"
*ngIf="views[activeCurrencyId].length > 1"
id="dashboardViewsTabs"
#dashboardViewsTabs
>
<div
class="m-walletDashboardViews__tab"
......@@ -71,10 +71,12 @@
<m-walletSettings--tokens
class="m-walletDashboardViews__view"
*ngIf="activeCurrencyId === 'tokens'"
#tokenSettings
></m-walletSettings--tokens>
<m-walletSettings--cash
class="m-walletDashboardViews__view"
*ngIf="activeCurrencyId === 'cash'"
#cashSettings
></m-walletSettings--cash>
<m-walletSettings--eth
class="m-walletDashboardViews__view"
......
......@@ -5,20 +5,19 @@ import {
ChangeDetectorRef,
PLATFORM_ID,
Inject,
ViewChild,
ElementRef,
} from '@angular/core';
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
import { isPlatformBrowser } from '@angular/common';
import { Subscription } from 'rxjs';
import { WalletDashboardService } from './dashboard.service';
import { Session } from '../../../services/session';
import { ActivatedRoute, Router, ParamMap } from '@angular/router';
// import { MindsTitle } from '../../../services/ux/title';
import sidebarMenu from './sidebar-menu.default';
import { Menu } from '../../../common/components/sidebar-menu/sidebar-menu.component';
import { ShadowboxHeaderTab } from '../../../interfaces/dashboard';
// TODOOJM DON"T USE THIS BC SSR??
import { Storage } from '../../../services/storage';
import { FeaturesService } from '../../../services/features.service';
@Component({
selector: 'm-walletDashboard',
......@@ -26,6 +25,11 @@ import { Storage } from '../../../services/storage';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WalletDashboardComponent implements OnInit {
@ViewChild('tokensSettings', { static: true }) tokenSettingsEl: ElementRef;
@ViewChild('cashSettings', { static: true }) cashSettingsEl: ElementRef;
@ViewChild('dashboardViewsTabs', { static: true })
dashboardViewsTabsEl: ElementRef;
menu: Menu = sidebarMenu;
paramsSubscription: Subscription;
wallet = {};
......@@ -56,8 +60,6 @@ export class WalletDashboardComponent implements OnInit {
protected router: Router,
protected route: ActivatedRoute,
protected cd: ChangeDetectorRef,
// protected title: MindsTitle,
protected storage: Storage,
@Inject(PLATFORM_ID) private platformId
) {}
......@@ -68,14 +70,12 @@ export class WalletDashboardComponent implements OnInit {
}
if (
this.storage.get('walletOnboardingComplete') ||
(this.session.getLoggedInUser().rewards &&
this.session.getLoggedInUser().eth_wallet)
this.session.getLoggedInUser().rewards &&
this.session.getLoggedInUser().eth_wallet
) {
this.onboardingComplete = true;
}
// this.title.setTitle('Wallet');
this.wallet = this.walletService.getWallet();
this.route.paramMap.subscribe((params: ParamMap) => {
......@@ -130,7 +130,8 @@ export class WalletDashboardComponent implements OnInit {
}
onboardingCompleted() {
this.storage.set('walletOnboardingComplete', true);
// TODOOJM remove once verified its not necessary
// this.storage.set('walletOnboardingComplete', true);
this.onboardingComplete = true;
this.detectChanges();
}
......@@ -140,7 +141,11 @@ export class WalletDashboardComponent implements OnInit {
// TODOOJM change 'v2wallet' once url is changed in wallet module
this.router.navigate([`/v2wallet/${currency}/settings`]);
} else {
const settingsEl = document.getElementById(`${currency}Settings`);
const settingsEl =
currency === 'cash'
? this.cashSettingsEl.nativeElement
: this.tokenSettingsEl.nativeElement;
if (!settingsEl) {
this.updateView('settings');
}
......@@ -149,7 +154,7 @@ export class WalletDashboardComponent implements OnInit {
if (isPlatformBrowser(this.platformId)) {
setTimeout(
() =>
document.getElementById('dashboardViewsTabs').scrollIntoView({
this.dashboardViewsTabsEl.nativeElement.scrollIntoView({
behavior: 'smooth',
}),
0
......
......@@ -147,7 +147,6 @@ export class WalletDashboardService {
this.getEthAccount();
this.getStripeAccount();
// TODOOJM !!! remove any refs to window.Minds !!!
// TODOOJM toggle me before pushing
this.wallet = fakeData.wallet;
......
......@@ -5,7 +5,10 @@ import {
EventEmitter,
OnDestroy,
HostListener,
Inject,
PLATFORM_ID,
} from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
@Component({
selector: 'm-walletModal',
......@@ -23,16 +26,19 @@ export class WalletModalComponent implements OnDestroy {
}
@Output() closeModal: EventEmitter<any> = new EventEmitter();
constructor() {}
constructor(@Inject(PLATFORM_ID) protected platformId: Object) {}
show() {
if (document && document.body) {
this.justOpened = true;
document.body.classList.add('m-overlay-modal--shown--no-scroll');
// Prevent dismissal of modal when it's just been opened
this.showModalTimeout = setTimeout(() => {
this.justOpened = false;
}, 20);
if (isPlatformBrowser(this.platformId)) {
// Prevent dismissal of modal when it's just been opened
this.showModalTimeout = setTimeout(() => {
this.justOpened = false;
}, 20);
}
}
}
......
......@@ -6,12 +6,7 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
} from '@angular/core';
import {
FormBuilder,
AbstractControl,
FormGroup,
FormControl,
} from '@angular/forms';
import { FormBuilder } from '@angular/forms';
import { Client } from '../../../../services/api';
import { Session } from '../../../../services/session';
......@@ -32,6 +27,8 @@ export class WalletPhoneVerificationComponent implements OnInit {
secret: [''],
});
readonly userHasPhoneHash: boolean;
@Output() phoneVerificationComplete: EventEmitter<any> = new EventEmitter();
constructor(
......@@ -80,7 +77,6 @@ export class WalletPhoneVerificationComponent implements OnInit {
secret: this.form.value.secret,
}
);
window.Minds.user.rewards = true;
this.phoneVerificationComplete.emit();
} catch (e) {
this.invalidCode = true;
......
<div class="mdl-spinner mdl-js-spinner is-active" [mdl] *ngIf="!loaded"></div>
<div class="m-walletSettings" id="cashSettings" *ngIf="loaded">
<div class="m-walletSettings" *ngIf="loaded">
<ng-container *ngIf="!account">
<h2>Bank Information</h2>
<p>Add your bank account details where rewards are deposited.</p>
......
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { WalletDashboardService } from '../dashboard.service';
import { FormToastService } from '../../../../common/services/form-toast.service';
import {
FormGroup,
FormControl,
Validators,
AbstractControl,
} from '@angular/forms';
import { Subscription } from 'rxjs';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { Session } from '../../../../services/session';
@Component({
selector: 'm-walletSettings--cash',
......@@ -31,7 +26,8 @@ export class WalletSettingsCashComponent implements OnInit {
constructor(
protected walletService: WalletDashboardService,
private formToastService: FormToastService,
private cd: ChangeDetectorRef
private cd: ChangeDetectorRef,
protected session: Session
) {}
ngOnInit() {
......@@ -98,7 +94,8 @@ export class WalletSettingsCashComponent implements OnInit {
this.walletService
.leaveMonetization()
.then((response: any) => {
(<any>window).Minds.user.merchant = [];
// TODOOJM what to do here?
// (<any>window).Minds.user.merchant = [];
this.getAccount();
})
.catch(e => {
......
<div class="m-walletSettings" id="tokensSettings" *ngIf="wallet">
<div class="m-walletSettings" *ngIf="wallet">
<div class="m-walletSettingsView--setup" *ngIf="!display">
<h4>
On-chain address
......@@ -12,7 +12,7 @@
<div>
<img
class="metamask"
[src]="minds.cdn_assets_url + 'assets/ext/metamask.png'"
[src]="cdn_assets_url + 'assets/ext/metamask.png'"
/>
<h2>
MetaMask
......
......@@ -7,7 +7,12 @@ import {
Input,
Output,
EventEmitter,
Inject,
PLATFORM_ID,
} from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { ConfigsService } from '../../../../common/services/configs.service';
import { Router } from '@angular/router';
import {
FormGroup,
......@@ -24,7 +29,6 @@ import { Web3WalletService } from '../../../blockchain/web3-wallet.service';
import { getBrowser } from '../../../../utils/browser';
import { FormToastService } from '../../../../common/services/form-toast.service';
import { WalletDashboardService } from '../dashboard.service';
import { Subscription } from 'rxjs';
enum Views {
CreateAddress = 1,
......@@ -50,8 +54,8 @@ export class WalletSettingsTokensComponent implements OnInit, OnDestroy {
currentAddress: string = '';
downloadingMetamask: boolean = false;
form;
// TODOOJM remove this bc SSR -- used in html > [src]="minds.cdn_assets_url + 'assets/ext/metamask.png'"
minds = window.Minds;
readonly cdnAssetsUrl: string;
readonly Views = Views;
......@@ -66,8 +70,12 @@ export class WalletSettingsTokensComponent implements OnInit, OnDestroy {
protected blockchain: BlockchainService,
protected web3Wallet: Web3WalletService,
private formToastService: FormToastService,
protected walletService: WalletDashboardService
) {}
protected walletService: WalletDashboardService,
private configs: ConfigsService,
@Inject(PLATFORM_ID) protected platformId: Object
) {
this.cdnAssetsUrl = configs.get('cdn_assets_url');
}
// TODOOJM add fx to reload whenever the current setting is updated
......@@ -150,13 +158,15 @@ export class WalletSettingsTokensComponent implements OnInit, OnDestroy {
link.click();
document.body.removeChild(link);
setTimeout(() => {
URL.revokeObjectURL(objectUrl);
this.generatedAccount = null;
this.addressSetupComplete.emit();
this.inProgress = false;
this.detectChanges();
}, 1000);
if (isPlatformBrowser(this.platformId)) {
setTimeout(() => {
URL.revokeObjectURL(objectUrl);
this.generatedAccount = null;
this.addressSetupComplete.emit();
this.inProgress = false;
this.detectChanges();
}, 1000);
}
}
this.display = Views.CurrentAddress;
} catch (e) {
......@@ -211,7 +221,7 @@ export class WalletSettingsTokensComponent implements OnInit, OnDestroy {
default:
url = 'https://metamask.io';
}
// TODOOJM remove window?
window.open(url);
this.downloadingMetamask = true;
}
......@@ -220,11 +230,11 @@ export class WalletSettingsTokensComponent implements OnInit, OnDestroy {
this.linkingMetamask = true;
await this.web3Wallet.ready();
this.detectExternal();
// TODOOJM remove timers
this._externalTimer = setInterval(() => {
this.detectExternal();
}, 1000);
if (isPlatformBrowser(this.platformId)) {
this._externalTimer = setInterval(() => {
this.detectExternal();
}, 1000);
}
}
async detectExternal() {
......@@ -235,7 +245,6 @@ export class WalletSettingsTokensComponent implements OnInit, OnDestroy {
this.providedAddress = address;
this.detectChanges();
// TODOOJM remove timers
if (this.providedAddress) {
clearInterval(this._externalTimer);
this.provideAddress();
......
......@@ -169,6 +169,9 @@ const walletRoutes: Routes = [
// TODOOJM: also allow **
redirectTo: 'v2wallet/tokens/overview',
pathMatch: 'full',
data: {
title: 'Wallet',
},
},
{ path: 'v2wallet/:currency/:view', component: WalletDashboardComponent },
{ path: 'v2wallet/:currency', component: WalletDashboardComponent },
......