mirror of
https://github.com/dkmstr/openuds-gui.git
synced 2025-01-03 05:17:36 +03:00
added downloads page (actors mainly)
This commit is contained in:
parent
640352cdf5
commit
4345b7cbed
@ -33,6 +33,7 @@ import { ServicesGroupComponent } from './gui/components/services-group/services
|
||||
import { ModalComponent } from './gui/modal/modal.component';
|
||||
import { SafeHtmlPipe } from './gui/safe-html.pipe';
|
||||
import { AboutComponent } from './pages/about/about.component';
|
||||
import { DownloadsComponent } from './pages/downloads/downloads.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
@ -50,6 +51,7 @@ import { AboutComponent } from './pages/about/about.component';
|
||||
FooterComponent,
|
||||
ErrorComponent,
|
||||
AboutComponent,
|
||||
DownloadsComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -9,7 +9,7 @@
|
||||
</mat-menu>
|
||||
|
||||
<mat-menu #actions>
|
||||
<button mat-menu-item *ngIf="service.allow_users_remove" (click)="action('remove')">
|
||||
<button mat-menu-item *ngIf="service.allow_users_remove" (click)="action('release')">
|
||||
<i class="material-icons">delete</i>
|
||||
<uds-translate> Release service</uds-translate>
|
||||
</button>
|
||||
@ -20,7 +20,7 @@
|
||||
</mat-menu>
|
||||
|
||||
<mat-menu #menu>
|
||||
<button mat-menu-item [matMenuTriggerFor]="transports" *ngIf="hasManyTransports()">
|
||||
<button mat-menu-item [matMenuTriggerFor]="transports" *ngIf="showTransportsMenu()">
|
||||
<uds-translate>Transports</uds-translate>
|
||||
</button>
|
||||
<button mat-menu-item [matMenuTriggerFor]="actions" *ngIf="hasActions()">
|
||||
|
@ -49,6 +49,8 @@ export class ServiceComponent implements OnInit {
|
||||
klass.push('maintenance');
|
||||
} else if (this.service.not_accesible) {
|
||||
klass.push('forbidden');
|
||||
} else if (this.service.in_use) {
|
||||
klass.push('inuse');
|
||||
}
|
||||
if (klass.length > 1) {
|
||||
klass.push('alert');
|
||||
@ -65,14 +67,14 @@ export class ServiceComponent implements OnInit {
|
||||
return this.service.allow_users_remove || this.service.allow_users_reset;
|
||||
}
|
||||
|
||||
hasManyTransports() {
|
||||
return this.service.transports.length > 1;
|
||||
showTransportsMenu() {
|
||||
return this.service.transports.length > 1 && this.service.show_transports;
|
||||
}
|
||||
|
||||
hasMenu() {
|
||||
return this.service.maintenance === false &&
|
||||
this.service.not_accesible === false &&
|
||||
(this.hasActions() || this.hasManyTransports())
|
||||
(this.hasActions() || this.showTransportsMenu())
|
||||
;
|
||||
}
|
||||
|
||||
@ -91,7 +93,7 @@ export class ServiceComponent implements OnInit {
|
||||
'</p>'
|
||||
);
|
||||
} else {
|
||||
if (transport === null) {
|
||||
if (transport === null || this.service.show_transports === false) {
|
||||
transport = this.service.transports[0];
|
||||
}
|
||||
this.api.launchURL(transport.link);
|
||||
@ -99,38 +101,23 @@ export class ServiceComponent implements OnInit {
|
||||
}
|
||||
|
||||
action(type: string) {
|
||||
if (type === 'remove') {
|
||||
this.api.gui.yesno(
|
||||
django.gettext('Release service: ') + this.serviceName,
|
||||
django.gettext('Are you sure?'
|
||||
)).subscribe((val: boolean) => {
|
||||
if (val) {
|
||||
console.log('Releasing service');
|
||||
this.api.releaser(this.service.id).subscribe((service) => {
|
||||
this.api.gui.alert(
|
||||
django.gettext('Release service: ') + this.serviceName,
|
||||
django.gettext('Service released')
|
||||
);
|
||||
console.log(service);
|
||||
});
|
||||
const title = type === 'release' ? django.gettext('Release service: ') : django.gettext('Reset service: ') + this.serviceName;
|
||||
const action = type === 'release' ? django.gettext('Service released') : django.gettext('Service reseted');
|
||||
this.api.gui.yesno(
|
||||
title,
|
||||
django.gettext('Are you sure?')
|
||||
).subscribe((val) => {
|
||||
if (val) {
|
||||
this.api.action(type, this.service.id).subscribe((service) => {
|
||||
if (service) {
|
||||
this.api.gui.alert(
|
||||
title,
|
||||
action
|
||||
);
|
||||
}
|
||||
});
|
||||
} else { // 'reset'
|
||||
this.api.gui.yesno(
|
||||
django.gettext('Reset service: ') + this.serviceName,
|
||||
django.gettext('Are you sure?')
|
||||
).subscribe((val: boolean) => {
|
||||
if (val) {
|
||||
console.log('Reseting service');
|
||||
this.api.resetter(this.service.id).subscribe((service) => {
|
||||
this.api.gui.alert(
|
||||
django.gettext('Reset service: ') + this.serviceName,
|
||||
django.gettext('Service Reset')
|
||||
);
|
||||
console.log(service);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { LoginComponent } from '../pages/login/login.component';
|
||||
import { ClientDownloadComponent } from '../pages/client-download/client-download.component';
|
||||
import { DownloadsComponent } from '../pages/downloads/downloads.component';
|
||||
import { ServicesComponent } from '../pages/services/services.component';
|
||||
import { ErrorComponent } from '../pages/error/error.component';
|
||||
import { AboutComponent } from '../pages/about/about.component';
|
||||
@ -15,6 +16,8 @@ const routes: Routes = [
|
||||
{ path: 'login/:id', component: LoginComponent },
|
||||
|
||||
{ path: 'client-download', component: ClientDownloadComponent },
|
||||
{ path: 'downloads', component: DownloadsComponent },
|
||||
|
||||
{ path: 'error/:id', component: ErrorComponent },
|
||||
{ path: 'about', component: AboutComponent },
|
||||
|
||||
|
48
src/app/pages/downloads/downloads.component.css
Normal file
48
src/app/pages/downloads/downloads.component.css
Normal file
@ -0,0 +1,48 @@
|
||||
.actors-container {
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
margin: 0 2%;
|
||||
}
|
||||
|
||||
.banner {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.banner-text h1 {
|
||||
font-size: 2em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.actors {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
justify-content: space-around;
|
||||
align-content: center;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.actor {
|
||||
border: 1px solid;
|
||||
margin-top: 1rem;
|
||||
padding: 1em;
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 1rem 2rem rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
|
||||
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
|
||||
flex: 1 0 34%;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.actor:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: 0 0.1rem 0.2rem rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 1.5em;
|
||||
margin-bottom: 1em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.description {
|
||||
}
|
20
src/app/pages/downloads/downloads.component.html
Normal file
20
src/app/pages/downloads/downloads.component.html
Normal file
@ -0,0 +1,20 @@
|
||||
<div class="actors-container">
|
||||
|
||||
<div class="banner">
|
||||
<div class="banner-text">
|
||||
<h1>
|
||||
<uds-translate>Downloads</uds-translate>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="actors">
|
||||
<div class="actor" *ngFor="let p of api.actors" (click)="download(p.url)">
|
||||
<div class="name" [innerHTML]="p.name | safeHtml">
|
||||
</div>
|
||||
<div class="description" [innerHTML]="p.description | safeHtml ">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
24
src/app/pages/downloads/downloads.component.ts
Normal file
24
src/app/pages/downloads/downloads.component.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { UDSApiService } from '../../uds-api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'uds-downloads',
|
||||
templateUrl: './downloads.component.html',
|
||||
styleUrls: ['./downloads.component.css']
|
||||
})
|
||||
export class DownloadsComponent implements OnInit {
|
||||
|
||||
constructor(public api: UDSApiService) { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
download(url: string) {
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
img(image: string) {
|
||||
return this.api.staticURL( 'modern/img/' + image + '.png');
|
||||
}
|
||||
|
||||
}
|
@ -23,8 +23,7 @@ export interface UDSUrls {
|
||||
readonly services: string;
|
||||
readonly admin: string;
|
||||
readonly enabler: string;
|
||||
readonly resetter: string;
|
||||
readonly releaser: string;
|
||||
readonly action: string;
|
||||
readonly galleryImage: string;
|
||||
readonly transportIcon: string;
|
||||
}
|
||||
@ -39,7 +38,6 @@ export interface UDSConfig {
|
||||
readonly csrf_field: string;
|
||||
readonly csrf: string;
|
||||
readonly urls: UDSUrls;
|
||||
readonly bypassPluginDetection: boolean;
|
||||
}
|
||||
|
||||
export interface Downloadable {
|
||||
|
@ -16,22 +16,22 @@ export interface JSONTransport {
|
||||
}
|
||||
|
||||
export interface JSONService {
|
||||
allow_users_remove: boolean;
|
||||
allow_users_reset: boolean;
|
||||
id: string;
|
||||
comments: string;
|
||||
description: string;
|
||||
group: JSONGroup;
|
||||
id: string;
|
||||
imageId: string;
|
||||
is_use: boolean;
|
||||
maintenance: boolean;
|
||||
name: string;
|
||||
visual_name: string;
|
||||
not_accesible: boolean;
|
||||
show_transports: boolean;
|
||||
allow_users_remove: boolean;
|
||||
allow_users_reset: boolean;
|
||||
to_be_replaced: boolean;
|
||||
to_be_replaced_text: string;
|
||||
in_use: boolean;
|
||||
transports: JSONTransport[];
|
||||
visual_name: string;
|
||||
}
|
||||
|
||||
export interface JSONServicesInformation {
|
||||
|
@ -35,6 +35,13 @@ export class UDSApiService {
|
||||
return udsData.plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets actors list
|
||||
*/
|
||||
get actors(): Downloadable[] {
|
||||
return udsData.actors;
|
||||
}
|
||||
|
||||
/* Client enabler */
|
||||
enabler(serviceId: string, transportId: string) {
|
||||
const enabler = this.config.urls.enabler.replace('param1', serviceId).replace('param2', transportId);
|
||||
@ -42,15 +49,9 @@ export class UDSApiService {
|
||||
}
|
||||
|
||||
/* Services resetter */
|
||||
resetter(serviceId: string) {
|
||||
const resetter = this.config.urls.resetter.replace('param1', serviceId);
|
||||
return this.http.get<JSONService>(resetter);
|
||||
}
|
||||
|
||||
/* Services resetter */
|
||||
releaser(serviceId: string) {
|
||||
const releaser = this.config.urls.resetter.replace('param1', serviceId);
|
||||
return this.http.get<JSONService>(releaser);
|
||||
action(action: string, serviceId: string) {
|
||||
const actionURL = this.config.urls.action.replace('param1', serviceId).replace('param2', action);
|
||||
return this.http.get<JSONService>(actionURL);
|
||||
}
|
||||
|
||||
/* Images & static related */
|
||||
|
Loading…
Reference in New Issue
Block a user