/** * @param $config SliceConfig * @return Form */ public function _createSliceConfigUploadForm($config) { $form = new Form('upload'); //load up our engines. if (User::isAdmin()) { $engines = SliceEngine::getAllEngines()->getAll(); } else { $engines = SliceEngine::getPublicEngines()->getAll(); } $engs = array(); foreach ($engines as $row) { /* @var $e SliceEngine */ $e = $row['SliceEngine']; $engs[$e->id] = $e->getName(); } $form->add(SelectField::name('engine_id')->label('Slice Engine')->help('Which slicing engine does this config use?')->required(true)->value($config->get('engine_id'))->options($engs)); $form->add(TextField::name('config_name')->label('Config Name')->help('What is the name of this slicing configuration.')->required(true)->value($config->get('config_name'))); if ($config->isHydrated()) { $form->add(CheckboxField::name('expire_slicejobs')->label('Expire Old Slice Jobs')->help('If checked, old slice jobs will be expired and never re-used.')->value(1)); } $form->add(UploadField::name('config_file')->label('Configuration File')->help('The configuration file to use (.ini for Slic3r)')->required(true)); return $form; }
/** * @param $bot Bot is the selected bot * @return form Form the form we return */ private function _createDriverForm($bot) { //load up our apps. $authorized = User::$me->getAuthorizedApps()->getAll(); $apps[0] = "None"; foreach ($authorized as $row) { /* @var $e OAuthToken */ $e = $row['OAuthToken']; $apps[$e->id] = $e->getName(); } // load up our drivers $drivers = array('printcore' => 'RepRap Serial Driver', 'dummy' => 'Dummy Driver', 's3g' => 'Makerbot Driver (Experimental)'); $form = new Form('driver'); $form->action = $bot->getUrl() . "/edit"; $form->add(DisplayField::name('title')->label('')->value("<h2>Driver Configuration</h2>")); $form->add(SelectField::name('oauth_token_id')->id('oauth_token_dropdown')->label('Computer')->help('Which computer is this bot connected to? <a href="/apps">Full list in the apps area.</a>')->value($bot->get('oauth_token_id'))->options($apps)->onchange('update_driver_form(this)')); $form->add(SelectField::name('driver_name')->id('driver_name_dropdown')->label('Driver Name')->help('Which driver to use? <a href="/help">More info available in the help area.</a>')->required(true)->value($bot->get('driver_name'))->options($drivers)->onchange('update_driver_form(this)')); // $driver_form = Controller::byName('bot')->renderView('driver_form', array( // 'bot_id' => $bot->id, // 'driver' => $bot->get('driver_name'), // 'token_id' => $bot->get('oauth_token_id') // )); $form->add(RawField::name("driver_edit_area")->value('<div id="driver_edit_area"></div>')); return $form; }
/** * @param $bot Bot is the selected bot * @return form Form the form we return */ private function _createDriverForm($bot) { $form = new Form('driver'); $form->action = $bot->getUrl() . "/edit"; switch ($bot->getStatus()) { case BotState::Idle: case BotState::Offline: case BotState::Error: case BotState::Waiting: break; // We're okay to edit with these states // We're okay to edit with these states default: $form->add(ErrorField::name('error')->value("The bot must be in an idle, offline, error, or waiting state in order to edit the driver config.")); return $form; } //load up our apps. $authorized = User::$me->getAuthorizedApps()->getAll(); $apps[0] = "None"; foreach ($authorized as $row) { /* @var $e OAuthToken */ $e = $row['OAuthToken']; $apps[$e->id] = $e->getName(); } // load up our drivers $drivers = array('printcore' => 'RepRap Serial Driver', 'dummy' => 'Dummy Driver', 's3g' => 'Makerbot Driver (Experimental)'); $form->add(DisplayField::name('title')->label('')->value("<h2>Driver Configuration</h2>")); $form->add(SelectField::name('oauth_token_id')->id('oauth_token_dropdown')->label('Computer')->help('Which computer is this bot connected to? <a href="/apps">Full list in the apps area.</a>')->value($bot->get('oauth_token_id'))->options($apps)->onchange('update_driver_form(this)')); $form->add(SelectField::name('driver_name')->id('driver_name_dropdown')->label('Driver Name')->help('Which driver to use? <a href="/help">More info available in the help area.</a>')->required(true)->value($bot->get('driver_name'))->options($drivers)->onchange('update_driver_form(this)')); $form->add(RawField::name("driver_edit_area")->value('<div id="driver_edit_area"></div>')); return $form; }
/** * @param $file StorageInterface * @param $queue_id int * @return Form */ private function _createJobForm($file, $queue_id) { //load up our queues. $queues = User::$me->getQueues()->getAll(); $qs = array(); foreach ($queues as $row) { /* @var $q Queue */ $q = $row['Queue']; $qs[$q->id] = $q->getName(); } $form = new Form(); $form->add(DisplayField::name('file_name')->label('File')->help('The file that will be printed.')->value($file->getLink())); $form->add(SelectField::name('queue_id')->label('Queue')->help('Which queue are you adding this job to?')->required(true)->options($qs)->value($queue_id)); $form->add(TextField::name('quantity')->label('Quantity')->help('How many copies? Minimum 1, Maximum 100')->required(true)->value(1)); $form->add(CheckboxField::name('priority')->label('Is this a priority job?')->help('Check this box to push this job to the top of the queue')->checked(false)); return $form; }