Exemple #1
0
 /**
  * @param User $user
  * @return Form
  */
 private function _createProfileEditForm($user)
 {
     $form = new Form();
     $form->add(DisplayField::name('username')->label("Username")->value($user->get('username')));
     $form->add(EmailField::name('email')->label("Email")->value($user->get('email'))->required(true));
     if (User::$me->isAdmin()) {
         $form->add(CheckboxField::name('admin')->label("Is admin?")->help("Is this user an admin?")->checked($user->isAdmin()));
     }
     // todo add DateField
     /**
     $form->add(
     	DateField::name('birthday')
     		->label("Birthday")
     		->value($user->get('birthday'))
     );
     */
     $password_page = $user->getUrl() . "/changepass";
     $form->add(DisplayField::name('changepass')->label("Change Password")->value("Please visit the <a href=\"{$password_page}\">change password</a> page."));
     return $form;
 }
Exemple #2
0
 /**
  * @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;
 }
Exemple #3
0
 /**
  * @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;
 }
Exemple #4
0
 public function _createRegisterForm()
 {
     $form = new Form('register');
     if (!$this->args('username')) {
         $username = '';
     } else {
         $username = $this->args('username');
     }
     if (!$this->args('email')) {
         $email = '';
     } else {
         $email = $this->args('email');
     }
     $form->add(TextField::name('username')->label("Username")->value($username)->required(true));
     $form->add(EmailField::name('email')->label("Email address")->value($email)->required(true));
     $form->add(PasswordField::name('pass1')->label("Password")->required(true));
     $form->add(PasswordField::name('pass2')->label("Password Confirmation")->required(true));
     $tos = "By clicking on the \"Create your account\" button below, you certify that you have read and agree to our ";
     $tos .= "<a href=\"/tos\">Terms of use</a>";
     $tos .= " and ";
     $tos .= "<a href=\"/privacy\">Privacy Policy</a>.";
     $form->add(DisplayField::name('tos')->value($tos));
     $form->setSubmitText("Create your account");
     $form->setSubmitClass("btn btn-success btn-large");
     return $form;
 }
Exemple #5
0
 /**
  * @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;
 }