This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app',
|
||||
selector: 'app-app',
|
||||
templateUrl: './app.component.html'
|
||||
})
|
||||
export class AppComponent {
|
||||
|
||||
@@ -5,10 +5,19 @@ import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { NgxGaugeModule } from 'ngx-gauge';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
import {MatButtonModule, MatIconModule, MatCheckboxModule, MatSidenavModule, MatToolbarModule, MatTooltipModule, MatCardModule, MatInputModule, MatFormFieldModule, MatProgressBarModule, MatProgressSpinnerModule, MatSnackBarModule, MatDialogContent, MatDialogModule, MatListModule, MatPaginatorModule, MatTableModule, MAT_PAGINATOR_INTL_PROVIDER, MatPaginatorIntl, MatExpansionModule, MatSelectModule, MatDatepickerModule, MatNativeDateModule, MatTabsModule, MatGridListModule} from '@angular/material';
|
||||
import { MatButtonModule, MatIconModule,
|
||||
MatCheckboxModule, MatSidenavModule,
|
||||
MatToolbarModule, MatTooltipModule, MatCardModule,
|
||||
MatInputModule, MatFormFieldModule,
|
||||
MatProgressBarModule, MatProgressSpinnerModule,
|
||||
MatSnackBarModule, MatDialogModule,
|
||||
MatListModule, MatPaginatorModule, MatTableModule,
|
||||
MatPaginatorIntl, MatExpansionModule, MatSelectModule,
|
||||
MatDatepickerModule, MatNativeDateModule,
|
||||
MatTabsModule, MatGridListModule } from '@angular/material';
|
||||
|
||||
import { LocationStrategy, PathLocationStrategy, registerLocaleData, DatePipe } from '@angular/common';
|
||||
import LocaleDE from '@angular/common/locales/de'
|
||||
import LocaleDE from '@angular/common/locales/de';
|
||||
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
|
||||
|
||||
@@ -19,7 +28,7 @@ import { InsideComponent } from './layouts/inside.component';
|
||||
import { OutsideComponent } from './layouts/outside.component';
|
||||
import { FooterComponent } from './layouts/footer.component';
|
||||
|
||||
import { ToolbarButtonComponent } from './widgets/toolbar-button.component'
|
||||
import { ToolbarButtonComponent } from './widgets/toolbar-button.component';
|
||||
import { LoginComponent } from './views/login.component';
|
||||
import { DelayInterceptor } from './interceptors/delay.interceptor';
|
||||
import { AuthInterceptor } from './interceptors/auth.interceptor';
|
||||
@@ -80,18 +89,18 @@ import { ResourceService } from './services/resource.service';
|
||||
/**
|
||||
* Computes the api domain from the browser location.
|
||||
*/
|
||||
const apidomain = ():{ http: string, ws: string } => {
|
||||
let host = document.location.hostname;
|
||||
let port = document.location.port;
|
||||
let protocol = document.location.protocol;
|
||||
var hostportpath = "";
|
||||
const apidomain = (): { http: string, ws: string } => {
|
||||
const host = document.location.hostname;
|
||||
const port = document.location.port;
|
||||
const protocol = document.location.protocol;
|
||||
let hostportpath = '';
|
||||
if (port.length > 0) {
|
||||
hostportpath = "://" + host + ":" + port + "/api";
|
||||
hostportpath = '://' + host + ':' + port + '/api';
|
||||
} else {
|
||||
hostportpath = "://" + host + "/api"
|
||||
hostportpath = '://' + host + '/api';
|
||||
}
|
||||
let secure = (protocol != "http:")?"s":"";
|
||||
return { http: "http" + secure + hostportpath, ws: "ws" + secure + hostportpath };
|
||||
const secure = (protocol !== 'http:') ? 's' : '';
|
||||
return { http: 'http' + secure + hostportpath, ws: 'ws' + secure + hostportpath };
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -108,14 +117,14 @@ registerLocaleData(LocaleDE);
|
||||
ToolbarButtonComponent,
|
||||
ProfileButtonComponent,
|
||||
LanguageSelectComponent,
|
||||
DrawerComponent,
|
||||
DrawerComponent,
|
||||
LoginFieldComponent,
|
||||
PasswordFieldComponent,
|
||||
EmailFieldComponent,
|
||||
NameFieldComponent,
|
||||
DecisionPanelComponent,
|
||||
MessageDialogComponent,
|
||||
ConfirmationDialogComponent,
|
||||
ConfirmationDialogComponent,
|
||||
TileMapComponent,
|
||||
MarkerMapComponent,
|
||||
LoginComponent,
|
||||
@@ -123,7 +132,7 @@ registerLocaleData(LocaleDE);
|
||||
ShareComponent,
|
||||
ActivateComponent,
|
||||
ResetComponent,
|
||||
ChangeComponent,
|
||||
ChangeComponent,
|
||||
DevicesComponent,
|
||||
DeviceLocationComponent,
|
||||
PrivilegesComponent,
|
||||
@@ -147,7 +156,7 @@ registerLocaleData(LocaleDE);
|
||||
BrowserModule,
|
||||
BrowserAnimationsModule,
|
||||
FormsModule,
|
||||
FlexLayoutModule,
|
||||
FlexLayoutModule,
|
||||
NgxGaugeModule,
|
||||
HttpClientModule,
|
||||
MatProgressBarModule,
|
||||
@@ -155,7 +164,7 @@ registerLocaleData(LocaleDE);
|
||||
MatPaginatorModule,
|
||||
MatExpansionModule,
|
||||
MatTableModule,
|
||||
MatButtonModule,
|
||||
MatButtonModule,
|
||||
MatInputModule,
|
||||
MatFormFieldModule,
|
||||
MatListModule,
|
||||
@@ -177,8 +186,8 @@ registerLocaleData(LocaleDE);
|
||||
],
|
||||
providers: [
|
||||
// injection token for http client
|
||||
{ provide: "domain", useValue: apidomain().http },
|
||||
{ provide: "wsdomain", useValue: apidomain().ws },
|
||||
{ provide: 'domain', useValue: apidomain().http },
|
||||
{ provide: 'wsdomain', useValue: apidomain().ws },
|
||||
// location stategy for passing that with the router
|
||||
{ provide: LocationStrategy, useClass: PathLocationStrategy },
|
||||
// add two global interceptors (one two slow down the server and one for authentication)
|
||||
|
||||
@@ -26,48 +26,48 @@ import { ManageNoticesComponent } from './views/manage-notices.component';
|
||||
import { EditNoticeComponent } from './views/edit-notice.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{ path: "", canActivate: [AuthGuard], canActivateChild:[AuthGuard], children: [
|
||||
{ path: '', canActivate: [AuthGuard], canActivateChild: [AuthGuard], children: [
|
||||
// inside (logged in)
|
||||
{ path: 'devices', component: InsideComponent, children: [
|
||||
{ path:'', component: DevicesComponent },
|
||||
{ path:':id', children: [
|
||||
{ path: '', component: DevicesComponent },
|
||||
{ path: ':id', children: [
|
||||
{ path: 'location', component: DeviceLocationComponent },
|
||||
{ path: 'visits', component: DeviceVisitsComponent }
|
||||
] },
|
||||
]},
|
||||
{ path: 'notices', component: InsideComponent, children: [{ path:'', component: NoticesComponent }] },
|
||||
{ path: 'notices', component: InsideComponent, children: [{ path: '', component: NoticesComponent }] },
|
||||
{ path: 'places', component: InsideComponent, children: [
|
||||
{ path:'', component: PlacesComponent },
|
||||
{ path:':id', component: PlaceVisitsComponent }
|
||||
{ path: '', component: PlacesComponent },
|
||||
{ path: ':id', component: PlaceVisitsComponent }
|
||||
] },
|
||||
{ path: 'privileges', component: InsideComponent, children: [
|
||||
{ path:'', component: PrivilegesComponent },
|
||||
{ path:':token', component: ShareComponent }
|
||||
{ path: 'privileges', component: InsideComponent, children: [
|
||||
{ path: '', component: PrivilegesComponent },
|
||||
{ path: ':token', component: ShareComponent }
|
||||
] },
|
||||
{ path: 'profile', component: InsideComponent, children: [
|
||||
{ path:'', component: UserComponent }
|
||||
{ path: '', component: UserComponent }
|
||||
]},
|
||||
/// inside (admin)
|
||||
{ path: 'manage', component: InsideComponent, children: [
|
||||
{ path: 'logs', component: ManageLogComponent },
|
||||
{ path: 'system', component: ManageSystemComponent },
|
||||
{ path: 'users', component: ManageUsersComponent },
|
||||
{ path: 'notices', children:[
|
||||
{ path: 'notices', children: [
|
||||
{ path: '', component: ManageNoticesComponent },
|
||||
{ path: ':id', component: EditNoticeComponent }
|
||||
]}
|
||||
]},
|
||||
// outside (logged out)
|
||||
{ path: 'login', component: OutsideComponent, children: [{ path:'', component: LoginComponent }] },
|
||||
{ path: 'register', component: OutsideComponent, children: [{ path:'', component: RegisterComponent }] },
|
||||
{ path: 'reset', component: OutsideComponent, children: [
|
||||
{ path:'', component: ResetComponent },
|
||||
{ path:':token', component: ChangeComponent }
|
||||
{ path: 'login', component: OutsideComponent, children: [{ path: '', component: LoginComponent }] },
|
||||
{ path: 'register', component: OutsideComponent, children: [{ path: '', component: RegisterComponent }] },
|
||||
{ path: 'reset', component: OutsideComponent, children: [
|
||||
{ path: '', component: ResetComponent },
|
||||
{ path: ':token', component: ChangeComponent }
|
||||
] },
|
||||
{ path: 'activate', component: OutsideComponent, children: [{ path:':token', component: ActivateComponent }] },
|
||||
{ path: 'shares', component: OutsideComponent, children: [{ path:':token', component: ShareComponent }] },
|
||||
{ path: 'activate', component: OutsideComponent, children: [{ path: ':token', component: ActivateComponent }] },
|
||||
{ path: 'shares', component: OutsideComponent, children: [{ path: ':token', component: ShareComponent }] },
|
||||
// catch all
|
||||
{ path: '**', redirectTo: '/login' }
|
||||
{ path: '**', redirectTo: '/login' }
|
||||
]}
|
||||
];
|
||||
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
import { Directive } from "@angular/core";
|
||||
import { NgForm, ControlContainer } from "@angular/forms";
|
||||
import { Directive } from '@angular/core';
|
||||
import { NgForm, ControlContainer } from '@angular/forms';
|
||||
|
||||
/**
|
||||
/**
|
||||
* Angular's template driven forms do not allow composition
|
||||
* and the fallback of going to reactive froms is too
|
||||
* and the fallback of going to reactive froms is too
|
||||
* complicated for enabling trivial form reuse of validation
|
||||
* logic.
|
||||
*
|
||||
* logic.
|
||||
*
|
||||
* This directive, taken from the github page at
|
||||
* https://github.com/angular/angular/issues/9600
|
||||
* provides a clean and simple solution.
|
||||
*
|
||||
* The only thing that is required is to add
|
||||
* use-parent-form to our children and they will
|
||||
*
|
||||
* The only thing that is required is to add
|
||||
* useParentForm to our children and they will
|
||||
* properly attach to any enclosing ng form.
|
||||
*
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[use-parent-form]',
|
||||
selector: '[appUseParentForm]',
|
||||
providers: [
|
||||
{
|
||||
provide: ControlContainer,
|
||||
useFactory: function(form: NgForm):NgForm {
|
||||
useFactory: function(form: NgForm): NgForm {
|
||||
return form;
|
||||
},
|
||||
deps: [NgForm]
|
||||
}
|
||||
]
|
||||
})
|
||||
export class UseParentFormDirective {}
|
||||
export class UseParentFormDirective {}
|
||||
|
||||
@@ -8,38 +8,38 @@ import { ConsoleService } from '../services/console.service';
|
||||
export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
|
||||
private static readonly OUTSIDE: string[] = [
|
||||
"/login", "/register", "/shares", "/activate", "/reset"
|
||||
'/login', '/register', '/shares', '/activate', '/reset'
|
||||
];
|
||||
|
||||
private static readonly USER: string[] = [
|
||||
"/devices", "/notices", "/privileges", "/profile", "/places"
|
||||
'/devices', '/notices', '/privileges', '/profile', '/places'
|
||||
];
|
||||
|
||||
private static readonly ADMIN: string[] = [
|
||||
"/manage"
|
||||
'/manage'
|
||||
];
|
||||
|
||||
private static readonly NO_USER = "/login";
|
||||
private static readonly NO_ADMIN = "/notices";
|
||||
private static readonly NO_USER = '/login';
|
||||
private static readonly NO_ADMIN = '/notices';
|
||||
|
||||
|
||||
|
||||
constructor(private userService: UserService, private consoleService:ConsoleService, private router: Router) { }
|
||||
constructor(private userService: UserService, private consoleService: ConsoleService, private router: Router) { }
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean>|boolean {
|
||||
let url: string = state.url;
|
||||
const url: string = state.url;
|
||||
// known outside stuff is ok for everyone
|
||||
let outside = this.isOutside(url);
|
||||
this.consoleService.log("Guard: Accepting outside route: " + url);
|
||||
if (outside) return true;
|
||||
const outside = this.isOutside(url);
|
||||
this.consoleService.log('Guard: Accepting outside route: ' + url);
|
||||
if (outside) { return true; }
|
||||
// handle known user and admin routes
|
||||
let admin = this.isAdmin(url);
|
||||
let user = this.isUser(url);
|
||||
this.consoleService.log("Guard: Checking route: " + (admin?"admin":"not admin") + " " + (user?"user":"not user"));
|
||||
const admin = this.isAdmin(url);
|
||||
const user = this.isUser(url);
|
||||
this.consoleService.log('Guard: Checking route: ' + (admin ? 'admin' : 'not admin') + ' ' + (user ? 'user' : 'not user'));
|
||||
|
||||
if (admin || user) return this.allow(url, admin);
|
||||
if (admin || user) { return this.allow(url, admin); }
|
||||
// unknown route, go to default page
|
||||
if (this.userService.state.getValue() == UserState.Available) {
|
||||
if (this.userService.state.getValue() === UserState.Available) {
|
||||
this.router.navigate([AuthGuard.NO_ADMIN]);
|
||||
} else {
|
||||
this.router.navigate([AuthGuard.NO_USER]);
|
||||
@@ -51,22 +51,22 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
return this.canActivate(route, state);
|
||||
}
|
||||
|
||||
private allow(url:string, onlyAdmin:boolean): Observable<boolean>|boolean {
|
||||
if (this.userService.state.getValue() == UserState.Available) {
|
||||
private allow(url: string, onlyAdmin: boolean): Observable<boolean>|boolean {
|
||||
if (this.userService.state.getValue() === UserState.Available) {
|
||||
if (!onlyAdmin || this.userService.hasRole(UserRole.Admin)) {
|
||||
return true;
|
||||
} else {
|
||||
this.router.navigate([AuthGuard.NO_ADMIN]);
|
||||
return false;
|
||||
}
|
||||
} else if (this.userService.state.getValue() == UserState.Unavailable) {
|
||||
} else if (this.userService.state.getValue() === UserState.Unavailable) {
|
||||
this.userService.redirectUrl = url;
|
||||
this.router.navigate([AuthGuard.NO_USER]);
|
||||
return false;
|
||||
} else {
|
||||
let result = new Subject<boolean>();
|
||||
let subscription = this.userService.state.subscribe((state)=> {
|
||||
if (state == UserState.Available) {
|
||||
const result = new Subject<boolean>();
|
||||
const subscription = this.userService.state.subscribe((state) => {
|
||||
if (state === UserState.Available) {
|
||||
if (!onlyAdmin || this.userService.hasRole(UserRole.Admin)) {
|
||||
result.next(true);
|
||||
} else {
|
||||
@@ -79,7 +79,7 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
result.next(false);
|
||||
}
|
||||
});
|
||||
result.subscribe((e)=>{
|
||||
result.subscribe((e) => {
|
||||
subscription.unsubscribe();
|
||||
});
|
||||
return result;
|
||||
@@ -87,24 +87,24 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
}
|
||||
|
||||
private isOutside(url: string): boolean {
|
||||
for (let out of AuthGuard.OUTSIDE) {
|
||||
if (url.startsWith(out)) return true;
|
||||
for (const out of AuthGuard.OUTSIDE) {
|
||||
if (url.startsWith(out)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private isUser(url: string): boolean {
|
||||
for (let user of AuthGuard.USER) {
|
||||
if (url.startsWith(user)) return true;
|
||||
for (const user of AuthGuard.USER) {
|
||||
if (url.startsWith(user)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private isAdmin(url: string): boolean {
|
||||
for (let admin of AuthGuard.ADMIN) {
|
||||
if (url.startsWith(admin)) return true;
|
||||
for (const admin of AuthGuard.ADMIN) {
|
||||
if (url.startsWith(admin)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,28 +17,28 @@ export class AuthInterceptor implements HttpInterceptor {
|
||||
/**
|
||||
* Creates a new interceptor with the injected console service
|
||||
* and credentials service.
|
||||
*
|
||||
*
|
||||
* @param consoleService The console service for logging.
|
||||
* @param credentialService The credential service to create auth headers.
|
||||
*/
|
||||
*/
|
||||
constructor(private consoleService: ConsoleService, private credentialService: CredentialService) { }
|
||||
|
||||
/**
|
||||
* Intercepts the requests and possibly attaches an auth header.
|
||||
*
|
||||
*
|
||||
* @param req The request that is intercepted.
|
||||
* @param next The handler to continue the request.
|
||||
*/
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
let authHeader = this.credentialService.createHeader();
|
||||
const authHeader = this.credentialService.createHeader();
|
||||
let clone = req;
|
||||
if (authHeader != null) {
|
||||
this.consoleService.log("Attaching Authorization header.");
|
||||
clone = req.clone({ headers: req.headers.set("Authorization", authHeader)});
|
||||
this.consoleService.log('Attaching Authorization header.');
|
||||
clone = req.clone({ headers: req.headers.set('Authorization', authHeader)});
|
||||
} else {
|
||||
this.consoleService.log("Skipping Authorization header.");
|
||||
this.consoleService.log('Skipping Authorization header.');
|
||||
}
|
||||
return next.handle(clone);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export class DelayInterceptor implements HttpInterceptor {
|
||||
/**
|
||||
* The delay to slow down requests.
|
||||
*/
|
||||
private delay: number = 500;
|
||||
private delay = 500;
|
||||
|
||||
/**
|
||||
* Creates a new interceptor with the injected console service
|
||||
@@ -24,8 +24,8 @@ export class DelayInterceptor implements HttpInterceptor {
|
||||
* @param consoleService The console service for logging.
|
||||
* @param delay The configurable delay.
|
||||
*/
|
||||
constructor(private consoleService: ConsoleService, @Optional() @Inject('delayRequest') delay:number) {
|
||||
if (delay) this.delay = delay;
|
||||
constructor(private consoleService: ConsoleService, @Optional() @Inject('delayRequest') delay: number) {
|
||||
if (delay) { this.delay = delay; }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,18 +43,18 @@ export class DelayInterceptor implements HttpInterceptor {
|
||||
//
|
||||
// but we also want to delay errors, so we need to fully specify it
|
||||
const started = Date.now();
|
||||
var delayedRequest: Subject<HttpEvent<any>> = new Subject<HttpEvent<any>>();
|
||||
const delayedRequest: Subject<HttpEvent<any>> = new Subject<HttpEvent<any>>();
|
||||
next.handle(req).subscribe(event => {
|
||||
this.consoleService.log("Scheduling result for " + req.urlWithParams);
|
||||
this.schedule(started, ()=> delayedRequest.next(event) );
|
||||
this.consoleService.log('Scheduling result for ' + req.urlWithParams);
|
||||
this.schedule(started, () => delayedRequest.next(event) );
|
||||
}, error => {
|
||||
this.consoleService.log("Scheduling error for " + req.urlWithParams);
|
||||
this.consoleService.log('Scheduling error for ' + req.urlWithParams);
|
||||
// hacky: +1 to ensure that error is sent after result
|
||||
this.schedule(started + 100, ()=> delayedRequest.error(error) );
|
||||
this.schedule(started + 100, () => delayedRequest.error(error) );
|
||||
}, () => {
|
||||
this.consoleService.log("Scheduling completion for " + req.urlWithParams);
|
||||
this.consoleService.log('Scheduling completion for ' + req.urlWithParams);
|
||||
// hacky: +2 to ensure that completion is sent last
|
||||
this.schedule(started + 200, ()=> delayedRequest.complete() );
|
||||
this.schedule(started + 200, () => delayedRequest.complete() );
|
||||
});
|
||||
return delayedRequest;
|
||||
}
|
||||
@@ -68,18 +68,18 @@ export class DelayInterceptor implements HttpInterceptor {
|
||||
* @param completion The completion method to be called when the result
|
||||
* should be forwarded.
|
||||
*/
|
||||
schedule(started: number, completion: ()=>void): void {
|
||||
schedule(started: number, completion: () => void): void {
|
||||
const elapsed = Date.now() - started;
|
||||
this.consoleService.log("Data received after " + elapsed + "ms.");
|
||||
this.consoleService.log('Data received after ' + elapsed + 'ms.');
|
||||
if (elapsed >= this.delay) {
|
||||
this.consoleService.log("Forwarding data without delay.");
|
||||
this.consoleService.log('Forwarding data without delay.');
|
||||
completion();
|
||||
} else {
|
||||
var slowdown = this.delay - elapsed;
|
||||
this.consoleService.log("Delaying data for " + slowdown + "ms.");
|
||||
var delayedRequest: Subject<HttpEvent<any>> = new Subject<HttpEvent<any>>();
|
||||
const slowdown = this.delay - elapsed;
|
||||
this.consoleService.log('Delaying data for ' + slowdown + 'ms.');
|
||||
const delayedRequest: Subject<HttpEvent<any>> = new Subject<HttpEvent<any>>();
|
||||
setTimeout(() => {
|
||||
this.consoleService.log("Forwarding delayed data.");
|
||||
this.consoleService.log('Forwarding delayed data.');
|
||||
completion();
|
||||
}, slowdown);
|
||||
}
|
||||
|
||||
@@ -4,30 +4,30 @@ import { Subscription } from 'rxjs';
|
||||
import { UserService, UserRole } from '../services/user.service';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
/**
|
||||
/**
|
||||
* Shows the contents of the navigation drawer.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'drawer',
|
||||
selector: 'app-drawer',
|
||||
templateUrl: './drawer.component.html'
|
||||
})
|
||||
export class DrawerComponent implements OnInit, OnDestroy{
|
||||
export class DrawerComponent implements OnInit, OnDestroy {
|
||||
|
||||
admin:boolean = false;
|
||||
admin = false;
|
||||
|
||||
private subscription: Subscription;
|
||||
|
||||
constructor(public res: ResourceService, private userService: UserService) { }
|
||||
|
||||
ngOnInit():void {
|
||||
this.subscription = this.userService.state.subscribe((state)=> {
|
||||
ngOnInit(): void {
|
||||
this.subscription = this.userService.state.subscribe((state) => {
|
||||
this.admin = this.userService.hasRole(UserRole.Admin);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy():void {
|
||||
ngOnDestroy(): void {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
/**
|
||||
/**
|
||||
* The responsive footer of the web application
|
||||
* that contains a couple of links.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'footer',
|
||||
selector: 'app-footer',
|
||||
templateUrl: './footer.component.html'
|
||||
})
|
||||
export class FooterComponent {
|
||||
|
||||
constructor(public res: ResourceService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
<ng-template #noMenuButton><img src="assets/icons/home.svg" width="24px" height="24px" style="padding-right: 8px;padding-left:8px"></ng-template>
|
||||
<span>Maptology</span>
|
||||
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
|
||||
<profile-button></profile-button>
|
||||
<toolbar-button [title]="res.strings('button_logout')" color="accent" icon="lock" (click)="onLogout()"></toolbar-button>
|
||||
<app-profile-button></app-profile-button>
|
||||
<app-toolbar-button [title]="res.strings('button_logout')" color="accent" icon="lock" (click)="onLogout()"></app-toolbar-button>
|
||||
</div>
|
||||
</mat-toolbar>
|
||||
|
||||
<mat-sidenav-container style="flex:1;">
|
||||
<mat-sidenav [mode]="compact?'over':'side'" [opened]="opened">
|
||||
<drawer></drawer>
|
||||
<app-drawer></app-drawer>
|
||||
</mat-sidenav>
|
||||
<mat-sidenav-content>
|
||||
<router-outlet></router-outlet>
|
||||
</mat-sidenav-content>
|
||||
</mat-sidenav-container>
|
||||
|
||||
<footer></footer>
|
||||
<app-footer></app-footer>
|
||||
|
||||
</div>
|
||||
@@ -6,7 +6,7 @@ import { MatSidenavContainer, MatSidenav } from '@angular/material';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'inside',
|
||||
selector: 'app-inside',
|
||||
templateUrl: './inside.component.html'
|
||||
})
|
||||
export class InsideComponent implements OnInit, OnDestroy {
|
||||
@@ -18,60 +18,59 @@ export class InsideComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild(MatSidenav, { static: true }) drawer: MatSidenav;
|
||||
|
||||
compact: boolean = false;
|
||||
opened: boolean = true;
|
||||
compact = false;
|
||||
opened = true;
|
||||
|
||||
constructor(private userService: UserService, private router: Router, public res:ResourceService) { }
|
||||
constructor(private userService: UserService, private router: Router, public res: ResourceService) { }
|
||||
|
||||
ngOnInit():void {
|
||||
ngOnInit(): void {
|
||||
this.updateDrawer(window.innerWidth);
|
||||
this.opened = this.drawer.opened;
|
||||
this.drawerSubscription = this.drawer.openedChange.subscribe((state)=>{
|
||||
this.drawerSubscription = this.drawer.openedChange.subscribe((state) => {
|
||||
this.opened = state;
|
||||
});
|
||||
this.routerSubscription = this.router.events.subscribe((event)=> {
|
||||
if (this.compact) this.drawer.close();
|
||||
this.routerSubscription = this.router.events.subscribe((event) => {
|
||||
if (this.compact) { this.drawer.close(); }
|
||||
});
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event:Event) {
|
||||
onResize(event: Event) {
|
||||
this.updateDrawer((event.target as Window).innerWidth);
|
||||
|
||||
|
||||
}
|
||||
|
||||
toggleDrawer():void {
|
||||
toggleDrawer(): void {
|
||||
this.drawer.toggle();
|
||||
this.opened = this.drawer.opened;
|
||||
}
|
||||
|
||||
updateDrawer(width: number): void {
|
||||
if (width < InsideComponent.DRAWER_BREAKPOINT && !this.compact) {
|
||||
this.drawer.mode = "over";
|
||||
this.drawer.mode = 'over';
|
||||
this.drawer.close();
|
||||
this.compact = true;
|
||||
this.opened = false;
|
||||
} else if (width >= InsideComponent.DRAWER_BREAKPOINT && this.compact) {
|
||||
this.compact = false;
|
||||
this.drawer.mode = "side"
|
||||
this.drawer.mode = 'side';
|
||||
this.drawer.open();
|
||||
this.opened = true;
|
||||
}
|
||||
if (this.drawer.opened != this.opened) {
|
||||
if (this.opened) this.drawer.open();
|
||||
else this.drawer.close();
|
||||
if (this.drawer.opened !== this.opened) {
|
||||
if (this.opened) { this.drawer.open(); } else { this.drawer.close(); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ngOnDestroy():void {
|
||||
ngOnDestroy(): void {
|
||||
this.drawerSubscription.unsubscribe();
|
||||
this.routerSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
onLogout():void {
|
||||
onLogout(): void {
|
||||
this.userService.logout();
|
||||
this.router.navigate(["/"]);
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<img src="assets/icons/home.svg" width="24px" height="24px" style="padding-right: 8px;padding-left:8px">
|
||||
<span>Maptology</span>
|
||||
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto">
|
||||
<toolbar-button [title]="res.strings('button_register')" icon="mode_edit" link="/register"></toolbar-button>
|
||||
<toolbar-button [title]="res.strings('button_login')" color="accent" icon="lock_open" link="/login"></toolbar-button>
|
||||
<app-toolbar-button [title]="res.strings('button_register')" icon="mode_edit" link="/register"></app-toolbar-button>
|
||||
<app-toolbar-button [title]="res.strings('button_login')" color="accent" icon="lock_open" link="/login"></app-toolbar-button>
|
||||
</div>
|
||||
</mat-toolbar>
|
||||
|
||||
@@ -13,6 +13,6 @@
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
|
||||
<footer></footer>
|
||||
<app-footer></app-footer>
|
||||
|
||||
</div>
|
||||
@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'outside',
|
||||
selector: 'app-outside',
|
||||
templateUrl: './outside.component.html'
|
||||
})
|
||||
export class OutsideComponent {
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import { MatPaginatorIntl } from "@angular/material";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { Inject } from "@angular/core";
|
||||
import { MatPaginatorIntl } from '@angular/material';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
import { Inject } from '@angular/core';
|
||||
|
||||
export class GermanPaginatorProvider extends MatPaginatorIntl {
|
||||
|
||||
constructor(@Inject(ResourceService) public res: ResourceService) {
|
||||
super();
|
||||
this.firstPageLabel = res.strings("pagination_first_page");
|
||||
this.lastPageLabel = res.strings("pagination_last_page");
|
||||
this.nextPageLabel = res.strings("pagination_next_page");
|
||||
this.previousPageLabel = res.strings("pagination_previous_page");
|
||||
this.itemsPerPageLabel = res.strings("pagination_items_per_page");
|
||||
this.firstPageLabel = res.strings('pagination_first_page');
|
||||
this.lastPageLabel = res.strings('pagination_last_page');
|
||||
this.nextPageLabel = res.strings('pagination_next_page');
|
||||
this.previousPageLabel = res.strings('pagination_previous_page');
|
||||
this.itemsPerPageLabel = res.strings('pagination_items_per_page');
|
||||
}
|
||||
|
||||
getRangeLabel = (page: number, pageSize: number, length: number):string => {
|
||||
const labelOf = this.res.strings("pagination_of");
|
||||
getRangeLabel = (page: number, pageSize: number, length: number): string => {
|
||||
const labelOf = this.res.strings('pagination_of');
|
||||
if (length === 0 || pageSize === 0) { return '0 ' + labelOf + ' ' + length; }
|
||||
length = Math.max(length, 0);
|
||||
const startIndex = page * pageSize;
|
||||
const endIndex = startIndex < length ? Math.min(startIndex + pageSize, length) : startIndex + pageSize;
|
||||
return startIndex + 1 + ' - ' + endIndex + ' ' + labelOf + ' ' + length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Subject } from 'rxjs';
|
||||
@Injectable()
|
||||
export class ConsoleService {
|
||||
|
||||
private static LOG:boolean = false;
|
||||
private static LOG = false;
|
||||
|
||||
private data: string[] = [];
|
||||
public messages: Subject<string[]> = new Subject<string[]>();
|
||||
@@ -16,9 +16,9 @@ export class ConsoleService {
|
||||
constructor() { }
|
||||
|
||||
log(message: string) {
|
||||
if (!ConsoleService.LOG) return;
|
||||
var date: Date = new Date();
|
||||
message = date.toISOString() + " " + message;
|
||||
if (!ConsoleService.LOG) { return; }
|
||||
const date: Date = new Date();
|
||||
message = date.toISOString() + ' ' + message;
|
||||
console.log(message);
|
||||
this.data.push(message);
|
||||
this.messages.next(this.data);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { HttpErrorResponse } from '@angular/common/http';
|
||||
* the UserService. Application components should not use this
|
||||
* service, instead they should rely on the functions of the
|
||||
* UserService.
|
||||
*
|
||||
*
|
||||
* To let the stored credentials survive a page reload (without
|
||||
* actually having a session on the server), the credentials are
|
||||
* stored in the browser's session storage (if available). According
|
||||
@@ -24,17 +24,17 @@ export class CredentialService {
|
||||
/**
|
||||
* The key to store the password in the session store.
|
||||
*/
|
||||
private static KEY_PASSWORD = "password";
|
||||
private static KEY_PASSWORD = 'password';
|
||||
/**
|
||||
* The key to store the login in the session store.
|
||||
*/
|
||||
private static KEY_LOGIN = "login";
|
||||
private static KEY_LOGIN = 'login';
|
||||
|
||||
/**
|
||||
* The login name.
|
||||
*/
|
||||
private login: string;
|
||||
|
||||
|
||||
/**
|
||||
* The password.
|
||||
*/
|
||||
@@ -80,7 +80,7 @@ export class CredentialService {
|
||||
/**
|
||||
* Sets the credentials contained in the
|
||||
* service to the specified login and password.
|
||||
*
|
||||
*
|
||||
* @param login The login.
|
||||
* @param password The password.
|
||||
*/
|
||||
@@ -90,7 +90,7 @@ export class CredentialService {
|
||||
this.saveCredentials();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Clears the credentials stored in the service
|
||||
*/
|
||||
clearCredential(): void {
|
||||
@@ -100,8 +100,8 @@ export class CredentialService {
|
||||
/**
|
||||
* Determines whether the specified password
|
||||
* matches the stored password.
|
||||
*
|
||||
* @param password The password to check.
|
||||
*
|
||||
* @param password The password to check.
|
||||
* @returns True if the password matches.
|
||||
*/
|
||||
hasPassword(password: string): boolean {
|
||||
@@ -109,7 +109,7 @@ export class CredentialService {
|
||||
}
|
||||
|
||||
/** Determines whether the password and login name are set.
|
||||
*
|
||||
*
|
||||
* @returns True if the password and the username are set.
|
||||
*/
|
||||
hasCredential() {
|
||||
@@ -125,7 +125,7 @@ export class CredentialService {
|
||||
*/
|
||||
createHeader(): string {
|
||||
if (this.hasCredential()) {
|
||||
return "Basic " + btoa(this.login + ":" + this.password);
|
||||
return 'Basic ' + btoa(this.login + ':' + this.password);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { AbstractPageService } from '../utils/pagination';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
|
||||
/**
|
||||
* A service that handles visits for a particular device and time.
|
||||
* A service that handles visits for a particular device and time.
|
||||
*/
|
||||
@Injectable()
|
||||
export class DeviceVisitService implements DataSource<Visit> {
|
||||
@@ -19,45 +19,45 @@ export class DeviceVisitService implements DataSource<Visit> {
|
||||
readonly date = new BehaviorSubject<Date>(new Date());
|
||||
private elements = new BehaviorSubject<Visit[]>([]);
|
||||
private places: Map<number, Place> = new Map<number, Place>();
|
||||
private loaders:number = 0;
|
||||
private loaders = 0;
|
||||
|
||||
private id: number;
|
||||
private subscriptions = 0;
|
||||
|
||||
constructor(private apiClientService:ApiClientService) {
|
||||
constructor(private apiClientService: ApiClientService) {
|
||||
}
|
||||
|
||||
getVisits():Visit[] {
|
||||
getVisits(): Visit[] {
|
||||
return this.elements.getValue();
|
||||
}
|
||||
|
||||
setDevice(id:number) {
|
||||
if (this.loading.getValue()) return;
|
||||
setDevice(id: number) {
|
||||
if (this.loading.getValue()) { return; }
|
||||
this.loading.next(true);
|
||||
this.device.next(null);
|
||||
this.elements.next([]);
|
||||
this.id = id;
|
||||
if (id != null) {
|
||||
this.apiClientService.getDevice(id).subscribe((result)=>{
|
||||
this.apiClientService.getDevice(id).subscribe((result) => {
|
||||
this.device.next(result.body);
|
||||
this.loading.next(false);
|
||||
this.setDate(this.date.getValue());
|
||||
}, (error)=> {
|
||||
}, (error) => {
|
||||
this.id = null;
|
||||
this.loading.next(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setDate(date:Date) {
|
||||
if (this.loading.getValue()) return;
|
||||
setDate(date: Date) {
|
||||
if (this.loading.getValue()) { return; }
|
||||
this.loading.next(true);
|
||||
let d = (date==null)?new Date():new Date(date);
|
||||
const d = (date == null) ? new Date() : new Date(date);
|
||||
d.setHours(0, 0, 0, 0);
|
||||
let millis = d.getTime();
|
||||
const millis = d.getTime();
|
||||
this.date.next(d);
|
||||
this.elements.next([]);
|
||||
this.apiClientService.getDeviceVisits(this.id, millis, 24 * 60 * 60 * 1000).subscribe((result)=>{
|
||||
this.apiClientService.getDeviceVisits(this.id, millis, 24 * 60 * 60 * 1000).subscribe((result) => {
|
||||
this.elements.next(result.body);
|
||||
this.loadPlaces();
|
||||
}, (error) => {
|
||||
@@ -66,36 +66,36 @@ export class DeviceVisitService implements DataSource<Visit> {
|
||||
});
|
||||
}
|
||||
|
||||
getPlace(id:number):Place {
|
||||
getPlace(id: number): Place {
|
||||
return this.places.get(id);
|
||||
}
|
||||
|
||||
|
||||
private loadPlaces() {
|
||||
var ids: number[] = new Array();
|
||||
for (let v of this.elements.getValue()) {
|
||||
const ids: number[] = new Array();
|
||||
for (const v of this.elements.getValue()) {
|
||||
if (this.getPlace(v.place) == null) {
|
||||
ids.push(v.place);
|
||||
}
|
||||
}
|
||||
if (ids.length == 0) {
|
||||
if (ids.length === 0) {
|
||||
this.loading.next(false);
|
||||
} else {
|
||||
this.loaders = ids.length;
|
||||
for (let v of ids) {
|
||||
this.apiClientService.getPlace(v).subscribe((result)=> {
|
||||
for (const v of ids) {
|
||||
this.apiClientService.getPlace(v).subscribe((result) => {
|
||||
this.finishLoading(v, result.body);
|
||||
}, (error)=>{
|
||||
}, (error) => {
|
||||
this.finishLoading(v, null);
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private finishLoading(id:number, place: Place) {
|
||||
if (place) this.places.set(id, place);
|
||||
private finishLoading(id: number, place: Place) {
|
||||
if (place) { this.places.set(id, place); }
|
||||
this.loaders -= 1;
|
||||
if (this.loaders == 0) {
|
||||
if (this.loaders === 0) {
|
||||
this.loading.next(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { HttpResponse } from '@angular/common/http';
|
||||
@Injectable()
|
||||
export class DeviceService extends AbstractPageService<Device, DevicePage> {
|
||||
|
||||
constructor(apiClientService:ApiClientService) {
|
||||
constructor(apiClientService: ApiClientService) {
|
||||
super(apiClientService);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
import { ConsoleService } from "./console.service";
|
||||
import { BehaviorSubject, Observable } from "rxjs";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { LogMessage } from "../../api/models";
|
||||
import { CollectionViewer } from "@angular/cdk/collections";
|
||||
import { CredentialService } from "./credential.service";
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { ConsoleService } from './console.service';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { LogMessage } from '../../api/models';
|
||||
import { CollectionViewer } from '@angular/cdk/collections';
|
||||
import { CredentialService } from './credential.service';
|
||||
|
||||
@Injectable()
|
||||
export class ManageLogService implements DataSource<LogMessage> {
|
||||
@@ -14,7 +14,7 @@ export class ManageLogService implements DataSource<LogMessage> {
|
||||
|
||||
readonly connecting: BehaviorSubject<boolean> = new BehaviorSubject(false);
|
||||
private messages: BehaviorSubject<LogMessage[]> = new BehaviorSubject([]);
|
||||
private subscriptions: number = 0;
|
||||
private subscriptions = 0;
|
||||
private socket: WebSocket;
|
||||
private timeout = null;
|
||||
private buffered: LogMessage[] = [];
|
||||
@@ -30,7 +30,7 @@ export class ManageLogService implements DataSource<LogMessage> {
|
||||
this.buffered = [];
|
||||
if (this.timeout != null) {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = null;
|
||||
this.timeout = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,32 +44,32 @@ export class ManageLogService implements DataSource<LogMessage> {
|
||||
|
||||
|
||||
open(): void {
|
||||
if (this.connecting.getValue() || this.socket) return;
|
||||
if (this.connecting.getValue() || this.socket) { return; }
|
||||
this.clear();
|
||||
this.consoleService.log("Connecting to server.");
|
||||
this.consoleService.log('Connecting to server.');
|
||||
this.connecting.next(true);
|
||||
this.socket = new WebSocket(this.domain + "/log/stream");
|
||||
this.socket.addEventListener<"open">("open", (event) => {
|
||||
this.create("Websocket connection opened.");
|
||||
this.socket = new WebSocket(this.domain + '/log/stream');
|
||||
this.socket.addEventListener<'open'>('open', (event) => {
|
||||
this.create('Websocket connection opened.');
|
||||
this.socket.send(this.credentialService.createHeader());
|
||||
});
|
||||
this.socket.addEventListener<"message">("message", (message) => {
|
||||
if (this.connecting.getValue()) this.connecting.next(false);
|
||||
let logMessage: LogMessage = JSON.parse(message.data);
|
||||
this.socket.addEventListener<'message'>('message', (message) => {
|
||||
if (this.connecting.getValue()) { this.connecting.next(false); }
|
||||
const logMessage: LogMessage = JSON.parse(message.data);
|
||||
// send to console, if setup
|
||||
if (ManageLogService.CONSOLE_OUTPUT) this.print(logMessage);
|
||||
if (ManageLogService.CONSOLE_OUTPUT) { this.print(logMessage); }
|
||||
this.add(logMessage);
|
||||
});
|
||||
this.socket.addEventListener<"close">("close", (close) => {
|
||||
this.socket.addEventListener<'close'>('close', (close) => {
|
||||
this.connecting.next(false);
|
||||
this.create("Websocket connection closed.");
|
||||
})
|
||||
this.create('Websocket connection closed.');
|
||||
});
|
||||
}
|
||||
|
||||
private create(message: string) {
|
||||
this.add({
|
||||
id: 0, className: "LogService", methodName: "",
|
||||
loggerName: "", level: "INFO", thread: 0,
|
||||
id: 0, className: 'LogService', methodName: '',
|
||||
loggerName: '', level: 'INFO', thread: 0,
|
||||
time: new Date().getTime(), trace: null,
|
||||
message: message
|
||||
});
|
||||
@@ -78,33 +78,36 @@ export class ManageLogService implements DataSource<LogMessage> {
|
||||
private add(logMessage: LogMessage): void {
|
||||
this.buffered.push(logMessage);
|
||||
if (this.timeout == null) {
|
||||
this.timeout = setTimeout(()=>{ this.submit() }, 500);
|
||||
}
|
||||
this.timeout = setTimeout(() => { this.submit(); }, 500);
|
||||
}
|
||||
}
|
||||
|
||||
private submit(): void {
|
||||
// create new array and announce
|
||||
let end = this.messages.getValue().length;
|
||||
var start = 0;
|
||||
if (end >= ManageLogService.MAXIMUM_MESSAGES - this.buffered.length)
|
||||
const end = this.messages.getValue().length;
|
||||
let start = 0;
|
||||
if (end >= ManageLogService.MAXIMUM_MESSAGES - this.buffered.length) {
|
||||
start = end - ManageLogService.MAXIMUM_MESSAGES + this.buffered.length;
|
||||
var newMessages = this.messages.getValue().slice(start, end).concat(this.buffered);
|
||||
}
|
||||
const newMessages = this.messages.getValue().slice(start, end).concat(this.buffered);
|
||||
this.buffered = [];
|
||||
this.messages.next(newMessages);
|
||||
this.timeout = null;
|
||||
}
|
||||
|
||||
private print(logMessage: LogMessage): void {
|
||||
var text = "[" + logMessage.id + "@" + logMessage.time + " (TRD-" + logMessage.thread + ") " + logMessage.className + "." + logMessage.methodName + "] " + logMessage.message;
|
||||
let text = '[' + logMessage.id + '@' + logMessage.time
|
||||
+ ' (TRD-' + logMessage.thread + ') ' + logMessage.className
|
||||
+ '.' + logMessage.methodName + '] ' + logMessage.message;
|
||||
if (logMessage.trace != null) {
|
||||
text += "\n" + logMessage.trace;
|
||||
text += '\n' + logMessage.trace;
|
||||
}
|
||||
this.consoleService.log(text);
|
||||
}
|
||||
|
||||
close(): void {
|
||||
if (this.socket != null) {
|
||||
this.consoleService.log("Disconnecting from server.");
|
||||
this.consoleService.log('Disconnecting from server.');
|
||||
this.socket.close();
|
||||
this.connecting.next(false);
|
||||
this.socket = null;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { AbstractPageService } from "../utils/pagination";
|
||||
import { NoticePage, Notice } from "../../api/models";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { Observable, BehaviorSubject, Subject } from "rxjs";
|
||||
import { HttpResponse } from "@angular/common/http";
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AbstractPageService } from '../utils/pagination';
|
||||
import { NoticePage, Notice } from '../../api/models';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { Observable, BehaviorSubject, Subject } from 'rxjs';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
|
||||
/**
|
||||
* A service that handles notices for admins.
|
||||
@@ -11,7 +11,7 @@ import { HttpResponse } from "@angular/common/http";
|
||||
@Injectable()
|
||||
export class ManageNoticeService extends AbstractPageService<Notice, NoticePage> {
|
||||
|
||||
constructor(apiClientService:ApiClientService) {
|
||||
constructor(apiClientService: ApiClientService) {
|
||||
super(apiClientService);
|
||||
}
|
||||
|
||||
@@ -20,20 +20,20 @@ export class ManageNoticeService extends AbstractPageService<Notice, NoticePage>
|
||||
}
|
||||
|
||||
setNotice(notice: Notice): Observable<Notice> {
|
||||
if (this.loading.getValue()) return new BehaviorSubject<Notice>(null);
|
||||
if (this.loading.getValue()) { return new BehaviorSubject<Notice>(null); }
|
||||
this.loading.next(true);
|
||||
var call: Observable<HttpResponse<Notice>>;
|
||||
if (notice.id == 0) {
|
||||
let call: Observable<HttpResponse<Notice>>;
|
||||
if (notice.id === 0) {
|
||||
call = this.apiClientService.addNotice(notice);
|
||||
} else {
|
||||
call = this.apiClientService.setNotice(notice.id, notice);
|
||||
}
|
||||
let result = new Subject<Notice>();
|
||||
call.subscribe((response)=>{
|
||||
const result = new Subject<Notice>();
|
||||
call.subscribe((response) => {
|
||||
this.loading.next(false);
|
||||
result.next(response.body);
|
||||
this.reload();
|
||||
}, (error)=> {
|
||||
}, (error) => {
|
||||
this.loading.next(false);
|
||||
result.next(null);
|
||||
this.reload();
|
||||
@@ -42,16 +42,16 @@ export class ManageNoticeService extends AbstractPageService<Notice, NoticePage>
|
||||
}
|
||||
|
||||
getNotice(id: number): Observable<Notice> {
|
||||
if (this.loading.getValue()) return new BehaviorSubject<Notice>(null);
|
||||
if (this.loading.getValue()) { return new BehaviorSubject<Notice>(null); }
|
||||
this.loading.next(true);
|
||||
let result = new Subject<Notice>();
|
||||
this.apiClientService.getNotice(id).subscribe((response)=>{
|
||||
const result = new Subject<Notice>();
|
||||
this.apiClientService.getNotice(id).subscribe((response) => {
|
||||
result.next(response.body);
|
||||
this.loading.next(false);
|
||||
}, (error)=> {
|
||||
}, (error) => {
|
||||
result.next(null);
|
||||
this.loading.next(false);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { AbstractPageService } from "../utils/pagination";
|
||||
import { User, UserPage } from "../../api/models";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { Observable, BehaviorSubject, Subject } from "rxjs";
|
||||
import { HttpResponse } from "@angular/common/http";
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AbstractPageService } from '../utils/pagination';
|
||||
import { User, UserPage } from '../../api/models';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { Observable, BehaviorSubject, Subject } from 'rxjs';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
|
||||
/**
|
||||
* A service that handles users for admins.
|
||||
@@ -17,7 +17,7 @@ export class ManageUserService extends AbstractPageService<User, UserPage> {
|
||||
*/
|
||||
private term: string = null;
|
||||
|
||||
constructor(apiClientService:ApiClientService) {
|
||||
constructor(apiClientService: ApiClientService) {
|
||||
super(apiClientService);
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ export class ManageUserService extends AbstractPageService<User, UserPage> {
|
||||
}
|
||||
}
|
||||
|
||||
setTerm(term: string):boolean {
|
||||
if (this.loading.getValue()) return false;
|
||||
setTerm(term: string): boolean {
|
||||
if (this.loading.getValue()) { return false; }
|
||||
if (term != null && term.trim().length > 0) {
|
||||
this.term = term.trim();
|
||||
} else {
|
||||
@@ -46,14 +46,14 @@ export class ManageUserService extends AbstractPageService<User, UserPage> {
|
||||
|
||||
|
||||
setUser(user: User): Observable<boolean> {
|
||||
if (this.loading.getValue()) return new BehaviorSubject<boolean>(false);
|
||||
if (this.loading.getValue()) { return new BehaviorSubject<boolean>(false); }
|
||||
this.loading.next(true);
|
||||
let result = new Subject<boolean>();
|
||||
this.apiClientService.setUser(user.id, user).subscribe((response)=>{
|
||||
const result = new Subject<boolean>();
|
||||
this.apiClientService.setUser(user.id, user).subscribe((response) => {
|
||||
result.next(true);
|
||||
this.loading.next(false);
|
||||
this.reload();
|
||||
}, (error)=> {
|
||||
}, (error) => {
|
||||
result.next(false);
|
||||
this.loading.next(false);
|
||||
this.reload();
|
||||
|
||||
@@ -9,12 +9,12 @@ import { AbstractPageService } from '../utils/pagination';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
|
||||
/**
|
||||
* A service that handles notices.
|
||||
* A service that handles notices.
|
||||
*/
|
||||
@Injectable()
|
||||
export class NoticeService extends AbstractPageService<Notice, NoticePage> {
|
||||
|
||||
constructor(apiClientService:ApiClientService) {
|
||||
constructor(apiClientService: ApiClientService) {
|
||||
super(apiClientService);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { AbstractPageService } from '../utils/pagination';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
|
||||
/**
|
||||
* A service that handles visiss for a particular place.
|
||||
* A service that handles visiss for a particular place.
|
||||
*/
|
||||
@Injectable()
|
||||
export class PlaceVisitService extends AbstractPageService<Visit, VisitPage> {
|
||||
@@ -17,34 +17,33 @@ export class PlaceVisitService extends AbstractPageService<Visit, VisitPage> {
|
||||
readonly place = new BehaviorSubject<Place>(null);
|
||||
private id: number;
|
||||
|
||||
constructor(apiClientService:ApiClientService) {
|
||||
constructor(apiClientService: ApiClientService) {
|
||||
super(apiClientService);
|
||||
}
|
||||
|
||||
setPlace(id:number) {
|
||||
if (this.id == id || this.loading.getValue()) return;
|
||||
setPlace(id: number) {
|
||||
if (this.id === id || this.loading.getValue()) { return; }
|
||||
this.id = null;
|
||||
this.place.next(null);
|
||||
this.reload();
|
||||
if (id != null) {
|
||||
this.id = id;
|
||||
this.loading.next(true);
|
||||
this.apiClientService.getPlace(id).subscribe((result)=>{
|
||||
this.apiClientService.getPlace(id).subscribe((result) => {
|
||||
this.place.next(result.body);
|
||||
this.loading.next(false);
|
||||
this.reload();
|
||||
}, (error)=> {
|
||||
}, (error) => {
|
||||
this.id = null;
|
||||
this.loading.next(false);
|
||||
this.reload();
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getPage(offset: number, size: number) {
|
||||
if (this.loading.getValue()) return;
|
||||
if (this.id == null) this.page.next(this.emptyPage());
|
||||
else super.getPage(offset, size);
|
||||
if (this.loading.getValue()) { return; }
|
||||
if (this.id == null) { this.page.next(this.emptyPage()); } else { super.getPage(offset, size); }
|
||||
}
|
||||
|
||||
protected loadPage(offset: number, size: number): Observable<HttpResponse<VisitPage>> {
|
||||
|
||||
@@ -9,12 +9,12 @@ import { AbstractPageService } from '../utils/pagination';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
|
||||
/**
|
||||
* A service that handles privileges.
|
||||
* A service that handles privileges.
|
||||
*/
|
||||
@Injectable()
|
||||
export class PlaceService extends AbstractPageService<Place, PlacePage> {
|
||||
|
||||
constructor(apiClientService:ApiClientService) {
|
||||
constructor(apiClientService: ApiClientService) {
|
||||
super(apiClientService);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ import { AbstractPageService } from '../utils/pagination';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
|
||||
/**
|
||||
* A service that handles privileges.
|
||||
* A service that handles privileges.
|
||||
*/
|
||||
@Injectable()
|
||||
export class PrivilegeService extends AbstractPageService<Privilege, PrivilegePage> {
|
||||
|
||||
constructor(apiClientService:ApiClientService) {
|
||||
constructor(apiClientService: ApiClientService) {
|
||||
super(apiClientService);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,8 +3,8 @@ import { ConsoleService } from './console.service';
|
||||
import { BehaviorSubject , Subject } from 'rxjs';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Router } from '@angular/router';
|
||||
import { User } from "../../api/models/user.model";
|
||||
import { ApiClientService } from "../../api/index";
|
||||
import { User } from '../../api/models/user.model';
|
||||
import { ApiClientService } from '../../api/index';
|
||||
import { UserPassword } from '../../api/models/userpassword.model';
|
||||
import { CredentialService } from './credential.service';
|
||||
import { HttpStatusCode } from '../utils/httpcodes';
|
||||
@@ -33,14 +33,14 @@ export enum UserState {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* The possible roles assigned by the service.
|
||||
*/
|
||||
export enum UserRole {
|
||||
/** The role of a regular user. */
|
||||
User = "user",
|
||||
User = 'user',
|
||||
/** The role of an admin user. */
|
||||
Admin = "admin"
|
||||
Admin = 'admin'
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,16 +64,16 @@ export class UserService {
|
||||
/**
|
||||
* The last error response, if state is Unauthorized.
|
||||
*/
|
||||
public readonly error: Subject<HttpErrorResponse> = new Subject<HttpErrorResponse>();
|
||||
public readonly error: Subject<HttpErrorResponse> = new Subject<HttpErrorResponse>();
|
||||
|
||||
/**
|
||||
* An url to redirect to after login.
|
||||
*/
|
||||
public redirectUrl:string;
|
||||
public redirectUrl: string;
|
||||
|
||||
/**
|
||||
* Creates a new service.
|
||||
*
|
||||
*
|
||||
* @param consoleService The console for logging.
|
||||
* @param apiClientService The api client for remote requests.
|
||||
* @param credentailService The credential service to manage the username and password.
|
||||
@@ -87,27 +87,27 @@ export class UserService {
|
||||
}
|
||||
|
||||
/** Returns an error handler. */
|
||||
createErrorHandler():(e:any) => void {
|
||||
return (e:any):void => {
|
||||
createErrorHandler(): (e: any) => void {
|
||||
return (e: any): void => {
|
||||
if (e instanceof HttpErrorResponse) {
|
||||
if (e.status == HttpStatusCode.FORBIDDEN) {
|
||||
if (e.status === HttpStatusCode.FORBIDDEN) {
|
||||
this.credentailService.setCredential(this.credentailService.getLogin(), null);
|
||||
}
|
||||
this.error.next(e);
|
||||
this.state.next(UserState.Unavailable);
|
||||
} else {
|
||||
this.consoleService.log("Unknown error in user service.");
|
||||
this.consoleService.log('Unknown error in user service.');
|
||||
console.dir(e);
|
||||
}
|
||||
this.state.next(UserState.Unavailable);
|
||||
this.state.next(UserState.Unavailable);
|
||||
};
|
||||
}
|
||||
|
||||
/** Returns the current login, if any.
|
||||
*
|
||||
*
|
||||
* @returns The current login.
|
||||
*/
|
||||
getLogin():string {
|
||||
getLogin(): string {
|
||||
return this.credentailService.getLogin();
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ export class UserService {
|
||||
* @returns True if the change has been applied.
|
||||
*/
|
||||
setUser(login: string, password: string): boolean {
|
||||
if (this.state.getValue() == UserState.Changing) return false;
|
||||
this.consoleService.log("Setting user credentials.");
|
||||
if (this.state.getValue() === UserState.Changing) { return false; }
|
||||
this.consoleService.log('Setting user credentials.');
|
||||
this.credentailService.setCredential(login, password);
|
||||
this.state.next(UserState.Unavailable);
|
||||
this.user.next(null);
|
||||
@@ -136,12 +136,12 @@ export class UserService {
|
||||
* the credential as a side-effect. If there is an
|
||||
* ongoing interaction, the call to this method will
|
||||
* be ignored.
|
||||
*
|
||||
*
|
||||
* @returns True if the login request has been issued.
|
||||
*/
|
||||
login(): boolean {
|
||||
if (this.state.getValue() == UserState.Changing) return false;
|
||||
this.consoleService.log("Issuing login request.");
|
||||
if (this.state.getValue() === UserState.Changing) { return false; }
|
||||
this.consoleService.log('Issuing login request.');
|
||||
this.state.next(UserState.Changing);
|
||||
this.user.next(null);
|
||||
this.apiClientService.getCurrentUser().subscribe(result => {
|
||||
@@ -154,7 +154,7 @@ export class UserService {
|
||||
/**
|
||||
* Requests a logout, that will be executed unless the
|
||||
* service is currently interacting with the server.
|
||||
*
|
||||
*
|
||||
* @returns True if the change has been applied.
|
||||
*/
|
||||
logout(): boolean {
|
||||
@@ -163,14 +163,14 @@ export class UserService {
|
||||
|
||||
/**
|
||||
* Requests a password change.
|
||||
*
|
||||
*
|
||||
* @param oldPassword The old password.
|
||||
* @param newPassword The new password.
|
||||
* @returns True if the change has been requested.
|
||||
*/
|
||||
changePassword(oldPassword: string, newPassword: string): boolean {
|
||||
if (!this.credentailService.hasPassword(oldPassword)) return false;
|
||||
if (this.state.getValue() == UserState.Changing) return false;
|
||||
if (!this.credentailService.hasPassword(oldPassword)) { return false; }
|
||||
if (this.state.getValue() === UserState.Changing) { return false; }
|
||||
this.state.next(UserState.Changing);
|
||||
this.user.next(null);
|
||||
this.apiClientService.setCurrentPassword({ password: newPassword }).subscribe(result => {
|
||||
@@ -184,11 +184,11 @@ export class UserService {
|
||||
|
||||
/**
|
||||
* Requests a change to the user.
|
||||
*
|
||||
*
|
||||
* @param user The user to change.
|
||||
*/
|
||||
changeUser(user: User): boolean {
|
||||
if (this.state.getValue() == UserState.Changing) return false;
|
||||
if (this.state.getValue() === UserState.Changing) { return false; }
|
||||
this.state.next(UserState.Changing);
|
||||
this.user.next(null);
|
||||
this.apiClientService.setCurrentUser(user).subscribe(result => {
|
||||
@@ -196,10 +196,10 @@ export class UserService {
|
||||
this.state.next(UserState.Available);
|
||||
}, error => {
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
if (error.status == HttpStatusCode.CONFLICT) {
|
||||
if (error.status === HttpStatusCode.CONFLICT) {
|
||||
this.user.next(error.error);
|
||||
this.error.next(error);
|
||||
this.state.next(UserState.Available)
|
||||
this.state.next(UserState.Available);
|
||||
} else {
|
||||
this.createErrorHandler()(error);
|
||||
}
|
||||
@@ -215,15 +215,15 @@ export class UserService {
|
||||
* return whether the specified role is assigned to the
|
||||
* user. If the user is not available or changing, the
|
||||
* result will always be false.
|
||||
*
|
||||
*
|
||||
* @param role The role to test.
|
||||
* @returns True if the user is available and the role
|
||||
* @returns True if the user is available and the role
|
||||
* is assigned.
|
||||
*/
|
||||
hasRole(role: UserRole): boolean {
|
||||
if (this.state.getValue() != UserState.Available) return false;
|
||||
for (let r of this.user.getValue().roles) {
|
||||
if (role === r) return true;
|
||||
if (this.state.getValue() !== UserState.Available) { return false; }
|
||||
for (const r of this.user.getValue().roles) {
|
||||
if (role === r) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,20 +10,20 @@ import { ApiClientService } from '../../api';
|
||||
@Injectable()
|
||||
export class VersionService {
|
||||
|
||||
private version = new BehaviorSubject<BuildVersion>(null);
|
||||
private loading: boolean = false;
|
||||
private version = new BehaviorSubject<BuildVersion>(null);
|
||||
private loading = false;
|
||||
|
||||
constructor(private apiClientService: ApiClientService) { }
|
||||
|
||||
subscribe(handler:(version:BuildVersion)=>void): Subscription {
|
||||
subscribe(handler: (version: BuildVersion) => void): Subscription {
|
||||
if (!this.loading && this.version.getValue() == null) {
|
||||
this.loading = true;
|
||||
this.apiClientService.getBuildVersion().subscribe((v)=> {
|
||||
this.apiClientService.getBuildVersion().subscribe((v) => {
|
||||
this.version.next(v.body);
|
||||
this.loading = false;
|
||||
}, (e)=> {
|
||||
}, (e) => {
|
||||
this.loading = false;
|
||||
})
|
||||
});
|
||||
}
|
||||
return this.version.subscribe(handler);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* The error codes for standard validations.
|
||||
*/
|
||||
export enum FormErrorCode {
|
||||
@@ -9,15 +9,15 @@ export enum FormErrorCode {
|
||||
MAXLENGTH = 4
|
||||
}
|
||||
|
||||
/**
|
||||
* A class that can act as base class for
|
||||
/**
|
||||
* A class that can act as base class for
|
||||
* components that require error encoding.
|
||||
*/
|
||||
export class FormErrorEncoder {
|
||||
|
||||
public readonly FormErrorCode = FormErrorCode;
|
||||
|
||||
public encode(errors: any):number {
|
||||
public encode(errors: any): number {
|
||||
if (errors.required) {
|
||||
return FormErrorCode.REQUIRED;
|
||||
} else if (errors.pattern) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
/**
|
||||
* Various http status codes to avoid using
|
||||
* numbers throughout the code.
|
||||
* numbers throughout the code.
|
||||
*/
|
||||
export enum HttpStatusCode {
|
||||
CONTINUE = 100,
|
||||
@@ -45,4 +45,4 @@ export enum HttpStatusCode {
|
||||
SERVICE_UNAVAILABLE = 503,
|
||||
GATEWAY_TIMEOUT = 504,
|
||||
HTTP_VERSION_NOT_SUPPORTED = 505,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { CollectionViewer } from "@angular/cdk/collections";
|
||||
import { Observable, BehaviorSubject, Subscription } from "rxjs";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
import { MatPaginator } from "@angular/material";
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { CollectionViewer } from '@angular/cdk/collections';
|
||||
import { Observable, BehaviorSubject, Subscription } from 'rxjs';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
import { MatPaginator } from '@angular/material';
|
||||
|
||||
export interface Page<E> {
|
||||
offset: number;
|
||||
size: number;
|
||||
total: number;
|
||||
elements:E[];
|
||||
elements: E[];
|
||||
}
|
||||
|
||||
export class PaginationHandler<D, P extends Page<D>> {
|
||||
|
||||
private pageSubscription: Subscription;
|
||||
private paginatorSubscription: Subscription;
|
||||
|
||||
constructor(private paginator: MatPaginator, private service: AbstractPageService<D, P>) {
|
||||
this.pageSubscription = this.service.page.subscribe((page)=>{
|
||||
|
||||
constructor(private paginator: MatPaginator, private service: AbstractPageService<D, P>) {
|
||||
this.pageSubscription = this.service.page.subscribe((page) => {
|
||||
this.paginator.length = page.total;
|
||||
this.paginator.pageSize = page.size;
|
||||
this.paginator.pageIndex = page.offset / page.size;
|
||||
});
|
||||
this.paginatorSubscription = this.paginator.page.subscribe((page)=>{
|
||||
let offset = page.pageIndex * page.pageSize;
|
||||
let size = page.pageSize;
|
||||
this.paginatorSubscription = this.paginator.page.subscribe((page) => {
|
||||
const offset = page.pageIndex * page.pageSize;
|
||||
const size = page.pageSize;
|
||||
this.service.getPage(offset, size);
|
||||
});
|
||||
}
|
||||
@@ -45,20 +45,20 @@ export abstract class AbstractPageService<D, P extends Page<D>> extends DataSour
|
||||
private subscriptions = 0;
|
||||
readonly loading = new BehaviorSubject<boolean>(false);
|
||||
|
||||
constructor(protected apiClientService:ApiClientService) {
|
||||
constructor(protected apiClientService: ApiClientService) {
|
||||
super();
|
||||
this.page.subscribe((page)=>{
|
||||
this.page.subscribe((page) => {
|
||||
this.elements.next(page.elements);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getPage(offset: number, size: number) {
|
||||
if (this.loading.getValue()) return;
|
||||
if (this.loading.getValue()) { return; }
|
||||
this.loading.next(true);
|
||||
this.loadPage(offset, size).subscribe((result)=>{
|
||||
this.loadPage(offset, size).subscribe((result) => {
|
||||
this.loading.next(false);
|
||||
let page = result.body;
|
||||
const page = result.body;
|
||||
this.page.next(page);
|
||||
}, (error) => {
|
||||
this.loading.next(false);
|
||||
|
||||
@@ -8,23 +8,29 @@ export class Snackbars {
|
||||
|
||||
/**
|
||||
* Shows an error message that disappears after a short period of time.
|
||||
*
|
||||
*
|
||||
* @param snackbar The snackbar service.
|
||||
* @param message The message.
|
||||
*/
|
||||
public static showError(snackbar: MatSnackBar, message: string, duration?:number) {
|
||||
if (duration == null) snackbar.open(message, null, { panelClass: ["snackbar-accent"], duration: Snackbars.DURATION_SHORT});
|
||||
else snackbar.open(message, null, { panelClass: ["snackbar-accent"], duration: duration});
|
||||
public static showError(snackbar: MatSnackBar, message: string, duration?: number) {
|
||||
if (duration == null) {
|
||||
snackbar.open(message, null, { panelClass: ['snackbar-accent'], duration: Snackbars.DURATION_SHORT});
|
||||
} else {
|
||||
snackbar.open(message, null, { panelClass: ['snackbar-accent'], duration: duration});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a permanent information message that does not disapper automatically.
|
||||
*
|
||||
*
|
||||
* @param snackbar The snackbar service.
|
||||
* @param message The message.
|
||||
*/
|
||||
public static showMessage(snackbar: MatSnackBar, message: string, duration?:number) {
|
||||
if (duration != null)snackbar.open(message, null, { panelClass: ["snackbar-primary"], duration: duration});
|
||||
else snackbar.open(message, null, { panelClass: ["snackbar-primary"]});
|
||||
public static showMessage(snackbar: MatSnackBar, message: string, duration?: number) {
|
||||
if (duration != null) {
|
||||
snackbar.open(message, null, { panelClass: ['snackbar-primary'], duration: duration});
|
||||
} else {
|
||||
snackbar.open(message, null, { panelClass: ['snackbar-primary']});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MatTable } from "@angular/material";
|
||||
import { ElementRef } from "@angular/core";
|
||||
import { MatTable } from '@angular/material';
|
||||
import { ElementRef } from '@angular/core';
|
||||
|
||||
export interface TableColumn {
|
||||
name: string;
|
||||
@@ -10,39 +10,39 @@ export interface TableColumn {
|
||||
|
||||
export class TableHandler {
|
||||
|
||||
private tableWidth:number = null;
|
||||
private tableWidth: number = null;
|
||||
private displayColumns: string[] = null;
|
||||
private minWidth: number;
|
||||
private columnsMap: Map<string, TableColumn> = new Map<string, TableColumn>();
|
||||
|
||||
|
||||
constructor(
|
||||
private table: ElementRef,
|
||||
private columns:TableColumn[],
|
||||
private table: ElementRef,
|
||||
private columns: TableColumn[],
|
||||
private fallback?: TableColumn[]) {
|
||||
// compute the min width once before going to fallback, if available
|
||||
this.minWidth = 0;
|
||||
for (let c of columns) {
|
||||
if (c.dropPriority < 0) c.dropPriority = 0;
|
||||
if (c.dropPriority == 0) this.minWidth += c.width;
|
||||
this.columnsMap.set(c.name, c);
|
||||
for (const c of columns) {
|
||||
if (c.dropPriority < 0) { c.dropPriority = 0; }
|
||||
if (c.dropPriority === 0) { this.minWidth += c.width; }
|
||||
this.columnsMap.set(c.name, c);
|
||||
}
|
||||
if (fallback) {
|
||||
for (let c of fallback) {
|
||||
for (const c of fallback) {
|
||||
this.columnsMap.set(c.name, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onCheck(): void {
|
||||
if (this.table.nativeElement.clientWidth != this.tableWidth) {
|
||||
if (this.table.nativeElement.clientWidth !== this.tableWidth) {
|
||||
this.displayColumns = null;
|
||||
}
|
||||
}
|
||||
|
||||
getColumnStyle(name: string): any {
|
||||
let c = this.columnsMap.get(name);
|
||||
if (c == null) return { };
|
||||
const c = this.columnsMap.get(name);
|
||||
if (c == null) { return { }; }
|
||||
if (c.fixedWidth) {
|
||||
return { 'width': c.width + 'px', 'min-width': c.width + 'px', 'max-width': c.width + 'px'};
|
||||
} else {
|
||||
@@ -50,7 +50,7 @@ export class TableHandler {
|
||||
}
|
||||
}
|
||||
|
||||
getDisplayColumns():string[] {
|
||||
getDisplayColumns(): string[] {
|
||||
if (this.displayColumns == null) {
|
||||
this.displayColumns = this.computeColumns();
|
||||
}
|
||||
@@ -60,20 +60,20 @@ export class TableHandler {
|
||||
private computeColumns(): string[] {
|
||||
this.tableWidth = this.table.nativeElement.clientWidth;
|
||||
// get the columns to process (if too small use fallback)
|
||||
var selectedColumns: TableColumn[] = [];
|
||||
let targetColumns: TableColumn[] = (this.fallback && (this.minWidth > this.tableWidth))?this.fallback:this.columns;
|
||||
const selectedColumns: TableColumn[] = [];
|
||||
const targetColumns: TableColumn[] = (this.fallback && (this.minWidth > this.tableWidth)) ? this.fallback : this.columns;
|
||||
// sort the copy by priority
|
||||
var columns = targetColumns.slice();
|
||||
columns.sort((c1, c2)=> { return c1.dropPriority - c2.dropPriority });
|
||||
const columns = targetColumns.slice();
|
||||
columns.sort((c1, c2) => c1.dropPriority - c2.dropPriority);
|
||||
// process columns
|
||||
var currentWidth: number = 0;
|
||||
let currentWidth = 0;
|
||||
while (columns.length > 0) {
|
||||
// for each priority, compute the length and the required width
|
||||
var requiredWidth: number = 0;
|
||||
var priority:number = columns[0].dropPriority;
|
||||
var index: number = 0;
|
||||
for (let c of columns) {
|
||||
if (c.dropPriority == priority) {
|
||||
let requiredWidth = 0;
|
||||
const priority: number = columns[0].dropPriority;
|
||||
let index = 0;
|
||||
for (const c of columns) {
|
||||
if (c.dropPriority === priority) {
|
||||
requiredWidth += c.width;
|
||||
index += 1;
|
||||
} else {
|
||||
@@ -81,8 +81,8 @@ export class TableHandler {
|
||||
}
|
||||
}
|
||||
// now check whether everything fits, and insert the columns as selection
|
||||
if (priority == 0 || this.tableWidth >= (currentWidth + requiredWidth)) {
|
||||
for (let c of columns.splice(0, index)) {
|
||||
if (priority === 0 || this.tableWidth >= (currentWidth + requiredWidth)) {
|
||||
for (const c of columns.splice(0, index)) {
|
||||
selectedColumns.push(c);
|
||||
}
|
||||
currentWidth += requiredWidth;
|
||||
@@ -92,14 +92,14 @@ export class TableHandler {
|
||||
}
|
||||
}
|
||||
// sort the result by the original ordering
|
||||
selectedColumns.sort((c1, c2)=> { return targetColumns.indexOf(c1) - targetColumns.indexOf(c2) })
|
||||
selectedColumns.sort((c1, c2) => targetColumns.indexOf(c1) - targetColumns.indexOf(c2));
|
||||
// get the name only
|
||||
let result: string[] = [];
|
||||
for (let c of selectedColumns) {
|
||||
const result: string[] = [];
|
||||
for (const c of selectedColumns) {
|
||||
result.push(c.name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,44 +1,43 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { MatDialog } from "@angular/material";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { MessageDialogComponent } from "../widgets/message-dialog.component";
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { HttpStatusCode } from "../utils/httpcodes";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { HttpStatusCode } from '../utils/httpcodes';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'activate',
|
||||
templateUrl: './activate.component.html',
|
||||
host: { class:'match-parent' },
|
||||
selector: 'app-activate',
|
||||
templateUrl: './activate.component.html'
|
||||
})
|
||||
export class ActivateComponent implements OnInit {
|
||||
|
||||
showMessage: boolean = true;
|
||||
|
||||
showMessage = true;
|
||||
|
||||
constructor(
|
||||
public res: ResourceService,
|
||||
private apiClientService: ApiClientService,
|
||||
private dialog: MatDialog,
|
||||
private router: Router,
|
||||
private apiClientService: ApiClientService,
|
||||
private dialog: MatDialog,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
let token = this.route.snapshot.paramMap.get('token');
|
||||
const token = this.route.snapshot.paramMap.get('token');
|
||||
if (!token) {
|
||||
this.router.navigate(["/"]);
|
||||
this.router.navigate(['/']);
|
||||
} else {
|
||||
this.apiClientService.verifyUserEmail(token).subscribe((result)=>{
|
||||
this.apiClientService.verifyUserEmail(token).subscribe((result) => {
|
||||
this.showMessage = false;
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('activate_success_title'),
|
||||
message: this.res.strings('activate_success_message'),
|
||||
button: this.res.strings('button_gotit')}).subscribe((close)=>{
|
||||
this.router.navigate(["/"]);
|
||||
})
|
||||
}, (error)=> {
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('activate_success_title'),
|
||||
message: this.res.strings('activate_success_message'),
|
||||
button: this.res.strings('button_gotit')}).subscribe((close) => {
|
||||
this.router.navigate(['/']);
|
||||
});
|
||||
}, (error) => {
|
||||
this.showMessage = false;
|
||||
var message: string = this.res.strings('activate_error_message');
|
||||
let message: string = this.res.strings('activate_error_message');
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
switch (error.status) {
|
||||
case HttpStatusCode.BAD_REQUEST:
|
||||
@@ -51,15 +50,15 @@ import { ResourceService } from "../services/resource.service";
|
||||
break;
|
||||
}
|
||||
}
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title:this.res.strings('activate_error_title'),
|
||||
message:message,
|
||||
button:this.res.strings('button_gotit') }).subscribe((close)=>{
|
||||
this.router.navigate(["/"]);
|
||||
})
|
||||
})
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('activate_error_title'),
|
||||
message: message,
|
||||
button: this.res.strings('button_gotit') }).subscribe((close) => {
|
||||
this.router.navigate(['/']);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form #changeForm="ngForm">
|
||||
<password-field (keyup.enter)="onChange()"></password-field>
|
||||
<app-password-field (keyup.enter)="onChange()"></app-password-field>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
||||
|
||||
@@ -15,14 +15,13 @@ import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'reset',
|
||||
templateUrl: './change.component.html',
|
||||
host: { class: 'match-parent' }
|
||||
selector: 'app-change',
|
||||
templateUrl: './change.component.html'
|
||||
})
|
||||
export class ChangeComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild(PasswordFieldComponent, { static: true }) passwordField: PasswordFieldComponent;
|
||||
@ViewChild("changeForm", { static: true }) resetForm: NgForm;
|
||||
@ViewChild('changeForm', { static: true }) resetForm: NgForm;
|
||||
|
||||
readonly idle = new BehaviorSubject<boolean>(true);
|
||||
|
||||
@@ -39,41 +38,42 @@ export class ChangeComponent implements OnInit, OnDestroy {
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.token = this.route.snapshot.paramMap.get("token");
|
||||
this.token = this.route.snapshot.paramMap.get('token');
|
||||
}
|
||||
|
||||
onChange(): void {
|
||||
this.snackbar.dismiss();
|
||||
if (!this.idle || !this.resetForm.valid) return;
|
||||
if (!this.idle || !this.resetForm.valid) { return; }
|
||||
this.setIdle(false);
|
||||
this.changeSubscription = this.apiClientService.resetUserPassword(this.token, { password: this.passwordField.password }).subscribe((result) => {
|
||||
this.changeSubscription = this.apiClientService.resetUserPassword
|
||||
(this.token, { password: this.passwordField.password }).subscribe((result) => {
|
||||
this.setIdle(true);
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('change_reset_success_title'),
|
||||
message: this.res.strings('change_reset_success_message'),
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('change_reset_success_title'),
|
||||
message: this.res.strings('change_reset_success_message'),
|
||||
button: this.res.strings('button_gotit') }).subscribe((close) => {
|
||||
this.router.navigate(["/"]);
|
||||
this.router.navigate(['/']);
|
||||
});
|
||||
}, (error) => {
|
||||
this.setIdle(true);
|
||||
var message: string = this.res.strings("change_reset_error_message");
|
||||
let message: string = this.res.strings('change_reset_error_message');
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
switch (error.status) {
|
||||
case HttpStatusCode.BAD_REQUEST:
|
||||
message = this.res.strings("change_reset_error_badlink");
|
||||
message = this.res.strings('change_reset_error_badlink');
|
||||
break;
|
||||
case HttpStatusCode.FORBIDDEN:
|
||||
message = this.res.strings("change_reset_error_expiredlink");
|
||||
message = this.res.strings('change_reset_error_expiredlink');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings("change_reset_error_title"),
|
||||
message: message,
|
||||
button: this.res.strings("button_gotit") }).subscribe((close) => {
|
||||
this.router.navigate(["/"]);
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('change_reset_error_title'),
|
||||
message: message,
|
||||
button: this.res.strings('button_gotit') }).subscribe((close) => {
|
||||
this.router.navigate(['/']);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export class ChangeComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.snackbar.dismiss();
|
||||
if (this.changeSubscription) this.changeSubscription.unsubscribe();
|
||||
if (this.changeSubscription) { this.changeSubscription.unsubscribe(); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<marker-map>
|
||||
<app-marker-map>
|
||||
<mat-accordion class="sidebar">
|
||||
<mat-expansion-panel class="mat-typography" style="width:280px;margin-right:10px;margin-top:10px">
|
||||
<mat-expansion-panel-header>
|
||||
@@ -81,4 +81,4 @@
|
||||
</mat-action-row>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</marker-map>
|
||||
</app-marker-map>
|
||||
@@ -1,22 +1,21 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from "@angular/core";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { MatDialog, MatSnackBar } from "@angular/material";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { MessageDialogComponent } from "../widgets/message-dialog.component";
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { HttpStatusCode } from "../utils/httpcodes";
|
||||
import { Subscription, BehaviorSubject } from "rxjs";
|
||||
import { Device, Location } from "../../api/models";
|
||||
import { Snackbars } from "../utils/snackbars";
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, HostBinding } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { HttpStatusCode } from '../utils/httpcodes';
|
||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { Device, Location } from '../../api/models';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import * as L from 'leaflet';
|
||||
import { TileMapComponent } from "../widgets/tile-map.component";
|
||||
import { MarkerMapComponent } from "../widgets/marker-map.component";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { TileMapComponent } from '../widgets/tile-map.component';
|
||||
import { MarkerMapComponent } from '../widgets/marker-map.component';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'device-location',
|
||||
templateUrl: './device-location.component.html',
|
||||
host: { class:'match-parent' },
|
||||
selector: 'app-device-location',
|
||||
templateUrl: './device-location.component.html'
|
||||
})
|
||||
export class DeviceLocationComponent implements OnInit, OnDestroy {
|
||||
|
||||
@@ -38,48 +37,48 @@ import { ResourceService } from "../services/resource.service";
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.id = this.route.snapshot.paramMap.get("id");
|
||||
this.id = this.route.snapshot.paramMap.get('id');
|
||||
this.updateDevice();
|
||||
this.updateLocation();
|
||||
}
|
||||
|
||||
isUpdatingDevice():boolean {
|
||||
isUpdatingDevice(): boolean {
|
||||
return this.deviceSubscription != null;
|
||||
}
|
||||
|
||||
isUpdatingLocation():boolean {
|
||||
isUpdatingLocation(): boolean {
|
||||
return this.locationSubscription != null;
|
||||
}
|
||||
|
||||
updateDevice():void {
|
||||
if (this.deviceSubscription) return;
|
||||
this.deviceSubscription = this.apiClientService.getDevice(parseInt(this.id, 10)).subscribe((result)=>{
|
||||
updateDevice(): void {
|
||||
if (this.deviceSubscription) { return; }
|
||||
this.deviceSubscription = this.apiClientService.getDevice(parseInt(this.id, 10)).subscribe((result) => {
|
||||
this.device.next(result.body);
|
||||
this.deviceSubscription = null;
|
||||
}, (error)=>{
|
||||
}, (error) => {
|
||||
Snackbars.showError(this.snackbar, this.res.strings('device_location_device_error'));
|
||||
this.deviceSubscription = null;
|
||||
});
|
||||
}
|
||||
|
||||
updateLocation():void {
|
||||
if (this.locationSubscription) return;
|
||||
this.locationSubscription = this.apiClientService.getDeviceLocation(parseInt(this.id, 10)).subscribe((result)=>{
|
||||
updateLocation(): void {
|
||||
if (this.locationSubscription) { return; }
|
||||
this.locationSubscription = this.apiClientService.getDeviceLocation(parseInt(this.id, 10)).subscribe((result) => {
|
||||
this.location.next(result.body);
|
||||
this.map.setMarkerPosition(result.body.coordinate);
|
||||
this.locationSubscription = null;
|
||||
}, (error)=>{
|
||||
}, (error) => {
|
||||
Snackbars.showError(this.snackbar, this.res.strings('device_location_location_error'));
|
||||
this.locationSubscription = null;
|
||||
this.map.setMarkerPosition(null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.deviceSubscription) this.deviceSubscription.unsubscribe();
|
||||
if (this.locationSubscription) this.locationSubscription.unsubscribe();
|
||||
if (this.deviceSubscription) { this.deviceSubscription.unsubscribe(); }
|
||||
if (this.locationSubscription) { this.locationSubscription.unsubscribe(); }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<marker-map>
|
||||
<app-marker-map>
|
||||
<mat-accordion class="sidebar">
|
||||
<mat-expansion-panel class="mat-typography" [ngStyle]="getPanelWidth()" style="margin-right:10px;margin-top:10px">
|
||||
<mat-expansion-panel-header>
|
||||
@@ -133,4 +133,4 @@
|
||||
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</marker-map>
|
||||
</app-marker-map>
|
||||
@@ -1,61 +1,60 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ElementRef, DoCheck } from "@angular/core";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { MatDialog, MatSnackBar, MatDatepicker, MatDatepickerInputEvent } from "@angular/material";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { MessageDialogComponent } from "../widgets/message-dialog.component";
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { HttpStatusCode } from "../utils/httpcodes";
|
||||
import { Subscription, BehaviorSubject } from "rxjs";
|
||||
import { Device, Location, Visit } from "../../api/models";
|
||||
import { Snackbars } from "../utils/snackbars";
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ElementRef, DoCheck } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar, MatDatepicker, MatDatepickerInputEvent } from '@angular/material';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { HttpStatusCode } from '../utils/httpcodes';
|
||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { Device, Location, Visit } from '../../api/models';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import * as L from 'leaflet';
|
||||
import { TileMapComponent } from "../widgets/tile-map.component";
|
||||
import { MarkerMapComponent } from "../widgets/marker-map.component";
|
||||
import { DeviceVisitService } from "../services/device-visit.service";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { ConfirmationDialogComponent } from "../widgets/confirmation-dialog.component";
|
||||
import { FormControl } from "@angular/forms";
|
||||
import { TableColumn, TableHandler } from "../utils/tables";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { TileMapComponent } from '../widgets/tile-map.component';
|
||||
import { MarkerMapComponent } from '../widgets/marker-map.component';
|
||||
import { DeviceVisitService } from '../services/device-visit.service';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { TableColumn, TableHandler } from '../utils/tables';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'device-visits',
|
||||
templateUrl: './device-visits.component.html',
|
||||
host: { class: 'match-parent' },
|
||||
selector: 'app-device-visits',
|
||||
templateUrl: './device-visits.component.html'
|
||||
})
|
||||
export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy, DoCheck {
|
||||
|
||||
private static COLUMNS: TableColumn[] = [
|
||||
{ name: "time", dropPriority: 0, width: 120, fixedWidth: true },
|
||||
{ name: "place", dropPriority: 0, width: 120 },
|
||||
{ name: "actions", dropPriority: 0, width: 130, fixedWidth: true }
|
||||
{ name: 'time', dropPriority: 0, width: 120, fixedWidth: true },
|
||||
{ name: 'place', dropPriority: 0, width: 120 },
|
||||
{ name: 'actions', dropPriority: 0, width: 130, fixedWidth: true }
|
||||
];
|
||||
|
||||
private static FALLBACK: TableColumn[] = [
|
||||
{ name: "visit", dropPriority: 0, width: 120 },
|
||||
{ name: "actions", dropPriority: 0, width: 130, fixedWidth: true }
|
||||
{ name: 'visit', dropPriority: 0, width: 120 },
|
||||
{ name: 'actions', dropPriority: 0, width: 130, fixedWidth: true }
|
||||
];
|
||||
|
||||
private static readonly DAY = 24 * 60 * 60 * 1000;
|
||||
|
||||
@ViewChild(MarkerMapComponent, { static: true }) map: MarkerMapComponent;
|
||||
@ViewChild("table", { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
|
||||
id: string;
|
||||
|
||||
maxDate = new Date();
|
||||
minDate = new Date();
|
||||
selectedDate = new Date();
|
||||
minTime: number = 0;
|
||||
maxTime: number = 0;
|
||||
minTime = 0;
|
||||
maxTime = 0;
|
||||
|
||||
device: BehaviorSubject<Device>;
|
||||
dataSource: DataSource<Visit>;
|
||||
loading: BehaviorSubject<boolean>
|
||||
date: BehaviorSubject<Date>
|
||||
loading: BehaviorSubject<boolean>;
|
||||
date: BehaviorSubject<Date>;
|
||||
deleting = new BehaviorSubject<boolean>(false);
|
||||
|
||||
compact: boolean = false;
|
||||
compact = false;
|
||||
|
||||
private places: L.CircleMarker[] = [];
|
||||
private tableHandler: TableHandler;
|
||||
@@ -91,7 +90,7 @@ export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy,
|
||||
}
|
||||
|
||||
hasNextDay(): boolean {
|
||||
let next = this.selectedDate.getTime() + DeviceVisitsComponent.DAY;
|
||||
const next = this.selectedDate.getTime() + DeviceVisitsComponent.DAY;
|
||||
return this.maxDate.getTime() >= next;
|
||||
}
|
||||
|
||||
@@ -101,7 +100,7 @@ export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy,
|
||||
|
||||
|
||||
hasPreviousDay(): boolean {
|
||||
let next = this.selectedDate.getTime() - DeviceVisitsComponent.DAY;
|
||||
const next = this.selectedDate.getTime() - DeviceVisitsComponent.DAY;
|
||||
return this.minDate.getTime() <= next;
|
||||
}
|
||||
|
||||
@@ -111,8 +110,11 @@ export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy,
|
||||
|
||||
|
||||
getPanelWidth(): any {
|
||||
if (this.compact) return { width: "280px" };
|
||||
else return { width: "520px" };
|
||||
if (this.compact) {
|
||||
return { width: '280px' };
|
||||
} else {
|
||||
return { width: '520px' };
|
||||
}
|
||||
}
|
||||
|
||||
getStyle(column: string): any {
|
||||
@@ -130,11 +132,11 @@ export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy,
|
||||
|
||||
ngOnInit() {
|
||||
this.tableHandler = new TableHandler(this.table, DeviceVisitsComponent.COLUMNS, DeviceVisitsComponent.FALLBACK);
|
||||
this.id = this.route.snapshot.paramMap.get("id");
|
||||
this.id = this.route.snapshot.paramMap.get('id');
|
||||
this.deviceVisitSerivce.setDevice(+this.id);
|
||||
this.dateSubscription = this.date.subscribe((date) => {
|
||||
this.selectedDate = date;
|
||||
let d = new Date(date);
|
||||
const d = new Date(date);
|
||||
d.setHours(0, 0, 0, 0);
|
||||
this.minTime = d.getTime();
|
||||
d.setHours(23, 59, 59, 999);
|
||||
@@ -155,8 +157,11 @@ export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy,
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.loadingSubscription = this.loading.subscribe((load) => {
|
||||
if (load) this.clearPlaces();
|
||||
else this.createPlaces();
|
||||
if (load) {
|
||||
this.clearPlaces();
|
||||
} else {
|
||||
this.createPlaces();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,15 +173,15 @@ export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy,
|
||||
}
|
||||
|
||||
getPlaceName(id: number): string {
|
||||
let place = this.deviceVisitSerivce.getPlace(id);
|
||||
const place = this.deviceVisitSerivce.getPlace(id);
|
||||
if (!place) {
|
||||
return "" + id;
|
||||
return '' + id;
|
||||
} else if (place.nickname) {
|
||||
return place.nickname;
|
||||
} else if (place.address) {
|
||||
return place.address;
|
||||
} else {
|
||||
return "" + place.id;
|
||||
return '' + place.id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,11 +208,11 @@ export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy,
|
||||
this.deleting.next(false);
|
||||
this.deviceVisitSerivce.setDevice(+this.id);
|
||||
Snackbars.showError(this.snackbar, this.res.strings('visits_delete_error'));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
onSelectPlace(id: number): void {
|
||||
let place = this.deviceVisitSerivce.getPlace(id);
|
||||
const place = this.deviceVisitSerivce.getPlace(id);
|
||||
if (!place) {
|
||||
Snackbars.showError(this.snackbar, this.res.strings('visits_place_load_error'));
|
||||
this.map.setPinPosition(null);
|
||||
@@ -223,55 +228,55 @@ export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy,
|
||||
|
||||
private createPlaces(): void {
|
||||
// compute the total and individual stay duration
|
||||
let placeDurations = new Map<number, number>();
|
||||
var totalDuration = 0;
|
||||
for (let v of this.deviceVisitSerivce.getVisits()) {
|
||||
let begin = this.getTime(v.beginTime);
|
||||
let end = this.getTime(v.endTime);
|
||||
var duration = end - begin;
|
||||
const placeDurations = new Map<number, number>();
|
||||
let totalDuration = 0;
|
||||
for (const v of this.deviceVisitSerivce.getVisits()) {
|
||||
const begin = this.getTime(v.beginTime);
|
||||
const end = this.getTime(v.endTime);
|
||||
let duration = end - begin;
|
||||
totalDuration += duration;
|
||||
if (placeDurations.has(v.place)) {
|
||||
duration += placeDurations.get(v.place);
|
||||
}
|
||||
placeDurations.set(v.place, duration);
|
||||
}
|
||||
var latlngs: ([number, number])[] = new Array();
|
||||
const latlngs: ([number, number])[] = new Array();
|
||||
// create circles for places
|
||||
placeDurations.forEach((v, k) => {
|
||||
let place = this.deviceVisitSerivce.getPlace(k);
|
||||
const place = this.deviceVisitSerivce.getPlace(k);
|
||||
if (place != null) {
|
||||
let pos = new L.LatLng(place.coordinate.latitude, place.coordinate.longitude);
|
||||
const pos = new L.LatLng(place.coordinate.latitude, place.coordinate.longitude);
|
||||
latlngs.push([place.coordinate.latitude, place.coordinate.longitude]);
|
||||
let circle = L.circleMarker(pos, {
|
||||
const circle = L.circleMarker(pos, {
|
||||
radius: 36,
|
||||
fillColor: "#f9a825",
|
||||
fillColor: '#f9a825',
|
||||
fill: true,
|
||||
stroke: true,
|
||||
weight: 4,
|
||||
fillOpacity: this.getOpacity(v, totalDuration),
|
||||
opacity: 0.8,
|
||||
color: "#01579b"
|
||||
})
|
||||
color: '#01579b'
|
||||
});
|
||||
this.places.push(circle);
|
||||
circle.addTo(this.map.map.map);
|
||||
}
|
||||
});
|
||||
if (latlngs.length > 0) {
|
||||
let bounds = new L.LatLngBounds(latlngs);
|
||||
const bounds = new L.LatLngBounds(latlngs);
|
||||
this.map.centerBounds(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
private getOpacity(duration: number, total: number): number {
|
||||
let maxOpacity = 0.8;
|
||||
if (total == 0) return maxOpacity;
|
||||
let fraction = duration / total;
|
||||
const maxOpacity = 0.8;
|
||||
if (total === 0) { return maxOpacity; }
|
||||
const fraction = duration / total;
|
||||
return fraction * maxOpacity;
|
||||
}
|
||||
|
||||
private clearPlaces(): void {
|
||||
this.map.setPinPosition(null);
|
||||
for (let c of this.places) {
|
||||
for (const c of this.places) {
|
||||
c.remove();
|
||||
}
|
||||
this.places = [];
|
||||
|
||||
@@ -12,23 +12,22 @@ import { TableHandler, TableColumn } from '../utils/tables';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'devices',
|
||||
templateUrl: 'devices.component.html',
|
||||
host: { class: 'match-parent' }
|
||||
selector: 'app-devices',
|
||||
templateUrl: 'devices.component.html'
|
||||
})
|
||||
export class DevicesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
|
||||
private static COLUMNS: TableColumn[] = [
|
||||
{ name: "id", dropPriority: 2, width: 140, fixedWidth: true },
|
||||
{ name: "os", dropPriority: 1, width: 60, fixedWidth: true },
|
||||
{ name: "manufacturer", dropPriority: 0, width: 200 },
|
||||
{ name: "model", dropPriority: 0, width: 200 },
|
||||
{ name: "creationTime", dropPriority: 3, width: 130, fixedWidth: true },
|
||||
{ name: "modificationTime", dropPriority: 4, width: 130, fixedWidth: true },
|
||||
{ name: "actions", dropPriority: 0, width: 130, fixedWidth: true }
|
||||
{ name: 'id', dropPriority: 2, width: 140, fixedWidth: true },
|
||||
{ name: 'os', dropPriority: 1, width: 60, fixedWidth: true },
|
||||
{ name: 'manufacturer', dropPriority: 0, width: 200 },
|
||||
{ name: 'model', dropPriority: 0, width: 200 },
|
||||
{ name: 'creationTime', dropPriority: 3, width: 130, fixedWidth: true },
|
||||
{ name: 'modificationTime', dropPriority: 4, width: 130, fixedWidth: true },
|
||||
{ name: 'actions', dropPriority: 0, width: 130, fixedWidth: true }
|
||||
];
|
||||
|
||||
@ViewChild("table", { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
|
||||
dataSource: DataSource<Device>;
|
||||
@@ -71,8 +70,11 @@ export class DevicesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
}
|
||||
|
||||
getOsIcon(os: string): string {
|
||||
if (os === "ANDROID") return "android";
|
||||
else return "smartphone";
|
||||
if (os === 'ANDROID') {
|
||||
return 'android';
|
||||
} else {
|
||||
return 'smartphone';
|
||||
}
|
||||
}
|
||||
|
||||
onDelete(id: number): void {
|
||||
@@ -98,7 +100,7 @@ export class DevicesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
this.deleting.next(false);
|
||||
this.deviceSerivce.reload();
|
||||
Snackbars.showError(this.snackbar, this.res.strings('devices_delete_error'));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</ng-container>
|
||||
<ng-template #content>
|
||||
<div fxLayout.gt-sm="row" fxLayout.lt-md="column" fxLayoutAlign.gt-sm="space-around start" fxLayoutAlign.lt-md="start stretch">
|
||||
<mat-card class="mat-typography" fxFlex="flex: 1 1 450px" style="margin:20px">
|
||||
<mat-card class="mat-typography" fxFlex="grow" style="margin:20px">
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>{{ res.strings('edit_notice_content_title') }}</mat-card-title>
|
||||
<mat-card-subtitle>{{ res.strings('edit_notice_content_subtitle') }}</mat-card-subtitle>
|
||||
@@ -55,7 +55,7 @@
|
||||
<mat-icon [matTooltip]="res.strings('edit_notice_add_language_tooltip')" class="icon-button">add_circle_outline</mat-icon>
|
||||
</ng-template>
|
||||
<div style="margin:30px" fxLayout="column" fxLayoutAlign="center center">
|
||||
<language-select #langSelect style="margin-top:50px" [languages]="getOtherLanguages()" [value]="getOtherLanguages()[0].value"></language-select>
|
||||
<app-language-select #langSelect style="margin-top:50px" [languages]="getOtherLanguages()" [value]="getOtherLanguages()[0].value"></app-language-select>
|
||||
<button style="margin-top:50px" mat-raised-button color="primary" (click)="onAddLanguage(langSelect.value)">
|
||||
<mat-icon class="button-icon">playlist_add</mat-icon>
|
||||
<span>{{ res.strings('button_add') }}</span>
|
||||
|
||||
@@ -16,15 +16,14 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ResourceService, Language } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'edit-notice',
|
||||
selector: 'app-edit-notice',
|
||||
templateUrl: 'edit-notice.component.html',
|
||||
host: { class: 'match-parent' },
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
styles: [".mat-tab-label { width: 65px !important; min-width: 0px !important } "]
|
||||
styles: ['.mat-tab-label { width: 65px !important; min-width: 0px !important } ']
|
||||
})
|
||||
export class EditNoticeComponent extends FormErrorEncoder implements OnInit, OnDestroy {
|
||||
|
||||
readonly languages:Language[];
|
||||
readonly languages: Language[];
|
||||
|
||||
readonly loading: BehaviorSubject<boolean>;
|
||||
id: string;
|
||||
@@ -47,18 +46,18 @@ export class EditNoticeComponent extends FormErrorEncoder implements OnInit, OnD
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.id = this.route.snapshot.paramMap.get("id");
|
||||
this.id = this.route.snapshot.paramMap.get('id');
|
||||
if (!this.isNew()) {
|
||||
this.loadSubscription = this.mangeNoticeService.getNotice(+this.id).subscribe((notice) => {
|
||||
if (notice == null) {
|
||||
Snackbars.showError(this.snackbar, this.res.strings('edit_notice_load_error'));
|
||||
this.router.navigate(["/manage/notices"]);
|
||||
this.router.navigate(['/manage/notices']);
|
||||
} else {
|
||||
this.setNotice(notice);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let date = new Date();
|
||||
const date = new Date();
|
||||
date.setHours(0);
|
||||
date.setMinutes(0);
|
||||
date.setSeconds(0);
|
||||
@@ -80,31 +79,31 @@ export class EditNoticeComponent extends FormErrorEncoder implements OnInit, OnD
|
||||
}
|
||||
|
||||
isNew(): boolean {
|
||||
return +this.id == 0;
|
||||
return +this.id === 0;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.loadSubscription != null) this.loadSubscription.unsubscribe();
|
||||
if (this.loadSubscription != null) { this.loadSubscription.unsubscribe(); }
|
||||
}
|
||||
|
||||
setNotice(notice: Notice): void {
|
||||
if (notice.id != +this.id) {
|
||||
this.router.navigate(["/manage/notices/" + notice.id]);
|
||||
if (notice.id !== +this.id) {
|
||||
this.router.navigate(['/manage/notices/' + notice.id]);
|
||||
}
|
||||
this.notice = notice;
|
||||
this.messages = new Map<string, Message>();
|
||||
for (let m of notice.messages) {
|
||||
for (const m of notice.messages) {
|
||||
this.messages.set(m.language, m);
|
||||
}
|
||||
let date = new Date(notice.expirationTime);
|
||||
const date = new Date(notice.expirationTime);
|
||||
this.expirationDate = date;
|
||||
let min = date.getMinutes();
|
||||
this.expirationTime = ((min < 10) ? "0" : "") + date.getHours() + ":" + ((min < 10) ? "0" : "") + min;
|
||||
const min = date.getMinutes();
|
||||
this.expirationTime = ((min < 10) ? '0' : '') + date.getHours() + ':' + ((min < 10) ? '0' : '') + min;
|
||||
}
|
||||
|
||||
getOtherLanguages(): Language[] {
|
||||
var missing: Language[] = [];
|
||||
for (let lang of this.languages) {
|
||||
const missing: Language[] = [];
|
||||
for (const lang of this.languages) {
|
||||
if (!this.messages.has(lang.value)) {
|
||||
missing.push(lang);
|
||||
}
|
||||
@@ -113,16 +112,16 @@ export class EditNoticeComponent extends FormErrorEncoder implements OnInit, OnD
|
||||
}
|
||||
|
||||
hasAllLanguages(): boolean {
|
||||
for (let lang of this.languages) {
|
||||
if (!this.messages.has(lang.value)) return false;
|
||||
for (const lang of this.languages) {
|
||||
if (!this.messages.has(lang.value)) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
onAddLanguage(lang: string): void {
|
||||
var message: Message = { language: lang, title: "", body: "" } as Message;
|
||||
for (let m of this.notice.messages) {
|
||||
if (m.language == lang) {
|
||||
let message: Message = { language: lang, title: '', body: '' } as Message;
|
||||
for (const m of this.notice.messages) {
|
||||
if (m.language === lang) {
|
||||
message = m;
|
||||
}
|
||||
}
|
||||
@@ -133,17 +132,15 @@ export class EditNoticeComponent extends FormErrorEncoder implements OnInit, OnD
|
||||
this.messages.delete(lang);
|
||||
}
|
||||
|
||||
|
||||
|
||||
onSave(): void {
|
||||
this.notice.messages = [];
|
||||
this.messages.forEach((m: Message, k: string) => {
|
||||
this.notice.messages.push(m);
|
||||
});
|
||||
if (this.notice.minimumVersion == null) this.notice.minimumVersion = 0;
|
||||
if (this.notice.maximumVersion == null) this.notice.maximumVersion = 0;
|
||||
let exp = new Date(this.expirationDate);
|
||||
let time = this.getExpirationTime();
|
||||
if (this.notice.minimumVersion == null) { this.notice.minimumVersion = 0; }
|
||||
if (this.notice.maximumVersion == null) { this.notice.maximumVersion = 0; }
|
||||
const exp = new Date(this.expirationDate);
|
||||
const time = this.getExpirationTime();
|
||||
exp.setHours(time.h);
|
||||
exp.setMinutes(time.m);
|
||||
exp.setSeconds(0);
|
||||
@@ -153,11 +150,11 @@ export class EditNoticeComponent extends FormErrorEncoder implements OnInit, OnD
|
||||
}
|
||||
|
||||
private getExpirationTime(): { h: number, m: number } {
|
||||
var result = { h: 0, m: 0 };
|
||||
if (this.expirationTime == null || this.expirationTime.indexOf(":") == -1) {
|
||||
this.expirationTime = "0:00";
|
||||
const result = { h: 0, m: 0 };
|
||||
if (this.expirationTime == null || this.expirationTime.indexOf(':') === -1) {
|
||||
this.expirationTime = '0:00';
|
||||
}
|
||||
let idx = this.expirationTime.indexOf(":");
|
||||
const idx = this.expirationTime.indexOf(':');
|
||||
result.h = +this.expirationTime.substring(0, idx);
|
||||
result.m = +this.expirationTime.substring(idx + 1);
|
||||
return result;
|
||||
@@ -170,10 +167,10 @@ export class EditNoticeComponent extends FormErrorEncoder implements OnInit, OnD
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings('edit_notice_save_success'), Snackbars.DURATION_SHORT);
|
||||
this.setNotice(result);
|
||||
} else {
|
||||
Snackbars.showError(this.snackbar, this.res.strings('edit_notice_save_error'))
|
||||
Snackbars.showError(this.snackbar, this.res.strings('edit_notice_save_error'));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form #loginForm="ngForm">
|
||||
<login-field [login]="login"></login-field>
|
||||
<password-field [password]="password" (keyup.enter)="onLogin()"></password-field>
|
||||
<app-login-field [login]="login"></app-login-field>
|
||||
<app-password-field [password]="password" (keyup.enter)="onLogin()"></app-password-field>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center" style="min-height:60px">
|
||||
|
||||
@@ -15,9 +15,8 @@ import { BuildVersion } from '../../api/models';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'login',
|
||||
templateUrl: './login.component.html',
|
||||
host: { class:'match-parent' },
|
||||
selector: 'app-login',
|
||||
templateUrl: './login.component.html'
|
||||
})
|
||||
export class LoginComponent implements OnInit, OnDestroy {
|
||||
|
||||
@@ -25,14 +24,14 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild(LoginFieldComponent, { static: true }) loginField: LoginFieldComponent;
|
||||
@ViewChild(PasswordFieldComponent, { static: true }) passwordField: PasswordFieldComponent;
|
||||
@ViewChild("loginForm", { static: true }) loginForm: NgForm;
|
||||
@ViewChild('loginForm', { static: true }) loginForm: NgForm;
|
||||
|
||||
login:string;
|
||||
password:string;
|
||||
columns: number = 2;
|
||||
login: string;
|
||||
password: string;
|
||||
columns = 2;
|
||||
|
||||
readonly idle = new BehaviorSubject<boolean>(false);
|
||||
|
||||
|
||||
private version: BuildVersion;
|
||||
private stateSubscription: Subscription;
|
||||
private errorSubscription: Subscription;
|
||||
@@ -40,16 +39,16 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(
|
||||
public res: ResourceService,
|
||||
private userService: UserService,
|
||||
private datePipe: DatePipe,
|
||||
private versionService: VersionService,
|
||||
private snackbar: MatSnackBar,
|
||||
private router: Router) {
|
||||
private userService: UserService,
|
||||
private datePipe: DatePipe,
|
||||
private versionService: VersionService,
|
||||
private snackbar: MatSnackBar,
|
||||
private router: Router) {
|
||||
this.login = userService.getLogin();
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event:Event) {
|
||||
onResize(event: Event) {
|
||||
this.updateColumns((event.target as Window).innerWidth);
|
||||
}
|
||||
|
||||
@@ -64,60 +63,60 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.updateColumns(window.innerWidth);
|
||||
this.stateSubscription = this.userService.state.subscribe((state)=> {
|
||||
this.stateSubscription = this.userService.state.subscribe((state) => {
|
||||
if (state === UserState.Available) {
|
||||
this.idle.next(false);
|
||||
var url = "/notices";
|
||||
this.idle.next(false);
|
||||
let url = '/notices';
|
||||
if (this.userService.redirectUrl != null) {
|
||||
url = this.userService.redirectUrl;
|
||||
this.userService.redirectUrl = null;
|
||||
this.userService.redirectUrl = null;
|
||||
}
|
||||
this.router.navigateByUrl(url);
|
||||
} else {
|
||||
this.idle.next(state !== UserState.Changing);
|
||||
this.loginField.disabled=! this.idle.getValue();
|
||||
this.loginField.disabled=! this.idle.getValue();
|
||||
this.loginField.disabled = ! this.idle.getValue();
|
||||
this.loginField.disabled = ! this.idle.getValue();
|
||||
}
|
||||
});
|
||||
this.errorSubscription = this.userService.error.subscribe((error)=> {
|
||||
this.password = "";
|
||||
this.errorSubscription = this.userService.error.subscribe((error) => {
|
||||
this.password = '';
|
||||
if (error.status === HttpStatusCode.FORBIDDEN) {
|
||||
Snackbars.showError(this.snackbar, "Zugriff verweigert. Prüf Deine Eingaben und versuchs nochmal.");
|
||||
Snackbars.showError(this.snackbar, 'Zugriff verweigert. Prüf Deine Eingaben und versuchs nochmal.');
|
||||
} else {
|
||||
Snackbars.showError(this.snackbar, "Fehler bei der Anmeldung (" + error.status + "). Hast Du gerade kein Netz?");
|
||||
Snackbars.showError(this.snackbar, 'Fehler bei der Anmeldung (' + error.status + '). Hast Du gerade kein Netz?');
|
||||
}
|
||||
});
|
||||
this.versionSubscription = this.versionService.subscribe((v)=> {
|
||||
this.versionSubscription = this.versionService.subscribe((v) => {
|
||||
this.version = v;
|
||||
});
|
||||
}
|
||||
|
||||
getTime():string {
|
||||
getTime(): string {
|
||||
if (this.version) {
|
||||
return this.datePipe.transform(this.version.time, "short");
|
||||
return this.datePipe.transform(this.version.time, 'short');
|
||||
} else {
|
||||
return "-";
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
|
||||
getVersion():string {
|
||||
getVersion(): string {
|
||||
if (this.version) {
|
||||
return this.version.build;
|
||||
} else {
|
||||
return "-";
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
|
||||
onLogin():void {
|
||||
onLogin(): void {
|
||||
this.snackbar.dismiss();
|
||||
if (!this.idle || !this.loginForm.valid) return;
|
||||
if (!this.idle || !this.loginForm.valid) { return; }
|
||||
this.login = this.loginField.login;
|
||||
this.password = this.passwordField.password;
|
||||
this.userService.setUser(this.login, this.password);
|
||||
this.userService.login();
|
||||
}
|
||||
|
||||
ngOnDestroy():void {
|
||||
ngOnDestroy(): void {
|
||||
this.snackbar.dismiss();
|
||||
this.stateSubscription.unsubscribe();
|
||||
this.errorSubscription.unsubscribe();
|
||||
|
||||
@@ -1,33 +1,32 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, DoCheck, ElementRef } from "@angular/core";
|
||||
import { BehaviorSubject, Observable } from "rxjs";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { LogMessage } from "../../api/models";
|
||||
import { CollectionViewer } from "@angular/cdk/collections";
|
||||
import { ManageLogService } from "../services/manage-log.service";
|
||||
import { LogDialogComponent } from "../widgets/log-dialog.component";
|
||||
import { MatDialog } from "@angular/material";
|
||||
import { TableColumn, TableHandler } from "../utils/tables";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { Component, OnInit, OnDestroy, ViewChild, DoCheck, ElementRef } from '@angular/core';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { LogMessage } from '../../api/models';
|
||||
import { CollectionViewer } from '@angular/cdk/collections';
|
||||
import { ManageLogService } from '../services/manage-log.service';
|
||||
import { LogDialogComponent } from '../widgets/log-dialog.component';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { TableColumn, TableHandler } from '../utils/tables';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'manage-log',
|
||||
templateUrl: './manage-log.component.html',
|
||||
host: { class: 'match-parent' },
|
||||
selector: 'app-manage-log',
|
||||
templateUrl: './manage-log.component.html'
|
||||
})
|
||||
export class ManageLogComponent implements OnInit, OnDestroy, DoCheck {
|
||||
|
||||
private static COLUMNS: TableColumn[] = [
|
||||
{ name: "id", dropPriority: 1, width: 80, fixedWidth: true },
|
||||
{ name: "time", dropPriority: 3, width: 170, fixedWidth: true },
|
||||
{ name: "level", dropPriority: 0, width: 60, fixedWidth: true },
|
||||
{ name: "thread", dropPriority: 4, width: 50, fixedWidth: true },
|
||||
{ name: "className", dropPriority: 5, width: 220, fixedWidth: true },
|
||||
{ name: "message", dropPriority: 0, width: 200 },
|
||||
{ name: "trace", dropPriority: 2, width: 60, fixedWidth: true },
|
||||
{ name: "actions", dropPriority: 0, width: 60, fixedWidth: true }
|
||||
{ name: 'id', dropPriority: 1, width: 80, fixedWidth: true },
|
||||
{ name: 'time', dropPriority: 3, width: 170, fixedWidth: true },
|
||||
{ name: 'level', dropPriority: 0, width: 60, fixedWidth: true },
|
||||
{ name: 'thread', dropPriority: 4, width: 50, fixedWidth: true },
|
||||
{ name: 'className', dropPriority: 5, width: 220, fixedWidth: true },
|
||||
{ name: 'message', dropPriority: 0, width: 200 },
|
||||
{ name: 'trace', dropPriority: 2, width: 60, fixedWidth: true },
|
||||
{ name: 'actions', dropPriority: 0, width: 60, fixedWidth: true }
|
||||
];
|
||||
|
||||
@ViewChild("table", { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
|
||||
readonly connecting: BehaviorSubject<boolean>;
|
||||
readonly dataSource: DataSource<LogMessage>;
|
||||
@@ -35,7 +34,7 @@ export class ManageLogComponent implements OnInit, OnDestroy, DoCheck {
|
||||
|
||||
private tableHandler: TableHandler;
|
||||
|
||||
constructor(public res:ResourceService, private logService: ManageLogService, private dialog: MatDialog) {
|
||||
constructor(public res: ResourceService, private logService: ManageLogService, private dialog: MatDialog) {
|
||||
this.connecting = logService.connecting;
|
||||
this.dataSource = logService;
|
||||
}
|
||||
@@ -80,26 +79,29 @@ export class ManageLogComponent implements OnInit, OnDestroy, DoCheck {
|
||||
}
|
||||
|
||||
getClassName(name: string) {
|
||||
let idx = name.lastIndexOf(".");
|
||||
if (idx == -1) return name;
|
||||
else return name.substring(idx + 1);
|
||||
const idx = name.lastIndexOf('.');
|
||||
if (idx === -1) {
|
||||
return name;
|
||||
} else {
|
||||
return name.substring(idx + 1);
|
||||
}
|
||||
}
|
||||
|
||||
getLevel(level: string) {
|
||||
if (level == 'ERROR') {
|
||||
return "error"
|
||||
} else if (level == 'SEVERE') {
|
||||
return "error_outline"
|
||||
} else if (level == 'INFO') {
|
||||
return "info_outline";
|
||||
if (level === 'ERROR') {
|
||||
return 'error';
|
||||
} else if (level === 'SEVERE') {
|
||||
return 'error_outline';
|
||||
} else if (level === 'INFO') {
|
||||
return 'info_outline';
|
||||
} else {
|
||||
return "panorama_fish_eye";
|
||||
return 'panorama_fish_eye';
|
||||
}
|
||||
}
|
||||
|
||||
getColor(level: string): string {
|
||||
if (level == 'ERROR' || level == 'SEVERE') {
|
||||
return "accent";
|
||||
if (level === 'ERROR' || level === 'SEVERE') {
|
||||
return 'accent';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<mat-icon>forum</mat-icon>
|
||||
<span style="margin-left: 10px">Hinweise</span>
|
||||
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
|
||||
<language-select style="padding-top:5px;" [value]="language" (change)="language = $event"></language-select>
|
||||
<app-language-select style="padding-top:5px;" [value]="language" (change)="language = $event"></app-language-select>
|
||||
<button mat-icon-button matTooltip="Hinweis hinzufügen" routerLink="0" [disabled]="loading.getValue()">
|
||||
<mat-icon>add_circle_outline</mat-icon>
|
||||
</button>
|
||||
|
||||
@@ -16,48 +16,47 @@ import { TableHandler, TableColumn } from '../utils/tables';
|
||||
import { ResourceService, Language } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'manage-notices',
|
||||
templateUrl: 'manage-notices.component.html',
|
||||
host: { class:'match-parent' }
|
||||
selector: 'app-manage-notices',
|
||||
templateUrl: 'manage-notices.component.html'
|
||||
})
|
||||
export class ManageNoticesComponent extends FormErrorEncoder implements OnInit, OnDestroy, DoCheck {
|
||||
|
||||
|
||||
|
||||
private static COLUMNS: TableColumn[] = [
|
||||
{ name: "id", dropPriority: 6, width: 120, fixedWidth:true},
|
||||
{ name: "published", dropPriority: 1, width: 55, fixedWidth:true},
|
||||
{ name: "announced", dropPriority: 1, width: 110, fixedWidth:true},
|
||||
{ name: "languages", dropPriority: 2, width: 140, fixedWidth:true},
|
||||
{ name: "title", dropPriority: 0, width: 350},
|
||||
{ name: "creationTime", dropPriority: 4, width: 130, fixedWidth:true},
|
||||
{ name: "expirationTime", dropPriority: 3, width: 130 , fixedWidth:true},
|
||||
{ name: "modificationTime", dropPriority: 5, width: 130 , fixedWidth:true},
|
||||
{ name: "actions", dropPriority: 0, width: 90, fixedWidth: true }
|
||||
{ name: 'id', dropPriority: 6, width: 120, fixedWidth: true},
|
||||
{ name: 'published', dropPriority: 1, width: 55, fixedWidth: true},
|
||||
{ name: 'announced', dropPriority: 1, width: 110, fixedWidth: true},
|
||||
{ name: 'languages', dropPriority: 2, width: 140, fixedWidth: true},
|
||||
{ name: 'title', dropPriority: 0, width: 350},
|
||||
{ name: 'creationTime', dropPriority: 4, width: 130, fixedWidth: true},
|
||||
{ name: 'expirationTime', dropPriority: 3, width: 130 , fixedWidth: true},
|
||||
{ name: 'modificationTime', dropPriority: 5, width: 130 , fixedWidth: true},
|
||||
{ name: 'actions', dropPriority: 0, width: 90, fixedWidth: true }
|
||||
];
|
||||
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
@ViewChild("table", { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
|
||||
language: string;
|
||||
|
||||
readonly languages:Language[];
|
||||
readonly languages: Language[];
|
||||
readonly dataSource: DataSource<Notice>;
|
||||
readonly loading:BehaviorSubject<boolean>;
|
||||
|
||||
readonly loading: BehaviorSubject<boolean>;
|
||||
|
||||
private tableHandler: TableHandler;
|
||||
private pageHandler: PaginationHandler<Notice, NoticePage>;
|
||||
|
||||
constructor(
|
||||
public res: ResourceService,
|
||||
private mangeNoticeService: ManageNoticeService,
|
||||
private mangeNoticeService: ManageNoticeService,
|
||||
private snackbar: MatSnackBar,
|
||||
private dialog:MatDialog) {
|
||||
private dialog: MatDialog) {
|
||||
super();
|
||||
this.dataSource = mangeNoticeService;
|
||||
this.loading = mangeNoticeService.loading;
|
||||
this.languages = res.languages;
|
||||
this.language = res.strings('language');
|
||||
}
|
||||
}
|
||||
|
||||
getStyle(column: string): any {
|
||||
return this.tableHandler.getColumnStyle(column);
|
||||
@@ -75,50 +74,50 @@ export class ManageNoticesComponent extends FormErrorEncoder implements OnInit,
|
||||
this.tableHandler = new TableHandler(this.table, ManageNoticesComponent.COLUMNS, null);
|
||||
this.pageHandler = new PaginationHandler(this.paginator, this.mangeNoticeService);
|
||||
this.mangeNoticeService.reload();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.pageHandler.destroy();
|
||||
}
|
||||
|
||||
getTitle(notice: Notice): string {
|
||||
for (let m of notice.messages) {
|
||||
if (m.language == this.language) {
|
||||
for (const m of notice.messages) {
|
||||
if (m.language === this.language) {
|
||||
return m.title;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
hasLanguage(notice:Notice, lang:string) {
|
||||
for (let m of notice.messages) {
|
||||
if (m.language == lang) return true;
|
||||
hasLanguage(notice: Notice, lang: string) {
|
||||
for (const m of notice.messages) {
|
||||
if (m.language === lang) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
onDelete(notice: Notice):void {
|
||||
if (this.loading.getValue()) return;
|
||||
onDelete(notice: Notice): void {
|
||||
if (this.loading.getValue()) { return; }
|
||||
notice.deleted = true;
|
||||
this.updateNotice(notice);
|
||||
}
|
||||
|
||||
onRestore(notice: Notice):void {
|
||||
if (this.loading.getValue()) return;
|
||||
onRestore(notice: Notice): void {
|
||||
if (this.loading.getValue()) { return; }
|
||||
notice.deleted = false;
|
||||
this.updateNotice(notice);
|
||||
}
|
||||
|
||||
private updateNotice(notice:Notice) {
|
||||
this.mangeNoticeService.setNotice(notice).subscribe((result)=> {
|
||||
private updateNotice(notice: Notice) {
|
||||
this.mangeNoticeService.setNotice(notice).subscribe((result) => {
|
||||
if (result != null) {
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings("manage_notices_change_success") , Snackbars.DURATION_SHORT);
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings('manage_notices_change_success') , Snackbars.DURATION_SHORT);
|
||||
} else {
|
||||
Snackbars.showError(this.snackbar, this.res.strings("manage_notices_change_error"));
|
||||
Snackbars.showError(this.snackbar, this.res.strings('manage_notices_change_error'));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
import { Component, OnInit, OnDestroy, HostListener } from "@angular/core";
|
||||
import { SystemStatistic, EntityStatistic, LoadStatistic } from "../../api/models";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { Subscription, Observable, BehaviorSubject } from "rxjs";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { CollectionViewer } from "@angular/cdk/collections";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { Component, OnInit, OnDestroy, HostListener } from '@angular/core';
|
||||
import { SystemStatistic, EntityStatistic, LoadStatistic } from '../../api/models';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { Subscription, Observable, BehaviorSubject } from 'rxjs';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { CollectionViewer } from '@angular/cdk/collections';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
|
||||
class EntityDataSource implements DataSource<EntityStatistic> {
|
||||
|
||||
entities = new BehaviorSubject<EntityStatistic[]>([]);
|
||||
|
||||
connect(collectionViewer: CollectionViewer): Observable<EntityStatistic[]> {
|
||||
return this.entities;
|
||||
}
|
||||
disconnect(collectionViewer: CollectionViewer): void {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'manage-system',
|
||||
templateUrl: './manage-system.component.html',
|
||||
host: { class: 'match-parent' },
|
||||
selector: 'app-manage-system',
|
||||
templateUrl: './manage-system.component.html'
|
||||
})
|
||||
export class ManageSystemComponent implements OnInit, OnDestroy {
|
||||
|
||||
@@ -20,20 +33,20 @@ export class ManageSystemComponent implements OnInit, OnDestroy {
|
||||
system: SystemStatistic;
|
||||
readonly entities = new EntityDataSource();
|
||||
load: LoadStatistic;
|
||||
columns:number = 1;
|
||||
columns = 1;
|
||||
|
||||
private loadSubscription: Subscription;
|
||||
private entitySubscription: Subscription;
|
||||
private systemSubscription: Subscription;
|
||||
|
||||
private loadTimer:any = null;
|
||||
private loadTimer: any = null;
|
||||
private entityTimer: any = null;
|
||||
private systemTimer: any = null;
|
||||
|
||||
constructor(public res: ResourceService, private apiClientService: ApiClientService) { }
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event:Event) {
|
||||
onResize(event: Event) {
|
||||
this.updateColumns((event.target as Window).innerWidth);
|
||||
}
|
||||
|
||||
@@ -56,38 +69,38 @@ export class ManageSystemComponent implements OnInit, OnDestroy {
|
||||
this.loadSubscription.unsubscribe();
|
||||
this.entitySubscription.unsubscribe();
|
||||
this.systemSubscription.unsubscribe();
|
||||
if (this.loadTimer != null) clearTimeout(this.loadTimer);
|
||||
if (this.entityTimer != null) clearTimeout(this.entityTimer);
|
||||
if (this.systemTimer != null) clearTimeout(this.systemTimer);
|
||||
if (this.loadTimer != null) { clearTimeout(this.loadTimer); }
|
||||
if (this.entityTimer != null) { clearTimeout(this.entityTimer); }
|
||||
if (this.systemTimer != null) { clearTimeout(this.systemTimer); }
|
||||
}
|
||||
|
||||
hasEntities():boolean {
|
||||
return this.entities.entities.getValue().length == 0;
|
||||
hasEntities(): boolean {
|
||||
return this.entities.entities.getValue().length === 0;
|
||||
}
|
||||
|
||||
private updateLoad(): Subscription {
|
||||
return this.apiClientService.getLoadStatistic().subscribe((result)=>{
|
||||
return this.apiClientService.getLoadStatistic().subscribe((result) => {
|
||||
this.load = result.body;
|
||||
this.loadTimer = setTimeout(()=>this.loadSubscription = this.updateLoad(),ManageSystemComponent.TIMEOUT_LOAD);
|
||||
},(error)=>{
|
||||
this.loadTimer = setTimeout(()=>this.loadSubscription = this.updateLoad(),ManageSystemComponent.TIMEOUT_ERROR);
|
||||
this.loadTimer = setTimeout(() => this.loadSubscription = this.updateLoad(), ManageSystemComponent.TIMEOUT_LOAD);
|
||||
}, (error) => {
|
||||
this.loadTimer = setTimeout(() => this.loadSubscription = this.updateLoad(), ManageSystemComponent.TIMEOUT_ERROR);
|
||||
});
|
||||
}
|
||||
|
||||
private updateEntities(): Subscription {
|
||||
return this.apiClientService.getEntityStatistics().subscribe((result)=>{
|
||||
return this.apiClientService.getEntityStatistics().subscribe((result) => {
|
||||
this.entities.entities.next(result.body);
|
||||
this.entityTimer = setTimeout(()=>this.entitySubscription = this.updateEntities(), ManageSystemComponent.TIMEOUT_ENTITY);
|
||||
}, (error)=>{
|
||||
this.entityTimer = setTimeout(()=>this.entitySubscription = this.updateEntities(), ManageSystemComponent.TIMEOUT_ERROR);
|
||||
this.entityTimer = setTimeout(() => this.entitySubscription = this.updateEntities(), ManageSystemComponent.TIMEOUT_ENTITY);
|
||||
}, (error) => {
|
||||
this.entityTimer = setTimeout(() => this.entitySubscription = this.updateEntities(), ManageSystemComponent.TIMEOUT_ERROR);
|
||||
});
|
||||
}
|
||||
|
||||
private updateSystem(): Subscription {
|
||||
return this.apiClientService.getSystemStatistic().subscribe((result)=>{
|
||||
return this.apiClientService.getSystemStatistic().subscribe((result) => {
|
||||
this.system = result.body;
|
||||
}, (error)=> {
|
||||
this.systemTimer = setTimeout(()=>this.systemSubscription = this.updateSystem(), ManageSystemComponent.TIMEOUT_ERROR);
|
||||
}, (error) => {
|
||||
this.systemTimer = setTimeout(() => this.systemSubscription = this.updateSystem(), ManageSystemComponent.TIMEOUT_ERROR);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -95,42 +108,42 @@ export class ManageSystemComponent implements OnInit, OnDestroy {
|
||||
return this.system != null && this.load != null;
|
||||
}
|
||||
|
||||
getCpuLoad():number {
|
||||
return (this.load.cpuLoad / Math.max(1, this.system.processors) * 100)
|
||||
getCpuLoad(): number {
|
||||
return (this.load.cpuLoad / Math.max(1, this.system.processors) * 100);
|
||||
}
|
||||
|
||||
getMemory(bytes: number):string {
|
||||
let megabytes = Math.floor(bytes / (1024*1024));
|
||||
let gb = Math.floor(megabytes / 1000);
|
||||
let mb = megabytes - (gb * 1000);
|
||||
var memory = "";
|
||||
|
||||
getMemory(bytes: number): string {
|
||||
const megabytes = Math.floor(bytes / (1024 * 1024));
|
||||
const gb = Math.floor(megabytes / 1000);
|
||||
const mb = megabytes - (gb * 1000);
|
||||
let memory = '';
|
||||
if (gb > 0) {
|
||||
memory += gb + " " + this.res.strings(gb==1?"manage_system_gb":"manage_system_gbs");
|
||||
memory += gb + ' ' + this.res.strings(gb === 1 ? 'manage_system_gb' : 'manage_system_gbs');
|
||||
}
|
||||
memory += mb + " " + this.res.strings(mb==1?"manage_system_mb":"manage_system_mbs");
|
||||
memory += mb + ' ' + this.res.strings(mb === 1 ? 'manage_system_mb' : 'manage_system_mbs');
|
||||
return memory;
|
||||
}
|
||||
|
||||
getUptime(uptime:number):string {
|
||||
let time = this.getTime(uptime);
|
||||
var result = "";
|
||||
getUptime(uptime: number): string {
|
||||
const time = this.getTime(uptime);
|
||||
let result = '';
|
||||
if (time.d > 0) {
|
||||
result += time.d + " " + this.res.strings(time.d>1?"manage_system_days":"manage_system_day");
|
||||
result += time.d + ' ' + this.res.strings(time.d > 1 ? 'manage_system_days' : 'manage_system_day');
|
||||
}
|
||||
if (time.d > 0 || time.h > 0) {
|
||||
result += time.h + " " + this.res.strings(time.h==1?"manage_system_hour":"manage_system_hours");
|
||||
result += time.h + ' ' + this.res.strings(time.h === 1 ? 'manage_system_hour' : 'manage_system_hours');
|
||||
}
|
||||
if (time.d > 0 || time.h > 0 || time.m > 0) {
|
||||
result += time.m + " " + this.res.strings(time.m==1?"manage_system_minute":"manage_system_minutes");
|
||||
result += time.m + ' ' + this.res.strings(time.m === 1 ? 'manage_system_minute' : 'manage_system_minutes');
|
||||
}
|
||||
if (this.columns > 1) {
|
||||
result += time.s + " " + this.res.strings(time.s==1?"manage_system_second":"manage_system_seconds");
|
||||
result += time.s + ' ' + this.res.strings(time.s === 1 ? 'manage_system_second' : 'manage_system_seconds');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private getTime(ms:number): {d:number, h:number, m: number, s: number} {
|
||||
var d, h, m, s;
|
||||
|
||||
private getTime(ms: number): {d: number, h: number, m: number, s: number} {
|
||||
let d, h, m, s;
|
||||
s = Math.floor(ms / 1000);
|
||||
m = Math.floor(s / 60);
|
||||
s = s % 60;
|
||||
@@ -143,16 +156,3 @@ export class ManageSystemComponent implements OnInit, OnDestroy {
|
||||
|
||||
|
||||
}
|
||||
|
||||
class EntityDataSource implements DataSource<EntityStatistic> {
|
||||
|
||||
entities = new BehaviorSubject<EntityStatistic[]>([]);
|
||||
|
||||
connect(collectionViewer: CollectionViewer): Observable<EntityStatistic[]> {
|
||||
return this.entities;
|
||||
}
|
||||
disconnect(collectionViewer: CollectionViewer): void {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,29 +16,28 @@ import { TableColumn, TableHandler } from '../utils/tables';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'manage-users',
|
||||
templateUrl: 'manage-users.component.html',
|
||||
host: { class:'match-parent' }
|
||||
selector: 'app-manage-users',
|
||||
templateUrl: 'manage-users.component.html'
|
||||
})
|
||||
export class ManageUsersComponent extends FormErrorEncoder implements OnInit, OnDestroy, DoCheck {
|
||||
|
||||
|
||||
private static COLUMNS: TableColumn[] = [
|
||||
{ name: "id", dropPriority: 5, width: 120, fixedWidth:true},
|
||||
{ name: "type", dropPriority: 0, width: 55, fixedWidth:true},
|
||||
{ name: "login", dropPriority: 0, width: 150},
|
||||
{ name: "name", dropPriority: 1, width: 200},
|
||||
{ name: "email", dropPriority: 2, width: 200},
|
||||
{ name: "creationTime", dropPriority: 3, width: 130, fixedWidth:true},
|
||||
{ name: "modificationTime", dropPriority: 4, width: 130 , fixedWidth:true},
|
||||
{ name: "actions", dropPriority: 0, width: 90, fixedWidth: true }
|
||||
{ name: 'id', dropPriority: 5, width: 120, fixedWidth: true},
|
||||
{ name: 'type', dropPriority: 0, width: 55, fixedWidth: true},
|
||||
{ name: 'login', dropPriority: 0, width: 150},
|
||||
{ name: 'name', dropPriority: 1, width: 200},
|
||||
{ name: 'email', dropPriority: 2, width: 200},
|
||||
{ name: 'creationTime', dropPriority: 3, width: 130, fixedWidth: true},
|
||||
{ name: 'modificationTime', dropPriority: 4, width: 130 , fixedWidth: true},
|
||||
{ name: 'actions', dropPriority: 0, width: 90, fixedWidth: true }
|
||||
];
|
||||
|
||||
@ViewChild('searchForm', { static: true }) searchForm:NgForm;
|
||||
@ViewChild("table", { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild('searchForm', { static: true }) searchForm: NgForm;
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
|
||||
dataSource: DataSource<User>;
|
||||
readonly loading:BehaviorSubject<boolean>;
|
||||
readonly loading: BehaviorSubject<boolean>;
|
||||
term: string;
|
||||
|
||||
private tableHandler: TableHandler;
|
||||
@@ -49,9 +48,9 @@ export class ManageUsersComponent extends FormErrorEncoder implements OnInit, On
|
||||
public res: ResourceService,
|
||||
private apiClientService: ApiClientService,
|
||||
private userService: UserService,
|
||||
private manageUserService: ManageUserService,
|
||||
private manageUserService: ManageUserService,
|
||||
private snackbar: MatSnackBar,
|
||||
private dialog:MatDialog) {
|
||||
private dialog: MatDialog) {
|
||||
super();
|
||||
this.dataSource = manageUserService;
|
||||
this.loading = manageUserService.loading;
|
||||
@@ -74,73 +73,73 @@ export class ManageUsersComponent extends FormErrorEncoder implements OnInit, On
|
||||
this.tableHandler = new TableHandler(this.table, ManageUsersComponent.COLUMNS);
|
||||
this.pageHandler = new PaginationHandler(this.paginator, this.manageUserService);
|
||||
this.manageUserService.reload();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.pageHandler.destroy();
|
||||
}
|
||||
|
||||
getCorrespondence(user: User):string {
|
||||
for (let email of user.emails) {
|
||||
if (email.correspondence) return email.address;
|
||||
getCorrespondence(user: User): string {
|
||||
for (const email of user.emails) {
|
||||
if (email.correspondence) { return email.address; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
onSearch():void {
|
||||
if (this.searchForm.invalid || this.loading.getValue()) return;
|
||||
onSearch(): void {
|
||||
if (this.searchForm.invalid || this.loading.getValue()) { return; }
|
||||
this.manageUserService.setTerm(this.term);
|
||||
}
|
||||
|
||||
isAdmin(user: User):boolean {
|
||||
for (let r of user.roles) {
|
||||
if (r == UserRole.Admin) return true;
|
||||
isAdmin(user: User): boolean {
|
||||
for (const r of user.roles) {
|
||||
if (r === UserRole.Admin) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
isSelf(user: User):boolean {
|
||||
isSelf(user: User): boolean {
|
||||
return user.id === this.userService.user.getValue().id;
|
||||
}
|
||||
|
||||
onDelete(user: User):void {
|
||||
if (this.loading.getValue()) return;
|
||||
onDelete(user: User): void {
|
||||
if (this.loading.getValue()) { return; }
|
||||
user.deleted = true;
|
||||
this.updateUser(user);
|
||||
}
|
||||
|
||||
onRestore(user: User):void {
|
||||
if (this.loading.getValue()) return;
|
||||
onRestore(user: User): void {
|
||||
if (this.loading.getValue()) { return; }
|
||||
user.deleted = false;
|
||||
this.updateUser(user);
|
||||
}
|
||||
|
||||
makeAdmin(user: User):void {
|
||||
if (this.loading.getValue()) return;
|
||||
let i = user.roles.indexOf(UserRole.Admin);
|
||||
if (i != -1) return;
|
||||
makeAdmin(user: User): void {
|
||||
if (this.loading.getValue()) { return; }
|
||||
const i = user.roles.indexOf(UserRole.Admin);
|
||||
if (i !== -1) { return; }
|
||||
user.roles.push(UserRole.Admin);
|
||||
this.updateUser(user);
|
||||
}
|
||||
|
||||
makeUser(user: User): void {
|
||||
if (this.loading.getValue()) return;
|
||||
let i = user.roles.indexOf(UserRole.Admin);
|
||||
if (i == -1) return;
|
||||
if (this.loading.getValue()) { return; }
|
||||
const i = user.roles.indexOf(UserRole.Admin);
|
||||
if (i === -1) { return; }
|
||||
user.roles.splice(i, 1);
|
||||
this.updateUser(user);
|
||||
}
|
||||
|
||||
|
||||
private updateUser(user:User) {
|
||||
this.manageUserService.setUser(user).subscribe((result)=> {
|
||||
private updateUser(user: User) {
|
||||
this.manageUserService.setUser(user).subscribe((result) => {
|
||||
if (result) {
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings("manage_users_success"), Snackbars.DURATION_SHORT);
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings('manage_users_success'), Snackbars.DURATION_SHORT);
|
||||
} else {
|
||||
Snackbars.showError(this.snackbar, this.res.strings("manage_users_error"));
|
||||
Snackbars.showError(this.snackbar, this.res.strings('manage_users_error'));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<ng-container *ngFor="let n of page.getValue().elements">
|
||||
<ng-container *ngIf="canShow(n, getLanguage())">
|
||||
<mat-grid-tile colspan="1" rowspan="1">
|
||||
<notice-card [language]="getLanguage()" [notice]="n" class="notice-card"></notice-card>
|
||||
<app-notice-card [language]="getLanguage()" [notice]="n" class="notice-card"></app-notice-card>
|
||||
</mat-grid-tile>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
@@ -14,27 +14,26 @@ import { NoticePage, Notice } from '../../api/models';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'notices',
|
||||
templateUrl: './notices.component.html',
|
||||
host: { class: 'match-parent' },
|
||||
selector: 'app-notices',
|
||||
templateUrl: './notices.component.html'
|
||||
})
|
||||
export class NoticesComponent implements OnInit {
|
||||
|
||||
loading: BehaviorSubject<boolean> = new BehaviorSubject(true);
|
||||
page: BehaviorSubject<NoticePage>;
|
||||
columns: number = 1;
|
||||
columns = 1;
|
||||
|
||||
constructor(public res: ResourceService, private noticeService: NoticeService) {
|
||||
this.page = noticeService.page;
|
||||
this.loading = noticeService.loading;
|
||||
}
|
||||
|
||||
public getLanguage():string {
|
||||
return this.res.strings("language");
|
||||
public getLanguage(): string {
|
||||
return this.res.strings('language');
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event:Event) {
|
||||
onResize(event: Event) {
|
||||
this.updateColumns((event.target as Window).innerWidth);
|
||||
}
|
||||
|
||||
@@ -56,8 +55,8 @@ export class NoticesComponent implements OnInit {
|
||||
}
|
||||
|
||||
canShow(notice: Notice, language: String) {
|
||||
for (let m of notice.messages) {
|
||||
if (m.language === language) return true;
|
||||
for (const m of notice.messages) {
|
||||
if (m.language === language) { return true; }
|
||||
}
|
||||
console.dir(notice);
|
||||
return false;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<marker-map>
|
||||
<app-marker-map>
|
||||
<mat-accordion class="sidebar">
|
||||
<mat-expansion-panel class="mat-typography" [ngStyle]="getPanelWidth()" style="margin-right:10px;margin-top:10px">
|
||||
<mat-expansion-panel-header>
|
||||
@@ -111,4 +111,4 @@
|
||||
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</marker-map>
|
||||
</app-marker-map>
|
||||
@@ -1,45 +1,44 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ViewEncapsulation, DoCheck, ElementRef, Input } from "@angular/core";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { MatDialog, MatSnackBar, MatPaginator } from "@angular/material";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { MessageDialogComponent } from "../widgets/message-dialog.component";
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { HttpStatusCode } from "../utils/httpcodes";
|
||||
import { Subscription, BehaviorSubject } from "rxjs";
|
||||
import { Device, Location, Place, VisitPage, Visit } from "../../api/models";
|
||||
import { Snackbars } from "../utils/snackbars";
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ViewEncapsulation, DoCheck, ElementRef, Input } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar, MatPaginator } from '@angular/material';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { HttpStatusCode } from '../utils/httpcodes';
|
||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { Device, Location, Place, VisitPage, Visit } from '../../api/models';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import * as L from 'leaflet';
|
||||
import { TileMapComponent } from "../widgets/tile-map.component";
|
||||
import { MarkerMapComponent } from "../widgets/marker-map.component";
|
||||
import { PlaceVisitService } from "../services/place-visit.service";
|
||||
import { Page, PaginationHandler } from "../utils/pagination";
|
||||
import { ConfirmationDialogComponent } from "../widgets/confirmation-dialog.component";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { TableColumn, TableHandler } from "../utils/tables";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { TileMapComponent } from '../widgets/tile-map.component';
|
||||
import { MarkerMapComponent } from '../widgets/marker-map.component';
|
||||
import { PlaceVisitService } from '../services/place-visit.service';
|
||||
import { Page, PaginationHandler } from '../utils/pagination';
|
||||
import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { TableColumn, TableHandler } from '../utils/tables';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'place-visits',
|
||||
templateUrl: './place-visits.component.html',
|
||||
host: { class: 'match-parent' },
|
||||
selector: 'app-place-visits',
|
||||
templateUrl: './place-visits.component.html'
|
||||
})
|
||||
export class PlaceVisitsComponent implements OnInit, AfterViewInit, OnDestroy, DoCheck {
|
||||
|
||||
private static COLUMNS: TableColumn[] = [
|
||||
{ name: "device", dropPriority: 0, width: 120 },
|
||||
{ name: "begin", dropPriority: 0, width: 130 },
|
||||
{ name: "end", dropPriority: 0, width: 130 },
|
||||
{ name: "actions", dropPriority: 0, width: 90, fixedWidth: true }
|
||||
{ name: 'device', dropPriority: 0, width: 120 },
|
||||
{ name: 'begin', dropPriority: 0, width: 130 },
|
||||
{ name: 'end', dropPriority: 0, width: 130 },
|
||||
{ name: 'actions', dropPriority: 0, width: 90, fixedWidth: true }
|
||||
];
|
||||
|
||||
private static FALLBACK: TableColumn[] = [
|
||||
{ name: "visit", dropPriority: 0, width: 120 },
|
||||
{ name: "actions", dropPriority: 0, width: 90, fixedWidth: true }
|
||||
{ name: 'visit', dropPriority: 0, width: 120 },
|
||||
{ name: 'actions', dropPriority: 0, width: 90, fixedWidth: true }
|
||||
];
|
||||
|
||||
@ViewChild(MarkerMapComponent, { static: true }) map: MarkerMapComponent;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
@ViewChild("table", { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
|
||||
id: string;
|
||||
readonly loading: BehaviorSubject<boolean>;
|
||||
@@ -50,7 +49,7 @@ export class PlaceVisitsComponent implements OnInit, AfterViewInit, OnDestroy, D
|
||||
private paginationHandler: PaginationHandler<Visit, VisitPage>;
|
||||
private placeSubscription: Subscription;
|
||||
private tableHandler: TableHandler;
|
||||
compact: boolean = false;
|
||||
compact = false;
|
||||
|
||||
|
||||
constructor(
|
||||
@@ -67,9 +66,12 @@ export class PlaceVisitsComponent implements OnInit, AfterViewInit, OnDestroy, D
|
||||
this.dataSource = placeService;
|
||||
}
|
||||
|
||||
getPanelWidth():any {
|
||||
if (this.compact) return { width: "280px"};
|
||||
else return { width: "520px" };
|
||||
getPanelWidth(): any {
|
||||
if (this.compact) {
|
||||
return { width: '280px'};
|
||||
} else {
|
||||
return { width: '520px' };
|
||||
}
|
||||
}
|
||||
|
||||
reloadPlace() {
|
||||
@@ -91,7 +93,7 @@ export class PlaceVisitsComponent implements OnInit, AfterViewInit, OnDestroy, D
|
||||
|
||||
ngOnInit() {
|
||||
this.tableHandler = new TableHandler(this.table, PlaceVisitsComponent.COLUMNS, PlaceVisitsComponent.FALLBACK);
|
||||
this.id = this.route.snapshot.paramMap.get("id");
|
||||
this.id = this.route.snapshot.paramMap.get('id');
|
||||
this.placeService.setPlace(+this.id);
|
||||
this.paginationHandler = new PaginationHandler<Visit, VisitPage>(this.paginator, this.placeService);
|
||||
}
|
||||
@@ -113,10 +115,10 @@ export class PlaceVisitsComponent implements OnInit, AfterViewInit, OnDestroy, D
|
||||
|
||||
onDelete(id: number): void {
|
||||
ConfirmationDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings("visits_delete_confirm_title"),
|
||||
message: this.res.strings("visits_delete_confirm_message"),
|
||||
positive: this.res.strings("button_yes"),
|
||||
negative: this.res.strings("button_no")
|
||||
title: this.res.strings('visits_delete_confirm_title'),
|
||||
message: this.res.strings('visits_delete_confirm_message'),
|
||||
positive: this.res.strings('button_yes'),
|
||||
negative: this.res.strings('button_no')
|
||||
}).subscribe((result) => {
|
||||
if (result != null && result.confirmed) {
|
||||
this.doDelete(id);
|
||||
@@ -129,12 +131,12 @@ export class PlaceVisitsComponent implements OnInit, AfterViewInit, OnDestroy, D
|
||||
this.apiClientService.deleteVisit(id).subscribe((result) => {
|
||||
this.deleting.next(false);
|
||||
this.placeService.reload();
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings("visits_delete_success"), Snackbars.DURATION_SHORT);
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings('visits_delete_success'), Snackbars.DURATION_SHORT);
|
||||
}, (error) => {
|
||||
this.deleting.next(false);
|
||||
this.placeService.reload();
|
||||
Snackbars.showError(this.snackbar, this.res.strings("visits_delete_error"));
|
||||
})
|
||||
Snackbars.showError(this.snackbar, this.res.strings('visits_delete_error'));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,29 +13,28 @@ import { TableHandler, TableColumn } from '../utils/tables';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'places',
|
||||
templateUrl: 'places.component.html',
|
||||
host: { class:'match-parent' }
|
||||
})
|
||||
selector: 'app-places',
|
||||
templateUrl: 'places.component.html'
|
||||
})
|
||||
export class PlacesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
|
||||
|
||||
private static COLUMNS: TableColumn[] = [
|
||||
{ name: "id", dropPriority: 1, width: 130, fixedWidth: true },
|
||||
{ name: "address", dropPriority: 0, width: 200 },
|
||||
{ name: "nickname", dropPriority: 0, width: 200 },
|
||||
{ name: "longitude", dropPriority: 4, width: 100, fixedWidth: true },
|
||||
{ name: "latitude", dropPriority: 4, width: 100, fixedWidth: true },
|
||||
{ name: "creationTime", dropPriority: 2, width: 130, fixedWidth: true },
|
||||
{ name: "modificationTime", dropPriority: 3, width: 130, fixedWidth: true },
|
||||
{ name: "actions", dropPriority: 0, width: 130, fixedWidth: true }
|
||||
{ name: 'id', dropPriority: 1, width: 130, fixedWidth: true },
|
||||
{ name: 'address', dropPriority: 0, width: 200 },
|
||||
{ name: 'nickname', dropPriority: 0, width: 200 },
|
||||
{ name: 'longitude', dropPriority: 4, width: 100, fixedWidth: true },
|
||||
{ name: 'latitude', dropPriority: 4, width: 100, fixedWidth: true },
|
||||
{ name: 'creationTime', dropPriority: 2, width: 130, fixedWidth: true },
|
||||
{ name: 'modificationTime', dropPriority: 3, width: 130, fixedWidth: true },
|
||||
{ name: 'actions', dropPriority: 0, width: 130, fixedWidth: true }
|
||||
];
|
||||
|
||||
private static FALLBACK: TableColumn[] = [
|
||||
{ name: "name", dropPriority: 0, width: 130 },
|
||||
{ name: "actions", dropPriority: 0, width: 130, fixedWidth: true }
|
||||
{ name: 'name', dropPriority: 0, width: 130 },
|
||||
{ name: 'actions', dropPriority: 0, width: 130, fixedWidth: true }
|
||||
];
|
||||
|
||||
@ViewChild("table", { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
|
||||
dataSource: DataSource<Place>;
|
||||
@@ -48,7 +47,7 @@ export class PlacesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
constructor(
|
||||
public res: ResourceService,
|
||||
private apiClientService: ApiClientService,
|
||||
private placeService: PlaceService,
|
||||
private placeService: PlaceService,
|
||||
private snackbar: MatSnackBar,
|
||||
private dialog: MatDialog) {
|
||||
this.dataSource = placeService;
|
||||
@@ -79,31 +78,31 @@ export class PlacesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
this.tableHandler = new TableHandler(this.table, PlacesComponent.COLUMNS, PlacesComponent.FALLBACK);
|
||||
this.pageHandler = new PaginationHandler(this.paginator, this.placeService);
|
||||
this.placeService.reload();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.pageHandler.destroy();
|
||||
}
|
||||
|
||||
onRename(id: number) {
|
||||
if (this.loading.getValue()) return;
|
||||
let p = this.placeService.page.getValue();
|
||||
for (let place of p.elements) {
|
||||
if (this.loading.getValue()) { return; }
|
||||
const p = this.placeService.page.getValue();
|
||||
for (const place of p.elements) {
|
||||
if (place.id === id) {
|
||||
NicknameDialogComponent.open(this.dialog, place).subscribe((result)=>{
|
||||
if (result) this.placeService.reload();
|
||||
NicknameDialogComponent.open(this.dialog, place).subscribe((result) => {
|
||||
if (result) { this.placeService.reload(); }
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onDelete(id:number):void {
|
||||
onDelete(id: number): void {
|
||||
ConfirmationDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings("places_delete_confirm_title"),
|
||||
message:this.res.strings("places_delete_confirm_message"),
|
||||
positive: this.res.strings("button_yes"),
|
||||
negative: this.res.strings("button_no")
|
||||
title: this.res.strings('places_delete_confirm_title'),
|
||||
message: this.res.strings('places_delete_confirm_message'),
|
||||
positive: this.res.strings('button_yes'),
|
||||
negative: this.res.strings('button_no')
|
||||
}).subscribe((result) => {
|
||||
if (result != null && result.confirmed) {
|
||||
this.doDelete(id);
|
||||
@@ -111,19 +110,19 @@ export class PlacesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
});
|
||||
}
|
||||
|
||||
private doDelete(id:number):void {
|
||||
this.deleting.next(true);
|
||||
private doDelete(id: number): void {
|
||||
this.deleting.next(true);
|
||||
this.apiClientService.deletePlace(id).subscribe((result) => {
|
||||
this.deleting.next(false);
|
||||
this.placeService.reload();
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings("places_delete_success"), Snackbars.DURATION_SHORT);
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings('places_delete_success'), Snackbars.DURATION_SHORT);
|
||||
}, (error) => {
|
||||
this.deleting.next(false);
|
||||
this.deleting.next(false);
|
||||
this.placeService.reload();
|
||||
Snackbars.showError(this.snackbar, this.res.strings("places_delete_error"));
|
||||
})
|
||||
Snackbars.showError(this.snackbar, this.res.strings('places_delete_error'));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,27 +14,26 @@ import { TableColumn, TableHandler } from '../utils/tables';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'privileges',
|
||||
templateUrl: 'privileges.component.html',
|
||||
host: { class: 'match-parent' }
|
||||
selector: 'app-privileges',
|
||||
templateUrl: 'privileges.component.html'
|
||||
})
|
||||
export class PrivilegesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
|
||||
private static COLUMNS: TableColumn[] = [
|
||||
{ name: "token", dropPriority: 2, width: 180, fixedWidth: true },
|
||||
{ name: "message", dropPriority: 0, width: 150},
|
||||
{ name: "destination", dropPriority: 1, width: 150 },
|
||||
{ name: "expirationTime", dropPriority: 3, width: 130, fixedWidth: true },
|
||||
{ name: "actions", dropPriority: 0, width: 90, fixedWidth: true }
|
||||
{ name: 'token', dropPriority: 2, width: 180, fixedWidth: true },
|
||||
{ name: 'message', dropPriority: 0, width: 150},
|
||||
{ name: 'destination', dropPriority: 1, width: 150 },
|
||||
{ name: 'expirationTime', dropPriority: 3, width: 130, fixedWidth: true },
|
||||
{ name: 'actions', dropPriority: 0, width: 90, fixedWidth: true }
|
||||
];
|
||||
|
||||
@ViewChild("table", { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
|
||||
dataSource: DataSource<Privilege>;
|
||||
private pageHandler: PaginationHandler<Privilege, PrivilegePage>;
|
||||
readonly deleting = new BehaviorSubject<boolean>(false);
|
||||
readonly loading:BehaviorSubject<boolean>;
|
||||
readonly loading: BehaviorSubject<boolean>;
|
||||
|
||||
private addSubscription: Subscription;
|
||||
private tableHandler: TableHandler;
|
||||
@@ -67,12 +66,12 @@ export class PrivilegesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
|
||||
ngOnInit() {
|
||||
this.tableHandler = new TableHandler(this.table, PrivilegesComponent.COLUMNS);
|
||||
let token = this.activatedRoute.snapshot.paramMap.get("add");
|
||||
const token = this.activatedRoute.snapshot.paramMap.get('add');
|
||||
this.pageHandler = new PaginationHandler(this.paginator, this.privilegeService);
|
||||
this.privilegeService.reload();
|
||||
if (token != null) {
|
||||
this.router.navigate(["/privileges"], { replaceUrl: true });
|
||||
this.addSubscription = this.privilegeService.loading.subscribe((value)=> {
|
||||
this.router.navigate(['/privileges'], { replaceUrl: true });
|
||||
this.addSubscription = this.privilegeService.loading.subscribe((value) => {
|
||||
if (!value) {
|
||||
this.onAdd(token);
|
||||
this.addSubscription.unsubscribe();
|
||||
@@ -85,24 +84,24 @@ export class PrivilegesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
|
||||
ngOnDestroy() {
|
||||
this.pageHandler.destroy();
|
||||
if (this.addSubscription) this.addSubscription.unsubscribe();
|
||||
if (this.addSubscription) { this.addSubscription.unsubscribe(); }
|
||||
}
|
||||
|
||||
onAdd(link?:string): void {
|
||||
onAdd(link?: string): void {
|
||||
ShareDialogComponent.open(this.dialog, link).subscribe((result) => {
|
||||
if (result) {
|
||||
this.privilegeService.reload();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onDelete(id: number): void {
|
||||
if (this.loading.getValue() || this.deleting.getValue()) return;
|
||||
if (this.loading.getValue() || this.deleting.getValue()) { return; }
|
||||
ConfirmationDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings("privileges_delete_confirm_title"),
|
||||
message: this.res.strings("privileges_delete_confirm_message"),
|
||||
positive: this.res.strings("button_yes"),
|
||||
negative: this.res.strings("button_no")
|
||||
title: this.res.strings('privileges_delete_confirm_title'),
|
||||
message: this.res.strings('privileges_delete_confirm_message'),
|
||||
positive: this.res.strings('button_yes'),
|
||||
negative: this.res.strings('button_no')
|
||||
}).subscribe((result) => {
|
||||
if (result != null && result.confirmed) {
|
||||
this.doDelete(id);
|
||||
@@ -115,14 +114,14 @@ export class PrivilegesComponent implements OnInit, OnDestroy, DoCheck {
|
||||
this.apiClientService.deletePrivilege(id).subscribe((result) => {
|
||||
this.deleting.next(false);
|
||||
this.privilegeService.reload();
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings("privileges_delete_success"), Snackbars.DURATION_SHORT);
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings('privileges_delete_success'), Snackbars.DURATION_SHORT);
|
||||
}, (error) => {
|
||||
this.deleting.next(false);
|
||||
this.privilegeService.reload();
|
||||
Snackbars.showError(this.snackbar, this.res.strings("privileges_delete_error"));
|
||||
})
|
||||
Snackbars.showError(this.snackbar, this.res.strings('privileges_delete_error'));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form #registerForm="ngForm">
|
||||
<name-field [name]="registration.name"></name-field>
|
||||
<email-field [email]="registration.email"></email-field>
|
||||
<login-field [login]="registration.login"></login-field>
|
||||
<password-field [password]="registration.password" (keyup.enter)="onRegister()"></password-field>
|
||||
<app-name-field [name]="registration.name"></app-name-field>
|
||||
<app-email-field [email]="registration.email"></app-email-field>
|
||||
<app-login-field [login]="registration.login"></app-login-field>
|
||||
<app-password-field [password]="registration.password" (keyup.enter)="onRegister()"></app-password-field>
|
||||
<mat-checkbox class="long-checkbox" [(ngModel)]="termsAccepted" name="termsAccepted">
|
||||
{{ res.strings('register_terms_pre') }}
|
||||
<a class="register-link" href="https://www.maptology.com/privacy-policy" target="_blank">
|
||||
|
||||
@@ -18,9 +18,8 @@ import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'register',
|
||||
templateUrl: './register.component.html',
|
||||
host: { class:'match-parent' },
|
||||
selector: 'app-register',
|
||||
templateUrl: './register.component.html'
|
||||
})
|
||||
export class RegisterComponent implements OnInit, OnDestroy {
|
||||
|
||||
@@ -28,26 +27,27 @@ export class RegisterComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(PasswordFieldComponent, { static: true }) passwordField: PasswordFieldComponent;
|
||||
@ViewChild(NameFieldComponent, { static: true }) nameField: NameFieldComponent;
|
||||
@ViewChild(EmailFieldComponent, { static: true }) emailField: EmailFieldComponent;
|
||||
@ViewChild("registerForm", { static: true }) registerForm: NgForm;
|
||||
@ViewChild('registerForm', { static: true }) registerForm: NgForm;
|
||||
|
||||
readonly idle = new BehaviorSubject<boolean>(true);
|
||||
|
||||
columns: number = 2;
|
||||
registration: UserRegistration = { login:"", name:"", email:"", password:"" }
|
||||
|
||||
columns = 2;
|
||||
registration: UserRegistration = { login: '', name: '', email: '', password: '' };
|
||||
|
||||
termsAccepted: true;
|
||||
|
||||
private registrationSubscription: Subscription;
|
||||
|
||||
constructor(public res:ResourceService, private apiClientService:ApiClientService, private snackbar: MatSnackBar, private router: Router, private dialog: MatDialog) { }
|
||||
constructor(public res: ResourceService, private apiClientService: ApiClientService,
|
||||
private snackbar: MatSnackBar, private router: Router, private dialog: MatDialog) { }
|
||||
|
||||
|
||||
ngOnInit():void {
|
||||
ngOnInit(): void {
|
||||
this.updateColumns(window.innerWidth);
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event:Event) {
|
||||
onResize(event: Event) {
|
||||
this.updateColumns((event.target as Window).innerWidth);
|
||||
}
|
||||
|
||||
@@ -59,44 +59,44 @@ export class RegisterComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
onRegister():void {
|
||||
onRegister(): void {
|
||||
this.snackbar.dismiss();
|
||||
if (!this.idle || !this.registerForm.valid) return;
|
||||
if (!this.idle || !this.registerForm.valid) { return; }
|
||||
if (!this.termsAccepted) {
|
||||
this.showTermsMessage();
|
||||
} else {
|
||||
this.sendRegister();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private showTermsMessage():void {
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('register_accept_terms_title'),
|
||||
message: this.res.strings('register_accept_terms_message'),
|
||||
private showTermsMessage(): void {
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('register_accept_terms_title'),
|
||||
message: this.res.strings('register_accept_terms_message'),
|
||||
button: this.res.strings('button_gotit') });
|
||||
}
|
||||
|
||||
private sendRegister():void {
|
||||
private sendRegister(): void {
|
||||
this.setIdle(false);
|
||||
this.registration = {
|
||||
login:this.loginField.login,
|
||||
name:this.nameField.name,
|
||||
password:this.passwordField.password,
|
||||
email:this.emailField.email
|
||||
}
|
||||
this.registrationSubscription = this.apiClientService.registerUser(this.registration).subscribe((response)=>{
|
||||
this.registration = {
|
||||
login: this.loginField.login,
|
||||
name: this.nameField.name,
|
||||
password: this.passwordField.password,
|
||||
email: this.emailField.email
|
||||
};
|
||||
this.registrationSubscription = this.apiClientService.registerUser(this.registration).subscribe((response) => {
|
||||
this.setIdle(true);
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('register_success_title'),
|
||||
message: this.res.strings('register_success_message'),
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('register_success_title'),
|
||||
message: this.res.strings('register_success_message'),
|
||||
button: this.res.strings('button_gotit') }).subscribe((e) => {
|
||||
this.router.navigate(["/"]);
|
||||
this.router.navigate(['/']);
|
||||
});
|
||||
this.registrationSubscription = null;
|
||||
}, (error)=>{
|
||||
this.registrationSubscription = null;
|
||||
}, (error) => {
|
||||
this.registrationSubscription = null;
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
var message = "";
|
||||
let message = '';
|
||||
switch (error.status) {
|
||||
case HttpStatusCode.CONFLICT:
|
||||
message = this.res.strings('register_conflict_error');
|
||||
@@ -111,7 +111,7 @@ export class RegisterComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
private setIdle(idle: boolean):void {
|
||||
private setIdle(idle: boolean): void {
|
||||
this.loginField.disabled = !idle;
|
||||
this.emailField.disabled = !idle;
|
||||
this.passwordField.disabled = !idle;
|
||||
@@ -119,8 +119,8 @@ export class RegisterComponent implements OnInit, OnDestroy {
|
||||
this.idle.next(idle);
|
||||
}
|
||||
|
||||
ngOnDestroy():void {
|
||||
if (this.registrationSubscription) this.registrationSubscription.unsubscribe();
|
||||
ngOnDestroy(): void {
|
||||
if (this.registrationSubscription) { this.registrationSubscription.unsubscribe(); }
|
||||
this.snackbar.dismiss();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form #resetForm="ngForm">
|
||||
<login-field [login]="login" (keyup.enter)="onReset()"></login-field>
|
||||
<app-login-field [login]="login" (keyup.enter)="onReset()"></app-login-field>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
||||
|
||||
@@ -15,14 +15,13 @@ import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'reset',
|
||||
templateUrl: './reset.component.html',
|
||||
host: { class: 'match-parent' },
|
||||
selector: 'app-reset',
|
||||
templateUrl: './reset.component.html'
|
||||
})
|
||||
export class ResetComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild(LoginFieldComponent, { static: true }) loginField: LoginFieldComponent;
|
||||
@ViewChild("resetForm", { static: true }) resetForm: NgForm;
|
||||
@ViewChild('resetForm', { static: true }) resetForm: NgForm;
|
||||
|
||||
readonly idle = new BehaviorSubject<boolean>(true);
|
||||
|
||||
@@ -30,7 +29,9 @@ export class ResetComponent implements OnInit, OnDestroy {
|
||||
|
||||
login: string;
|
||||
|
||||
constructor(public res: ResourceService, private userService: UserService, private apiClientService: ApiClientService, private snackbar: MatSnackBar, private dialog: MatDialog, private router: Router) { }
|
||||
constructor(public res: ResourceService, private userService: UserService,
|
||||
private apiClientService: ApiClientService, private snackbar: MatSnackBar,
|
||||
private dialog: MatDialog, private router: Router) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.login = this.userService.getLogin();
|
||||
@@ -38,15 +39,15 @@ export class ResetComponent implements OnInit, OnDestroy {
|
||||
|
||||
onReset(): void {
|
||||
this.snackbar.dismiss();
|
||||
if (!this.idle || !this.resetForm.valid) return;
|
||||
if (!this.idle || !this.resetForm.valid) { return; }
|
||||
this.setIdle(false);
|
||||
this.resetSubscription = this.apiClientService.resetUser(this.loginField.login).subscribe((result) => {
|
||||
this.setIdle(true);
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('reset_confirm_title'),
|
||||
message: this.res.strings('reset_confirm_message'),
|
||||
MessageDialogComponent.open(this.dialog, {
|
||||
title: this.res.strings('reset_confirm_title'),
|
||||
message: this.res.strings('reset_confirm_message'),
|
||||
button: this.res.strings('button_gotit') }).subscribe((close) => {
|
||||
this.router.navigate(["/"]);
|
||||
this.router.navigate(['/']);
|
||||
});
|
||||
}, (error) => {
|
||||
this.setIdle(true);
|
||||
@@ -69,6 +70,6 @@ export class ResetComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.snackbar.dismiss();
|
||||
if (this.resetSubscription) this.resetSubscription.unsubscribe();
|
||||
if (this.resetSubscription) { this.resetSubscription.unsubscribe(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<marker-map>
|
||||
<app-marker-map>
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel class="mat-typography" style="width:280px;margin-right:10px;margin-top:10px">
|
||||
<mat-expansion-panel-header>
|
||||
@@ -84,4 +84,4 @@
|
||||
</button>
|
||||
</div>
|
||||
</ng-container>
|
||||
</marker-map>
|
||||
</app-marker-map>
|
||||
@@ -1,24 +1,23 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from "@angular/core";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { MatDialog, MatSnackBar } from "@angular/material";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { MessageDialogComponent } from "../widgets/message-dialog.component";
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { HttpStatusCode } from "../utils/httpcodes";
|
||||
import { Subscription, BehaviorSubject } from "rxjs";
|
||||
import { Device, Location, ShareInfo } from "../../api/models";
|
||||
import { Snackbars } from "../utils/snackbars";
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { HttpStatusCode } from '../utils/httpcodes';
|
||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { Device, Location, ShareInfo } from '../../api/models';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import * as L from 'leaflet';
|
||||
import { TileMapComponent } from "../widgets/tile-map.component";
|
||||
import { MarkerMapComponent } from "../widgets/marker-map.component";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { TileMapComponent } from '../widgets/tile-map.component';
|
||||
import { MarkerMapComponent } from '../widgets/marker-map.component';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'share',
|
||||
templateUrl: './share.component.html',
|
||||
host: { class:'match-parent' },
|
||||
selector: 'app-share',
|
||||
templateUrl: './share.component.html'
|
||||
})
|
||||
export class ShareComponent implements AfterViewInit, OnDestroy {
|
||||
export class ShareComponent implements AfterViewInit, OnInit, OnDestroy {
|
||||
|
||||
@ViewChild(MarkerMapComponent, { static: true }) map: MarkerMapComponent;
|
||||
|
||||
@@ -39,51 +38,51 @@ import { ResourceService } from "../services/resource.service";
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.token = this.route.snapshot.paramMap.get("token");
|
||||
this.token = this.route.snapshot.paramMap.get('token');
|
||||
this.updateInfo();
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
}
|
||||
|
||||
isUpdatingInfo():boolean {
|
||||
isUpdatingInfo(): boolean {
|
||||
return this.infoSubscription != null;
|
||||
}
|
||||
|
||||
isUpdatingLocation():boolean {
|
||||
isUpdatingLocation(): boolean {
|
||||
return this.infoSubscription != null || this.locationSubscription != null;
|
||||
}
|
||||
|
||||
isOutside():boolean {
|
||||
isOutside(): boolean {
|
||||
if (this.route.parent != null) {
|
||||
return this.route.parent.snapshot.url[0].path != "privileges";
|
||||
return this.route.parent.snapshot.url[0].path !== 'privileges';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
addShare():void {
|
||||
this.router.navigate(["/privileges", { add: this.token}]);
|
||||
addShare(): void {
|
||||
this.router.navigate(['/privileges', { add: this.token}]);
|
||||
}
|
||||
|
||||
updateInfo():void {
|
||||
if (this.infoSubscription) return;
|
||||
this.infoSubscription = this.apiClientService.getShareInfo(this.token).subscribe((result)=>{
|
||||
updateInfo(): void {
|
||||
if (this.infoSubscription) { return; }
|
||||
this.infoSubscription = this.apiClientService.getShareInfo(this.token).subscribe((result) => {
|
||||
this.info.next(result.body);
|
||||
this.infoSubscription = null;
|
||||
this.updateLocation();
|
||||
}, (error)=>{
|
||||
}, (error) => {
|
||||
Snackbars.showError(this.snackbar, this.res.strings('share_no_update_info'));
|
||||
this.infoSubscription = null;
|
||||
});
|
||||
}
|
||||
|
||||
updateLocation():void {
|
||||
if (this.locationSubscription) return;
|
||||
this.locationSubscription = this.apiClientService.getShareLocation(this.token).subscribe((result)=>{
|
||||
updateLocation(): void {
|
||||
if (this.locationSubscription) { return; }
|
||||
this.locationSubscription = this.apiClientService.getShareLocation(this.token).subscribe((result) => {
|
||||
this.location.next(result.body);
|
||||
this.map.setMarkerPosition(result.body.coordinate);
|
||||
this.locationSubscription = null;
|
||||
}, (error)=>{
|
||||
}, (error) => {
|
||||
Snackbars.showError(this.snackbar, this.res.strings('share_no_update_location'));
|
||||
this.map.setMarkerPosition(null);
|
||||
this.locationSubscription = null;
|
||||
@@ -91,9 +90,9 @@ import { ResourceService } from "../services/resource.service";
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.locationSubscription) this.locationSubscription.unsubscribe();
|
||||
if (this.infoSubscription) this.infoSubscription.unsubscribe();
|
||||
if (this.locationSubscription) { this.locationSubscription.unsubscribe(); }
|
||||
if (this.infoSubscription) { this.infoSubscription.unsubscribe(); }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form #userForm="ngForm">
|
||||
<name-field [name]="u.name" (keyup.enter)="onChangeUser()"></name-field>
|
||||
<app-name-field [name]="u.name" (keyup.enter)="onChangeUser()"></app-name-field>
|
||||
<mat-form-field style="width: 100%;">
|
||||
<mat-select [placeholder]="res.strings('user_change_primary')" name="email" [(ngModel)]="correspondence" style="width: 100%;">
|
||||
<mat-select-trigger>
|
||||
@@ -42,8 +42,8 @@
|
||||
<mat-card-subtitle>{{ res.strings('user_password_subtitle') }}</mat-card-subtitle>
|
||||
<mat-card-content class="caption" style="flex:1">
|
||||
<form #passwordForm="ngForm">
|
||||
<password-field #oldPassword name="oldPassword" [label]="res.strings('user_password_old')" [hint]="res.strings('user_password_old_hint')"></password-field>
|
||||
<password-field #newPassword name="newPassword" [label]="res.strings('user_password_new')" [hint]="res.strings('user_password_new_hint')" (keyup.enter)="onChangePassword()"></password-field>
|
||||
<app-password-field #oldPassword name="oldPassword" [label]="res.strings('user_password_old')" [hint]="res.strings('user_password_old_hint')"></app-password-field>
|
||||
<app-password-field #newPassword name="newPassword" [label]="res.strings('user_password_new')" [hint]="res.strings('user_password_new_hint')" (keyup.enter)="onChangePassword()"></app-password-field>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
||||
@@ -60,7 +60,7 @@
|
||||
<mat-card-subtitle>{{ res.strings('user_add_email_subtitle') }}</mat-card-subtitle>
|
||||
<mat-card-content class="caption" style="flex:1">
|
||||
<form #emailForm="ngForm">
|
||||
<email-field (keyup.enter)="onAddEmail()"></email-field>
|
||||
<app-email-field (keyup.enter)="onAddEmail()"></app-email-field>
|
||||
</form>
|
||||
<div style="height:70px"></div>
|
||||
</mat-card-content>
|
||||
|
||||
@@ -16,9 +16,8 @@ import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'user',
|
||||
templateUrl: './user.component.html',
|
||||
host: { class:'match-parent' },
|
||||
selector: 'app-user',
|
||||
templateUrl: './user.component.html'
|
||||
})
|
||||
export class UserComponent implements OnInit, OnDestroy {
|
||||
|
||||
@@ -26,36 +25,37 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(MatSelect, { static: false }) emailSelect: MatSelect;
|
||||
|
||||
// add email
|
||||
@ViewChild(EmailFieldComponent, { static: false }) emailField: EmailFieldComponent;
|
||||
@ViewChild(EmailFieldComponent, { static: false }) emailField: EmailFieldComponent;
|
||||
|
||||
// change passwords
|
||||
@ViewChild("oldPassword", { static: false }) oldPasswordField: PasswordFieldComponent;
|
||||
@ViewChild("newPassword", { static: false }) newPasswordField: PasswordFieldComponent;
|
||||
@ViewChild('oldPassword', { static: false }) oldPasswordField: PasswordFieldComponent;
|
||||
@ViewChild('newPassword', { static: false }) newPasswordField: PasswordFieldComponent;
|
||||
|
||||
readonly idle = new BehaviorSubject<boolean>(true);
|
||||
|
||||
columns: number = 1;
|
||||
columns = 1;
|
||||
correspondence: Email;
|
||||
emails: Email[] = [];
|
||||
|
||||
user: BehaviorSubject<User>;
|
||||
private userSubscription: Subscription;
|
||||
|
||||
constructor(public res:ResourceService, private userService: UserService, private snackbar: MatSnackBar, private dialog: MatDialog, private router: Router) {
|
||||
constructor(public res: ResourceService, private userService: UserService,
|
||||
private snackbar: MatSnackBar, private dialog: MatDialog, private router: Router) {
|
||||
this.user = userService.user;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.updateColumns(window.innerWidth);
|
||||
this.userSubscription = this.userService.user.subscribe((user)=>{
|
||||
this.userSubscription = this.userService.user.subscribe((user) => {
|
||||
this.idle.next(user != null);
|
||||
this.correspondence = this.getCorrespondence();
|
||||
this.emails = this.getEmails();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event:Event) {
|
||||
onResize(event: Event) {
|
||||
this.updateColumns((event.target as Window).innerWidth);
|
||||
}
|
||||
|
||||
@@ -67,64 +67,65 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy():void {
|
||||
ngOnDestroy(): void {
|
||||
this.userSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
private getEmails():Email[] {
|
||||
if (this.user.getValue() == null) return [];
|
||||
return this.user.getValue().emails.sort((a, b)=>{
|
||||
private getEmails(): Email[] {
|
||||
if (this.user.getValue() == null) { return []; }
|
||||
return this.user.getValue().emails.sort((a, b) => {
|
||||
return a.address.localeCompare(b.address);
|
||||
});
|
||||
}
|
||||
|
||||
private getCorrespondence():Email {
|
||||
if (this.user.getValue() == null) return null;
|
||||
for (let email of this.user.getValue().emails) {
|
||||
if (email.correspondence) return email;
|
||||
private getCorrespondence(): Email {
|
||||
if (this.user.getValue() == null) { return null; }
|
||||
for (const email of this.user.getValue().emails) {
|
||||
if (email.correspondence) { return email; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
onAddEmail() {
|
||||
if (this.user.getValue() == null) return;
|
||||
let u = this.user.getValue();
|
||||
let email = this.emailField.email;
|
||||
for (var i = 0, s = u.emails.length; i < s; i++) {
|
||||
if (this.user.getValue() == null) { return; }
|
||||
const u = this.user.getValue();
|
||||
const email = this.emailField.email;
|
||||
for (let i = 0, s = u.emails.length; i < s; i++) {
|
||||
if (u.emails[i].address === email) {
|
||||
Snackbars.showError(this.snackbar, this.res.strings('user_email_registered_already'), Snackbars.DURATION_SHORT);
|
||||
this.emailField.email = "";
|
||||
this.emailField.email = '';
|
||||
return;
|
||||
}
|
||||
}
|
||||
u.emails.push({address:email, id:0, correspondence: false, creationTime: 0, modificationTime: 0, deleted: false, verified: false});
|
||||
u.emails.push({address: email, id: 0, correspondence: false, creationTime: 0, modificationTime: 0, deleted: false, verified: false});
|
||||
this.userService.changeUser(u);
|
||||
}
|
||||
|
||||
onChangePassword() {
|
||||
if (this.user.getValue() == null) return;
|
||||
if (this.user.getValue() == null) { return; }
|
||||
if (!this.userService.changePassword(this.oldPasswordField.password, this.newPasswordField.password)) {
|
||||
this.oldPasswordField.password = "";
|
||||
this.newPasswordField.password = "";
|
||||
MessageDialogComponent.open(this.dialog, {title: this.res.strings('user_password_wrong_title'), message: this.res.strings('user_password_wrong_message')});
|
||||
this.oldPasswordField.password = '';
|
||||
this.newPasswordField.password = '';
|
||||
MessageDialogComponent.open(this.dialog,
|
||||
{title: this.res.strings('user_password_wrong_title'), message: this.res.strings('user_password_wrong_message')});
|
||||
}
|
||||
}
|
||||
|
||||
onChangeUser() {
|
||||
if (this.user.getValue() == null) return;
|
||||
let u = this.user.getValue();
|
||||
if (this.user.getValue() == null) { return; }
|
||||
const u = this.user.getValue();
|
||||
u.name = this.nameField.name;
|
||||
let id = this.correspondence.id;
|
||||
for (var i = 0, s = u.emails.length; i < s; i++) {
|
||||
const id = this.correspondence.id;
|
||||
for (let i = 0, s = u.emails.length; i < s; i++) {
|
||||
u.emails[i].correspondence = (u.emails[i].id === id);
|
||||
}
|
||||
this.userService.changeUser(u);
|
||||
}
|
||||
|
||||
onDeleteEmail(id:number) {
|
||||
if (this.user.getValue() == null) return;
|
||||
let u = this.user.getValue();
|
||||
for (var i = 0, s = u.emails.length; i < s; i++) {
|
||||
onDeleteEmail(id: number) {
|
||||
if (this.user.getValue() == null) { return; }
|
||||
const u = this.user.getValue();
|
||||
for (let i = 0, s = u.emails.length; i < s; i++) {
|
||||
if (u.emails[i].id === id) {
|
||||
u.emails[i].deleted = true;
|
||||
this.userService.changeUser(u);
|
||||
|
||||
@@ -1,41 +1,50 @@
|
||||
import { Component, Inject } from "@angular/core";
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from "@angular/material";
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
export interface ConfirmationDialogData {
|
||||
title:string;
|
||||
message:string;
|
||||
positive?:string;
|
||||
negative?:string;
|
||||
title: string;
|
||||
message: string;
|
||||
positive?: string;
|
||||
negative?: string;
|
||||
}
|
||||
|
||||
export interface ConfirmationDialogResult {
|
||||
confirmed:boolean;
|
||||
confirmed: boolean;
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'confirmation-dialog',
|
||||
selector: 'app-confirmation-dialog',
|
||||
templateUrl: 'confirmation-dialog.component.html',
|
||||
})
|
||||
export class ConfirmationDialogComponent {
|
||||
|
||||
|
||||
title: String;
|
||||
message: String;
|
||||
positive: String;
|
||||
negative: String;
|
||||
|
||||
public static open(dialog: MatDialog, d: ConfirmationDialogData, w?: string): Observable<ConfirmationDialogResult> {
|
||||
if (w == null) { w = '450px'; }
|
||||
const ref = dialog.open(ConfirmationDialogComponent, {
|
||||
width: w,
|
||||
data: d
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
constructor(public dialog: MatDialogRef<ConfirmationDialogComponent, ConfirmationDialogResult>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: ConfirmationDialogData, public res: ResourceService) {
|
||||
@Inject(MAT_DIALOG_DATA) public data: ConfirmationDialogData, public res: ResourceService) {
|
||||
this.title = data.title;
|
||||
this.message = data.message;
|
||||
this.positive = data.positive;
|
||||
this.negative = data.negative;
|
||||
if (!this.positive) this.positive = res.strings("button_ok");
|
||||
if (!this.negative) this.negative = res.strings("button_cancel");
|
||||
if (!this.positive) { this.positive = res.strings('button_ok'); }
|
||||
if (!this.negative) { this.negative = res.strings('button_cancel'); }
|
||||
}
|
||||
|
||||
|
||||
onClose(): void {
|
||||
this.dialog.close({ confirmed: false});
|
||||
}
|
||||
@@ -44,13 +53,4 @@ export interface ConfirmationDialogResult {
|
||||
this.dialog.close({confirmed: true});
|
||||
}
|
||||
|
||||
public static open(dialog: MatDialog, d: ConfirmationDialogData, w?:string):Observable<ConfirmationDialogResult> {
|
||||
if (w == null) w = "450px";
|
||||
let ref = dialog.open(ConfirmationDialogComponent, {
|
||||
width: w,
|
||||
data: d
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import { Component, Input, Output, EventEmitter, ViewChild, ElementRef, DoCheck } from "@angular/core";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { Component, Input, Output, EventEmitter, ViewChild, ElementRef, DoCheck } from '@angular/core';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'decision-panel',
|
||||
selector: 'app-decision-panel',
|
||||
templateUrl: 'decision-panel.component.html'
|
||||
})
|
||||
export class DecisionPanelComponent implements DoCheck {
|
||||
|
||||
@ViewChild("panel", { read: ElementRef, static: true }) panel:ElementRef;
|
||||
@ViewChild('panel', { read: ElementRef, static: true }) panel: ElementRef;
|
||||
|
||||
@Input() positiveName:string;
|
||||
@Input() negativeName:string;
|
||||
@Input() positiveIcon:string = "done";
|
||||
@Input() negativeIcon:string = "close";
|
||||
@Input() processing:boolean = false;
|
||||
@Input() disabled:boolean = false;
|
||||
@Input() positiveName: string;
|
||||
@Input() negativeName: string;
|
||||
@Input() positiveIcon = 'done';
|
||||
@Input() negativeIcon = 'close';
|
||||
@Input() processing = false;
|
||||
@Input() disabled = false;
|
||||
@Output() positive: EventEmitter<any> = new EventEmitter();
|
||||
@Output() negative: EventEmitter<any> = new EventEmitter();
|
||||
compact:boolean = false;
|
||||
compact = false;
|
||||
|
||||
constructor(public res: ResourceService) {
|
||||
this.positiveName = res.strings("button_ok");
|
||||
this.negativeName = res.strings("button_cancel");
|
||||
this.positiveName = res.strings('button_ok');
|
||||
this.negativeName = res.strings('button_cancel');
|
||||
}
|
||||
|
||||
onPositive() {
|
||||
@@ -33,8 +33,8 @@ export class DecisionPanelComponent implements DoCheck {
|
||||
}
|
||||
|
||||
ngDoCheck() {
|
||||
let width = this.panel.nativeElement.clientWidth;
|
||||
const width = this.panel.nativeElement.clientWidth;
|
||||
this.compact = (width < 250);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<mat-form-field [hintLabel]="res.strings('email_field_hint')" fxFlex="1 1 100%" use-parent-form>
|
||||
<mat-form-field [hintLabel]="res.strings('email_field_hint')" fxFlex="1 1 100%" appUseParentForm>
|
||||
<input matInput #emailField="ngModel" maxlength="32" name="email" [placeholder]="res.strings('email_field_placeholder')" [(ngModel)]="email" pattern=".+@.+\..+" required [disabled]="disabled">
|
||||
<mat-hint align="end">{{emailField.value?.length || 0}}/90</mat-hint>
|
||||
<mat-error *ngIf="emailField.invalid">
|
||||
|
||||
@@ -8,10 +8,10 @@ import { ResourceService } from '../services/resource.service';
|
||||
/**
|
||||
* A validated field that enables a user to enter the
|
||||
* email. The email will be available through the
|
||||
* components name which also acts as an input.
|
||||
* components name which also acts as an input.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'email-field',
|
||||
selector: 'app-email-field',
|
||||
templateUrl: './email-field.component.html'
|
||||
})
|
||||
export class EmailFieldComponent extends FormErrorEncoder {
|
||||
@@ -19,11 +19,11 @@ export class EmailFieldComponent extends FormErrorEncoder {
|
||||
/**
|
||||
* The email address.
|
||||
*/
|
||||
@Input() email:string;
|
||||
@Input() email: string;
|
||||
/**
|
||||
* Disables the field.
|
||||
*/
|
||||
@Input() disabled:boolean;
|
||||
@Input() disabled: boolean;
|
||||
|
||||
constructor(public res: ResourceService) {
|
||||
super();
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { Input, Component, Output, EventEmitter } from "@angular/core";
|
||||
import { ResourceService, Language } from "../services/resource.service";
|
||||
import { Input, Component, Output, EventEmitter } from '@angular/core';
|
||||
import { ResourceService, Language } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'language-select',
|
||||
selector: 'app-language-select',
|
||||
templateUrl: 'language-select.component.html',
|
||||
})
|
||||
})
|
||||
export class LanguageSelectComponent {
|
||||
|
||||
|
||||
@Input() languages: Language[];
|
||||
|
||||
@Input() value: string;
|
||||
|
||||
@Output() change: EventEmitter<string> = new EventEmitter();
|
||||
|
||||
constructor(public res: ResourceService) {
|
||||
constructor(public res: ResourceService) {
|
||||
this.languages = res.languages;
|
||||
this.value = res.strings('language');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
import { Component, Inject } from "@angular/core";
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from "@angular/material";
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material';
|
||||
import { Observable } from 'rxjs';
|
||||
import { LogMessage } from "../../api/models";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { LogMessage } from '../../api/models';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'log-dialog',
|
||||
selector: 'app-log-dialog',
|
||||
templateUrl: 'log-dialog.component.html',
|
||||
})
|
||||
export class LogDialogComponent {
|
||||
|
||||
|
||||
message: LogMessage;
|
||||
|
||||
public static open(dialog: MatDialog, d: LogMessage, w?: string): Observable<any> {
|
||||
const ref = dialog.open(LogDialogComponent, {
|
||||
width: w,
|
||||
data: d
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
constructor(public dialog: MatDialogRef<LogDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: LogMessage,
|
||||
public res: ResourceService) {
|
||||
public res: ResourceService) {
|
||||
this.message = data;
|
||||
}
|
||||
|
||||
|
||||
onClose(): void {
|
||||
this.dialog.close();
|
||||
}
|
||||
|
||||
public static open(dialog: MatDialog, d: LogMessage, w?:string):Observable<any> {
|
||||
let ref = dialog.open(LogDialogComponent, {
|
||||
width: w,
|
||||
data: d
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<mat-form-field [hintLabel]="res.strings('login_field_hint')" fxFlex="1 1 100%" use-parent-form>
|
||||
<mat-form-field [hintLabel]="res.strings('login_field_hint')" fxFlex="1 1 100%" appUseParentForm>
|
||||
<input matInput #loginField="ngModel" minlength="5" maxlength="32"
|
||||
name="login" [placeholder]="res.strings('login_field_placeholder')" [(ngModel)]="login" pattern="[a-zA-Z0-9]*" required [disabled]="disabled">
|
||||
<mat-hint align="end">{{loginField.value?.length || 0}}/32</mat-hint>
|
||||
|
||||
@@ -8,10 +8,10 @@ import { ResourceService } from '../services/resource.service';
|
||||
/**
|
||||
* A validated field that enables a user to enter the
|
||||
* login name. The name will be available through the
|
||||
* components login which also acts as an input.
|
||||
* components login which also acts as an input.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'login-field',
|
||||
selector: 'app-login-field',
|
||||
templateUrl: './login-field.component.html'
|
||||
})
|
||||
export class LoginFieldComponent extends FormErrorEncoder {
|
||||
@@ -19,11 +19,11 @@ export class LoginFieldComponent extends FormErrorEncoder {
|
||||
/**
|
||||
* The login name
|
||||
*/
|
||||
@Input() login:string;
|
||||
@Input() login: string;
|
||||
/**
|
||||
* Disables the field.
|
||||
*/
|
||||
@Input() disabled:boolean;
|
||||
@Input() disabled: boolean;
|
||||
|
||||
constructor(public res: ResourceService) {
|
||||
super();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div style="display:flex;flex:1;height:100%">
|
||||
<tile-map #tile style="display:flex;flex:1;min-height:100%;min-width:100%;"></tile-map>
|
||||
<app-tile-map #tile style="display:flex;flex:1;min-height:100%;min-width:100%;"></app-tile-map>
|
||||
<div #overlay style="position:absolute;flex-direction:column;right:0px;overflow:auto;max-height: 100%;z-index:1000000;">
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterContentInit, AfterViewInit, ElementRef } from "@angular/core";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { MatDialog, MatSnackBar } from "@angular/material";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { MessageDialogComponent } from "../widgets/message-dialog.component";
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { HttpStatusCode } from "../utils/httpcodes";
|
||||
import { Subscription, BehaviorSubject } from "rxjs";
|
||||
import { Device, Location } from "../../api/models";
|
||||
import { Snackbars } from "../utils/snackbars";
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterContentInit, AfterViewInit, ElementRef } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { HttpStatusCode } from '../utils/httpcodes';
|
||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { Device, Location } from '../../api/models';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import * as L from 'leaflet';
|
||||
import { TileMapComponent } from "../widgets/tile-map.component";
|
||||
import { TileMapComponent } from '../widgets/tile-map.component';
|
||||
|
||||
@Component({
|
||||
selector: 'marker-map',
|
||||
templateUrl: './marker-map.component.html',
|
||||
host: { class: 'match-parent' },
|
||||
selector: 'app-marker-map',
|
||||
templateUrl: './marker-map.component.html'
|
||||
})
|
||||
export class MarkerMapComponent implements AfterViewInit {
|
||||
|
||||
@ViewChild(TileMapComponent, { static: true }) map: TileMapComponent;
|
||||
@ViewChild("overlay", { read: ElementRef, static: true }) overlaySpace: ElementRef;
|
||||
@ViewChild("tile", { read: ElementRef, static: true }) tileSpace: ElementRef;
|
||||
@ViewChild('overlay', { read: ElementRef, static: true }) overlaySpace: ElementRef;
|
||||
@ViewChild('tile', { read: ElementRef, static: true }) tileSpace: ElementRef;
|
||||
|
||||
private marker: L.Marker;
|
||||
private markerPosition: { latitude: number, longitude: number };
|
||||
@@ -50,11 +49,11 @@ export class MarkerMapComponent implements AfterViewInit {
|
||||
}
|
||||
|
||||
private updateMarker() {
|
||||
if (!this.marker) return;
|
||||
if (!this.marker) { return; }
|
||||
if (this.markerPosition == null) {
|
||||
this.marker.remove();
|
||||
} else {
|
||||
let c = new L.LatLng(this.markerPosition.latitude, this.markerPosition.longitude);
|
||||
const c = new L.LatLng(this.markerPosition.latitude, this.markerPosition.longitude);
|
||||
this.marker.setLatLng(c);
|
||||
this.marker.addTo(this.map.map);
|
||||
this.centerPoint(c);
|
||||
@@ -67,11 +66,11 @@ export class MarkerMapComponent implements AfterViewInit {
|
||||
}
|
||||
|
||||
private updatePin() {
|
||||
if (!this.pin) return;
|
||||
if (!this.pin) { return; }
|
||||
if (this.pinPosition == null) {
|
||||
this.pin.remove();
|
||||
} else {
|
||||
let c = new L.LatLng(this.pinPosition.latitude, this.pinPosition.longitude);
|
||||
const c = new L.LatLng(this.pinPosition.latitude, this.pinPosition.longitude);
|
||||
this.pin.setLatLng(c);
|
||||
this.pin.addTo(this.map.map);
|
||||
this.centerPoint(c);
|
||||
@@ -87,13 +86,13 @@ export class MarkerMapComponent implements AfterViewInit {
|
||||
centerBounds(latLngExp: L.LatLngBoundsExpression, maxZoom?: number): void {
|
||||
// hacky workaround for bug in leaflet
|
||||
this.map.map.invalidateSize();
|
||||
let overlayWidth = this.overlaySpace.nativeElement.clientWidth;
|
||||
let tileWidth = this.tileSpace.nativeElement.clientWidth;
|
||||
let freeWidth = tileWidth - overlayWidth;
|
||||
var padding = 0;
|
||||
const overlayWidth = this.overlaySpace.nativeElement.clientWidth;
|
||||
const tileWidth = this.tileSpace.nativeElement.clientWidth;
|
||||
const freeWidth = tileWidth - overlayWidth;
|
||||
let padding = 0;
|
||||
if (freeWidth > 100) {
|
||||
padding = overlayWidth;
|
||||
}
|
||||
}
|
||||
this.map.map.fitBounds(latLngExp, {
|
||||
paddingBottomRight: [ padding, 0],
|
||||
maxZoom: maxZoom
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
import { Component, Inject } from "@angular/core";
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from "@angular/material";
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
export interface MessageDialogData {
|
||||
title:string;
|
||||
message:string;
|
||||
button?:string;
|
||||
title: string;
|
||||
message: string;
|
||||
button?: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'message-dialog',
|
||||
selector: 'app-message-dialog',
|
||||
templateUrl: 'message-dialog.component.html',
|
||||
})
|
||||
export class MessageDialogComponent {
|
||||
|
||||
|
||||
title: String;
|
||||
message: String;
|
||||
button: String;
|
||||
|
||||
public static open(dialog: MatDialog, d: MessageDialogData, w?: string): Observable<any> {
|
||||
if (w == null) { w = '450px'; }
|
||||
const ref = dialog.open(MessageDialogComponent, {
|
||||
width: w,
|
||||
data: d
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
constructor(public dialog: MatDialogRef<MessageDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: MessageDialogData, public res: ResourceService) {
|
||||
@Inject(MAT_DIALOG_DATA) public data: MessageDialogData, public res: ResourceService) {
|
||||
this.title = data.title;
|
||||
this.message = data.message;
|
||||
this.button = data.button;
|
||||
if (!this.button) this.button = res.strings('button_ok');
|
||||
if (!this.button) { this.button = res.strings('button_ok'); }
|
||||
}
|
||||
|
||||
|
||||
onClose(): void {
|
||||
this.dialog.close();
|
||||
}
|
||||
|
||||
public static open(dialog: MatDialog, d: MessageDialogData, w?:string):Observable<any> {
|
||||
if (w == null) w = "450px";
|
||||
let ref = dialog.open(MessageDialogComponent, {
|
||||
width: w,
|
||||
data: d
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<mat-form-field [hintLabel]="res.strings('name_field_hint')" fxFlex="1 1 100%" use-parent-form>
|
||||
<mat-form-field [hintLabel]="res.strings('name_field_hint')" fxFlex="1 1 100%" appUseParentForm>
|
||||
<input matInput #nameField="ngModel" maxlength="64" name="name" [placeholder]="res.strings('name_field_placeholder')" [(ngModel)]="name" pattern="([A-Za-z]|[\u00C0-\u00FF]| ){0,64}" required [disabled]="disabled">
|
||||
<mat-hint align="end">{{nameField.value?.length || 0}}/64</mat-hint>
|
||||
<mat-error *ngIf="nameField.invalid">
|
||||
|
||||
@@ -8,10 +8,10 @@ import { ResourceService } from '../services/resource.service';
|
||||
/**
|
||||
* A validated field that enables a user to enter the
|
||||
* human name. The name will be available through the
|
||||
* components name which also acts as an input.
|
||||
* components name which also acts as an input.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'name-field',
|
||||
selector: 'app-name-field',
|
||||
templateUrl: './name-field.component.html'
|
||||
})
|
||||
export class NameFieldComponent extends FormErrorEncoder {
|
||||
@@ -19,13 +19,13 @@ export class NameFieldComponent extends FormErrorEncoder {
|
||||
/**
|
||||
* The human name
|
||||
*/
|
||||
@Input() name:string;
|
||||
@Input() name: string;
|
||||
/**
|
||||
* Disables the field.
|
||||
*/
|
||||
@Input() disabled:boolean;
|
||||
@Input() disabled: boolean;
|
||||
|
||||
constructor(public res:ResourceService) {
|
||||
constructor(public res: ResourceService) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<form #nameForm="ngForm">
|
||||
<mat-form-field [hintLabel]="res.strings('nickname_dialog_hint')" fxFlex="1 1 100%" use-parent-form>
|
||||
<mat-form-field [hintLabel]="res.strings('nickname_dialog_hint')" fxFlex="1 1 100%" appUseParentForm>
|
||||
<input matInput #nameField="ngModel" name="name" maxlength="140" [placeholder]="res.strings('nickname_dialog_placeholder')" (keyup.enter)="onAccept()" [(ngModel)]="name" pattern="(\w|[\u00C0-\u00FF]| ){0,140}"
|
||||
[disabled]="isLoading()">
|
||||
<mat-hint align="end">{{nameField.value?.length || 0}} / 140</mat-hint>
|
||||
@@ -17,7 +17,7 @@
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<decision-panel
|
||||
<app-decision-panel
|
||||
[positiveName]="res.strings('button_save')"
|
||||
positiveIcon="save"
|
||||
[negativeName]="res.strings('button_cancel')"
|
||||
@@ -25,5 +25,5 @@
|
||||
[processing]="isLoading()"
|
||||
[disabled]="nameForm.invalid"
|
||||
(positive)="onAccept()"
|
||||
(negative)="onClose()"></decision-panel>
|
||||
(negative)="onClose()"></app-decision-panel>
|
||||
</mat-card>
|
||||
@@ -1,40 +1,49 @@
|
||||
import { Component, Inject, ViewChild } from "@angular/core";
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog, MatSnackBar } from "@angular/material";
|
||||
import { Component, Inject, ViewChild } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { NgForm } from "@angular/forms";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { Snackbars } from "../utils/snackbars";
|
||||
import { FormErrorEncoder } from "../utils/formcodes";
|
||||
import { Place } from "../../api/models";
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { HttpStatusCode } from "../utils/httpcodes";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import { FormErrorEncoder } from '../utils/formcodes';
|
||||
import { Place } from '../../api/models';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { HttpStatusCode } from '../utils/httpcodes';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'nickname-dialog',
|
||||
selector: 'app-nickname-dialog',
|
||||
templateUrl: 'nickname-dialog.component.html',
|
||||
})
|
||||
export class NicknameDialogComponent extends FormErrorEncoder {
|
||||
|
||||
@ViewChild("nameForm", { static: true }) nameForm: NgForm;
|
||||
|
||||
@ViewChild('nameForm', { static: true }) nameForm: NgForm;
|
||||
|
||||
name: String;
|
||||
private place: Place;
|
||||
private subscription: Subscription;
|
||||
|
||||
public static open(dialog: MatDialog, data: Place, w?: string): Observable<boolean> {
|
||||
if (w == null) { w = '450px'; }
|
||||
const ref = dialog.open(NicknameDialogComponent, {
|
||||
data: data,
|
||||
width: w
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
constructor(
|
||||
public snackbar: MatSnackBar,
|
||||
public apiClientService: ApiClientService,
|
||||
public apiClientService: ApiClientService,
|
||||
public dialog: MatDialogRef<any, boolean>,
|
||||
@Inject(MAT_DIALOG_DATA) data: Place,
|
||||
public res: ResourceService
|
||||
) {
|
||||
) {
|
||||
super();
|
||||
this.place = data;
|
||||
this.name = data.nickname;
|
||||
}
|
||||
|
||||
isLoading():boolean{
|
||||
}
|
||||
|
||||
isLoading(): boolean {
|
||||
return this.subscription != null;
|
||||
}
|
||||
|
||||
@@ -43,16 +52,16 @@ import { ResourceService } from "../services/resource.service";
|
||||
}
|
||||
|
||||
onAccept(): void {
|
||||
if (this.nameForm.invalid || this.subscription) return;
|
||||
if (this.nameForm.invalid || this.subscription) { return; }
|
||||
this.place.nickname = this.name.trim();
|
||||
this.subscription = this.apiClientService.setPlace(this.place.id, this.place).subscribe((result)=>{
|
||||
this.subscription = this.apiClientService.setPlace(this.place.id, this.place).subscribe((result) => {
|
||||
this.subscription = null;
|
||||
this.dialog.close(true);
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings('nickname_dialog_success'), Snackbars.DURATION_SHORT);
|
||||
}, (error)=>{
|
||||
}, (error) => {
|
||||
this.subscription = null;
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
if (error.status == HttpStatusCode.CONFLICT && error.error) {
|
||||
if (error.status === HttpStatusCode.CONFLICT && error.error) {
|
||||
this.place = JSON.parse(error.error) as Place;
|
||||
this.name = this.place.nickname;
|
||||
Snackbars.showError(this.snackbar, this.res.strings('nickname_dialog_conflict'));
|
||||
@@ -64,13 +73,4 @@ import { ResourceService } from "../services/resource.service";
|
||||
});
|
||||
}
|
||||
|
||||
public static open(dialog: MatDialog, data: Place, w?:string):Observable<boolean> {
|
||||
if (w == null) w = "450px";
|
||||
let ref = dialog.open(NicknameDialogComponent, {
|
||||
data: data,
|
||||
width: w
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { Notice, Message } from "../../api/models";
|
||||
import { Input, Component } from "@angular/core";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { Notice, Message } from '../../api/models';
|
||||
import { Input, Component } from '@angular/core';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'notice-card',
|
||||
selector: 'app-notice-card',
|
||||
templateUrl: './notice-card.component.html'
|
||||
})
|
||||
export class NoticeCardComponent {
|
||||
|
||||
|
||||
/**
|
||||
* The notice bound to the card.
|
||||
*/
|
||||
@Input() notice:Notice;
|
||||
@Input() notice: Notice;
|
||||
|
||||
/**
|
||||
* The preferred language to display.
|
||||
@@ -25,12 +25,12 @@ import { ResourceService } from "../services/resource.service";
|
||||
@Input() createdLabel: string;
|
||||
|
||||
constructor(public res: ResourceService) {
|
||||
this.modifiedLabel = res.strings("notice_card_creation");
|
||||
this.createdLabel = res.strings("notice_card_modification");
|
||||
this.modifiedLabel = res.strings('notice_card_creation');
|
||||
this.createdLabel = res.strings('notice_card_modification');
|
||||
}
|
||||
|
||||
getTimeLabel(): string {
|
||||
if (this.notice.modificationTime == this.notice.creationTime) {
|
||||
if (this.notice.modificationTime === this.notice.creationTime) {
|
||||
return this.createdLabel;
|
||||
} else {
|
||||
return this.modifiedLabel;
|
||||
@@ -38,20 +38,26 @@ import { ResourceService } from "../services/resource.service";
|
||||
}
|
||||
|
||||
getTitle(): string {
|
||||
let m = this.getMessage();
|
||||
if (m == null) return "";
|
||||
else return m.title;
|
||||
const m = this.getMessage();
|
||||
if (m == null) {
|
||||
return '';
|
||||
} else {
|
||||
return m.title;
|
||||
}
|
||||
}
|
||||
|
||||
getBody(): string {
|
||||
let m = this.getMessage();
|
||||
if (m == null) return "";
|
||||
else return m.body;
|
||||
const m = this.getMessage();
|
||||
if (m == null) {
|
||||
return '';
|
||||
} else {
|
||||
return m.body;
|
||||
}
|
||||
}
|
||||
|
||||
private getMessage(): Message {
|
||||
for (let m of this.notice.messages) {
|
||||
if (m.language == this.language) {
|
||||
for (const m of this.notice.messages) {
|
||||
if (m.language === this.language) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -59,4 +65,4 @@ import { ResourceService } from "../services/resource.service";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<mat-form-field [hintLabel]="hint" fxFlex="1 1 100%" use-parent-form>
|
||||
<mat-form-field [hintLabel]="hint" fxFlex="1 1 100%" appUseParentForm>
|
||||
<input matInput #passwordField="ngModel" [name]="name" [placeholder]="label" [(ngModel)]="password" minlength="5" required [disabled]="disabled" [type]="hide ? 'password' : 'text'">
|
||||
<mat-icon matSuffix (click)="hide = !hide" [matTooltip]="res.strings(hide?'password_field_show':'password_field_show')">{{hide ? 'visibility' : 'visibility_off'}}</mat-icon>
|
||||
<mat-hint align="end">{{passwordField.value?.length || 0}}</mat-hint>
|
||||
|
||||
@@ -8,48 +8,48 @@ import { ResourceService } from '../services/resource.service';
|
||||
/**
|
||||
* A validated field that enables a user to enter the
|
||||
* login name. The name will be available through the
|
||||
* components login which also acts as an input.
|
||||
* components login which also acts as an input.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'password-field',
|
||||
selector: 'app-password-field',
|
||||
templateUrl: './password-field.component.html'
|
||||
})
|
||||
})
|
||||
export class PasswordFieldComponent extends FormErrorEncoder {
|
||||
|
||||
/**
|
||||
* Hide or show the password.
|
||||
*/
|
||||
hide:boolean = true;
|
||||
hide = true;
|
||||
|
||||
/**
|
||||
* The password bound to the component.
|
||||
*/
|
||||
@Input() password:string;
|
||||
@Input() password: string;
|
||||
/**
|
||||
* Disables the field.
|
||||
*/
|
||||
@Input() disabled:boolean;
|
||||
@Input() disabled: boolean;
|
||||
|
||||
/**
|
||||
* The name of the field
|
||||
*/
|
||||
@Input() name:string = "password";
|
||||
@Input() name = 'password';
|
||||
|
||||
/**
|
||||
* The label for the field.
|
||||
*/
|
||||
@Input() label:string;
|
||||
@Input() label: string;
|
||||
|
||||
/**
|
||||
* The hint for the field.
|
||||
*/
|
||||
@Input() hint:string;
|
||||
@Input() hint: string;
|
||||
|
||||
|
||||
constructor(public res: ResourceService) {
|
||||
super();
|
||||
this.label = res.strings("password_field_placeholder");
|
||||
this.hint = res.strings("password_field_hint")
|
||||
this.label = res.strings('password_field_placeholder');
|
||||
this.hint = res.strings('password_field_hint');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ import { Router, RouterEvent, NavigationEnd } from '@angular/router';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { UserService } from '../services/user.service';
|
||||
|
||||
/**
|
||||
/**
|
||||
* Implements a responsive profile button for the toolbar.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'profile-button',
|
||||
selector: 'app-profile-button',
|
||||
templateUrl: './profile-button.component.html'
|
||||
})
|
||||
export class ProfileButtonComponent {
|
||||
@@ -17,10 +17,10 @@ export class ProfileButtonComponent {
|
||||
*/
|
||||
login: string;
|
||||
|
||||
constructor(private userService: UserService) {
|
||||
constructor(private userService: UserService) {
|
||||
this.login = userService.getLogin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<form #shareForm="ngForm">
|
||||
<mat-form-field [hintLabel]="res.strings('share_dialog_hint')" fxFlex="1 1 100%" use-parent-form>
|
||||
<mat-form-field [hintLabel]="res.strings('share_dialog_hint')" fxFlex="1 1 100%" useParentForm>
|
||||
<input matInput #linkField="ngModel" name="link" [placeholder]="res.strings('share_dialog_placeholder')" (keyup.enter)="onAccept()" [(ngModel)]="link" pattern="[ ]*(https:\/\/www.maptology.com\/app\/shares\/){0,1}([A-Za-z0-9_-]){22,22}[ ]*"
|
||||
required [disabled]="isLoading()">
|
||||
<mat-hint align="end">{{linkField.value?.length || 0}}</mat-hint>
|
||||
@@ -18,7 +18,7 @@
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<decision-panel
|
||||
<app-decision-panel
|
||||
[positiveName]="res.strings('button_save')"
|
||||
positiveIcon="save"
|
||||
[negativeName]="res.strings('button_cancel')"
|
||||
@@ -27,5 +27,5 @@
|
||||
[disabled]="shareForm.invalid"
|
||||
(positive)="onAccept()"
|
||||
(negative)="onClose()"
|
||||
></decision-panel>
|
||||
></app-decision-panel>
|
||||
</mat-card>
|
||||
@@ -1,35 +1,43 @@
|
||||
import { Component, Inject, ViewChild } from "@angular/core";
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog, MatSnackBar } from "@angular/material";
|
||||
import { Component, Inject, ViewChild } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { NgForm } from "@angular/forms";
|
||||
import { ApiClientService } from "../../api";
|
||||
import { Snackbars } from "../utils/snackbars";
|
||||
import { FormErrorEncoder } from "../utils/formcodes";
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import { FormErrorEncoder } from '../utils/formcodes';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'share-dialog',
|
||||
selector: 'app-share-dialog',
|
||||
templateUrl: 'share-dialog.component.html',
|
||||
})
|
||||
export class ShareDialogComponent extends FormErrorEncoder {
|
||||
|
||||
@ViewChild("shareForm", { static: true }) shareForm: NgForm;
|
||||
|
||||
@ViewChild('shareForm', { static: true }) shareForm: NgForm;
|
||||
|
||||
link: String;
|
||||
private subscription: Subscription;
|
||||
|
||||
public static open(dialog: MatDialog, link?: string, w?: string): Observable<boolean> {
|
||||
const ref = dialog.open(ShareDialogComponent, {
|
||||
data: (link) ? link : '',
|
||||
width: w
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
constructor(
|
||||
public snackbar: MatSnackBar,
|
||||
public apiClientService: ApiClientService,
|
||||
public apiClientService: ApiClientService,
|
||||
public dialog: MatDialogRef<any, boolean>,
|
||||
@Inject(MAT_DIALOG_DATA) data: string,
|
||||
public res: ResourceService
|
||||
) {
|
||||
) {
|
||||
super();
|
||||
this.link = data;
|
||||
}
|
||||
|
||||
isLoading():boolean{
|
||||
}
|
||||
|
||||
isLoading(): boolean {
|
||||
return this.subscription != null;
|
||||
}
|
||||
|
||||
@@ -38,26 +46,18 @@ import { ResourceService } from "../services/resource.service";
|
||||
}
|
||||
|
||||
onAccept(): void {
|
||||
if (this.shareForm.invalid || this.subscription) return;
|
||||
var token = this.link.trim();
|
||||
let idx = token.lastIndexOf("/");
|
||||
if (idx != -1) token = token.substring(idx + 1);
|
||||
this.subscription = this.apiClientService.addCurrentUserPrivilege(token).subscribe((result)=>{
|
||||
if (this.shareForm.invalid || this.subscription) { return; }
|
||||
let token = this.link.trim();
|
||||
const idx = token.lastIndexOf('/');
|
||||
if (idx !== -1) { token = token.substring(idx + 1); }
|
||||
this.subscription = this.apiClientService.addCurrentUserPrivilege(token).subscribe((result) => {
|
||||
this.subscription = null;
|
||||
this.dialog.close(true);
|
||||
Snackbars.showMessage(this.snackbar, this.res.strings('share_dialog_success'), Snackbars.DURATION_SHORT);
|
||||
}, (error)=>{
|
||||
}, (error) => {
|
||||
this.subscription = null;
|
||||
Snackbars.showError(this.snackbar, this.res.strings('share_dialog_error'));
|
||||
});
|
||||
}
|
||||
|
||||
public static open(dialog: MatDialog, link?:string, w?:string):Observable<boolean> {
|
||||
let ref = dialog.open(ShareDialogComponent, {
|
||||
data: (link)?link:"",
|
||||
width: w
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Component, OnInit, ElementRef, ViewChild } from "@angular/core";
|
||||
import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';
|
||||
import * as L from 'leaflet';
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'tile-map',
|
||||
selector: 'app-tile-map',
|
||||
templateUrl: './tile-map.component.html'
|
||||
})
|
||||
export class TileMapComponent implements OnInit {
|
||||
@@ -14,10 +14,10 @@ export class TileMapComponent implements OnInit {
|
||||
private static readonly DEFAULT_ICON_SCALE = 0.2;
|
||||
|
||||
|
||||
private static readonly DEFAULT_PIN_URL = "assets/markers/marker_pin.png";
|
||||
private static readonly DEFAULT_NORMAL_URL = "assets/markers/marker_normal.png";
|
||||
private static readonly DEFAULT_SELECTED_URL = "assets/markers/marker_selected.png";
|
||||
private static readonly DEFAULT_SHADOW_URL = "assets/markers/marker_shadow.png";
|
||||
private static readonly DEFAULT_PIN_URL = 'assets/markers/marker_pin.png';
|
||||
private static readonly DEFAULT_NORMAL_URL = 'assets/markers/marker_normal.png';
|
||||
private static readonly DEFAULT_SELECTED_URL = 'assets/markers/marker_selected.png';
|
||||
private static readonly DEFAULT_SHADOW_URL = 'assets/markers/marker_shadow.png';
|
||||
|
||||
@ViewChild('map', { read: ElementRef, static: true }) mapElement: ElementRef;
|
||||
|
||||
@@ -32,7 +32,7 @@ export class TileMapComponent implements OnInit {
|
||||
this.iconNormal = this.createMarkerIcon(TileMapComponent.DEFAULT_NORMAL_URL);
|
||||
this.iconSelected = this.createMarkerIcon(TileMapComponent.DEFAULT_NORMAL_URL);
|
||||
this.iconPin = this.createPinIcon(TileMapComponent.DEFAULT_PIN_URL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
getWidth(): number {
|
||||
@@ -60,8 +60,8 @@ export class TileMapComponent implements OnInit {
|
||||
}).addTo(this.map);
|
||||
}
|
||||
|
||||
private createMarkerIcon(url: string):L.Icon {
|
||||
let href = this.getBaseHref();
|
||||
private createMarkerIcon(url: string): L.Icon {
|
||||
const href = this.getBaseHref();
|
||||
return new L.Icon({
|
||||
iconUrl: href + url,
|
||||
shadowUrl: href + TileMapComponent.DEFAULT_SHADOW_URL,
|
||||
@@ -72,8 +72,8 @@ export class TileMapComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private createPinIcon(url: string):L.Icon {
|
||||
let href = this.getBaseHref();
|
||||
private createPinIcon(url: string): L.Icon {
|
||||
const href = this.getBaseHref();
|
||||
return new L.Icon({
|
||||
iconUrl: href + url,
|
||||
iconAnchor: [this.scale(100), this.scale(100)],
|
||||
@@ -81,18 +81,18 @@ export class TileMapComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private getBaseHref():string{
|
||||
let bases = document.getElementsByTagName('base');
|
||||
private getBaseHref(): string {
|
||||
const bases = document.getElementsByTagName('base');
|
||||
let baseHref = null;
|
||||
if (bases.length > 0) baseHref = bases[0].href;
|
||||
if (baseHref == null) baseHref = "/";
|
||||
if (bases.length > 0) { baseHref = bases[0].href; }
|
||||
if (baseHref == null) { baseHref = '/'; }
|
||||
return baseHref;
|
||||
}
|
||||
|
||||
private scale(v:number):number {
|
||||
private scale(v: number): number {
|
||||
return v * TileMapComponent.DEFAULT_ICON_SCALE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Router, RouterEvent, NavigationEnd } from '@angular/router';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
/**
|
||||
/**
|
||||
* Implements a responsive button for the toolbar
|
||||
* that consists of an icon, text and a link.
|
||||
* Optionally, it can be disabled and it is possible
|
||||
@@ -11,7 +11,7 @@ import { Subscription } from 'rxjs';
|
||||
* button will be flat.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'toolbar-button',
|
||||
selector: 'app-toolbar-button',
|
||||
templateUrl: './toolbar-button.component.html'
|
||||
})
|
||||
export class ToolbarButtonComponent implements OnInit, OnDestroy {
|
||||
@@ -53,7 +53,7 @@ export class ToolbarButtonComponent implements OnInit, OnDestroy {
|
||||
|
||||
/**
|
||||
* Creates a new button.
|
||||
*
|
||||
*
|
||||
* @param router The router.
|
||||
*/
|
||||
constructor(private router: Router) { }
|
||||
@@ -62,12 +62,12 @@ export class ToolbarButtonComponent implements OnInit, OnDestroy {
|
||||
this.routerSubscription = this.router.events.subscribe((event) => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
this.updateVisibility();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.updateVisibility();
|
||||
}
|
||||
|
||||
private updateVisibility():void {
|
||||
private updateVisibility(): void {
|
||||
this.visible = (this.router.url !== this.link);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<app></app>
|
||||
<app-app></app-app>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -105,7 +105,7 @@ body {
|
||||
|
||||
.narrow-value {
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
font-size: 10px;
|
||||
word-break:break-all;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user