1
0
mirror of https://github.com/dkmstr/openuds-gui.git synced 2025-01-03 05:17:36 +03:00

advancing

This commit is contained in:
Adolfo Gómez García 2018-05-18 09:50:30 +02:00
parent 574844ff36
commit b919a429ee
8 changed files with 94 additions and 42 deletions

View File

@ -19,7 +19,7 @@
"changeOrigin": true, "changeOrigin": true,
"logLevel": "info" "logLevel": "info"
}, },
"/login": { "/log.*": {
"target": { "target": {
"host": "172.27.0.1", "host": "172.27.0.1",
"protocol": "http:", "protocol": "http:",

View File

@ -1,16 +1,23 @@
<div class="px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center"> <div class="px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
<h1 class="display-4"><uds-translate>UDS Plugin</uds-translate></h1> <h1 class="display-4">
<p class="lead"><uds-translate>Download uds plugin for your platform</uds-translate></p> <uds-translate>UDS Plugin</uds-translate>
</div> </h1>
<p class="lead">
<uds-translate>Download UDS client plugin for your platform</uds-translate>
</p>
</div>
<div class="container"> <div class="container">
<div class="card-deck mb-3"> <div class="card-deck mb-3">
<div class="card mb-4" *ngFor="let p of plugins"> <div class="card mb-4" *ngFor="let p of api.plugins">
<img class="card-img-top" src="/static/modern/img/{{ p.os }}.png"> <img class="card-img-top" src="/static/modern/img/{{ p.name }}.png">
<div class="card-body d-flex flex-column"> <div class="card-body d-flex flex-column">
<h4 class="card-title">{{ p.os }}</h4> <h4 class="card-title">{{ p.name }}</h4>
<p class="card-text">{{ p.description }}</p> <p class="card-text">{{ p.description }}</p>
<a class="btn btn-lg btn-block btn-outline-primary mt-auto" href="{{ p.url }}"><uds-translate>Download</uds-translate></a> <a class="btn btn-lg btn-block btn-outline-primary mt-auto" href="{{ p.url }}">
</div> <uds-translate>Download</uds-translate>
</div> </a>
</div> </div>
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { UdsApiService, Plugin } from '../uds-api.service'; import { UdsApiService, Downloadable } from '../uds-api.service';
@Component({ @Component({
selector: 'uds-client-download', selector: 'uds-client-download',
@ -8,10 +8,9 @@ import { UdsApiService, Plugin } from '../uds-api.service';
}) })
export class ClientDownloadComponent implements OnInit { export class ClientDownloadComponent implements OnInit {
plugins: Plugin[]; plugins: Downloadable[];
constructor(private api: UdsApiService) { constructor(public api: UdsApiService) {
this.plugins = api.getPlugins();
} }
ngOnInit() { ngOnInit() {

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { UdsApiService, Plugin } from '../uds-api.service'; import { UdsApiService, Downloadable } from '../uds-api.service';
@Component({ @Component({
selector: 'uds-login', selector: 'uds-login',
@ -8,7 +8,7 @@ import { UdsApiService, Plugin } from '../uds-api.service';
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
constructor(private api: UdsApiService) { } constructor(public api: UdsApiService) { }
ngOnInit() { ngOnInit() {
} }

View File

@ -3,10 +3,10 @@
<img alt="Universal Desktop Services" src="/static/modern/img/udsicon.png" class="navbar-img pull-left"> <img alt="Universal Desktop Services" src="/static/modern/img/udsicon.png" class="navbar-img pull-left">
Universal Desktop Services Universal Desktop Services
</a> </a>
<button class="navbar-toggler" type="button" (click)="isNavbarCollapsed = !isNavbarCollapsed" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" (click)="isNavbarCollapsed = !isNavbarCollapsed" data-target="#navbarUDS" aria-controls="navbarUDS" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div [ngbCollapse]="isNavbarCollapsed" class="navbar-collapse" id="navbarsExampleDefault"> <div [ngbCollapse]="isNavbarCollapsed" class="navbar-collapse" id="navbarUDS">
<ul class="navbar-nav ml-auto"> <ul class="navbar-nav ml-auto">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" routerLink="/client-download"><i class="fa fa-download"></i> UDS Plugin</a> <a class="nav-link" routerLink="/client-download"><i class="fa fa-download"></i> UDS Plugin</a>
@ -15,11 +15,22 @@
<a class="nav-link" href="#"><uds-translate>About</uds-translate></a> <a class="nav-link" href="#"><uds-translate>About</uds-translate></a>
</li> </li>
<li class="nav-item dropdown dropdown-menu-right" ngbDropdown> <li class="nav-item dropdown dropdown-menu-right" ngbDropdown>
<a class="nav-link dropdown-toggle" id="dropdown01" ngbDropdownToggle>{{ lang }}</a> <a class="nav-link dropdown-toggle" id="navbarLangDropdown" ngbDropdownToggle>{{ lang }}</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown01" ngbDropdownMenu> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarLangDropdown" ngbDropdownMenu>
<a class="dropdown-item" href="#" *ngFor="let l of langs">{{ l.name }}</a> <a class="dropdown-item" href="#" *ngFor="let l of langs">{{ l.name }}</a>
</div> </div>
</li> </li>
<li *ngIf="api.user.isLogged" class="nav-item dropdown dropdown-menu-right" ngbDropdown>
<a class="nav-link dropdown-toggle" id="navbarUserDropdown" ngbDropdownToggle>{{ api.user.user }}</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarUserDropdown" ngbDropdownMenu>
<a class="dropdown-item" href="#"><uds-translate>Preferences</uds-translate></a>
<a class="dropdown-item" href="#"><uds-translate>Dashboard</uds-translate></a>
<a class="dropdown-item" href="#"><uds-translate>Downloads</uds-translate></a>
<a class="dropdown-item" href="{{ api.urls.logout }}"><uds-translate>Logout</uds-translate></a>
</div>
</li>
</ul> </ul>
</div> </div>
</nav> </nav>

View File

@ -12,10 +12,11 @@ export class NavbarComponent implements OnInit {
langs: Lang[]; // Available languages langs: Lang[]; // Available languages
isNavbarCollapsed = true; isNavbarCollapsed = true;
constructor(api: UdsApiService) { constructor(public api: UdsApiService) {
const lang = api.getCurrentLanguage(); const lang = api.currentLanguage;
// Add "non current lang" to list
this.langs = []; this.langs = [];
for (const l of api.getAvailableLanguages()) { for (const l of api.availableLanguages) {
if (l.id === lang) { if (l.id === lang) {
this.lang = l.name; this.lang = l.name;
} else { } else {

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { UdsApiService, Plugin } from '../uds-api.service'; import { UdsApiService, Downloadable } from '../uds-api.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
@Component({ @Component({
@ -13,7 +13,8 @@ export class ServicesComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
if (this.api.userLoggedIn() === false) { // Redirect, if not logged in, to login screen
if (!this.api.user.isLogged) {
this.router.navigate(['login']); this.router.navigate(['login']);
} }
} }

View File

@ -2,34 +2,67 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
export interface Lang { export interface Lang {
id: string; readonly id: string;
name: string; readonly name: string;
} }
export interface Plugin { export interface Downloadable {
url: string; readonly url: string;
description: string; readonly description: string;
os: string; readonly name: string;
}
export interface Profile {
readonly user: string;
readonly role: string;
}
// User related
export class User {
readonly user: string;
readonly role: string;
constructor(profile: Profile) {
this.user = profile.user;
this.role = profile.role;
}
get isStaff(): boolean {
return this.role === 'staff';
}
get isLogged(): boolean {
return this.user != null;
}
}
// URLs related
export interface UDSUrls {
readonly lang: string;
readonly logout: string;
} }
@Injectable() @Injectable()
export class UdsApiService { export class UdsApiService {
readonly user: User;
constructor(private http: HttpClient) { } constructor(private http: HttpClient) {
this.user = new User(udsData.profile);
}
getCurrentLanguage(): string { get currentLanguage(): string {
return udsData.config.language; return udsData.config.language;
} }
getAvailableLanguages(): Lang[] { get availableLanguages(): Lang[] {
return udsData.config.available_languages; return udsData.config.available_languages;
} }
getPlugins(): Plugin[] { get plugins(): Downloadable[] {
return udsData.plugins; return udsData.plugins;
} }
userLoggedIn(): boolean { get urls(): UDSUrls {
return udsData.profile.user != null; return udsData.config.urls;
} }
} }