Skip to content

Commit

Permalink
Add admin section to manage users and server settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreb committed Oct 11, 2023
1 parent 65588d9 commit 9f6caf9
Show file tree
Hide file tree
Showing 8 changed files with 627 additions and 26 deletions.
87 changes: 87 additions & 0 deletions app/src/app/admin/admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.example-action-buttons {
padding-bottom: 20px;
}

.example-headers-align .mat-expansion-panel-header-description {
justify-content: space-between;
align-items: center;
}

.example-headers-align .mat-mdc-form-field + .mat-mdc-form-field {
margin-left: 8px;
}

.online {
margin-left: 0.2em;
margin-bottom: -0.2em;
}

.relay-status-0 {
color: silver;
}

.relay-status-1 {
color: green;
}

.relay-status-2 {
color: orange;
}

.relay-status-3 {
color: red;
}

.relay-status-4 {
color: rgb(49, 49, 210);
}

.relay-read-disabled {
color: rgb(49, 49, 210) !important;
}

.relay-disabled {
color: rgb(234, 136, 9) !important;
}

.primary-relay {
color: rgb(198, 3, 181);
}

.relay-options {
margin-top: 0.4em;
margin-bottom: 0.2em;
}

.settings-action-buttons {
padding-top: 0.8em;
padding-bottom: 1em;
}

.settings-action-buttons button {
margin-bottom: 1em;
margin-right: 1em;
}

/* When changing the sidenav-content to flex, the toolbar does not render properly, so a minor hack is needed. */
@media only screen and (max-width: 599px) {
.settings-action-buttons button {
width: 100%;
margin-right: 0;
}

.mat-expansion-panel-header-title {
flex-grow: 2 !important;
}

.mat-expansion-panel-header-description {
flex-grow: 1 !important;
}
}

.relay-button {
margin-top: 0.8em;
}
.options-slider {
margin-left: 1em;
}
178 changes: 178 additions & 0 deletions app/src/app/admin/admin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<div class="full-page">
<mat-tab-group>
<!-- <mat-tab>
<ng-template mat-tab-label>
<mat-icon class="example-tab-icon">dns</mat-icon>
<span *ngIf="(appState.displayLabels$ | async) === false">&nbsp;Relays</span>
</ng-template>
<ng-template matTabContent>
<div class="page">
<app-relays [relays]="relayService.items2"></app-relays>
<div class="settings-action-buttons">
<button mat-flat-button color="primary" (click)="getRelays()">Append from extension</button><button mat-flat-button color="primary" (click)="getDefaultRelays()">Append from app</button>
<br />
<button mat-flat-button (click)="dataService.publishContactsAndRelays()">Publish relay (and following) list</button> <button mat-flat-button (click)="dataService.publishRelays()">Publish relay (NIP-65) list</button><br /><br />
<button mat-flat-button color="warn" (click)="deleteRelays()">Delete all relays</button>
</div>
</div>
</ng-template>
</mat-tab> -->
<mat-tab>
<ng-template mat-tab-label>
<mat-icon class="example-tab-icon">manage_accounts</mat-icon>
<span *ngIf="(appState.displayLabels$ | async) === false">&nbsp;{{'Admin.Users' | translate }}</span>
</ng-template>
<ng-template matTabContent>
<div class="page">
<!-- <mat-card>
<mat-card-header>
<mat-card-title>{{ 'Settings.OptionsTitle' | translate}}</mat-card-title>
<mat-card-subtitle>{{ 'Settings.OptionsDescription' | translate}}</mat-card-subtitle>
</mat-card-header>
<mat-card-content> -->
<!-- <br />
<mat-form-field class="input-full-width">
<mat-label>{{ 'Settings.DisplayLanguage' | translate}}</mat-label>
<mat-select (selectionChange)="onLanguageChanged($event)" [(value)]="optionsService.values.language">
<mat-option *ngFor="let lang of translate.getLangs()" [value]="lang"> {{ lang | translate }}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="input-full-width">
<mat-label>{{ 'Settings.ChooseMode' | translate }}</mat-label>
<mat-select (selectionChange)="theme.darkMode = !theme.darkMode" [value]="theme.darkMode">
<mat-option [value]="true">{{ 'Settings.Dark' | translate }}</mat-option>
<mat-option [value]="false">{{ 'Settings.Light' | translate }}</mat-option>
</mat-select>
</mat-form-field> -->
<!-- </mat-card-content>
</mat-card> -->

<br />

<!-- <mat-card>
<mat-card-header>
<mat-card-title>{{ 'Settings.MediaTitle' | translate }}</mat-card-title>
<mat-card-subtitle>{{ 'Settings.MediaSubtitle' | translate }}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<mat-form-field class="input-full-width">
<mat-select [(value)]="optionsService.values.mediaService"> -->
<!-- <mat-option [value]="'void.cat'">void.cat</mat-option> -->
<!-- <mat-option [value]="'nostr.build'">nostr.build</mat-option>
</mat-select>
</mat-form-field>
<p class="dimmed" *ngIf="optionsService.values.mediaService == 'nostr.build'">
By uploading media using this <a href="https://nostr.build" target="_blank">nostr.build</a> you agree to their Terms of Service: <a href="https://nostr.build/tos.html" target="_blank">https://nostr.build/tos.html</a>
</p>
<p class="dimmed" *ngIf="optionsService.values.mediaService == 'void.cat'">
By uploading media using this <a href="https://void.cat" target="_blank">void.cat</a> you agree to their Terms of Service.
</p>
</mat-card-content>
</mat-card> -->

