Skip to content
Snippets Groups Projects
Commit d4598d47 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #0000 TIME 4 onlyoffice some tests

parent 4c6929ff
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ $app->add(function (\Slim\Http\Request $request, \Slim\Http\Response $response,
$route = $request->getAttribute('route');
$currentMethod = empty($route) ? '' : $route->getMethods()[0];
$currentRoute = empty($route) ? '' : $route->getPattern();
if (!in_array($currentMethod.$currentRoute, $routesWithoutAuthentication) && preg_match('/POST\/test*/', $currentMethod.$currentRoute) == 0) {
if (!in_array($currentMethod.$currentRoute, $routesWithoutAuthentication)) {
$login = \SrcCore\controllers\AuthenticationController::authentication();
if (!empty($login)) {
\SrcCore\controllers\CoreController::setGlobals(['login' => $login]);
......
......@@ -383,22 +383,26 @@ class JnlpController
public static function test(Request $request, Response $response)
{
if (($body_stream = file_get_contents("php://input"))===false) {
echo "Bad Request";
}
$data = json_decode($body_stream, true);
if ($data["status"] == 2) {
if ($data["status"] == 2 || $data["status"] == 6) {
$downloadUri = $data["url"];
if (($new_data = file_get_contents($downloadUri))===false) {
echo "Bad Response";
} else {
echo $new_data;
$tmpPath = CoreConfigModel::getTmpPath();
$fileOnTmp = "tmp_file_onlyoffice_{$data["key"]}.odt";
file_put_contents($tmpPath.$fileOnTmp, $new_data, LOCK_EX);
// echo $new_data;
//file_put_contents($path_for_save, $new_data, LOCK_EX);
}
}
return $response->withJson(['error' => 0]);
}
}
......@@ -33,59 +33,59 @@ export class EcplOnlyofficeViewerComponent implements OnInit, AfterViewInit {
docEditor: any;
showModalWindow: boolean = false;
@HostListener('window:message',['$event'])
@HostListener('window:message', ['$event'])
onMessage(e: any) {
console.log(e);
const response = JSON.parse(e.data);
if (response.event === 'onDownloadAs') {
this.onDownloadAs(response.data);
this.saveDocument();
}
}
constructor(private zone: NgZone, public http: HttpClient) { }
constructor(private zone: NgZone, public http: HttpClient) { }
quit() {
this.docEditor.downloadAs();
//this.docEditor.destroyEditor();
}
onDocumentStateChange(event: any) {
if (event.data) {
console.log('The document changed');
console.log(event);
} else {
console.log('Changes are collected on document editing service');
saveDocument() {
const content = {
"c": "forcesave",
"key": "azerty4",
"userdata": "Bernard BLIER"
}
}
onDownloadAs(url: any) {
const optionRequete = {
headers: new HttpHeaders({
'Access-Control-Allow-Origin':'*',
})
};
this.http.get(url, optionRequete).pipe(
tap((data: any) => {
console.log(data);
}),
catchError((err: any) => {
console.log(err)
return of(false);
})
).subscribe();
params: content
};
this.http.post('http://10.2.95.76:8765/coauthoring/CommandService.ashx', {}, optionRequete).pipe().subscribe();
}
ngOnInit() { }
generateUniqueId(length: number = 5) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
ngAfterViewInit() {
this.editorConfig = {
documentType: 'text',
document: {
fileType: 'odt',
key: 'toto',
key: 'azerty4',
title: this.onlyofficeName,
url: `http://10.2.95.76/rep_standard.odt`,
url: `http://cchaplin:maarch@10.2.95.76/maarch_courrier_develop/rest/resources/1660/originalContent`,
permissions: {
comment: false,
download: true,
......@@ -95,7 +95,7 @@ export class EcplOnlyofficeViewerComponent implements OnInit, AfterViewInit {
}
},
editorConfig: {
callbackUrl: 'http://10.2.95.76/maarch_courrier_develop/rest/test',
callbackUrl: 'http://cchaplin:maarch@10.2.95.76/maarch_courrier_develop/rest/test',
lang: 'fr-FR',
mode: 'edit',
customization: {
......@@ -103,7 +103,7 @@ export class EcplOnlyofficeViewerComponent implements OnInit, AfterViewInit {
comments: false,
compactToolbar: false,
feedback: false,
forcesave: false,
forcesave: true,
goback: false,
hideRightMenu: true,
showReviewChanges: false,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment