Skip to content

Commit

Permalink
Merge branch 'cc-2652-display-info-about-import' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
James authored and James committed Aug 8, 2011
2 parents 773f948 + 65a758c commit bfa2fa6
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 2 deletions.
4 changes: 3 additions & 1 deletion airtime_mvc/application/controllers/ApiController.php
Expand Up @@ -451,6 +451,9 @@ public function reloadMetadataAction() {
}
}

// update import timestamp
Application_Model_Preference::SetImportTimestamp();

if ($mode == "create") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = str_replace("\\", "", $filepath);
Expand Down Expand Up @@ -508,7 +511,6 @@ public function reloadMetadataAction() {
$file->delete();
}
}

$this->view->id = $file->getId();
}

Expand Down
10 changes: 10 additions & 0 deletions airtime_mvc/application/controllers/PreferenceController.php
Expand Up @@ -13,6 +13,7 @@ public function init()
->addActionContext('change-stor-directory', 'json')
->addActionContext('reload-watch-directory', 'json')
->addActionContext('remove-watch-directory', 'json')
->addActionContext('is-import-in-progress', 'json')
->initContext();
}

Expand Down Expand Up @@ -157,6 +158,15 @@ public function removeWatchDirectoryAction()
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
$this->view->subform = $watched_dirs_form->render();
}

public function isImportInProgressAction(){
$now = time();
$res = false;
if(Application_Model_Preference::GetImportTimestamp()+5 > $now){
$res = true;
}
die(json_encode($res));
}
}


Expand Down
9 changes: 9 additions & 0 deletions airtime_mvc/application/models/Preference.php
Expand Up @@ -356,5 +356,14 @@ public static function SetRemindMeDate($now){
public static function GetRemindMeDate(){
return Application_Model_Preference::GetValue("remindme");
}

public static function SetImportTimestamp(){
$now = time();
Application_Model_Preference::SetValue("import_timestamp", $now);
}

public static function GetImportTimestamp(){
return Application_Model_Preference::GetValue("import_timestamp");
}
}

16 changes: 16 additions & 0 deletions airtime_mvc/public/js/airtime/library/library.js
Expand Up @@ -55,6 +55,19 @@ function confirmDeletePlaylist(params){
}
}

function checkImportStatus(){
$.getJSON('/Preference/is-import-in-progress', function(data){
var div = $('#library_display_processing');
if(data == true){
div.html("Import is being processed");
div.css('visibility', 'visible');
}else{
div.css('visibility', 'hidden');
div.html("Processing...");
}
})
}

function deletePlaylist(json) {
if(json.message) {
alert(json.message);
Expand Down Expand Up @@ -172,4 +185,7 @@ $(document).ready(function() {
"sSearch": ""
}
}).fnSetFilteringDelay(350);

checkImportStatus()
setInterval( "checkImportStatus()", 2000 );
});
15 changes: 15 additions & 0 deletions install_minimal/include/AirtimeInstall.php
Expand Up @@ -293,6 +293,21 @@ public static function SetUniqueId()
}
return true;
}

public static function SetImportTimestamp()
{
global $CC_DBC;

$now = time();

$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '$now')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
return false;
}
return true;
}


public static function GetAirtimeVersion()
{
Expand Down
2 changes: 2 additions & 0 deletions install_minimal/include/airtime-db-install.php
Expand Up @@ -47,7 +47,9 @@
echo "* Setting Airtime version".PHP_EOL;
AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION);

// set up some keys in DB
AirtimeInstall::SetUniqueId();
AirtimeInstall::SetImportTimestamp();

if (AirtimeInstall::$databaseTablesCreated) {

Expand Down
32 changes: 32 additions & 0 deletions install_minimal/upgrades/airtime-1.9.0/airtime-upgrade.php
Expand Up @@ -352,6 +352,34 @@ public static function InsertCountryDataIntoDatabase(){
echo "* Inserting data into country table".PHP_EOL;
Airtime190Upgrade::execSqlQuery($sql);
}

public static function SetUniqueId()
{
global $CC_DBC;

$uniqueId = md5(uniqid("", true));

$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
return false;
}
return true;
}

public static function SetImportTimestamp()
{
global $CC_DBC;

$now = time();

$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '$now')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
return false;
}
return true;
}
}

class AirtimeIni{
Expand Down Expand Up @@ -783,6 +811,10 @@ public static function installMediaMonitor($values){

AirtimeInstall::InsertCountryDataIntoDatabase();

// set up some keys in DB
AirtimeInstall::SetUniqueId();
AirtimeInstall::SetImportTimestamp();

AirtimeIni::CreateMonitFile();

AirtimeInstall::CreateSymlinksToUtils();
Expand Down
Expand Up @@ -8,7 +8,7 @@

def encode_to(obj, encoding='utf-8'):
if isinstance(obj, basestring):
if not isinstance(obj, string):
if not isinstance(obj, str):
obj = obj.encode(encoding)
return obj

Expand Down

0 comments on commit bfa2fa6

Please sign in to comment.