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