creation of the panels structure

This commit is contained in:
Nicolas Constant 2018-09-22 00:22:51 -04:00
parent 658aaec338
commit 0c9994849c
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
28 changed files with 321 additions and 130 deletions

View File

@ -1,6 +1,6 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ElectronService } from 'ngx-electron';
import { NavigationService } from './services/navigation.service';
import { NavigationService, LeftPanelType } from './services/navigation.service';
import { Subscription } from 'rxjs';
import { AccountWrapper } from './models/account.models';
@ -22,11 +22,11 @@ export class AppComponent implements OnInit, OnDestroy{
}
ngOnInit(): void {
this.columnEditorSub = this.navigationService.openColumnEditorSubject.subscribe((acc: AccountWrapper) => {
if(acc) {
this.floatingColumnActive = true;
} else {
this.columnEditorSub = this.navigationService.activatedPanelSubject.subscribe((type: LeftPanelType) => {
if(type === LeftPanelType.Closed) {
this.floatingColumnActive = false;
} else {
this.floatingColumnActive = true;
}
});
}

View File

@ -23,12 +23,15 @@ import { AccountsState } from "./states/accounts.state";
import { AccountIconComponent } from './components/left-side-bar/account-icon/account-icon.component';
import { NavigationService } from "./services/navigation.service";
import { FloatingColumnComponent } from './components/floating-column/floating-column.component';
import { ColumnsEditorComponent } from './components/floating-column/columns-editor/columns-editor.component';
import { MessageEditorComponent } from './components/floating-column/message-editor/message-editor.component';
import { StreamsState } from "./states/streams.state";
import { StatusComponent } from "./components/stream/status/status.component";
import { MastodonService } from "./services/mastodon.service";
import { AttachementsComponent } from './components/stream/status/attachements/attachements.component';
import { SettingsComponent } from './components/floating-column/settings/settings.component';
import { AddNewAccountComponent } from './components/floating-column/add-new-account/add-new-account.component';
import { SearchComponent } from './components/floating-column/search/search.component';
import { AddNewStatusComponent } from "./components/floating-column/add-new-status/add-new-status.component";
import { ManageAccountComponent } from "./components/floating-column/manage-account/manage-account.component";
const routes: Routes = [
{ path: "", redirectTo: "home", pathMatch: "full" },
@ -48,9 +51,12 @@ const routes: Routes = [
RegisterNewAccountComponent,
AccountIconComponent,
FloatingColumnComponent,
ColumnsEditorComponent,
MessageEditorComponent,
AttachementsComponent
ManageAccountComponent,
AddNewStatusComponent,
AttachementsComponent,
SettingsComponent,
AddNewAccountComponent,
SearchComponent
],
imports: [
BrowserModule,

View File

@ -0,0 +1,3 @@
<p>
add-new-account works!
</p>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AddNewAccountComponent } from './add-new-account.component';
describe('AddNewAccountComponent', () => {
let component: AddNewAccountComponent;
let fixture: ComponentFixture<AddNewAccountComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddNewAccountComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddNewAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-add-new-account',
templateUrl: './add-new-account.component.html',
styleUrls: ['./add-new-account.component.scss']
})
export class AddNewAccountComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AddNewAccountComponent } from '../add-new-account/add-new-account.component';
describe('AddNewAccountComponent', () => {
let component: AddNewAccountComponent;
let fixture: ComponentFixture<AddNewAccountComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddNewAccountComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddNewAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-add-new-status',
templateUrl: './add-new-status.component.html',
styleUrls: ['./add-new-status.component.scss']
})
export class AddNewStatusComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

View File

@ -3,7 +3,9 @@
<a class="close-button" href (click)="closePanel()" title="close">x</a>
</div>
<app-columns-editor *ngIf="columnEditorIsOpen" [account]="userAccountUsed"></app-columns-editor>
<app-message-editor *ngIf="messageEditorIsOpen"></app-message-editor>
<app-manage-account *ngIf="openPanel === 'manageAccount'" [account]="userAccountUsed"></app-manage-account>
<app-add-new-status *ngIf="openPanel === 'createNewStatus'"></app-add-new-status>
<app-add-new-account *ngIf="openPanel === 'addNewAccount'"></app-add-new-account>
<app-search *ngIf="openPanel === 'search'"></app-search>
<app-settings *ngIf="openPanel === 'settings'"></app-settings>
</div>

View File

@ -1,34 +1,51 @@
import { Component, OnInit } from '@angular/core';
import { NavigationService } from '../../services/navigation.service';
import { NavigationService, LeftPanelType } from '../../services/navigation.service';
import { AccountWrapper } from '../../models/account.models';
@Component({
selector: 'app-floating-column',
templateUrl: './floating-column.component.html',
styleUrls: ['./floating-column.component.scss']
selector: 'app-floating-column',
templateUrl: './floating-column.component.html',
styleUrls: ['./floating-column.component.scss']
})
export class FloatingColumnComponent implements OnInit {
userAccountUsed: AccountWrapper;
columnEditorIsOpen: boolean;
messageEditorIsOpen: boolean;
userAccountUsed: AccountWrapper;
constructor(private readonly navigationService: NavigationService) { }
openPanel: string;
ngOnInit() {
this.navigationService.openColumnEditorSubject.subscribe((acc: AccountWrapper) => {
this.userAccountUsed = acc;
if(this.userAccountUsed) {
this.columnEditorIsOpen = true;
} else {
this.columnEditorIsOpen = false;
}
});
}
closePanel(): boolean {
this.navigationService.closeColumnEditor();
return false;
}
constructor(private readonly navigationService: NavigationService) { }
ngOnInit() {
this.navigationService.activatedPanelSubject.subscribe((type: LeftPanelType) => {
switch (type) {
case LeftPanelType.Closed:
this.openPanel = '';
break;
case LeftPanelType.AddNewAccount:
this.openPanel = 'addNewAccount';
break;
case LeftPanelType.CreateNewStatus:
this.openPanel = 'createNewStatus';
break;
case LeftPanelType.ManageAccount:
this.userAccountUsed = this.navigationService.getAccountToManage();
this.openPanel = 'manageAccount';
break;
case LeftPanelType.Search:
this.openPanel = 'search';
break;
case LeftPanelType.Settings:
this.openPanel = 'settings';
break;
default:
this.openPanel = '';
}
});
}
closePanel(): boolean {
this.navigationService.closePanel();
return false;
}
}

View File

@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MessageEditorComponent } from './message-editor.component';
import { ManageAccountComponent } from './manage-account.component';
describe('MessageEditorComponent', () => {
let component: MessageEditorComponent;
let fixture: ComponentFixture<MessageEditorComponent>;
describe('ManageAccountComponent', () => {
let component: ManageAccountComponent;
let fixture: ComponentFixture<ManageAccountComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MessageEditorComponent ]
declarations: [ ManageAccountComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MessageEditorComponent);
fixture = TestBed.createComponent(ManageAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

View File

@ -5,11 +5,11 @@ import { AccountsStateModel, AccountInfo } from '../../../states/accounts.state'
import { AccountWrapper } from '../../../models/account.models';
@Component({
selector: 'app-columns-editor',
templateUrl: './columns-editor.component.html',
styleUrls: ['./columns-editor.component.scss']
selector: 'app-manage-account',
templateUrl: './manage-account.component.html',
styleUrls: ['./manage-account.component.scss']
})
export class ColumnsEditorComponent implements OnInit {
export class ManageAccountComponent implements OnInit {
@Input() account: AccountWrapper;
availableStreams: StreamElement[] = [];

View File

@ -1,15 +0,0 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-message-editor',
templateUrl: './message-editor.component.html',
styleUrls: ['./message-editor.component.scss']
})
export class MessageEditorComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

View File

@ -0,0 +1,3 @@
<p>
search works!
</p>

View File

@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ColumnsEditorComponent } from './columns-editor.component';
import { SearchComponent } from './search.component';
describe('ColumnsEditorComponent', () => {
let component: ColumnsEditorComponent;
let fixture: ComponentFixture<ColumnsEditorComponent>;
describe('SearchComponent', () => {
let component: SearchComponent;
let fixture: ComponentFixture<SearchComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ColumnsEditorComponent ]
declarations: [ SearchComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ColumnsEditorComponent);
fixture = TestBed.createComponent(SearchComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.scss']
})
export class SearchComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

View File

@ -0,0 +1,3 @@
<p>
settings works!
</p>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SettingsComponent } from './settings.component';
describe('SettingsComponent', () => {
let component: SettingsComponent;
let fixture: ComponentFixture<SettingsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SettingsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SettingsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-settings',
templateUrl: './settings.component.html',
styleUrls: ['./settings.component.scss']
})
export class SettingsComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

View File

@ -1,9 +1,8 @@
<div class="left-bar">
<a class="left-bar-button left-bar-button--status left-bar-link" href title="write new message" (click)="createNewToot()">
<!-- <span class="ion ion-md-paper-plane" style="font-size: 32px;"></span> -->
<a class="left-bar-button left-bar-button--status left-bar-link" href title="write new message" (click)="createNewStatus()">
<span class="ion ion-md-send" style="font-size: 32px;"></span>
</a>
<a class="left-bar-button left-bar-button--search left-bar-link" href title="search" (click)="createNewToot()">
<a class="left-bar-button left-bar-button--search left-bar-link" href title="search" (click)="openSearch()">
<span class="ion ion-md-search" style="font-size: 32px;"></span>
</a>
@ -14,11 +13,11 @@
<!-- <a href title="{{ account.username }}" (click)="toogleAccount(account.id)"><img src="{{ account.avatar }}" /></a> -->
</div>
<a class="left-bar-button left-bar-button--add left-bar-link" href title="add new account" [routerLink]="['/register']">
<a class="left-bar-button left-bar-button--add left-bar-link" href title="add new account" (click)="addNewAccount()">
<span class="ion ion-md-add" style="font-size:26px;"></span>
</a>
<a class="left-bar-button left-bar-button--cog left-bar-link" href title="settings" (click)="createNewToot()">
<a class="left-bar-button left-bar-button--cog left-bar-link" href title="settings" (click)="openSettings()">
<span class="ion ion-md-cog" style="font-size: 32px;"></span>
</a>
</div>

View File

@ -5,66 +5,82 @@ import { Store } from "@ngxs/store";
import { Account } from "../../services/models/mastodon.interfaces";
import { AccountWrapper } from "../../models/account.models";
import { AccountsStateModel, AccountInfo } from "../../states/accounts.state";
import { NavigationService } from "../../services/navigation.service";
import { NavigationService, LeftPanelType } from "../../services/navigation.service";
import { MastodonService } from "../../services/mastodon.service";
@Component({
selector: "app-left-side-bar",
templateUrl: "./left-side-bar.component.html",
styleUrls: ["./left-side-bar.component.scss"]
selector: "app-left-side-bar",
templateUrl: "./left-side-bar.component.html",
styleUrls: ["./left-side-bar.component.scss"]
})
export class LeftSideBarComponent implements OnInit, OnDestroy {
accounts: AccountWrapper[] = [];
accounts$: Observable<AccountInfo[]>;
accounts: AccountWrapper[] = [];
accounts$: Observable<AccountInfo[]>;
private loadedAccounts: { [index: string]: AccountInfo } = {};
private sub: Subscription;
private loadedAccounts: { [index: string]: AccountInfo } = {};
private sub: Subscription;
constructor(
private readonly navigationService: NavigationService,
private readonly mastodonService: MastodonService,
private readonly store: Store) {
constructor(
private readonly navigationService: NavigationService,
private readonly mastodonService: MastodonService,
private readonly store: Store) {
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
}
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
}
private currentLoading: number;
ngOnInit() {
this.accounts$.subscribe((accounts: AccountInfo[]) => {
if (accounts) {
this.loadedAccounts = {};
this.accounts.length = 0;
private currentLoading: number;
ngOnInit() {
this.accounts$.subscribe((accounts: AccountInfo[]) => {
if (accounts) {
this.loadedAccounts = {};
this.accounts.length = 0;
for (let acc of accounts) {
const accWrapper = new AccountWrapper();
accWrapper.username = `${acc.username}@${acc.instance}`;
this.accounts.push(accWrapper);
this.loadedAccounts[accWrapper.username] = acc;
for (let acc of accounts) {
const accWrapper = new AccountWrapper();
accWrapper.username = `${acc.username}@${acc.instance}`;
this.accounts.push(accWrapper);
this.loadedAccounts[accWrapper.username] = acc;
this.mastodonService.retrieveAccountDetails(acc)
.then((result: Account) => {
accWrapper.avatar = result.avatar;
});
}
}
});
}
this.mastodonService.retrieveAccountDetails(acc)
.then((result: Account) => {
accWrapper.avatar = result.avatar;
});
}
}
});
}
ngOnDestroy(): void {
this.sub.unsubscribe();
}
ngOnDestroy(): void {
this.sub.unsubscribe();
}
onToogleAccountNotify(acc: AccountWrapper) {
console.warn(`onToogleAccountNotify username ${acc.username}`);
}
onToogleAccountNotify(acc: AccountWrapper) {
console.warn(`onToogleAccountNotify username ${acc.username}`);
}
onOpenMenuNotify(acc: AccountWrapper) {
console.warn(`onOpenMenuNotify username ${acc.username}`);
this.navigationService.openColumnEditor(acc);
}
onOpenMenuNotify(acc: AccountWrapper) {
console.warn(`onOpenMenuNotify username ${acc.username}`);
this.navigationService.openColumnEditor(acc);
}
createNewToot(): boolean {
return false;
}
createNewStatus(): boolean {
this.navigationService.openPanel(LeftPanelType.CreateNewStatus);
return false;
}
openSearch(): boolean {
this.navigationService.openPanel(LeftPanelType.Search);
return false;
}
addNewAccount(): boolean {
this.navigationService.openPanel(LeftPanelType.AddNewAccount);
return false;
}
openSettings(): boolean {
this.navigationService.openPanel(LeftPanelType.Settings);
return false;
}
}

View File

@ -5,20 +5,42 @@ import { AccountWrapper } from '../models/account.models';
@Injectable()
export class NavigationService {
openColumnEditorSubject = new BehaviorSubject<AccountWrapper>(null);
columnSelectedSubject = new BehaviorSubject<number>(-1);
constructor() { }
private accountToManage: AccountWrapper;
activatedPanelSubject = new BehaviorSubject<LeftPanelType>(LeftPanelType.Closed);
// openColumnEditorSubject = new BehaviorSubject<AccountWrapper>(null);
columnSelectedSubject = new BehaviorSubject<number>(-1);
openColumnEditor(acc: AccountWrapper) {
this.openColumnEditorSubject.next(acc);
}
constructor() { }
closeColumnEditor() {
this.openColumnEditorSubject.next(null);
}
openColumnEditor(acc: AccountWrapper) {
this.accountToManage = acc;
this.activatedPanelSubject.next(LeftPanelType.ManageAccount);
}
columnSelected(index: number): void {
this.columnSelectedSubject.next(index);
}
openPanel(type: LeftPanelType){
this.activatedPanelSubject.next(type);
}
closePanel() {
this.activatedPanelSubject.next(LeftPanelType.Closed);
this.accountToManage = null;
}
columnSelected(index: number): void {
this.columnSelectedSubject.next(index);
}
getAccountToManage(): AccountWrapper {
return this.accountToManage;
}
}
export enum LeftPanelType {
Closed = 0,
ManageAccount = 1,
CreateNewStatus = 2,
Search = 3,
AddNewAccount = 4,
Settings = 5
}