Skip to content

Commit

Permalink
update api for use uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Weber committed Nov 15, 2018
1 parent d73d312 commit 3d36f65
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 125 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ script:
# compilation du projet
- npm run build
# récuperation de elfinder
- curl -o elfinder.zip https://codeload.github.com/Studio-42/elFinder/zip/2.1.42
- curl -o elfinder.zip https://codeload.github.com/Studio-42/elFinder/zip/2.1.23
- mkdir elfinder
- unzip -d elfinder elfinder.zip
- mv elfinder/elFinder-2.1.42 elfinder/elfinder
- mv elfinder/elFinder-2.1.23 elfinder/elfinder
# on construit une release
- mkdir release
- cp -r elfinder/elfinder release/
Expand Down
4 changes: 1 addition & 3 deletions api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
$session = &\OMV\Session::getInstance();
$session->start();

if ($session->isAuthenticated() && !$session->isTimeout()) {
if ($session->isAuthenticated() && !$session->isTimeout() && file_exists("./webdesk_config.js")) {
require("./index.html");
echo "<script> WEBDESK_CONFIG['username'] = '".$session->getUsername()."'; </script>";
}
else{

require("./login/login.php");
}
exit;
Expand Down
15 changes: 8 additions & 7 deletions api/login/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}

//construction de la config
$str = buildConfig($context);
$str = buildConfig($context,$session);
file_put_contents('/etc/webdesk/webdesk_config.js',$str);

}
Expand All @@ -68,11 +68,12 @@
Construction de la config
*/

function buildConfig($context) {
function buildConfig($context,$session) {
return 'WEBDESK_CONFIG = {
"iconWidth": 100,
"username": "'.$session->getUsername().'",
"navbar" : '.buildNavBar($context).',
"dock" : '.buildDock($context).'
"dock" : '.buildDock($context,$session).'
}';
};

Expand Down Expand Up @@ -113,7 +114,7 @@ function buildNavBar($context) {
]';
};