<!-- <br />
<mat-card>
<mat-card-header>
<mat-card-title>{{ 'Settings.Reactions' | translate }}</mat-card-title>
<mat-card-subtitle>{{ 'Settings.ReactionsSubtitle' | translate }}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>{{'Settings.ReactionsNote' | translate }}</p>
<mat-slide-toggle class="options-slider" (change)="optionsService.save()" [(ngModel)]="optionsService.values.enableReactions">{{ 'Settings.EnableReactions' | translate }}</mat-slide-toggle>
</mat-card-content>
</mat-card>
<br />
<mat-card>
<mat-card-header>
<mat-card-title>{{ 'Settings.Zapping' | translate }}</mat-card-title>
<mat-card-subtitle>{{ 'Settings.ZappingSubtitle' | translate }}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<mat-slide-toggle class="options-slider" (change)="optionsService.save()" [(ngModel)]="optionsService.values.enableZapping">{{ 'Settings.EnableZapping' | translate }}</mat-slide-toggle>
</mat-card-content>
</mat-card> -->

<!-- <br />
<mat-card>
<mat-card-header>
<mat-card-title>{{ 'Settings.MediaWidgets' | translate }}</mat-card-title>
<mat-card-subtitle>{{ 'Settings.MediaWidgetsSubtitle' |translate }}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>{{ 'Settings.MediaWidgetsNote' | translate }}</p>
<mat-slide-toggle class="options-slider" (change)="optionsService.save()" [(ngModel)]="optionsService.values.enableSpotify">{{ 'Settings.EnableSpotify' | translate }}</mat-slide-toggle>
<mat-slide-toggle class="options-slider" (change)="optionsService.save()" [(ngModel)]="optionsService.values.enableTidal">{{ 'Settings.EnableTidal' | translate }}</mat-slide-toggle>
<p><button mat-button (click)="openMediaPlayer()">{{ 'Settings.OpenMediaPlayer' | translate }}</button></p>
</mat-card-content>
</mat-card> -->

<!-- <br />
<mat-card>
<mat-card-content>
<button mat-stroked-button (click)="registerHandler('web+nostr', 'nostr')">{{ 'Settings.RegisterProtocolHandler' | translate }}</button>
<br /><br />
<div class="dimmed">{{ 'Settings.RegisterProtocolHandlerNote' | translate }}</div>
</mat-card-content>
</mat-card> -->
</div>
</ng-template>
</mat-tab>

<mat-tab>
<ng-template mat-tab-label>
<mat-icon class="example-tab-icon">settings_applications</mat-icon>
<span *ngIf="(appState.displayLabels$ | async) === false">&nbsp;{{ 'App.Settings' | translate }}</span>
</ng-template>
<ng-template matTabContent>
<div class="page">
<!-- <mat-card *ngIf="hasPrivateKey">
<mat-card-header>
<mat-card-title>{{ 'Settings.ExportPrivateKey' | translate }}</mat-card-title>
<mat-card-subtitle>{{ 'Settings.ExportPrivateKeyNote' | translate }}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<button class="signup-button" mat-stroked-button (click)="exportPrivateKey()">{{ 'Settings.ExportPrivateKey' | translate }}</button>
<div class="selectable wrap" *ngIf="verifiedWalletPassword === true">
<br />{{ 'Settings.PrivateKey' | translate }}:
<p>
{{ privateKey }}<button class="copy-button" mat-icon-button [cdkCopyToClipboard]="privateKey!">
<mat-icon>content_copy</mat-icon>
</button>
</p>
<p>
<img [src]="qrCodePrivateKey" class="qr-code" />
</p>
</div>
<div *ngIf="verifiedWalletPassword === false">{{ 'Settings.InvalidPassword' | translate }}</div>
<button *ngIf="verifiedWalletPassword === true" class="signup-button" mat-flat-button color="warn" (click)="resetPrivateKey()">{{ 'Settings.Hide' | translate }}</button>
</mat-card-content>
</mat-card> -->

<!-- <p>
<button mat-flat-button color="warn" (click)="clearProfileCache()">Clear Public Profile Cache</button>
</p>
<p *ngIf="wipedNonFollow">All public profile cache data was cleared.</p>
<p>
<button mat-flat-button color="warn" (click)="clearNotesCache()">Clear Notes Cache</button>
</p>
<p *ngIf="wipedNotes">All cached notes data was cleared.</p> -->
<!-- <br />
<p>
<button mat-flat-button color="warn" (click)="db.clearAndReload()">{{ 'Settings.WipeLocalDatabase' | translate }}</button>
</p>
<p *ngIf="wiped">{{ 'Settings.AllLocalDataCacheWasCleared' | translate }}</p> -->
</div>
</ng-template>
</mat-tab>
</mat-tab-group>
</div>
Loading

0 comments on commit 9f6caf9

Please sign in to comment.