Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
271 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Godbout\Alfred\Time\Menus\Everhour; | ||
|
||
use Godbout\Alfred\Workflow\Icon; | ||
use Godbout\Alfred\Workflow\Item; | ||
use Godbout\Alfred\Time\Menus\Menu; | ||
use Godbout\Alfred\Workflow\ScriptFilter; | ||
|
||
class SetupApikey extends Menu | ||
{ | ||
public static function scriptFilter() | ||
{ | ||
ScriptFilter::add( | ||
self::apikey(), | ||
self::back() | ||
); | ||
} | ||
|
||
private static function apikey() | ||
{ | ||
global $argv; | ||
|
||
return Item::create() | ||
->title('Enter your API token above') | ||
->subtitle('Save ' . self::userInput()) | ||
->arg('everhour_setup_apikey_save') | ||
->variable('everhour_apikey', self::userInput()) | ||
->icon(Icon::create('resources/icons/everhour.png')); | ||
} | ||
|
||
private static function back() | ||
{ | ||
return Item::create() | ||
->title('Back') | ||
->subtitle('Go back to Everhour options') | ||
->arg('everhour_setup') | ||
->icon(Icon::create('resources/icons/everhour.png')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Godbout\Alfred\Time\Menus\Everhour; | ||
|
||
use Godbout\Alfred\Time\Workflow; | ||
use Godbout\Alfred\Workflow\Icon; | ||
use Godbout\Alfred\Workflow\Item; | ||
use Godbout\Alfred\Time\Menus\Menu; | ||
use Godbout\Alfred\Workflow\ScriptFilter; | ||
|
||
class SetupApikeySave extends Menu | ||
{ | ||
public static function scriptFilter() | ||
{ | ||
self::saveApikey(); | ||
|
||
ScriptFilter::add( | ||
self::apikeySaved(), | ||
self::back() | ||
); | ||
} | ||
|
||
private static function saveApikey() | ||
{ | ||
Workflow::getConfig()->write('everhour.api_token', getenv('everhour_apikey')); | ||
} | ||
|
||
private static function apikeySaved() | ||
{ | ||
return Item::create() | ||
->title('API KEY SAVED!') | ||
->subtitle('You can just press Enter.') | ||
->icon(Icon::create('resources/icons/everhour.png')) | ||
->arg('do') | ||
->variable('timer_action', 'exit'); | ||
} | ||
|
||
private static function back() | ||
{ | ||
return Item::create() | ||
->title('Back') | ||
->subtitle('Go back to Everhour Setup') | ||
->arg('everhour_setup') | ||
->icon(Icon::create('resources/icons/everhour.png')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Godbout\Alfred\Time\Menus\Everhour; | ||
|
||
use Godbout\Alfred\Time\Workflow; | ||
use Godbout\Alfred\Workflow\Icon; | ||
use Godbout\Alfred\Workflow\Item; | ||
use Godbout\Alfred\Time\Menus\Menu; | ||
use Godbout\Alfred\Workflow\ScriptFilter; | ||
|
||
class SetupState extends Menu | ||
{ | ||
public static function scriptFilter() | ||
{ | ||
self::saveState(); | ||
|
||
ScriptFilter::add( | ||
self::stateSaved(), | ||
self::back() | ||
); | ||
} | ||
|
||
private static function saveState() | ||
{ | ||
Workflow::disableAllServices(); | ||
|
||
self::toEnable() ? Workflow::enableService('everhour') : Workflow::disableService('everhour'); | ||
} | ||
|
||
private static function stateSaved() | ||
{ | ||
return Item::create() | ||
->title(self::stateTitle()) | ||
->subtitle(self::stateSubtitle()) | ||
->icon(Icon::create('resources/icons/everhour.png')) | ||
->arg('do') | ||
->variable('timer_action', 'exit'); | ||
} | ||
|
||
private static function stateTitle() | ||
{ | ||
return 'Everhour ' . (self::toEnable() ? 'ENABLED!' : 'DISABLED!'); | ||
} | ||
|
||
protected static function stateSubtitle() | ||
{ | ||
return (self::toEnable() ? 'Other services disabled. ' : '') . 'You may press enter to quit the workflow'; | ||
} | ||
|
||
private static function back() | ||
{ | ||
return Item::create() | ||
->title('Back') | ||
->subtitle('Go back to Everhour options') | ||
->arg('everhour_setup') | ||
->icon(Icon::create('resources/icons/everhour.png')); | ||
} | ||
|
||
protected static function toEnable() | ||
{ | ||
return getenv('everhour_enabled') === 'true'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters