Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cophilot committed Oct 6, 2023
1 parent b0739ce commit 8d6ba28
Show file tree
Hide file tree
Showing 30 changed files with 502 additions and 126 deletions.
2 changes: 2 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { MakeAdminComponent } from './user-input/make-admin/make-admin.component
import { WhatsNewComponent } from './whats-new/whats-new.component';
import { ImpressumComponent } from './impressum/impressum.component';
import { ConnectViaUrlComponent } from './connect-via-url/connect-via-url.component';
import { DeploySpecComponent } from './user-input/deploy-spec/deploy-spec.component';

const routes: Routes = [
{ path: '', component: HomeComponent },
Expand All @@ -25,6 +26,7 @@ const routes: Routes = [
{ path: 'user/make/admin', component: MakeAdminComponent },
{ path: 'user/change/password', component: ChangePasswordComponent },
{ path: 'login', component: LogInComponent },
{ path: 'deploy', component: DeploySpecComponent },
{ path: 'error', component: ErrorPageComponent },
{ path: 'chapter/:chapterName', component: ChapterComponent },
{ path: 'chapter/:chapterName/edit', component: EditChapterComponent },
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { ConnectViaUrlComponent } from './connect-via-url/connect-via-url.compon
import { HashLocationStrategy, LocationStrategy } from '@angular/common';
import { AddFileComponent } from './user-input/add-file/add-file.component';
import { NotificationComponent } from './notification/notification.component';
import { DeploySpecComponent } from './user-input/deploy-spec/deploy-spec.component';
@NgModule({
declarations: [
AppComponent,
Expand Down Expand Up @@ -108,6 +109,7 @@ import { NotificationComponent } from './notification/notification.component';
ConnectViaUrlComponent,
AddFileComponent,
NotificationComponent,
DeploySpecComponent,
],
imports: [
BrowserModule,
Expand Down
7 changes: 6 additions & 1 deletion src/app/chapter-new/chapter-new.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ export class ChapterNewComponent {
return;
}

if(this.name.includes('#')){
if (this.name.includes('#')) {
this.isWrong = true;
this.wrongText = 'Chapter name cannot contain #';
return;
}
if (this.name.includes('~')) {
this.isWrong = true;
this.wrongText = 'Chapter name cannot contain ~';
return;
}

let newChapter = new Chapter(
this.name,
Expand Down
13 changes: 11 additions & 2 deletions src/app/chapter/chapter.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,14 @@ <h1>{{ chapter.Title }}</h1>
(closeEmitter)="export($event)"
></app-export-options> -->
</div>
<app-table-of-content *ngIf="showTOC" (event)="onTOCInput($event)" [chapter]="chapter"></app-table-of-content>
<app-header class="sticky" [chapter]="chapter" (pageChange)="onTOCInput($event - 1)"></app-header>
<app-table-of-content
*ngIf="showTOC"
(event)="onTOCInput($event)"
[chapter]="chapter"
[currentPage]="currentPage"
></app-table-of-content>
<app-header
class="sticky"
[chapter]="chapter"
(pageChange)="onTOCInput($event - 1)"
></app-header>
97 changes: 55 additions & 42 deletions src/app/chapter/chapter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,53 +37,66 @@ export class ChapterComponent {
) {}

ngOnInit(): void {
let x = this.route.snapshot.paramMap.get('chapterName');
if (x == null) {
this.router.navigate(['/']);
return;
let x = this.route.snapshot.paramMap.get('chapterName');

if (x == null) {
this.router.navigate(['/']);
return;
}

this.chapterName = x;
this.chapterManger.init().then(() => {
let heading = undefined;
if (this.chapterName.includes('~')) {
heading = this.chapterName.split('~')[1].toLowerCase();
this.chapterName = this.chapterName.split('~')[0];
}
this.chapter = this.chapterManger.getChapterByName(
this.chapterName,
true
);

if (!this.chapter.IsPrivate) {
if (
UserManger.userLevel == 2 ||
(UserManger.userLevel == 1 &&
this.chapter.Author == UserManger.userName)
) {
VerifyCache.verifyChapter(this.chapter.Title, '', false);
}

this.chapterName = x;
this.chapterManger.init().then(() => {
this.chapter = this.chapterManger.getChapterByName(
this.chapterName,
true
);
if (!this.chapter.IsPrivate) {
if (
UserManger.userLevel == 2 ||
(UserManger.userLevel == 1 &&
this.chapter.Author == UserManger.userName)
) {
VerifyCache.verifyChapter(this.chapter.Title, '', false);
}

this.contentVisible = VerifyCache.isChapterVerified(
this.chapter.Title
);
this.contentVisible = VerifyCache.isChapterVerified(this.chapter.Title);
} else {
if (
UserManger.userLevel == 2 ||
(UserManger.userLevel == 1 &&
this.chapter.Author == UserManger.userName)
) {
this.contentVisible = true;
} else {
if (
UserManger.userLevel == 2 ||
(UserManger.userLevel == 1 &&
this.chapter.Author == UserManger.userName)
) {
this.contentVisible = true;
} else {
this.router.navigate(['/login']);
}
this.router.navigate(['/login']);
}
let pageLocalStorage = this.localStorageService.getPageForChapter(
this.chapterName
);
if (pageLocalStorage < 0) {
pageLocalStorage = 0;
}
if (pageLocalStorage > this.chapter.Pages.length - 1) {
pageLocalStorage = this.chapter.Pages.length - 1;
}
this.currentPage = pageLocalStorage;
}
let pageLocalStorage = this.localStorageService.getPageForChapter(
this.chapterName
);
if (pageLocalStorage < 0) {
pageLocalStorage = 0;
}
if (pageLocalStorage > this.chapter.Pages.length - 1) {
pageLocalStorage = this.chapter.Pages.length - 1;
}
this.currentPage = pageLocalStorage;
this.pageInput = this.currentPage + 1;

if (heading != undefined) {
let headingPage = this.chapter.getPageForHeading(heading);
if (headingPage != -1) {
this.currentPage = headingPage;
this.pageInput = this.currentPage + 1;
});
}
}
});
}

onPageInput() {
Expand Down
29 changes: 16 additions & 13 deletions src/app/code-window/code-window.component.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
<div id="window" [class]="db?'db':''">
<div id="window" [class]="db ? 'db' : ''">
<div id="navbar">
<div id="window-controls">
<div class="red dot"></div>
<div class="yellow dot" (dblclick)="onDblClick()"></div>
<div class="green dot"></div>
<div class="green dot" (dblclick)="toggleCopyable()"></div>
</div>
<div class="test">
<div id="window-title">{{ title }}</div>
<p class="copiedMessage" *ngIf="copied"></p>
<img
class="copy"
*ngIf="!copied && copyable"
[src]="
'assets/imgs/' +
(getDarkModeEnabled() ? 'darkmode' : 'lightmode') +
'/copy.png'
"
alt="Copy"
(click)="copyCode()"
class="copy"
*ngIf="!copied && copyable"
[src]="
'assets/imgs/' +
(getDarkModeEnabled() ? 'darkmode' : 'lightmode') +
'/copy.png'
"
alt="Copy"
(click)="copyCode()"
/>
</div>
<div>
<div class="code">
<pre prism *ngIf="language" [class]="'test' + (copyable?'':' noselect')">
<pre
prism
*ngIf="language"
[class]="'test' + (copyable ? '' : ' noselect')"
>
<code #codeEle class="language-{{ language }}">
{{code}}
</code>
</pre>
</div>
</div>

</div>
</div>
8 changes: 8 additions & 0 deletions src/app/code-window/code-window.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, ElementRef, Input, ViewChild } from '@angular/core';
import * as Prism from 'prismjs';
import { ColorSchemeService } from '../services/color-scheme.service';
import { UserManger } from 'src/utils/classes';

@Component({
selector: 'app-code-window',
Expand Down Expand Up @@ -34,6 +35,13 @@ export class CodeWindowComponent {
}
}

toggleCopyable() {
if (UserManger.userLevel == 0) {
return;
}
this.copyable = !this.copyable;
}

getDarkModeEnabled() {
return this.colorSchemeService.darkModeEnabled;
}
Expand Down
15 changes: 12 additions & 3 deletions src/app/edit/edit-chapter/edit-chapter.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div *ngIf="contentVisible" class="content">
<div class="header">
<button *ngIf="!preview" (click)="goBack()" class="backButton">Back</button>
<div *ngIf="!preview" class="tocButton" (click)="setTOC(true)">
<div *ngIf="!preview" class="tocButton" (click)="setTOC(true)">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
Expand Down Expand Up @@ -68,7 +68,12 @@ <h1 *ngIf="preview" class="previewHeading">PREVIEW</h1>
</button>
<button (click)="save()">{{ (changes ? "*" : "") + "Save" }}</button>
</div>
<app-table-of-content *ngIf="showTOC" (event)="onTOCInput($event)" [chapter]="chapter"></app-table-of-content>
<app-table-of-content
*ngIf="showTOC"
(event)="onTOCInput($event)"
[chapter]="chapter"
[currentPage]="currentPage"
></app-table-of-content>

<app-edit-chapter-meta-data
[updateChapter]="chapter"
Expand All @@ -86,4 +91,8 @@ <h1 *ngIf="preview" class="previewHeading">PREVIEW</h1>
(sureEmitter)="deletePage($event)"
></app-are-you-sure>
</div>
<app-header class="sticky" [chapter]="chapter" (pageChange)="onTOCInput($event - 1)"></app-header>
<app-header
class="sticky"
[chapter]="chapter"
(pageChange)="onTOCInput($event - 1)"
></app-header>
6 changes: 3 additions & 3 deletions src/app/header/header.component.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
header {
box-shadow: 2px 2px 2px rgba(0,0,0,0.1);
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
background-color: var(--header-color);
z-index: 1000;
button {
Expand Down Expand Up @@ -111,7 +111,7 @@ header {
scale: 1.1;
}
}
@media screen and (max-width: 600px) {
@media screen and (max-width: 800px) {
.logo {
height: 30px;
margin-left: 10px;
Expand Down Expand Up @@ -169,4 +169,4 @@ header {
100% {
transform: rotateZ(360deg);
}
};
}
4 changes: 2 additions & 2 deletions src/app/home/home.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
opacity: 0.5;
}
}
@media screen and (max-width: 600px) {
@media screen and (max-width: 800px) {
.serverStatus {
display: none;
}
.version {
display: none;
}
};
}
15 changes: 14 additions & 1 deletion src/app/loading-screen/loading-screen.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<div class="loadingscrren">
<div class="background"></div>
<div class="lds-default"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
<div class="lds-default">
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
<div [style.background]="color"></div>
</div>
</div>
4 changes: 1 addition & 3 deletions src/app/loading-screen/loading-screen.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
left: 50%;
transform: translate(-50%, -50%);


& div {
position: absolute;
width: 6px;
height: 6px;
background: var(--secondary-color);
border-radius: 50%;
animation: lds-default 1.2s linear infinite;
}
Expand Down Expand Up @@ -96,4 +94,4 @@
50% {
transform: scale(1.5);
}
};
}
6 changes: 3 additions & 3 deletions src/app/loading-screen/loading-screen.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Component } from '@angular/core';
import { Component, Input } from '@angular/core';

@Component({
selector: 'app-loading-screen',
templateUrl: './loading-screen.component.html',
styleUrls: ['./loading-screen.component.scss']
styleUrls: ['./loading-screen.component.scss'],
})
export class LoadingScreenComponent {

@Input() color: string = 'var(--primary-color)';
}
2 changes: 1 addition & 1 deletion src/app/notification/notification.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
animation: slideOutToButton 0.51s ease-in-out;
}

@media screen and (max-width: 600px) {
@media screen and (max-width: 800px) {
.box {
width: 100%;
left: 0px;
Expand Down
2 changes: 1 addition & 1 deletion src/app/search-bar-header/search-bar-header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
margin-top: 20px;
color: var(--text-color);
}
@media screen and (max-width: 600px) {
@media screen and (max-width: 800px) {
.searchBar {
width: 100%;
border-radius: 0px;
Expand Down
Loading

0 comments on commit 8d6ba28

Please sign in to comment.