changepermissions & 1 rankserver
This commit is contained in:
Generated
+3
-3
@@ -17940,9 +17940,9 @@
|
||||
"integrity": "sha512-ZYzRkETgBrdEGzL5JSKimvjI2CX7ioyZCkX2BpcfyjqI+079W0wHAyj5W4rIZMcDSOHgLZtgz1IdDi/vU77KEQ=="
|
||||
},
|
||||
"rpclibrary": {
|
||||
"version": "1.8.3",
|
||||
"resolved": "https://registry.npmjs.org/rpclibrary/-/rpclibrary-1.8.3.tgz",
|
||||
"integrity": "sha512-8pQRbMXQKCf3+v+XM01d+1Bw73pg5YzgyhW/ACpYON1I4re5fZAjWGPyLc+ms+MlYQIlKc3Uk92PGot2sbb85Q==",
|
||||
"version": "1.9.2",
|
||||
"resolved": "https://registry.npmjs.org/rpclibrary/-/rpclibrary-1.9.2.tgz",
|
||||
"integrity": "sha512-MOtVm0IBRLryXag1IwkYNPVFegbvW10+MbCjhr3GptO3MA7nHZ545ammgoCWnREtGOgFeN4Jib/EBDOJ9Ep41Q==",
|
||||
"requires": {
|
||||
"bsock": "^0.1.9",
|
||||
"http": "0.0.0",
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
"normalize.css": "6.0.0",
|
||||
"pace-js": "1.0.2",
|
||||
"roboto-fontface": "0.8.0",
|
||||
"rpclibrary": "^1.8.3",
|
||||
"rpclibrary": "^1.9.2",
|
||||
"rxjs": "6.5.2",
|
||||
"rxjs-compat": "6.3.0",
|
||||
"socicon": "3.0.5",
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
|
||||
<div class="header-container">
|
||||
<nb-actions size="small">
|
||||
|
||||
<nb-action
|
||||
*ngIf="modifyPermissions"
|
||||
icon="settings-2-outline"
|
||||
link="/permissions">
|
||||
</nb-action>
|
||||
<nb-action
|
||||
*ngIf="!newmessage"
|
||||
icon="message-square-outline"
|
||||
|
||||
@@ -48,6 +48,7 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||
chatlog: ShoutMessage[] = []
|
||||
newmessage = false
|
||||
lastmessage = "asdasd"
|
||||
modifyPermissions
|
||||
|
||||
constructor(private sidebarService: NbSidebarService,
|
||||
private router: Router,
|
||||
@@ -62,7 +63,7 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||
this.themeService.changeTheme("dark");
|
||||
|
||||
this.currentTheme = this.themeService.currentTheme;
|
||||
|
||||
this.modifyPermissions = this.api.get('modifyPermissions')
|
||||
this.user = this.api.getCurrentUser()
|
||||
if(this.user)
|
||||
this.userMenu.unshift({ title: 'Profile', link: '/frontcraft/user/'+this.user.username });
|
||||
|
||||
@@ -2,7 +2,11 @@ import { ExtraOptions, RouterModule, Routes } from '@angular/router';
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
const routes: Routes = [
|
||||
|
||||
{
|
||||
path: 'permissions',
|
||||
loadChildren: () => import('./frontcraft/permissions/permissions.module')
|
||||
.then(m => m.PermissionsModule),
|
||||
},
|
||||
{
|
||||
path: 'auth',
|
||||
loadChildren: () => import('./frontcraft/auth/auth.module')
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<nb-card>
|
||||
<nb-card-body>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Name
|
||||
</th>
|
||||
<th *ngFor="let rank of ranks">
|
||||
{{rank}}
|
||||
</th>
|
||||
</tr>
|
||||
<tr *ngFor="let perm of permissions">
|
||||
<td>{{perm.rpcname}}</td>
|
||||
<td *ngFor="let rank of ranks">
|
||||
<nb-toggle
|
||||
[(ngModel)]="perm[rank]"
|
||||
(checkedChange)="settingChanged($event, rank, perm)">
|
||||
</nb-toggle>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</nb-card-body>
|
||||
</nb-card>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ApiService as ApiService } from '../../services/login-api';
|
||||
import { Router } from '@angular/router';
|
||||
import { _Rank, _Class, _Race, RPCPermission } from '../../../../../../backend/Types/Types'
|
||||
import { NbToastrService } from '@nebular/theme';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'changePermissions',
|
||||
templateUrl: './changePermissions.component.html',
|
||||
})
|
||||
export class ChangePermissionsComponent implements OnInit{
|
||||
|
||||
permissions:RPCPermission[] = []
|
||||
ranks = _Rank
|
||||
|
||||
constructor(
|
||||
private router : Router,
|
||||
private api : ApiService,
|
||||
private toastr: NbToastrService
|
||||
){}
|
||||
|
||||
async ngOnInit(){
|
||||
const modify = this.api.get('modifyPermissions')
|
||||
if(!modify) return
|
||||
this.permissions = await modify.getPermissions()
|
||||
}
|
||||
|
||||
settingChanged = async (value, key, perm:RPCPermission) => {
|
||||
const modify = this.api.get('modifyPermissions')
|
||||
if(!modify) return
|
||||
|
||||
|
||||
perm[key] = value
|
||||
console.log(perm);
|
||||
|
||||
|
||||
await modify.setPermission(perm).catch(e => {
|
||||
|
||||
})
|
||||
this.toastr.success('Permission updated', 'Success')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ApiService } from '../services/login-api';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'auth-layout',
|
||||
template: `
|
||||
<ngx-one-column-no-sidebar-layout>
|
||||
<router-outlet></router-outlet>
|
||||
</ngx-one-column-no-sidebar-layout>
|
||||
`,
|
||||
})
|
||||
|
||||
export class PermissionsComponent implements OnInit{
|
||||
constructor(
|
||||
private loginSvc : ApiService,
|
||||
private router: Router
|
||||
){}
|
||||
|
||||
ngOnInit(){
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { PermissionsComponent } from './permissions-layout.component';
|
||||
import { ChangePermissionsComponent } from './changePermissions/changePermissions.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: PermissionsComponent,
|
||||
children: [
|
||||
{
|
||||
path: '**',
|
||||
component: ChangePermissionsComponent,
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class PermissionsRoutingModule {
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import {
|
||||
NbAlertModule,
|
||||
NbButtonModule,
|
||||
NbCheckboxModule,
|
||||
NbInputModule,
|
||||
NbMenuModule,
|
||||
NbCardModule,
|
||||
NbSelectModule,
|
||||
NbToggleModule
|
||||
} from '@nebular/theme';
|
||||
import { PermissionsComponent } from './permissions-layout.component';
|
||||
import { ThemeModule } from '../../@theme/theme.module';
|
||||
import { PermissionsRoutingModule } from './permissions-routing.module';
|
||||
import { ChangePermissionsComponent } from './changePermissions/changePermissions.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
NbToggleModule,
|
||||
PermissionsRoutingModule,
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
RouterModule,
|
||||
NbAlertModule,
|
||||
NbInputModule,
|
||||
NbButtonModule,
|
||||
NbCheckboxModule,
|
||||
ThemeModule,
|
||||
NbMenuModule,
|
||||
NbCardModule,
|
||||
NbSelectModule
|
||||
],
|
||||
declarations: [
|
||||
PermissionsComponent,
|
||||
ChangePermissionsComponent,
|
||||
],
|
||||
})
|
||||
export class PermissionsModule {
|
||||
}
|
||||
@@ -34,7 +34,7 @@ export class ApiService{
|
||||
)
|
||||
|
||||
sock.hook('kick', () => {
|
||||
this.logout()
|
||||
this.kick()
|
||||
})
|
||||
|
||||
sock.hook('getUserData', () => auth)
|
||||
@@ -110,6 +110,11 @@ export class ApiService{
|
||||
return async (msg: ShoutMessage) => await this.get('Shoutbox').shout(res.uuid, msg)
|
||||
}
|
||||
|
||||
kick = async () => {
|
||||
await this.logout()
|
||||
location.reload()
|
||||
}
|
||||
|
||||
logout = async () => {
|
||||
this.cookieSvc.set('token', undefined)
|
||||
if(this.auth){
|
||||
|
||||
Reference in New Issue
Block a user