Test
This commit is contained in:
parent
c206e0204d
commit
a25ace59fe
2 changed files with 599 additions and 626 deletions
|
@ -67,7 +67,7 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
|||
|
||||
|
||||
var result = $http.post('../server/index.php',
|
||||
$.param({"token": Identity.getToken(), "task": "image", 'action': 'updateImage', 'id': image.id, 'opt': {'name': image.name,'protected':image.protected, 'visibility':image.visibility}}));
|
||||
$.param({"token": Identity.getToken(), "task": "image", 'action': 'updateImage', 'id': image.id, 'opt': {'name': image.name, 'visibility':image.visibility, 'protected':image.protected}}));
|
||||
|
||||
// Wait and handle the response
|
||||
result.then(function (response) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* File containing the Image Class.
|
||||
*
|
||||
|
@ -8,7 +9,6 @@
|
|||
* @author Evan Pisani 'yogg at epsina . com'
|
||||
*
|
||||
*/
|
||||
|
||||
use OpenCloud\Common\Error\BadResponseError;
|
||||
use OpenCloud\Common\Error\BaseError;
|
||||
use OpenCloud\Common\Error\NotImplementedError;
|
||||
|
@ -45,7 +45,6 @@ class image implements Core{
|
|||
$this->libClass = $app->getLibClass("Image");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute an action
|
||||
*
|
||||
|
@ -85,8 +84,7 @@ class image implements Core{
|
|||
}
|
||||
}
|
||||
$options['name'] = $opt['name'];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$this->app->setOutput("Error", "Missing parameter 'name' for the new image");
|
||||
}
|
||||
|
||||
|
@ -135,7 +133,6 @@ class image implements Core{
|
|||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
$this->app->setOutput("Images", $image);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,7 +160,6 @@ class image implements Core{
|
|||
}
|
||||
|
||||
$this->app->setOutput("Images", $result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,15 +174,13 @@ class image implements Core{
|
|||
|
||||
if (!isset($id)) {
|
||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
if ($image == null) { // if the image don't exists -> error
|
||||
$this->app->setOutput("Error", "Image doesn't exist");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$this->app->setOutput("Images", $image);
|
||||
}
|
||||
} catch (BadResponseError $e) {
|
||||
|
@ -211,18 +205,15 @@ class image implements Core{
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private function updateImage() {
|
||||
$id = $this->app->getPostParam("id");
|
||||
$opt = $this->app->getPostParam("opt");
|
||||
|
||||
if (!isset($id)) {
|
||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||
}
|
||||
else if(!isset($opt)){
|
||||
} else if (!isset($opt)) {
|
||||
$this->app->setOutput("Error", "Incorrect opt parameter");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
|
@ -243,7 +234,7 @@ class image implements Core{
|
|||
$options['minRam'] = $opt['minRam'];
|
||||
}
|
||||
if (isset($opt['protected'])) { // boolean
|
||||
$options['protected'] = $opt['protected'];
|
||||
$options['protected'] = $opt['protected'] == "true" ? true : false;
|
||||
}
|
||||
if (isset($opt['visibility'])) { // public, private
|
||||
$options['visibility'] = $opt['visibility'];
|
||||
|
@ -278,8 +269,7 @@ class image implements Core{
|
|||
$id = $this->app->getPostParam("id");
|
||||
if (!isset($id)) {
|
||||
$this->app->setOutput("Error", "Image doesn't exist");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
$image = $this->libClass->getImage($id);
|
||||
|
@ -313,9 +303,7 @@ class image implements Core{
|
|||
|
||||
if (!isset($id)) {
|
||||
$this->app->setOutput("Error", "Incorrect parameter");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
|
@ -350,9 +338,7 @@ class image implements Core{
|
|||
|
||||
if (!isset($id)) {
|
||||
$this->app->setOutput("Error", "Incorrect parameter");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
|
@ -390,11 +376,9 @@ class image implements Core{
|
|||
|
||||
if (!isset($id)) {
|
||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||
}
|
||||
else if(!isset($file_name)){
|
||||
} else if (!isset($file_name)) {
|
||||
$this->app->setOutput("Error", "Incorrect file name parameter");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
|
@ -429,8 +413,7 @@ class image implements Core{
|
|||
|
||||
if (!isset($id)) {
|
||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
|
@ -467,11 +450,9 @@ class image implements Core{
|
|||
|
||||
if (!isset($image_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||
}
|
||||
else if(!isset($member_id)){
|
||||
} else if (!isset($member_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
|
||||
|
@ -495,7 +476,6 @@ class image implements Core{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List members of an image
|
||||
*
|
||||
|
@ -509,11 +489,9 @@ class image implements Core{
|
|||
|
||||
if (!isset($image_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||
}
|
||||
else if(!isset($member_id)){
|
||||
} else if (!isset($member_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($image_id);
|
||||
|
@ -553,11 +531,9 @@ class image implements Core{
|
|||
|
||||
if (!isset($image_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||
}
|
||||
else if(!isset($member_id)){
|
||||
} else if (!isset($member_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
|
||||
|
@ -599,11 +575,9 @@ class image implements Core{
|
|||
|
||||
if (!isset($image_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||
}
|
||||
else if(!isset($member_id)){
|
||||
} else if (!isset($member_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
|
||||
|
@ -646,11 +620,9 @@ class image implements Core{
|
|||
|
||||
if (!isset($image_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||
}
|
||||
else if(!isset($member_id)){
|
||||
} else if (!isset($member_id)) {
|
||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
$service = $this->libClass;
|
||||
|
||||
|
@ -678,4 +650,5 @@ class image implements Core{
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Reference in a new issue