-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31e6510
commit fff0357
Showing
7 changed files
with
122 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="tuxlab-admin-settings" fxLayout="column" fxLayoutAlign="flex-start center"> | ||
|
||
<h1> Settings </h1> | ||
|
||
<textarea mdInput mdTextareaAutosize *ngIf="settings" [(ngModel)]="settings" [disabled]="!edit_mode"></textarea> | ||
|
||
<div class="fab" fxLayout="row" fxLayoutAlign="flex-end center"> | ||
<ng-container [ngSwitch]="edit_mode"> | ||
<button md-fab *ngSwitchCase="true" (click)="update()"> | ||
<md-icon>save</md-icon> | ||
</button> | ||
<button md-fab *ngSwitchCase="false" (click)="edit_mode = true"> | ||
<md-icon>edit</md-icon> | ||
</button> | ||
</ng-container> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.tuxlab-admin-settings{ | ||
width: 100%; | ||
max-width: 960px !important; | ||
min-height: 80vh; | ||
|
||
margin:0 auto; | ||
|
||
h1{ | ||
font-weight: 300; | ||
width: 100%; | ||
} | ||
|
||
textarea{ | ||
width: 100%; | ||
min-height: 800px; | ||
padding: 15px; | ||
|
||
color: #000 !important; | ||
background-color: #fff; | ||
font-family: "Courier New", courier, monospace; | ||
} | ||
|
||
div.fab{ | ||
width: 100%; | ||
position: relative; | ||
top: -100px; | ||
|
||
padding: 10px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Meteor Imports | ||
import { Meteor } from 'meteor/meteor'; | ||
import { MeteorComponent } from 'angular2-meteor'; | ||
|
||
// Angular Imports | ||
import { Component, NgZone } from '@angular/core'; | ||
|
||
// Admin Settings Component | ||
import template from "./admin_settings.component.html"; | ||
import style from "./admin_settings.component.scss"; | ||
|
||
@Component({ | ||
selector: 'tuxlab-admin-settings', | ||
template, | ||
styles: [ style ] | ||
}) | ||
|
||
// Export Dashboard Class | ||
export class AdminSettings extends MeteorComponent { | ||
private settings : any; | ||
private edit_mode : boolean = false; | ||
|
||
constructor(private zone : NgZone) { | ||
super(); | ||
} | ||
|
||
ngOnInit(){ | ||
Meteor.call('Settings.get', (err, res) => { | ||
this.settings = JSON.stringify(res, null, 2); | ||
}) | ||
} | ||
|
||
update(){ | ||
Meteor.call('Settings.set', JSON.parse(this.settings), () => { | ||
this.edit_mode = false; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Users } from '../../both/collections/user.collection'; | ||
|
||
Meteor.methods({ | ||
|
||
'Settings.get'(){ | ||
if (!Meteor.userId()){ | ||
throw new Meteor.Error("Unauthorized"); | ||
} else if (Users.isGlobalAdministrator(Meteor.userId())){ | ||
return Meteor.settings; | ||
} else { | ||
throw new Meteor.Error("Unauthorized"); | ||
} | ||
}, | ||
|
||
'Settings.set'({settings}){ | ||
if (!Meteor.userId()){ | ||
throw new Meteor.Error("Unauthorized"); | ||
} else if (Users.isGlobalAdministrator(Meteor.userId())){ | ||
return Meteor.settings = settings; | ||
} else { | ||
throw new Meteor.Error("Unauthorized"); | ||
} | ||
} | ||
|
||
}); |