function buildDock($context) {
function buildDock($context,$session) {
$links = \OMV\Rpc\Rpc::call("WebDesk", "getLinkList", [], $context , \OMV\Rpc\Rpc::MODE_REMOTE, TRUE);

$prep = [];
Expand All @@ -130,7 +131,7 @@ function buildDock($context) {
return json_encode([
"default" => [
[
"id" => "about",
"uuid" => "about",
"image"=> "/assets/flatjoy-circle-deviantart/Apple.png",
"title"=> "Présentation",
"text"=> "Bienvenue, sur l\'interface de gestion de Bureau virtuel. N\'oubliez pas de changer les url d\'iframe et de configurer vos propres icones",
Expand All @@ -139,13 +140,13 @@ function buildDock($context) {
"ref"=> null
],
[
"id"=> "elfinder",
"uuid"=> "elfinder",
"image"=> "/assets/flatjoy-circle-deviantart/Folder%20Files.png",
"iframe"=> "/elfinder/elfinder.html",
"title"=> "Finder"
]
],
$_POST['username'] => $prep
$session->getUsername() => $prep
], JSON_PRETTY_PRINT );

/*return '{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"ng": "ng",
"start": "ng serve --port=4300",
"build": "ng build --prod && cp -r api/* dist/ && rm -rf cp -r ./openmediavault-webdesk/etc/webdesk/* && cp -r ./elfinder-dist ./openmediavault-webdesk/etc/webdesk/elfinder && cp -r ./dist/* ./openmediavault-webdesk/etc/webdesk",
"build": "ng build --prod && cp -r api/* dist/ && rm -rf ./openmediavault-webdesk/etc/webdesk/* && cp -r ./elfinder-dist ./openmediavault-webdesk/etc/webdesk/elfinder && cp -r ./dist/* ./openmediavault-webdesk/etc/webdesk",
"compress" : "cd ./openmediavault-webdesk/etc/webdesk && tar czvf * dist-omv-web-desk.tar.gz",
"test": "ng test",
"lint": "ng lint",
Expand Down
2 changes: 1 addition & 1 deletion src/app/_models/dock-item.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MixinObject } from './mixin';

export class DockItem extends MixinObject {
public id = '';
public uuid = '';
public image = '';
public iframe = '';
public title = '';
Expand Down
2 changes: 1 addition & 1 deletion src/app/_widgets/dock/dock.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="dock" #dockdiv >
<ng-container *ngFor="let item of winlist; let i = index;">
<img src="{{item.image}}" [width]="iconWidth/2" (click)="dockSelect(item.id)" title="{{item.title}}"/>
<img src="{{item.image}}" [width]="iconWidth/2" (click)="dockSelect(item.uuid)" title="{{item.title}}"/>
</ng-container>
</div>
8 changes: 4 additions & 4 deletions src/app/_widgets/dock/dock.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class DockComponent implements OnInit {
private dockSelect(id) {
// get win param by id
const win = this.winlist.filter( (wind) => {
return (wind.id === id);
return (wind.uuid === id);
})[0];

// verify if not duplicated
Expand All @@ -62,22 +62,22 @@ export class DockComponent implements OnInit {

// on laisse passé un timeout, pour avoir le temps de construire le dom
setTimeout(( scope) => {
const cur_win = scope._wm.createWindowFromQuery('#' + win.id, {
const cur_win = scope._wm.createWindowFromQuery('#' + win.uuid, {
title: win.title,
width: 250,
height: 280,
x: scope.x_pos,
y: scope.y_pos,
events: {
closed: () => {
console.log('closed sur ' + win.id);
console.log('closed sur ' + win.uuid);
win.ref = null;
win.opened = false;
win.selected = false;
cur_win.destroy();
},
focus: () => {
console.log('focus sur ' + win.id);
console.log('focus sur ' + win.uuid);
scope.winlist.forEach((autre) => {
autre.selected = false;
});
Expand Down
4 changes: 2 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<ng-container *ngFor="let item of winlist; let i = index;">

<ng-container *ngIf="item.iframe">
<div [hidden]="!item.opened" [id]="item.id" class="intrinsic-container" (resize)="winresize()">
<div [hidden]="!item.opened" [id]="item.uuid" class="intrinsic-container" (resize)="winresize()">
<iframe [src]="item.iframe | safe" allowfullscreen></iframe>
</div>
</ng-container>

<ng-container *ngIf="!item.iframe">
<div [hidden]="!item.opened" [id]="item.id" class="mywin {{item.id}}">{{item.text}}</div>
<div [hidden]="!item.opened" [id]="item.uuid" class="mywin {{item.uuid}}">{{item.text}}</div>
</ng-container>

</ng-container>
Expand Down
25 changes: 9 additions & 16 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { DockComponent } from './_widgets/dock/dock.component';
import { WindowService } from './_services/window.service';
import { NavbarItem, NavbarSubItem} from './_models/navbar-item';
import { DockItem } from './_models/dock-item';
Expand All @@ -20,16 +19,15 @@ export class AppComponent implements OnInit {

constructor(private _wm: WindowService ) {
// recupere la conf pour le user
if ( WEBDESK_CONFIG['username'] ) {
const user = WEBDESK_CONFIG['username'];
if ( WEBDESK_CONFIG['dock'][user] ) {
this.dock_conf = WEBDESK_CONFIG['dock'][user];
}
}
// sinon conf par defaut
if ( !this.dock_conf ) {
this.dock_conf = WEBDESK_CONFIG['dock']['default'];
let user = 'default';
console.log(WEBDESK_CONFIG['username'],WEBDESK_CONFIG['dock']);
if ( WEBDESK_CONFIG['username'] && typeof WEBDESK_CONFIG['dock'][user] !== 'undefined') {
user = WEBDESK_CONFIG['username'];
}
console.log('user courant : ', user);

//Récupération de la conf
this.dock_conf = WEBDESK_CONFIG['dock'][user];

this.dock_conf.forEach( (win) => {
this.winlist.push(new DockItem(win));
Expand All @@ -42,12 +40,7 @@ export class AppComponent implements OnInit {
this.iconWidth = WEBDESK_CONFIG['iconWidth'];
}

public ngOnInit() {


}


public ngOnInit() {}

private toggleExpose() {
this._wm.toggleExpose();
Expand Down
88 changes: 0 additions & 88 deletions src/webdesk_config.js

This file was deleted.

0 comments on commit 3d36f65

Please sign in to comment.